Skip to content

Equivalence checking

Whether two circuits behave the same, for every input and at every step: check_equivalence builds a miter of the two (the second on the first's inputs) and checks each pair of outputs with the same name with the engines. See the guide.

equivalence

Equivalence checking: do two circuits behave the same, for every input, at every step?

Two versions of a circuit (a circuit and its simplification, a design and its restructuring, a Lustre model and the circuit drawn from it) are compared on their interface: the same inputs and the same outputs, by name, of the same types. check_equivalence builds a miter, both circuits in one context, the second on the first's inputs and under a namespace of its own, and, for each pair of outputs with the same name, a target reached when they differ (their exclusive or for booleans, their inequality for the other types). Each target is checked on its own by intrepid's engines:

  • unreachable: the two outputs are the same at every step, from the initial states of both circuits (sequential equivalence, the latches starting at their initial values);
  • reachable: they differ, and the trace that reaches the target is the witness: the inputs, step by step, and both outputs along them.

The circuits are EQUIVALENT when every target is unreachable, NOT EQUIVALENT when one is reached, and UNKNOWN otherwise (no engine answered within the timeout or the depth). The assumptions of either circuit (its Assume blocks, a Lustre model's assertions) restrict the inputs of both.

A side is a circuit diagram (a dict, or the path of a *.icircuit, see intrepyd.diagram) or a subclass of intrepyd.circuit.Circuit, as intrepyd.tools.translate_lustre and translate_simulink make them. python -m intrepyd.diagram equivalence A B compares two diagrams and prints the answer as JSON.

EquivalenceError

Bases: ValueError

Two circuits that cannot be compared: their interfaces differ.

check_equivalence

check_equivalence(first, second, engine=None, timeout=30, depth=None, certificates=False)

Compares two circuits (see the module documentation), with engine (None or "portfolio" for all, or one of bmc, kind, br, pdr), timeout seconds per pair of outputs and, for bmc and kind, at most depth steps; with certificates, a pair proved the same comes with its proof. Raises EquivalenceError if the interfaces differ. Returns::

{"verdict": "equivalent" | "not equivalent" | "unknown",
 "inputs": {"x": "int8", ...}, "outputs": {"y": "bool", ...},
 "assumptions": ["first: env", ...],
 "results": [{"output": "y", "type": "bool",
              "verdict": "same" | "differs" | "unknown",
              "engine": "pdr", "time": 0.12,
              "step": 3,              # where they differ (differs)
              "witness": {"steps": 4, "stimuli": {"x": ["1", ...]},
                          "first": ["F", ...], "second": ["T", ...]},
              "certificate": "..."}]}  # same, with certificates

interface

interface(source)

The inputs and the outputs of a circuit, their type names by name.

interface_problems

interface_problems(first, second)

What keeps two circuits from being compared: inputs or outputs that one has and the other has not, or of different types; [] if none.