Skip to content

Satisfiability migration#6

Open
samysweb wants to merge 28 commits intosamysweb:devfrom
JanGontscharow:satisfiability-migration
Open

Satisfiability migration#6
samysweb wants to merge 28 commits intosamysweb:devfrom
JanGontscharow:satisfiability-migration

Conversation

@samysweb
Copy link
Copy Markdown
Owner

@samysweb samysweb commented Apr 1, 2026

@JanGontscharow we will be merging with dev first -- hence a new pull request

@samysweb samysweb mentioned this pull request Apr 1, 2026
Copy link
Copy Markdown
Owner Author

@samysweb samysweb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks good, I left a few small minor comments. I'll look into rational support for Satisfiability.jl

# this avoids numbers ≥ 1000000 in the expression
# which avoids unknown Symbol error in the Solver
# the zero_var is introduced to avoid simplification by Satisfiability
function secure_int(val::Integer, zero_var)
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's nice! 😃

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can turn LIMIT into a global, configurable constant

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I gave this some more thought: While I like the idea, it's unfortunate that we end up needing division of expressions where it's not necessary. I am looking into adding Rational{BigInt} support for Satisfiability.jl right now, I think there's a good chance that's feasible...

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-> I'll look into this

return smt_cache[n]
end
# same value as the Z3 implementation
x_rat = rationalize(Int32,Float32(n.value))
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think with secure_int in place, we could get rid of this, right?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to Rational support -> I'll look into this

Comment thread src/SMTInterface/Main.jl
#print_msg("[SMT] ", constraints[conflict_clauses[string(c)]])
push!(conflicts,conflict_clauses[string(c)])
end
# TODO
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to have another look at whether I can get the cores to work. If not, we should throw an error here until we have a fix.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-> I'll look into this

Comment thread src/SMTInterface/Main.jl
@satvariable(C[1:n], Bool) # conflict bools
additional = []

cons_trans = map(con -> ast2smt(con, variables, additional, Dict()), constraints)
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and also in lin_feasible: Ideally, we would translate the constraints with a for loop. This will allow us to reuse the smt_cache across constraints...

Comment thread src/SMTInterface/Main.jl
cons_trans = map(con -> ast2smt(con, variables, additional, Dict()), constraints)
expr = Sat.and(cons_trans...)

!isempty(additional) && (expr = expr ∧ Sat.and(additional...))
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and also in lin_feasible: Please use an if statement

Comment thread src/SMTInterface/Main.jl
expr = Satisfiability.__wrap_const(expr)
end
# needs qf_nra since ast2smt(TermNumber) uses fractions with variables in the denominator
res = sat!(expr, solver=Z3(), logic="QF_NRA")
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QF_LRA should be sufficient here?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an issue with our current number representation, right?

@samysweb
Copy link
Copy Markdown
Owner Author

samysweb commented Apr 1, 2026

Also, I believe we can remove the "old" SMT folders then?

@samysweb
Copy link
Copy Markdown
Owner Author

samysweb commented Apr 1, 2026

Caveat: Only reviewed code so far, I still want to test it on my machine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants