Documentation

CslibFrontier.Computability.Circuit.Boolean.CodeComposition

Combining De Morgan circuit codes on shared inputs and in sequence #

Specializes the signature-polymorphic raw circuit-code combinators of CslibFrontier.Computability.Circuit.Encoding.Combinators to Cslib.Circuits.Boolean.Op and Cslib.Circuits.Boolean.encCode.

Main definitions #

Main results #

References #

@[reducible, inline]

Run two raw De Morgan codes on shared inputs, listing the first code's outputs before the second's.

Appending two raw codes sums their gate counts.

Appending two raw codes sums their output counts.

Raw shared-input composition agrees with ordinary typed circuit append.

The outputs of combined codes are the two output lists in order, on every input.

Combining circuit codes is polynomial-time, including binary input and wire counts.

@[reducible, inline]

Combine a list of raw De Morgan codes on shared inputs, preserving block and output order.

@[simp]

Combining an empty list of raw codes yields the empty code.

Adding a final block is ordinary shared-input append.

The combined code retains every gate, without padding the individual blocks.

The combined code retains all outputs, including repeated outputs and zero-gate blocks.

Combining arbitrary raw blocks is polynomial-time in their complete encodings.

theorem Cslib.Circuits.Boolean.appendCodes_code {k n : ℕ} (cs : Fin k → Circuit signature n 1) :
appendCodes n (List.ofFn fun (j : Fin k) => (cs j).code) = (Circuit.pi cs).code

Combining single-output circuit codes agrees with Circuit.pi.

@[reducible, inline]

Combine equal-sized De Morgan gate blocks on shared inputs.

Bundling raw blocks is polynomial-time in their encodings and binary layout parameters.

theorem Cslib.Circuits.Boolean.length_bundleCode (n blockSize : ℕ) (codes : List (List (Op × List ℕ) × List ℕ)) (hlen : ∀ c ∈ codes, c.1.length = blockSize) :
(bundleCode n blockSize codes).1.length = codes.length * blockSize

Equal-sized blocks occupy their number times their common gate count.

theorem Cslib.Circuits.Boolean.bundleCode_append_singleton (n blockSize : ℕ) (codes : List (List (Op × List ℕ) × List ℕ)) (code : List (Op × List ℕ) × List ℕ) (hlen : ∀ c ∈ codes, c.1.length = blockSize) :
bundleCode n blockSize (codes ++ [code]) = appendCode n (bundleCode n blockSize codes) code

Adding the next equal-sized block is shared-input append.

theorem Cslib.Circuits.Boolean.bundleCode_eq_foldl_appendCode (n blockSize : ℕ) (codes : List (List (Op × List ℕ) × List ℕ)) (hlen : ∀ c ∈ codes, c.1.length = blockSize) :
bundleCode n blockSize codes = List.foldl (appendCode n) ([], []) codes

For equal-sized blocks, direct relocation agrees with repeated shared-input append.

theorem Cslib.Circuits.Boolean.bundleCode_eq_appendCodes (n blockSize : ℕ) (codes : List (List (Op × List ℕ) × List ℕ)) (hlen : ∀ c ∈ codes, c.1.length = blockSize) :
bundleCode n blockSize codes = appendCodes n codes

Fixed-size bundling is a specialization of the varying-size constructor.

theorem Cslib.Circuits.Boolean.bundleCode_code {k n : ℕ} (cs : Fin k → Circuit signature n 1) (blockSize : ℕ) (hs : ∀ (j : Fin k), (cs j).size = blockSize) :
bundleCode n blockSize (List.ofFn fun (j : Fin k) => (cs j).code) = (Circuit.pi cs).code

The typed and raw bundles have the same code when component sizes agree.

theorem Cslib.Circuits.Boolean.exists_circuit_bundleCode {k n : ℕ} (cs : Fin k → Circuit signature n 1) (blockSize : ℕ) (hs : ∀ (j : Fin k), (cs j).size = blockSize) :
∃ (c : Circuit signature n k), bundleCode n blockSize (List.ofFn fun (j : Fin k) => (cs j).code) = c.code ∧ ∀ (x : Fin n → Bool) (j : Fin k), c.eval interpretation x j = (cs j).eval interpretation x 0

Equal-sized single-output codes form one typed circuit with the corresponding output order.

@[reducible, inline]

Feed the outputs of c to the inputs of d, matching the argument order of Circuit.comp.

Raw sequential composition is the code of typed circuit composition.

Sequential composition retains both gate lists.

Sequential composition retains the later circuit's number of outputs.

Construct sequential circuit codes in polynomial time.