Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle undefined results from model evaluation #1820

Merged
merged 2 commits into from
May 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .unreleased/bug-fixes/1819.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix nested set membership in the arrays encoding, see #1819
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,16 @@ class Z3SolverContext(val config: SolverConfig) extends SolverContext {
val (smtEx, _) = toExpr(ex)
val z3expr = z3solver.getModel.eval(smtEx, true)
if (z3expr.isBool) {
val isTrue = z3expr.getBoolValue.equals(Z3_lbool.Z3_L_TRUE)
ValEx(if (isTrue) TlaBool(true) else TlaBool(false)) // in undefined case, just return false
z3expr.getBoolValue match {
case Z3_lbool.Z3_L_TRUE =>
ValEx(TlaBool(true))
case Z3_lbool.Z3_L_FALSE =>
ValEx(TlaBool(false))
case _ =>
// If we cannot get a result from evaluating the model, we query the solver
z3solver.add(z3expr.asInstanceOf[BoolExpr])
ValEx(TlaBool(sat()))
}
} else if (z3expr.isIntNum) {
ValEx(TlaInt(z3expr.asInstanceOf[IntNum].getBigInteger))
} else {
Expand Down