Skip to content

Conversation

@kfriedberger
Copy link
Member

Several solvers referenced a live prover context in the model, allowing the user to insert further queries in the model or remove queries from the context, potentially making the model inconsistent and unreliable for further iteration or evaluation.

The solution consists of several steps, for some solvers:

  • compute the value-assignments upfront when constructing the model.
  • invalidate the model once the context is changed.

Solvers that already provide a persistent model, such as MathSAT, SMTInterpol, and Z3, will not change their behaviour.
However, other solvers will throw an exception on invalid usage.

While this change is backward-compatible in the API, it is a serious bugfix that changes the behaviour of some solver bindings in JavaSMT, because we need to loosen a basic guarantee for models.

…nging the underlying context.

Several solvers referenced a live prover context in the model,
allowing the user to insert further queries in the model or remove queries from the context,
potentially making the model inconsistent and unreliable for further iteration or evaluation.

The solution consists of several steps, for some solvers:
- compute the value-assignments upfront when constructing the model.
- invalidate the model once the context is changed.

Solvers that already provide a persistent model, such as MathSAT, SMTInterpol, and Z3,
will not change their behaviour.
However, other solvers will throw an exception on invalid usage.

While this change is backward-compatible in the API,
it is a serious bugfix that changes the behaviour of some solver bindings in JavaSMT,
because we need to loosen a basic guarantee for models.
Copy link
Contributor

@baierd baierd left a comment

Choose a reason for hiding this comment

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

Nice addition/cleanup! Thank you!

2 requests to extend the cleanup even more, nothing mayor.

* returned <code>false</code>.
*/
@Override
public List<BooleanFormula> getUnsatCore() {
Copy link
Contributor

Choose a reason for hiding this comment

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

UnsatCores can also affect solver states (e.g. in Z3). It might be a good idea to generally assume that they do?

Copy link
Member Author

Choose a reason for hiding this comment

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

Can you give an example? Why would Z3 change its state when calling getUnsatCore?

Copy link
Contributor

@daniel-raffler daniel-raffler left a comment

Choose a reason for hiding this comment

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

Looks good to me!

…and unsat core.

This fixes a invalid return value in Z3OptimizationProver:
We wrongly returned "false" instead of throwing "UnsupportedOperationException".
@kfriedberger kfriedberger requested a review from baierd November 19, 2025 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants