Attach a simplifier to the solver for incremental pre-processing. The solver will use the simplifier for incremental pre-processing of assertions.
The simplifier to attach
Check whether the assertions in the solver are consistent or not.
Optionally, you can provide additional boolean expressions as assumptions. These assumptions are temporary and only used for this check - they are not permanently added to the solver.
A promise resolving to:
- 'sat' if the assertions (plus assumptions) are satisfiable
- 'unsat' if they are unsatisfiable
- 'unknown' if Z3 cannot determine satisfiability
const solver = new Solver();
const x = Int.const('x');
solver.add(x.gt(0));
// Check without assumptions
await solver.check(); // 'sat'
// Check with temporary assumption (doesn't modify solver)
await solver.check(x.lt(0)); // 'unsat'
await solver.check(); // still 'sat' - assumption was temporary
unsatCore - Retrieve unsat core after checking with assumptions
Explain why two expressions are congruent according to the solver's reasoning. Returns a proof term explaining the congruence.
Note: This works primarily with SimpleSolver and may not work with terms eliminated during preprocessing.
An expression representing the proof of congruence
Retrieve the next expression in the congruence class containing the given expression. The congruence class forms a circular linked list.
Note: This works primarily with SimpleSolver and may not work with terms eliminated during preprocessing.
The next expression in the congruence class
Retrieve the root of the congruence class containing the given expression. This is useful for understanding equality reasoning in the solver.
Note: This works primarily with SimpleSolver and may not work with terms eliminated during preprocessing.
The root expression of the congruence class
Extract cubes from the solver for cube-and-conquer parallel solving. Each call returns the next cube (conjunction of literals) from the solver. Returns an empty AstVector when the search space is exhausted.
A promise resolving to an AstVector containing the cube literals
Retrieve fixed assignments to a set of variables as consequences given assumptions. Each consequence is an implication: assumptions => variable = value.
A promise resolving to the status and a vector of consequence expressions
Return a string describing why the last call to check returned 'unknown'.
A string explaining the reason, or an empty string if the last check didn't return unknown
Register a callback that is invoked when clauses are inferred during solving. The callback is called when a clause is:
Requires the Emscripten module to be passed to createApi.
Retrieve statistics for the solver. Returns performance metrics, memory usage, decision counts, and other diagnostic information.
A Statistics object containing solver metrics
Convert the solver's assertions to SMT-LIB2 format as a benchmark.
This exports the current set of assertions in the solver as an SMT-LIB2 string, which can be used for bug reporting, sharing problems, or benchmarking.
Optionalstatus: stringStatus string such as "sat", "unsat", or "unknown" (default: "unknown")
A string representation of the solver's assertions in SMT-LIB2 format
Retrieve the unsat core after a check that returned 'unsat'.
The unsat core is a (typically small) subset of the assumptions that were sufficient to determine unsatisfiability. This is useful for understanding which assumptions are conflicting.
Note: To use unsat cores effectively, you should call check with assumptions (not just assertions added via add).
An AstVector containing the subset of assumptions that caused UNSAT
const solver = new Solver();
const x = Bool.const('x');
const y = Bool.const('y');
const z = Bool.const('z');
solver.add(x.or(y));
solver.add(x.or(z));
const result = await solver.check(x.not(), y.not(), z.not());
if (result === 'unsat') {
const core = solver.unsatCore();
// core will contain a minimal set of conflicting assumptions
console.log('UNSAT core size:', core.length());
}
check - Check with assumptions to use with unsat core
Assert a constraint and associate it with a tracking literal (Boolean constant). This is the TypeScript equivalent of
assertAndTrackin other Z3 language bindings.When the solver returns
unsat, the tracked literals that contributed to unsatisfiability can be retrieved via unsatCore.