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

Add support for model minimization and maximization #171

Merged
merged 2 commits into from
Jan 7, 2022
Merged
Changes from 1 commit
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
8 changes: 5 additions & 3 deletions src/main/scala/inox/solvers/z3/NativeZ3Optimizer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ trait NativeZ3Optimizer extends AbstractUnrollingOptimizer with Z3Unrolling { se

override val name = "native-z3-opt"

protected object underlying extends {
protected val underlying = NativeZ3Solver.synchronized(new {
Copy link
Contributor Author

@mbovel mbovel Jan 6, 2022

Choose a reason for hiding this comment

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

you should probably share the object on which synchronization is performed between NativeZ3Solver and NativeZ3Optimizer.

So would it make sense to just use NativeZ3Solver.synchronized in both classes?

val program: targetProgram.type = targetProgram
val context = self.context
} with AbstractOptimizer with Z3Native {
Expand All @@ -32,7 +32,7 @@ trait NativeZ3Optimizer extends AbstractUnrollingOptimizer with Z3Unrolling { se
private[this] val optimizer: ScalaZ3Optimizer = z3.mkOptimizer()

private def tryZ3[T](res: => T): Option[T] =
// @nv: Z3 optimizer throws an exceptiopn when canceled instead of returning Unknown
// @nv: Z3 optimizer throws an exception when canceled instead of returning Unknown
try { Some(res) } catch { case e: Z3Exception if e.getMessage == "canceled" => None }

def assertCnstr(ast: Z3AST): Unit = tryZ3(optimizer.assertCnstr(ast))
Expand Down Expand Up @@ -77,5 +77,7 @@ trait NativeZ3Optimizer extends AbstractUnrollingOptimizer with Z3Unrolling { se
super.pop()
optimizer.pop()
}
}
})

override def free(): Unit = NativeZ3Solver.synchronized(super.free())
}