Internal: Shannon Upper Bound Construction #
The Shannon (1949) upper bound: every Boolean function on N variables
can be computed by a fan-in-2 AND/OR circuit of size at most C * 2^N / N,
for a fixed constant C and all sufficiently large N.
This is the full-column-library variant (C = 18). The tighter
(1 + o(1)) · 2^N / N bound due to Lupanov (1958) uses column grouping
and is not yet formalized.
Construction #
Split N inputs into k = ⌊log₂ N⌋ - 1 address variables and
q = N - k data variables. Decompose any f : {0,1}^N → {0,1} as
f(a,y) = ⋁ᵧ [mintermᵧ(data) ∧ colᵧ(addr)] where colᵧ(a) = f(a,y).
Build shared minterm trees for both variable groups, a pattern library
for column functions, AND/OR combining layers. Total ≤ 18 · 2^N / N
gates for N ≥ 16.
Parameters #
Number of address variables: ⌊log₂ N⌋ - 1.
Equations
- Complexity.ShannonUpper.addrBits N = Nat.log 2 N - 1
Instances For
Gate Construction Helpers #
Binary Circuit Composition #
Compose two circuits with a binary AND/OR.
Equations
- One or more equations did not get rendered due to their size.
Instances For
binopCircuit correctly computes the OR of two circuits' outputs.
The output gate of binopCircuit applies OR to wires N + G₁ and
N + G₁ + G₂ + 1, which replicate the output gates of c₁ and c₂.
The proof shows that wire values in the combined circuit agree with
wire values in the original circuits (via binop_wireValue_c₁ and
binop_wireValue_c₂), then combines.
Arithmetic #
Nat.log helpers #
Key identities #
N² ≤ 2^N for N ≥ 16 #
Term-by-term bounds #
Circuit Construction #
Gate construction helper #
Circuit layout #
Total gate count of the Shannon circuit for kk address and qq data
variables: one constant-false gate, the data minterm tree
(2^(qq+1) - 4), the address minterm tree (2^(kk+1) - 4), the column
library (2^(2^kk) OR chains of length 2^kk - 1), the AND layer
(2^qq), and the final OR chain (2^qq - 1).
Equations
Instances For
The Shannon gate array is nonempty.
Section offsets (not private so they can be unfolded after set) #
Gate-index offset of Section C (address minterm tree): after the constant-false gate and the data minterm tree.
Instances For
Gate-index offset of Section D (column library): after Section C.
Equations
- Complexity.ShannonUpper.columnLibraryOffset kk qq = Complexity.ShannonUpper.addrTreeOffset qq + (2 ^ (kk + 1) - 4)
Instances For
Gate-index offset of Section E (AND layer): after the column library.
Equations
- Complexity.ShannonUpper.andLayerOffset kk qq = Complexity.ShannonUpper.columnLibraryOffset kk qq + 2 ^ 2 ^ kk * (2 ^ kk - 1)
Instances For
Gate-index offset of Section F (final OR chain): after the AND layer.
Equations
- Complexity.ShannonUpper.orChainOffset kk qq = Complexity.ShannonUpper.andLayerOffset kk qq + 2 ^ qq
Instances For
Power-of-2 helpers #
Minterm tree level #
Level of node j in a minterm tree, where level l occupies indices
2^(l+1) - 4, …, 2^(l+2) - 5: equals ⌊log₂ (j + 4)⌋ - 1.
Equations
- Complexity.ShannonUpper.treeLevel j = Nat.log 2 (j + 4) - 1
Instances For
Index of the first minterm-tree node at level l: 2^(l+1) - 4.
Equations
- Complexity.ShannonUpper.treeBase l = 2 ^ (l + 1) - 4
Instances For
Position of node j within level l of a minterm tree.
Equations
Instances For
Index of the parent (at level l - 1) of the level-l node at
position m: the parent's level position is m % 2^l.
Equations
- Complexity.ShannonUpper.treeParentIndex l m = Complexity.ShannonUpper.treeBase (l - 1) + m % 2 ^ l
Instances For
A minterm-tree node's parent has a strictly smaller index, so tree wiring is acyclic.
Column pattern encoding #
Column encodings are indices into the library of 2^(2^k) patterns.
The column function of f at data row y: maps an address a to
f(a, y), reading the first k input bits from a and the remaining
q bits from y.
Equations
Instances For
Pattern-library index of the column of f at data row y:
encodeColumn applied to columnFunction.
Equations
- Complexity.ShannonUpper.columnPatternIndex N f k q hkq y = Complexity.ShannonUpper.encodeColumn k (Complexity.ShannonUpper.columnFunction N f k q hkq y)
Instances For
Shannon gate array #
Correctness #
Bit-vector testBit lemma #
columnFunction reconstruction lemma #
Circuit correctness #
Key identity #
Connecting the last wire to the OR chain #
Semantic decomposition of the circuit #
The OR chain accumulates AND-layer semantic values.
This is the key wire-level fact: by induction on r, the OR-chain gate
at position r in Section F evaluates to the foldl-OR of AND-layer
semantic values for y = 0, ..., r+1.
The proof requires tracing wireValue through the gate array, showing:
- The gate at index orChainOffset(k,q) + r is in Section F
- Section F gates are OR gates with inputs pointing to:
* For r=0: AND gates at andLayerOffset+0 and andLayerOffset+1
* For r>0: previous OR-chain gate and AND gate at andLayerOffset+(r+1)
- Each AND gate at andLayerOffset+y evaluates to andLayerSem (by wireValue_andLayer_sem)
- The OR of the accumulated value and the new AND output gives
the extended foldl
The data tree leaf and column library output wire-value proofs
trace wireValue through Sections B and D respectively via
tree-level induction.
OR chain induction #
The deep wireValue unfolding through all 6 sections (required for
wireValue_andLayer_sem) and the gate array branch analysis make this
the most technically challenging part of the formalization.
Main correctness theorem #
Assembled Shannon construction: for N ≥ 16, every Boolean function on
N variables has a fan-in-2 AND/OR circuit whose gate count (plus output
gate) is within the explicit section-by-section budget.