Documentation

Complexity.Computability.Circuit.Boolean.CodeSubstitution

Hardwiring a prefix of a Boolean circuit code #

prefixCode r n code replaces the first r.length inputs by r and leaves n live inputs. Two shared constant gates precede the original gates. The transformation is the raw code of ordinary circuit composition, with exactly two additional gates. Its constructor runs in polynomial time, with n in binary and all wire numbers in binary.

Main definitions #

Main results #

References #

Map an old wire to a live suffix input, a shared constant, or a shifted gate.

Instances For

    Hardwire a prefix, sharing two constant gates and retaining all original gates and outputs. Malformed codes are transformed as data; correctness is asserted on codes of typed circuits.

    Instances For

      Feed the fixed prefix bits followed by the live suffix inputs.

      Instances For

        Hardwire a prefix using the existing shared-constant substitution circuit.

        Instances For

          The raw hardwiring transformation is exactly the code of typed circuit composition.

          @[simp]

          Decoding the hardwired code produces the corresponding typed circuit.

          A valid circuit code remains valid after hardwiring its input prefix.

          @[simp]
          theorem Cslib.Circuits.Boolean.eval_prefixCircuit {n m : ℕ} (r : List Bool) (c : Circuit signature (r.length + n) m) (x : Fin n → Bool) :

          Hardwiring a prefix supplies its bits before the live inputs.

          theorem Cslib.Circuits.Boolean.evalOutputs_prefixCode {n m : ℕ} (r : List Bool) (c : Circuit signature (r.length + n) m) (x : Fin n → Bool) :
          List.map (evalOutput (List.ofFn x) (prefixCode r n c.code).1) (prefixCode r n c.code).2 = List.ofFn (c.eval interpretation (Fin.append (fun (i : Fin r.length) => r[↑i]) x))

          Reading the hardwired raw code's output wires gives the original circuit's outputs.

          @[simp]

          Exactly two gates are added, even if the constants or all outputs are unused.

          @[simp]
          theorem Cslib.Circuits.Boolean.length_prefixCode (r : List Bool) (n : ℕ) (code : List (Op × List ℕ) × List ℕ) :
          (prefixCode r n code).1.length = 2 + code.1.length ∧ (prefixCode r n code).2.length = code.2.length

          Hardwiring adds two gates and retains every designated output.

          Rewriting one wire is polynomial-time even when wire numbers and n are binary.

          Construct hardwired raw codes in polynomial time, with binary live-input and wire counts.