Internal: Completeness of fan-in-2 AND/OR #
This module proves CompleteBasis Basis.andOr2 using the generic simulation
lemma CompleteBasis.of_simulation. The proof compiles any circuit over
Basis.unboundedAON into one over Basis.andOr2 by decomposing each
unbounded fan-in gate into a chain of fan-in-2 gates.
Strategy #
Given a circuit c : Circuit Basis.unboundedAON N M G, we construct
c' : Circuit Basis.andOr2 N M G' with c'.eval = c.eval.
Each original gate with fan-in k is replaced by a chain of chainLen k
fan-in-2 gates:
k = 0: one constant gate (dual-op trick:OR(x₀, ¬x₀) = true, etc.)k = 1: one passthrough gate (op(x₀, x₀) = x₀)k ≥ 2:k - 1gates chaining the inputs left-to-right
The new circuit's internal gates consist of chains for all original internal gates followed by chains for all original output gates. The new output gates are trivial passthroughs reading the last wire of each output chain.
AONOp extensions #
Dual operation: swaps AND ↔ OR. Used for constant-gate construction.
Equations
Instances For
Identity element for fold: true for AND, false for OR.
Instances For
Chain length and prefix sums #
Segment lookup #
Given a flat index into a segmented array, find the segment and position.
Equations
- One or more equations did not get rendered due to their size.
- CircuitComplexity.CompileAON.segLookup 0 f idx h_2 = absurd h_2 ⋯
Instances For
Wire layout definitions #
Chain size function for internal gates (0-padded beyond G).
Equations
- CircuitComplexity.CompileAON.iChainF c i = if h : i < G then CircuitComplexity.CompileAON.chainLen (c.gates ⟨i, h⟩).fanIn else 0
Instances For
Chain size function for output gates (0-padded beyond M).
Equations
- CircuitComplexity.CompileAON.oChainF c j = if h : j < M then CircuitComplexity.CompileAON.chainLen (c.outputs ⟨j, h⟩).fanIn else 0
Instances For
Total number of compiled gates contributed by the internal gates.
Equations
Instances For
Total number of compiled gates contributed by the output gates.
Equations
Instances For
Total internal gates in the compiled circuit.
Equations
Instances For
Offset of the chain for internal gate i.
Equations
Instances For
Offset of the chain for output gate j.
Equations
Instances For
Wire remapping #
Map an old wire index to its new position. Input wires are unchanged;
internal gate i maps to the last gate of its chain.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Chain gate construction #
Build the j-th fan-in-2 gate in a chain for an original gate.
Components are split out so projections reduce without unfolding dite.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Compiled circuit #
Gate function for the compiled circuit. Components are separated so
projections reduce without going through dite.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Output gates: passthroughs reading the last wire of each output chain.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The compiled circuit over Basis.andOr2.
Equations
- CircuitComplexity.CompileAON.compileFn c = { gates := CircuitComplexity.CompileAON.compileGates c, outputs := CircuitComplexity.CompileAON.compileOutputs c, acyclic := ⋯ }
Instances For
Eval equivalence #
Key lemma: remapWire values in the compiled circuit match the original.
Fan-in-2 AND/OR is functionally complete.