The following are handwritten intermediate results for clean affine-input circuits. Two project verifiers checked the argument through C(f) ≤ n + 3. The original analysis records an author check of the extension through n + 6 and the reduction to R8. The graph arguments here are on paper. New tests check the integer transitions, the repaired counterexamples and the finite base case.
4.4 Lemmas and theorems
L1. The excess is a cycle count and the moves never raise it [Proven intermediate theorem]. Let K be a clean AIC over A.
- The output is a gate, i ≥ 2, and e(K) = Σ (t[w] − 1) ≥ 0, the sum over all nodes w other than the output. Also e(K) = E − V + 1 for the underlying connected multigraph with E wires and V nodes.
- Fixing. Let x be an input, a in F₂, and A′ = {ℓ[x] = a} non-empty. Then f[K] restricted to A′ is computed by an AIC K′ over A′ whose inputs are inputs of K other than x, and K′ is either trivial, or clean with s > s′ and e(K′) ≤ e(K) − (t[x] − 1).
- Killing. Suppose moreover that x feeds an AND-type top gate G = (ℓ[x] + a)(ℓ[y] + b) + c, so that ℓ[x] = a makes G constant. Then K′ can be taken such that: (i) if t[y] = 1, y is not an input of K′; (ii) if t[y] ≥ 2, then t[G] ≥ 1, and if K′ is clean, e(K′) ≤ e(K) − t[x] − t[G] + 1.
- Re-designation. If N = ℓ[x] + ℓ[y] + c is an XOR-type top gate and σ is the number of private inputs among x, y, then f[K] = f[K′] for an AIC K′ over the same A that is trivial (exactly when N is the output; then i′ = 1) or clean with s′ = s − 1, i′ = i + 1 − σ, e(K′) = e(K) − 2 + σ.
Proof. (1) Every node has a path to the output and inputs have no in-wires, so the output is a gate; the first gate in a topological order reads two different inputs. Each gate has two in-wires, so the out-degrees sum to 2s. The output has out-degree 0, every other node has out-degree ≥ 1, and there are s + i − 1 other nodes, so Σ (t[w] − 1) = 2s − (s + i − 1) = e. The graph is connected and E − V + 1 = 2s − (s + i) + 1 = e.
(4) Delete the two in-wires of N, label N by its form, delete x or y if it is left without an out-wire, and count.
(2) During the argument allow gates with 0, 1 or 2 in-wires, each carrying the function it computes of its in-nodes, and put b = E − V + (number of connected components). The number b does not increase when an edge is deleted (E drops by 1, the components rise by at most 1), when a vertex of degree j is deleted with its edges (for j ≥ 1, E − V drops by j − 1 and the components rise by at most j − 1; for j = 0, V and the components both drop by 1), or when an edge between two different vertices is contracted. Delete x and plug the constant a into its t[x] successors: every other node keeps its path to the output, so the graph stays connected and b = e − (t[x] − 1). Then repeat while possible: delete a non-output node with no out-wire; delete an in-wire on which the gate's function does not depend, or merge two parallel in-wires and replace the gate operation g by its diagonal u ↦ g(u,u); delete a gate with no in-wire (it computes a constant) and plug the constant into its successors, or stop with the constant circuit if it is the output; contract the in-wire of a gate with exactly one in-wire (it computes u or u + 1; its successors read u and absorb the negation; if it is the output, u becomes the output, negated if necessary). Each operation keeps the function on A′, lowers E + V and does not raise b. When none applies, either no gate is left, and after deleting the nodes that do not reach the output the circuit is trivial; or every gate has two in-wires from different nodes and depends on both, and every non-output node has an out-wire, hence a path to the output. In the second case the circuit is clean and connected, and e(K′) = b ≤ e − (t[x] − 1) by (1). Immediately after fixing x, its successors are unary or constant. Eliminate these first. At least one gate is removed and none is created, so s > s′.
(3) After x is deleted, G computes the constant c, so its in-wire from y is deleted. If t[y] = 1, y has no out-wire left and is deleted. If t[y] ≥ 2: G is not the output, because the other successor of y is a gate that must reach the output, and a path into G enters through x or y, which are inputs; so t[G] ≥ 1. Deleting the wire y → G keeps the graph connected (y keeps another successor, G keeps its out-wires), so b drops by 1. Deleting the constant gate G with its t[G] out-wires keeps it connected as well (no remaining node needs G to reach the output) and lowers b by t[G] − 1 more. So b ≤ e − (t[x] − 1) − 1 − (t[G] − 1) before the rest of the clean-up. ∎
L2. Only two shapes resist when e = 2 [Proven intermediate theorem]. Let K be clean with e(K) = 2 and suppose every top gate has two shared inputs. Then exactly two inputs x, y are shared, both of out-degree 2, every other non-output node has out-degree 1, and K has one of two shapes.
- S1 (one chain): gates G[0]..G[i]; G[0] reads x and y; G[j] reads G[j−1] and one input z[j]; the list z[1]..z[i] contains every input exactly once.
- S2 (two chains): two top gates G, G′ both read x and y; gates A[1]..A[p] and B[1]..B[q], where A[j] reads A[j−1] and a private input (A[0] = G) and likewise for B (B[0] = G′); a gate J reads A[p] and B[q]; gates C[1]..C[r], where C[j] reads C[j−1] and a private input (C[0] = J); the output is C[r]; p + q + r = i − 2.
Proof. By L1(1) the numbers t[w] − 1 sum to 2, and a top gate needs two different shared inputs; so exactly two inputs are shared, each of out-degree 2, and every other non-output node has out-degree 1. Every top gate reads {x, y}, so there are one or two top gates. Here s = i + 1; the inputs send i + 2 wires and the gates send s − 1 = i wires to gates. One top gate: the other i gates receive the remaining i input wires, at most one each because they are not top gates, hence exactly one each, plus one gate wire each; gate out-degrees are at most 1, so the gates form one path: S1. Two top gates: the other i − 1 gates receive i − 2 input wires, at most one each, so exactly one gate J has two gate in-wires and every other one has one input wire and one gate wire; out-degrees at most 1 make the gates a tree directed to the output with leaves G, G′ and one branching node J: S2. ∎ The shape count here follows from the wiring argument.
L3. Affine after few constraints [Proven intermediate theorem]. Call h: A → F₂ k-affine if every flat B inside A contains a flat B′ of codimension ≤ k in B on which h is affine.
- (0) A k-affine function is k′-affine for k′ ≥ k, and it is constant on a sub-flat of A of codimension ≤ k + 1.
- (i) If h is k-affine, ℓ an affine form and g a gate operation, then g(ℓ, h) is max(k,1)-affine.
- (ii) If h[1] is k[1]-affine and h[2] is k[2]-affine with k[1], k[2] ≥ 1, then g(h[1], h[2]) is (k[1] + k[2])-affine.
- (iii) Chain dichotomy. Let X[0] = h be any function on A, X[j] = g[j](ℓ[j], X[j−1]) for j = 1..k with affine forms ℓ[j], and B a flat inside A. Then either X[k] is affine on some B′ inside B of codimension ≤ 1 ("cut"), or X[k] = h + λ on B for an affine form λ ("pass").
- (iv) f[K] is 1-affine for shape S1 and 2-affine for shape S2; hence c(K) ≤ 2, respectively ≤ 3.
- (v) If i is even, then c(K) ≤ i/2 for every K of shape S1 or S2.
Proof. (0) An affine function on B′ is constant on B′ or on a hyperplane of B′.
(i) XOR-type: ℓ + h + c is affine wherever h is. AND-type (ℓ+a)(h+b)+c on B: if ℓ is not constant on B, the function is constant on B ∩ {ℓ = a}; if ℓ = a on B it is constant on B; if ℓ = a+1 on B it equals h + b + c, which is k-affine.
(ii) XOR-type: take B′ of codimension ≤ k[1] in B with h[1] affine, then B″ of codimension ≤ k[2] in B′ with h[2] affine. AND-type (h[1]+a)(h[2]+b)+c: take B′ with h[1] = m affine on B′. If m is not constant on B′, the function is constant on B′ ∩ {m = a}, of codimension ≤ k[1] + 1 ≤ k[1] + k[2]. If m = a on B′ it is constant. If m = a+1 on B′ it equals h[2] + b + c there, which is affine on some B″ of codimension ≤ k[2] in B′.
(iii) Induction on k; k = 0 is "pass" with λ = 0. If g[k] is XOR-type, X[k] = ℓ[k] + X[k−1] + c and the alternative for X[k−1] on B carries over. If g[k] = (ℓ[k] + a)(X[k−1] + b) + c: if ℓ[k] is not constant on B, X[k] is constant on B ∩ {ℓ[k] = a}; if ℓ[k] = a on B, X[k] is constant on B; if ℓ[k] = a + 1 on B, X[k] = X[k−1] + b + c on B and the alternative for X[k−1] carries over.
(iv) S1: G[0] = g(ℓ[x], ℓ[y]) is 1-affine by (i) with h = ℓ[y], then every G[j] by (i). S2: A[p] and B[q] are 1-affine, J is 2-affine by (ii), every C[j] is 2-affine by (i). Then apply (0).
(v) i = 2 and i = 4: fact E1. i ≥ 6: (iv) gives 3 ≤ i/2. ∎
Proposition A (excess at most 2) [Proven intermediate theorem]. If K is trivial, or clean with e(K) ≤ 2, then c(K) ≤ floor((i+1)/2) = β(i) = κ(i, e).
Proof. Induction on s. Trivial circuits: Fact T. If some input form is constant on A, fix it at no cost by L1(2): the number of inputs drops and e does not rise. So assume no form is constant on A; then every input can be fixed to either value at cost 1.
i odd. Fix any input: c ≤ 1 + β(i−1) = (i+1)/2.
i even. Take a top gate G with inputs x, y (the first gate in a topological order is one).
- (a) G is AND-type and y is private: fix ℓ[x] to the value that makes G constant. By L1(3)(i) x and y both disappear, so c ≤ 1 + (i−2)/2 = i/2.
- (b) G is XOR-type and y is private: re-designate G by L1(4). If x is private too, i′ = i − 1 and e′ = e, so c ≤ β(i−1) = i/2. Otherwise i′ = i, e′ = e − 1, s′ = s − 1 and induction gives i/2.
- (c) No top gate has a private input: every top gate has two shared inputs, which needs two extra wires, so e = 2, and L2 with L3(v) gives c ≤ i/2. ∎
For ordinary circuits and even n this says: C(f) ≤ n + 1 implies f is normal.
Theorem 1 (excess at most 4) [Proven intermediate theorem; confirmed by two verifiers]. If K is trivial, or clean with e(K) ≤ 4, then f[K] is constant on a sub-flat of A of codimension ≤ κ(i, e(K)) = floor((s + 2i + 4)/6).
Proof. Induction on s. The case e ≤ 2 is Proposition A. Forms constant on A are fixed at no cost as before.
- i even, e = 3 or 4; target i/2 + 1. Fix any input: c ≤ 1 + κ(i−1, 4) = 1 + i/2.
- i odd, e = 3; target (i+1)/2. If some input is shared, fix it: by L1(2) e′ ≤ 2 and i′ ≤ i − 1, so c ≤ 1 + (i−1)/2. Otherwise all inputs are private; take a top gate. AND-type: kill it by fixing one input; both inputs disappear, so c ≤ 1 + κ(i−2, 3) = 1 + (i−1)/2. XOR-type: re-designate it (σ = 2): i′ = i − 1, e′ = 3, so c ≤ κ(i−1, 3) = (i+1)/2.
- i odd, e = 4; target (i+1)/2. Take a top gate G. XOR-type: re-designate it. σ = 0 gives i′ = i + 1, e′ = 2, and Proposition A gives (i+1)/2; here the inputs x, y, G carry linearly dependent forms, which is why AICs are needed. σ = 1 gives (i, 3) and the bound (i+1)/2. σ = 2 gives (i−1, 4) and the bound (i−1)/2 + 1. AND-type with a private input: kill it by fixing the other input; c ≤ 1 + κ(i−2, 4) = (i+1)/2. AND-type with two shared inputs: kill it by fixing x; by L1(3)(ii) e′ ≤ 4 − t[x] − t[G] + 1 ≤ 2 and i′ ≤ i − 1, so c ≤ 1 + (i−1)/2. ∎
4.5 Two statements of the first pass that were false as written
Read the two counterexamples and their repairs in the final induction part.