Encoded fan-in-two circuits #
This module exposes the machine-facing representation of
Basis.andOr2 circuits and its correctness theorems.
Main definitions #
CircuitCode.RawGateandRawCircuit: proof-free ordered syntax.RawCircuit.WellFormed: nonempty, strictly backward-pointing gate lists.RawCircuit.encode/decode?: canonical terminated-unary bit codec.RawCircuit.eval?: array-backed iterative evaluation.CircuitCode.encodeCircuit: serialization of a typed circuit.CircuitCode.evalCode: decode and evaluate with an exact arity check.
Main results #
RawCircuit.decode?_eq_some_iff: exact decoder soundness and completeness.RawCircuit.eval?_isSome_iff: executable success exactly matches well-formedness.CircuitCode.evalCode_encodeCircuit: encoded evaluation agrees withCircuit.eval.CircuitCode.evalCode_encodeCircuit_of_length: the corresponding list-native theorem for machine-facing clients.CircuitCode.encodeCircuit_length_le_size: concrete polynomial bit-length bound for the unary encoding.
theorem
Complexity.CircuitCode.RawCircuit.eval?_isSome_iff
(circuit : RawCircuit)
(input : List Bool)
:
Raw evaluation succeeds precisely for nonempty topologically ordered circuits at the supplied input arity.
theorem
Complexity.CircuitCode.evalCode_encodeCircuit
{N G : ℕ}
[NeZero N]
(c : Circuit Basis.andOr2 N 1 G)
(input : BitString N)
:
Decoding and iteratively evaluating the canonical encoding of a typed fan-in-two circuit returns its typed output.
theorem
Complexity.CircuitCode.evalCode_encodeCircuit_of_length
{N G : ℕ}
[NeZero N]
(c : Circuit Basis.andOr2 N 1 G)
(input : List Bool)
(hinput : input.length = N)
:
List-native semantic correctness for an input of the declared arity.
theorem
Complexity.CircuitCode.encodeCircuit_length_le_size
{N G : ℕ}
[NeZero N]
(c : Circuit Basis.andOr2 N 1 G)
:
In the library's size convention, which counts internal and output gates but not primary inputs or free negations, unary circuit codes have quadratic length in the input arity and circuit size.