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 #
Cslib.Circuits.Boolean.Layered.getD_eval_schedule: every ready wire has its original value.Cslib.Circuits.Boolean.Layered.wellFormed_compile: every scheduled reference is valid.Cslib.Circuits.Boolean.Layered.outputs_valid_compile: output indices address the final row.Cslib.Circuits.Boolean.Layered.select_eval_compile: the ordered outputs equal the original circuit evaluation, including depth-zero wiring and repeated outputs.
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.
theorem Cslib.Circuits.Boolean.Layered.wellFormed_compile {n m : ℕ} (c : Circuit signature n m) :
WellFormed n (compile n c.code).1
The actual compiler produces a well-formed layered schedule for every typed circuit.
theorem Cslib.Circuits.Boolean.Layered.outputs_valid_compile {n m : ℕ} (c : Circuit signature n m) (i : ℕ) :
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.