Smt
opulse.solver.smt ¶
SMT-LIB export of operator definitions, including the z3 field.
Each operator f becomes two SMT-LIB functions whose arguments are
(definedness, value) pairs, one pair per operand::
(define-fun f_d ((a_d Bool) (a Int) (b_d Bool) (b Int)) Bool ...) ; f(a, b) is defined
(define-fun f_v ((a_d Bool) (a Int) (b_d Bool) (b Int)) Int ...) ; its value where defined
Operands carry definedness because a definition may ignore an undefined
operand (docs/reference/semantics.md section 4). Bodies call other operators by
name, so each export stays as small as the definition. Operators are
declared with define-funs-rec (also non-recursive ones: define-fun is
a macro in z3 and would inline whole dependency chains). The base operations come from a shared prelude in
which truncating division and the bound are spelled out (SMT-LIB div and
mod are Euclidean and would be wrong for negative operands).
module assembles a self-contained script (prelude, dependencies in
topological order, the operator). check_module evaluates it with z3 on
boundary inputs, NaN included, and compares every result with the reference
oracle; export never returns text that failed this check.
SmtEvaluator ¶
Evaluates ground terms over define-fun / define-funs-rec (Ints and Bools only).
Integer div/mod follow SMT-LIB (Euclidean: 0 <= mod < |divisor|);
a zero divisor is an error because the exported text never divides by zero.
is_operation ¶
is_operation(operator: Operator) -> bool
False for numeral-base markers, which are registered but never applied.
prelude ¶
prelude(encoder: Z3Encoder) -> str
Base operations as base_<name>_d / base_<name>_v over defined operands.
own_text ¶
own_text(
operator: Operator, definition: Definition, resolve
) -> str
The operator's own SMT-LIB functions (calls to other operators by name).
module ¶
module(
operator: Operator,
encoder: Z3Encoder,
base: str | None = None,
) -> str
Self-contained script: prelude, every dependency in topological order, the operator.
evaluate_module ¶
evaluate_module(
text: str, operator: Operator, points: list[tuple]
) -> list
Evaluate a module on concrete inputs (NAN allowed): one int or NAN per point.
z3 parses the module (so the text is valid SMT-LIB for it); the values come
from :class:SmtEvaluator, an independent evaluator of the SMT-LIB integer
theory with lazy ite (z3's simplifier expands both arms of an ite,
which does not terminate quickly on recursive definitions).
export ¶
export(
operator: Operator,
encoder: Z3Encoder,
base: str | None = None,
) -> str | None
The operator's own SMT-LIB functions after checking the assembled module; None for markers.