Documentation

Complexity.Computability.Circuit.Boolean.Layered.Compile.Correctness

Correctness of depth-bounded Boolean circuit compilation #

After the two microlevels for depth k, every original wire of depth at most k is available at its original position and has its original value. Deeper gates may remain placeholders. This invariant covers unused gates and the input-only initial row.

Main results #

theorem Cslib.Circuits.Boolean.Layered.length_eval_schedule (inputs : List Bool) (inputCount : ℕ) (gates : List (Op × List ℕ)) (depths : List ℕ) (k : ℕ) :
(eval inputs (schedule inputCount gates depths (k + 1))).length = inputCount + 3 * gates.length

Once a positive number of rounds has run, the row has the full working width.

Every compiled reference reads an available preceding-layer wire, including at depth zero.

theorem Cslib.Circuits.Boolean.Layered.toNat_lt_length_eval_schedule {n g : ℕ} (p : Program signature n g) (x : Fin n → Bool) (k : ℕ) (w : Wire n g) (hw : p.wireDepths w ≤ k) :

Every original wire of depth at most the completed level is available at its original index.

theorem Cslib.Circuits.Boolean.Layered.getD_eval_schedule {n g : ℕ} (p : Program signature n g) (x : Fin n → Bool) (k : ℕ) (w : Wire n g) (hw : p.wireDepths w ≤ k) :

The schedule preserves each completed original wire's value; deeper unused gates need not have been computed.

The actual compiler produces a well-formed layered schedule for every typed circuit.

All designated outputs select existing final wires. This also covers an empty schedule with dead gates, whose available final wires are only the original inputs.

Compilation preserves every output's Boolean value, in order and with repetitions.