Fixed-width binary circuit descriptions -- definitions #
This module gives fan-in-two raw circuits an Algebraic-style gate-slot view.
Every slot has fixed-width binary references, and a bounded description stores
exactly gateBound slots together with an explicit active gate count. Active
slots must point strictly backward; inactive slots are canonically zero.
The representation is proof-free and finite. A later codec flattens it into the Boolean cube used by approximate counting without parsing variable-length fields.
Positive binary width sufficient for every wire below
inputWidth + gateBound. Keeping the width positive lets the verified binary
comparator handle even the one-wire edge case.
Equations
- Complexity.CircuitCode.FixedWidth.referenceWidth inputWidth gateBound = max 1 (Fin.bitWidth (inputWidth + gateBound))
Instances For
Positive binary width sufficient for every gate count through
gateBound.
Equations
- Complexity.CircuitCode.FixedWidth.gateCountWidth gateBound = max 1 (Fin.bitWidth (gateBound + 1))
Instances For
Three control bits and two fixed-width wire references per gate.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Width of a flattened bounded description: one count field followed by
exactly gateBound gate slots.
Equations
- One or more equations did not get rendered due to their size.
Instances For
One fixed-width fan-in-two gate slot.
The operation bit uses the existing raw codec convention: true is AND and
false is OR. Reference words are little-endian so the circuit comparator can
validate them directly.
- op : Bool
Raw operation selector.
- negated0 : Bool
Whether the first input is negated.
- negated1 : Bool
Whether the second input is negated.
- input0 : BitString width
Little-endian first wire reference.
- input1 : BitString width
Little-endian second wire reference.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Natural value of the first little-endian reference word.
Equations
- slot.input0Value = Nat.fromBitsLE slot.input0.toList
Instances For
Natural value of the second little-endian reference word.
Equations
- slot.input1Value = Nat.fromBitsLE slot.input1.toList
Instances For
Convert a fixed slot to the existing proof-free gate syntax.
Equations
- slot.toRawGate = { op := Complexity.CircuitCode.RawGate.opOfBit slot.op, input₀ := slot.input0Value, input₁ := slot.input1Value, negated₀ := slot.negated0, negated₁ := slot.negated1 }
Instances For
Canonical all-zero inactive slot.
Equations
Instances For
Both binary references point to already available wires.
Equations
- slot.WellFormedAt available = (slot.input0Value < available ∧ slot.input1Value < available)
Instances For
Equations
- slot.instDecidableWellFormedAt available = id inferInstance
A bounded fixed-slot description.
gateCount.val slots are active, while all remaining slots are present so the
eventual bit encoding has one parameter-determined width.
Number of active gates, ranging from zero through
gateBound.- slots : Fin gateBound → GateSlot (referenceWidth inputWidth gateBound)
Fixed collection of gate slots.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Product view used to enumerate bounded descriptions exactly.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Active gate count as a natural number.
Equations
- description.gateCountNat = ↑description.gateCount
Instances For
View an active slot through the full fixed slot array.
Equations
- description.activeSlot index = description.slots ⟨↑index, ⋯⟩
Instances For
Existing raw-circuit syntax represented by the active slots.
Equations
- description.toRawCircuit = List.ofFn fun (index : Fin description.gateCountNat) => (description.activeSlot index).toRawGate
Instances For
The description has at least one active gate, hence a designated output.
Equations
- description.Positive = (0 < description.gateCountNat)
Instances For
Every active gate points to a primary input or an earlier active gate.
Equations
- description.TopologicallyWellFormed = ∀ (index : Fin description.gateCountNat), (description.activeSlot index).WellFormedAt (inputWidth + ↑index)
Instances For
Every inactive slot is the canonical all-zero slot.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Valid fixed-width descriptions are nonempty, topologically ordered, and canonically padded.
Equations
- description.WellFormed = (description.Positive ∧ description.TopologicallyWellFormed ∧ description.CanonicallyPadded)
Instances For
Equations
- description.instDecidablePositive = id inferInstance
Equations
- description.instDecidableTopologicallyWellFormed = id inferInstance
Equations
- description.instDecidableCanonicallyPadded = id inferInstance
Equations
- description.instDecidableWellFormed = id inferInstance