Skip to content

Equivalence

opulse.solver.equivalence

Equivalence of expressions and operators.

Two expressions over integer variables are equivalent when they agree, as values in ℤ ∪ {NaN}, for every assignment of the variables in [-B, B]. Verdicts follow :mod:opulse.solver.properties:

  • refuted - a counterexample assignment (concrete search or z3), always re-checked with the reference oracle;
  • proved - z3 shows that no counterexample exists;
  • bounded - z3 could not decide within its resource limit; no counterexample on the recorded small range.

SymPy is used only to propose simplifications of the arithmetic part (+ - * and negation); whether a proposal is valid is decided here under Opulse semantics. With a bound it often is not: (a + b) - b and a differ where a + b overflows to NaN.

encode_node

encode_node(
    encoder: Z3Encoder, node: Node, env: dict[str, ZVal]
) -> ZVal

z3 value of an expression tree whose variables are bound in env.

equivalent_operators

equivalent_operators(
    registry: OperatorRegistry,
    checker: EquivalenceChecker,
    operators: list[Operator] | None = None,
) -> list[tuple[Operator, Operator, Equivalence]]

Pairs of operators (same arity and position) with the same values on every input.

Candidates share a fingerprint (values on a fixed sample); each candidate pair is then decided by :meth:EquivalenceChecker.check on f(a, b) vs g(a, b).

sympy_candidate

sympy_candidate(
    node: Node, registry: OperatorRegistry
) -> Node | None

SymPy's expanded form of an arithmetic expression (+ - *, negation), or None.

The result is only a proposal; check it with :class:EquivalenceChecker.