Correctness of the machine-facing circuit codec #
This internal module proves that the proof-free encoding and iterative
evaluator in Encoding.Defs faithfully enforce their advertised syntactic
invariants. Semantic agreement with typed circuit evaluation is deliberately
kept in a separate proof layer.
The Boolean well-formedness check agrees with the WellFormedAt predicate.
The Boolean well-formedness check agrees with the WellFormed predicate.
Parsing an encoded gate list consumes exactly that list and leaves the caller-supplied suffix untouched.
A circuit prefix can be decoded in front of an arbitrary suffix.
Exact decoding is a left inverse of circuit serialization.
A circuit encoding consists of the unary gate count followed by the concatenated gate encodings.
Topological well-formedness of a nonempty gate list splits at its head.
Successful fixed-count gate decoding reconstructs the consumed input.
Running the iterative evaluator succeeds exactly for topological gate lists.
Successful iterative evaluation appends exactly one wire per gate.
Raw evaluation succeeds precisely for nonempty topologically ordered circuits.
Code evaluation succeeds exactly when the input length is the declared arity, the code is canonical, and the decoded raw circuit is well formed.
Erasing a typed gate's proofs never introduces an out-of-range reference.
Translating a typed single-output circuit produces one raw gate per internal gate, followed by its output gate.
Translation preserves the typed circuit's topological ordering.
Translation of a typed circuit is a valid raw single-output circuit.
A generic topological raw circuit with G gates and input arity N has
quadratic-size unary encoding.
A code produced from a typed circuit is evaluable exactly on inputs of the circuit's declared arity.
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.