recursive_nae_global_complement
For every positive depth k, complementing every input bit leaves the recursive ternary not-all-equal function unchanged.
Statement
theorem recursive_nae_global_complement (k : ℕ) : ∀ (hk : 1 ≤ k) (x : Fin (3 ^ k) → Bool), recursive_nae k (fun i => !(x i)) = recursive_nae k x
- Source
- The recursive function of arXiv:2611.16412 Section 5; supporting the odd-query clean-phase reduction for OP-1638.
- Verified
- 17 Nov 2026
- Axioms
Classical.choiceQuot.soundpropext- Built on 2
- recursive_naeThe k-th recursive block composition F_k = NAE₃^{∘ k} of the ternary not-all-equal Boolean function on 3^k bits.
- ternary_naeThe ternary not-all-equal Boolean function NAE₃ on 3 bits, which outputs 0 on 000 and 111 and 1 otherwise.
The proof, explained
The proof proceeds by induction on the depth k. The base case k = 0 is ruled out by the hypothesis 1 ≤ k. For the inductive step, the input of size 3^(k+1) is decomposed into three blocks of size 3^k. When k = 0 (depth 1), each sub-block has size 1 and evaluating depth 0 returns the input bit directly, so invariance under complement reduces to the base lemma that ternary NAE is unchanged when flipping all 3 bits (verified by exhaustive truth table analysis). When k ≥ 1, the induction hypothesis applies directly to each of the three sub-blocks, so the inputs to the outer ternary NAE gate are individually unchanged, completing the induction.
Base lemma: ternary NAE is invariant under bit negation
Unfolding the definition of ternary NAE and doing a case analysis on all 8 possible assignments to the three boolean inputs, simplifying each case.
unfold ternary_nae cases hx0 : x 0 <;> cases hx1 : x 1 <;> cases hx2 : x 2 <;> simp [hx0, hx1, hx2]
The case k = 0 is impossible because depth k is assumed to be at least 1
Proceed by induction on k. When k = 0, the hypothesis 1 ≤ 0 is contradictory, which omega resolves.
induction k with | zero => intro hk; omega
Unfold the definition of recursive NAE at depth k + 1
Assume the induction hypothesis for k, and let x be an input at depth k + 1. Decompose the input into 3 blocks of size 3^k via the canonical equivalence between Fin (3^(k+1)) and Fin 3 × Fin (3^k). Then recursive NAE at depth k+1 is by definition the ternary NAE applied to the recursive NAE evaluated on each of the 3 sub-blocks.
| succ k ih => intro hk x let split : Fin (3 ^ (k + 1)) ≃ Fin 3 × Fin (3 ^ k) := (finCongr (by ring : 3 * 3 ^ k = 3 ^ (k + 1))).symm.trans finProdFinEquiv.symm change ternary_nae (fun i => recursive_nae k (fun j => !(x (split.symm (i,j))))) = ternary_nae (fun i => recursive_nae k (fun j => x (split.symm (i,j))))Base case of the induction: depth k + 1 = 1
If k = 0, then depth is 1. At depth 0, recursive NAE simply returns the single input bit, so the recursive call on each block just negates that bit. The result then follows immediately from the base lemma ternary_nae_complement.
uses
ternary_nae_complementcases k with | zero => exact ternary_nae_complement _
Inductive step: depth k + 1 ≥ 2
If k is itself a successor (so the sub-blocks have depth at least 1), the induction hypothesis applies to each sub-block. Applying congruence and functional extensionality, each of the three sub-block evaluations is invariant under complementing its inputs by the induction hypothesis (since 1 ≤ k + 1). Therefore, the overall outputs coincide.
| succ k => congr 1 funext i exact ih (by omega) (fun j => x (split.symm (i,j)))
Written by a model (gemini-3.8-flash) from the Lean proof and the goal states Lean reported at each step. Lean verified the proof; this explanation is a reading aid and is not itself machine-checked.
Lean source view module on GitHub
Choose a tactic — a marked line — to see the goals Lean had before and after it, as in Lean’s infoview. Step with ← → or j k.
lemma ternary_nae_complement (x : Fin 3 → Bool) : ternary_nae (fun i => !(x i)) = ternary_nae x := by unfold ternary_nae cases hx0 : x 0 <;> cases hx1 : x 1 <;> cases hx2 : x 2 <;> simp [hx0, hx1, hx2]/-- Recursive ternary not-all-equal is invariant under global input complement at positive depth. -/theorem recursive_nae_global_complement (k : ℕ) : ∀ (hk : 1 ≤ k) (x : Fin (3 ^ k) → Bool), recursive_nae k (fun i => !(x i)) = recursive_nae k x := by induction k with | zero => intro hk; omega | succ k ih => intro hk x let split : Fin (3 ^ (k + 1)) ≃ Fin 3 × Fin (3 ^ k) := (finCongr (by ring : 3 * 3 ^ k = 3 ^ (k + 1))).symm.trans finProdFinEquiv.symm change ternary_nae (fun i => recursive_nae k (fun j => !(x (split.symm (i,j))))) = ternary_nae (fun i => recursive_nae k (fun j => x (split.symm (i,j)))) cases k with | zero => exact ternary_nae_complement _ | succ k => congr 1 funext i exact ih (by omega) (fun j => x (split.symm (i,j)))