Raw threshold-circuit fragments #
This file defines an appendable raw circuit that tests whether at least a
specified number of existing Boolean wires are true. The construction is the
standard unary dynamic program. Its state after reading i inputs records, for
each r, whether at least r of those inputs were true.
Two gates update each state cell:
next (r + 1) = previous (r + 1) OR (input AND previous r).
The fragment starts with reusable false and true wires, emits the table in
row-major order, and ends with a copy of the requested final state. Thus it has
exactly 3 + 2 * k * threshold gates for k referenced inputs.
The constant-false wire at the start of a threshold fragment.
Equations
- Complexity.CircuitCode.Threshold.falseWire available = available
Instances For
The constant-true wire at the start of a threshold fragment.
Equations
- Complexity.CircuitCode.Threshold.trueWire available = available + 1
Instances For
The conjunction wire for table cell (inputRow, thresholdColumn).
Equations
Instances For
The completed dynamic-programming state wire for a table cell.
Equations
- Complexity.CircuitCode.Threshold.cellWire available threshold inputRow thresholdColumn = Complexity.CircuitCode.Threshold.andWire available threshold inputRow thresholdColumn + 1
Instances For
Wire representing whether the first inputCount inputs contain at least
required true values.
The zero threshold is always true. Before any input has been processed, every positive threshold is false. All other states are table-cell outputs.
Equations
- Complexity.CircuitCode.Threshold.stateWire available threshold x✝ 0 = Complexity.CircuitCode.Threshold.trueWire available
- Complexity.CircuitCode.Threshold.stateWire available threshold 0 n.succ = Complexity.CircuitCode.Threshold.falseWire available
- Complexity.CircuitCode.Threshold.stateWire available threshold inputCount.succ required.succ = Complexity.CircuitCode.Threshold.cellWire available threshold inputCount required
Instances For
The two raw gates that update one unary threshold-table cell.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Emit the first columnCount cells of one table row.
Equations
- One or more equations did not get rendered due to their size.
- Complexity.CircuitCode.Threshold.rowPrefix available threshold inputRow input 0 = []
Instances For
Emit successive table rows, starting at inputRow.
Equations
- One or more equations did not get rendered due to their size.
- Complexity.CircuitCode.Threshold.rows available threshold inputRow 0 x_2 = []
Instances For
Absolute wire carrying the threshold fragment's final output.
Equations
Instances For
Compile an at-least-threshold test over existing absolute wire references.
The result is appendable without renumbering. Its output is true exactly when
at least threshold of the referenced wires are true.
Equations
- One or more equations did not get rendered due to their size.