Raw parity-circuit fragments -- definitions #
This module builds an appendable fan-in-two circuit for the XOR of selected existing wires. One false initializer and three gates per selected wire give a linear construction that retains sharing, unlike expansion into a Boolean formula tree.
XOR of a fixed-width Boolean vector, defined from its first coordinate toward its last coordinate.
Equations
- Complexity.CircuitCode.Parity.foldXor 0 x_2 = false
- Complexity.CircuitCode.Parity.foldXor count.succ bits = (bits 0 ^^ Complexity.CircuitCode.Parity.foldXor count fun (i : Fin count) => bits i.succ)
Instances For
Accumulator wire before processing the selected wire at step.
Equations
- Complexity.CircuitCode.Parity.accumulatorWire available step = available + 3 * step
Instances For
First wire emitted while folding one selected bit into the accumulator.
Equations
- Complexity.CircuitCode.Parity.orWire available step = available + 1 + 3 * step
Instances For
Second wire emitted while folding one selected bit into the accumulator.
Equations
- Complexity.CircuitCode.Parity.andWire available step = Complexity.CircuitCode.Parity.orWire available step + 1
Instances For
The three gates computing accumulator XOR input with shared
intermediates.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Process successive selected wires, starting at the supplied fold step.
Equations
- One or more equations did not get rendered due to their size.
- Complexity.CircuitCode.Parity.steps available step 0 x_2 = []
Instances For
Absolute wire carrying the final parity value.
Equations
- Complexity.CircuitCode.Parity.outputWire available inputCount = Complexity.CircuitCode.Parity.accumulatorWire available inputCount
Instances For
Compile the XOR of selected existing wires as an appendable raw fragment.
The fragment first creates a false accumulator and then uses three shared gates per selected wire.
Equations
- Complexity.CircuitCode.Parity.compileRaw available refs = [Complexity.CircuitCode.RawGate.constant 0 false] ++ Complexity.CircuitCode.Parity.steps available 0 inputCount refs