Skip to content

Add logic, engine and further options for Z3#626

Open
baierd wants to merge 32 commits intomasterfrom
613-feature-request-setting-solver-logic-via-javasmt
Open

Add logic, engine and further options for Z3#626
baierd wants to merge 32 commits intomasterfrom
613-feature-request-setting-solver-logic-via-javasmt

Conversation

@baierd
Copy link
Copy Markdown
Contributor

@baierd baierd commented Mar 24, 2026

This PR adds 3 explicit new configuration options to Z3:

  • logic: sets the logic used for all provers created in a Z3 context.
  • engine: sets the engine used in all provers of a Z3 context.
  • furtherOptions: allows to specify more options for Z3, besides the ones that we set internally or in other options. Note: option values can habe several types that need to be adhered to. Parsing these from Strings is difficult for the types unsigned int and float as for example 2 can be both. I extracted all options with float type and check against them, as there is only 7 or so.

Also, 2 new test classes are added.

  • Z3NativeApiTest: has 2 native tests, one for HORN solving with Spacer (taken from an old implementation that we did not merge), that shows logic selection and engine selection, as well as a test that checks whether we handle the types of option values correctly (even for new versions).
  • SolverNativeOptionsTest: tests that we can hand options through to the solver via our config options. Some tests (logic and HORN tests) should be moved out of that folder into dedicated test-classes once we implement common solutions.

I added some extensions to our test setup to handle configuration changes gracefully.
I also noticed that it is helpful to have a assertThat... implementation that actually uses multiple assertions (e.g. for HORN solving. As a conjunction of multiple formulas is no equal to asserting them on their own for Z3! I opened !625 to discuss and develop extensions for our Truth based API.)

Part of the request in #613.

Note: option values with type unsigned int take type int in Z3s Java API. We should check whether this is a bug or wraps around in C (meaning we need to translate values above Cs signed int maximum in Java!).

baierd added 30 commits March 18, 2026 18:08
… options. Also rework processing of options by adding type retrieval via the options (as int and double can otherwise not be discerned) and processing of options
…ption value type is double and removing the expensive resolving of all types
…ns info getter in Z3SolverContext to declutter the manager
… we want those to be proper settings in the future!) and resolve them correctly when building new Z3 solver instances
…text to fail early for known incompatibilities and make retrieval of important options easier + better option descriptions
… incremental usage for logic tests (as otherwise Z3 is equally fast with and without using the logic)
…r with certain options (Provided by Thomas Haar here: #613 (comment) referencing: Z3Prover/z3#8940 (comment) )
…y test that they work + documentation and refactor explicit timeout thread creation into a method
@baierd baierd linked an issue Mar 24, 2026 that may be closed by this pull request
@baierd baierd self-assigned this Mar 24, 2026
@baierd
Copy link
Copy Markdown
Contributor Author

baierd commented Mar 24, 2026

@kfriedberger i added 2 SMT files provided by @ThomasHaas. They have their licenses included already, but reuse is not recognizing them. Do i need to add our license on top, or the license provided in the files explicitly?

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

Development

Successfully merging this pull request may close these issues.

[Feature request] Setting Solver Logic via JavaSMT

1 participant