Guides

Configure a solver for your task

Choose the logic and options when you create a solver, before asserting the model or asking a query. Keep those choices in one setup function so a retry or a second solver uses the intended configuration. Start with the features your application needs, then measure any performance changes on its actual formulas.

The table below is generated from the pinned release. The values in its default column are fresh-solver defaults, not settings prescribed by this guide.

Option Value kind Default Description
produce-models bool false support the get-value and get-model commands
incremental bool true enable incremental solving
produce-unsat-cores bool false turn on unsat core generation.
tlimit-per uint64 0 set time limit per query in milliseconds
rlimit-per uint64 0 set resource limit per query

The complete option reference includes modes, reported numeric bounds, aliases, categories, and source links. Keeping that catalog generated makes a version change reviewable without copying hundreds of option descriptions into prose.

Select a configuration by the result you need

Task Configuration used by the tutorials Tested workflow
Read a satisfying assignment Set produce-models to true; read values after sat Results and models
Try temporary constraints Set incremental to true; balance push and pop Incremental solving
Explain conflicting assertions Set produce-unsat-cores to true; read the core after unsat Conflicting requirements
Bound work per query Choose rlimit-per and/or tlimit-per; retain an inconclusive result Results and solver limits

Explicitly enabling an application requirement keeps the setup readable even when the current default happens to agree. Option values are strings, as the runnable examples show. The result status still controls what the application can conclude: enabling models does not turn unknown into sat, and enabling cores does not make a satisfiable model contradictory.

The migration example puts its chosen logic and two required features together:

migration.mojo Download
var tm = TermManager()
var solver = Solver(tm)
solver.setLogic("QF_LRA")
solver.setOption("produce-models", "true")
solver.setOption("incremental", "true")
var x = tm.mkConst(tm.getRealSort(), "x")
var one = tm.mkReal(1)
var doubled = tm.mkTerm(Kind.ADD, x, x)
solver.assertFormula(tm.mkTerm(Kind.EQUAL, doubled, one))

Here the model is linear real arithmetic. Select the logic to match the terms you construct; changing resource limits does not permit terms outside that logic. The transcendental application uses QF_NRAT for exponential and sine checks and QF_NRA for its polynomial subqueries.

Use resource limits as application policy

The damped oscillation example uses a shared setup helper. Its budget is a parameter because the tutorial deliberately compares an inconclusive query with a more generous retry:

damped_oscillation.mojo Download
def configured(tm: TermManager, logic: String, budget: Int) raises -> Solver:
    var solver = Solver(tm)
    solver.setLogic(logic)
    solver.setOption("rlimit-per", String(budget))
    solver.setOption("tlimit-per", "1000")
    return solver^

Time and resource limits answer different operational needs. Use elapsed time to constrain responsiveness and resource units to bound solver work; neither is a decimal accuracy or error-tolerance setting. The example's values demonstrate its workflow and are not a general performance recommendation.

For a service or batch worker that must stop by an external deadline, run the solver in a process with its own timeout as well. The documentation test runner enforces a hard timeout on the example's process group. A forced termination produces a failed run, not a solver result.

On unknown, retain the pending question and its settings. You can retry with a larger budget, simplify the encoding, or split the domain into pieces whose union still covers it. The damped oscillation application shows how to preserve coverage across that retry.

Keep configuration experiments comparable

Record the pinned library version, logic, nondefault options, input formula, and result when comparing configurations. Use a fresh solver for independent experiments; copying a solver retains the same underlying instance and assertion stack. A faster run on one formula does not establish a better setting for another theory or workload.

If an option is rejected, first check its exact name, value kind, and modes in the generated reference, then check when the program sets it. Do not silently continue with a missing required feature. The binding raises an error for a failing call; see error handling.

cvc5_mojo v1.4.1.1 for Mojo 1.2 and cvc5 1.4.1 · Apache License 2.0 with LLVM Exceptions · Source on GitHub