line_cubic_boundary_extension
Removing the two designated boundary supports, adjoining the new index to every other support and adding four boundary supports preserves the line cubic moment invariant while increasing cardinality by two.
Statement
theorem line_cubic_boundary_extension (n : ℕ) (hn : 5 ≤ n) (S : Finset (Finset ℕ)) (h : LineBuild.Good n S) : LineBuild.Good (n+1) (LineBuild.step n S)- Source
- Auxiliary construction for OP-4, the line cubic exact-count question in arXiv:2610.01024; new boundary induction developed here.
- Verified
- 25 Oct 2026
- Axioms
Classical.choiceQuot.soundpropext- Used by 2
- line_cubic_nat_family_existsEvery n at least five admits a bounded natural-index support family of size 2n+1 with the required line cubic moments and the boundary…
- open_problem_line_cubic_t_countFor every integer n ≥ 5, there exists a parity representation of the line cubic syndrome of cardinality 2n + 1.
The proof, explained
The construction extends a family S satisfying the cubic moment invariant at stage n ≥ 5 to stage n+1 by removing the boundary supports {n-2} and {n-2, n-1}, adjoining n to every remaining set, and adding the four new boundary sets {n-2}, {n-2, n-1}, {n-1}, and {n-1, n}. A general summation identity shows that test sets disjoint from {n} preserve their moments because the boundary changes cancel modulo 2, while test sets containing n reduce to old moments plus boundary indicators. Evaluating these moment formulas on singletons, pairs, and triples verifies that degrees and pair moments remain zero, while triple moments vanish except on consecutive triples, thereby advancing the Good invariant to n+1 while increasing cardinality by two.
When a, b, c are pairwise distinct, the four boundary sets {a}, {a, b}, {b}, and {b, c} are mutually distinct.
For sets of different cardinalities (singletons versus doubletons), equality is impossible by congrArg Finset.card. For singletons {a} and {b}, equality would force a = b. For pairs {a, b} and {b, c}, equality implies a ∈ {b, c}, contradicting a ≠ b and a ≠ c.
uses
congrArg,Finset.cardhave h1 : ({a} : Finset ℕ) ≠ {a,b} := by intro h; have := congrArg Finset.card h; simp [hab] at this have h2 : ({a} : Finset ℕ) ≠ {b} := by simpa using hab have h3 : ({a} : Finset ℕ) ≠ {b,c} := by intro h; have := congrArg Finset.card h; simp [hbc] at this have h4 : ({a,b} : Finset ℕ) ≠ {b} := by intro h; have := congrArg Finset.card h; simp [hab] at this have h5 : ({a,b} : Finset ℕ) ≠ {b,c} := by intro h have hh : a ∈ ({b,c} : Finset ℕ) := h ▸ (by simp) simpa [hab, hac] using hh have h6 : ({b} : Finset ℕ) ≠ {b,c} := by intro h; have := congrArg Finset.card h; simp [hbc] at this exact ⟨h1,h2,h3,h4,h5,h6⟩
The indices n-2, n-1, and n are distinct, the reduced family T = (S \ {{n-2}}) \ {{n-2, n-1}} consists of sets not containing n, and adjoining n to sets of T is injective.
Because n ≥ 5, linear arithmetic shows n-2, n-1, and n are pairwise distinct, so the boundary sets are distinct by boundary_distinct. Since all elements of sets in S are strictly bounded by n, no set in S contains n. Erasing n from y ∪ {n} recovers y, making the insertion map injective on T.
uses
boundary_distinct,congrArgclassical let a := n-2 let b := n-1 let T := (S.erase {a}).erase {a,b} have hab : a ≠ b := by dsimp [a,b]; omega have han : a ≠ n := by dsimp [a]; omega have hbn : b ≠ n := by dsimp [b]; omega obtain ⟨h1,h2,h3,h4,h5,h6⟩ := boundary_distinct hab han hbn have hTS : T ⊆ S := fun y hy => (mem_erase.mp (mem_erase.mp hy).2).2 have hnc (y) (hy : y ∈ S) : n ∉ y := by intro hm; have := h.bounded y hy n hm; omega have hinj : Set.InjOn (insert n) (↑T : Set (Finset ℕ)) := by intro x hx y hy he have hh := congrArg (erase · n) he simpa [hnc x (hTS hx), hnc y (hTS hy)] using hh
The image of T under adjoining n is disjoint from the four boundary sets, |T| = |S| - 2, the boundary has size 4, and step n S decomposes as their disjoint union.
Every set in the image of T contains n, whereas the boundary sets {n-2}, {n-2, n-1}, and {n-1} do not. If the remaining boundary set {n-1, n} were in the image, erasing n would force {n-1} ∈ S, contradicting the hypothesis that {n-1} ∉ S. The four boundary sets are distinct, so their union has size 4, and erasing {n-2} and {n-2, n-1} from S decreases its cardinality by 2.
uses
mem_insert_self,Ne.symm,erase_insert,card_erase_of_memhave hdisj : Disjoint (T.image (insert n)) (boundary a b n) := by apply disjoint_left.mpr intro z hz hr obtain ⟨y,hy,rfl⟩ := mem_image.mp hz have hmem : n ∈ insert n y := mem_insert_self _ _ simp only [boundary, mem_insert, mem_singleton] at hr rcases hr with hr | hr | hr | hr · rw [hr] at hmem; simpa [Ne.symm han] using hmem · rw [hr] at hmem; simpa [Ne.symm han, Ne.symm hbn] using hmem · rw [hr] at hmem; simpa [Ne.symm hbn] using hmem · have hh := congrArg (erase · n) hr have hbr : ({b,n} : Finset ℕ).erase n = {b} := by ext i; simp; omega have he : y = {b} := by simpa only [erase_insert (hnc y (hTS hy)), hbr] using hh exact h.right (he ▸ hTS hy) have habmem : ({a,b} : Finset ℕ) ∈ S.erase {a} := by exact mem_erase.mpr ⟨Ne.symm h1, h.pair⟩ have hTcard : T.card = S.card - 2 := by dsimp [T] rw [card_erase_of_mem habmem, card_erase_of_mem h.left] omega have hRcard : (boundary a b n).card = 4 := by simp [boundary, h1,h2,h3,h4,h5,h6] have he : step n S = T.image (insert n) ∪ boundary a b n := rfl
The family step n S has elements strictly less than n+1, contains only non-empty sets, has cardinality 2(n+1)+1, contains {n-1} and {n-1, n}, and does not contain {n}.
Elements in sets from the image of T are bounded by n+1 because elements in S are < n, and boundary sets only contain indices among n-2, n-1, n < n+1. Non-emptiness holds because image sets contain n and boundary sets are non-empty. Disjointness of the union gives |step n S| = (|S| - 2) + 4 = 2n + 1 + 2 = 2(n+1) + 1. The sets {n-1} and {n-1, n} belong to the boundary, while {n} cannot belong to the image (which would require ∅ ∈ S) nor to the boundary.
uses
card_union_of_disjoint,card_image_of_injOnrefine ⟨?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ · intro y hy i hi rw [he] at hy rcases mem_union.mp hy with hy | hy · obtain ⟨z,hz,rfl⟩ := mem_image.mp hy rcases mem_insert.mp hi with rfl | hi · omega · have := h.bounded z (hTS hz) i hi; omega · simp only [boundary, mem_insert, mem_singleton] at hy rcases hy with rfl | rfl | rfl | rfl <;> simp only [mem_insert, mem_singleton] at hi <;> dsimp [a,b] at * <;> omega · intro y hy rw [he] at hy rcases mem_union.mp hy with hy | hy · obtain ⟨z,hz,rfl⟩ := mem_image.mp hy exact ⟨n, by simp⟩ · simp only [boundary, mem_insert, mem_singleton] at hy rcases hy with rfl | rfl | rfl | rfl <;> simp · rw [he, card_union_of_disjoint hdisj, card_image_of_injOn hinj, hTcard, hRcard, h.size] omega · rw [he]; simp [boundary, b] · rw [he]; simp [boundary, b] · intro hm rw [he] at hm rcases mem_union.mp hm with hm | hm · obtain ⟨y,hy,heq⟩ := mem_image.mp hm have hh := congrArg (erase · n) heq have hempty : y = ∅ := by simpa [hnc y (hTS hy)] using hh exact (h.nonempty y (hTS hy)).ne_empty hempty · simp only [boundary, mem_insert, mem_singleton] at hm rcases hm with hm | hm | hm | hm · have hh := congrArg (fun z : Finset ℕ => n ∈ z) hm simp [Ne.symm han] at hh · have hh := congrArg (fun z : Finset ℕ => n ∈ z) hm simp [Ne.symm han, Ne.symm hbn] at hh · have hh := congrArg (fun z : Finset ℕ => n ∈ z) hm simp [Ne.symm hbn] at hh · have hh := congrArg (fun z : Finset ℕ => b ∈ z) hm simp [hbn] at hh
For any test function f : Finset ℕ → ZMod 2, the sum over step n S equals the sum over S of f(y ∪ {n}) minus f({n-2, n}) and f({n-2, n-1, n}) plus the evaluations on the four boundary sets.
The sum splits over the disjoint union of the image of T and the boundary. By injectivity, the sum over the image of T is the sum of f(y ∪ {n}) over y ∈ T, which equals the sum over all of S minus the two removed sets {n-2} and {n-2, n-1} with n adjoined. Adding the four evaluations on the boundary sets completes the algebraic identity.
uses
sum_union,sum_image,sum_erase_add,sum_insert,sum_singleton· intro f rw [he, sum_union hdisj, sum_image hinj] have e1 := sum_erase_add (s := S) (f := fun y => f (insert n y)) h.left have e2 := sum_erase_add (s := S.erase {a}) (f := fun y => f (insert n y)) habmem change (∑ y ∈ T, f (insert n y)) + _ = _ rw [← e1, ← e2] simp only [boundary, sum_insert, mem_insert, mem_singleton, h1,h2,h3,h4,h5,h6, not_false_eq_true, sum_singleton] have e3 : insert n ({a} : Finset ℕ) = {a,n} := by ext i; simp; tauto have e4 : insert n ({a,b} : Finset ℕ) = {a,b,n} := by ext i; simp; tauto dsimp only [a,b] at e3 e4 rw [e3,e4] dsimp only [a,b] at * simp [boundary, h1,h2,h3,h4,h5,h6] ring
Adjoining an element c to y does not change whether A ⊆ y, provided c ∉ A.
Since c is not in A, any element of A that belongs to y ∪ {c} must already belong to y. Thus A ⊆ y ∪ {c} is logically equivalent to A ⊆ y, so their indicators in ZMod 2 coincide.
uses
propext,False.elim,mem_insert_of_memunfold chi congr 1 apply propext constructor · intro hs i hi rcases mem_insert.mp (hs hi) with he | he · exact False.elim (h (he ▸ hi)) · exact he · exact fun hs i hi => mem_insert_of_mem (hs hi)
Adjoining c to both B and y preserves the subset condition B ⊆ y, provided c ∉ B.
The subset relation B ∪ {c} ⊆ y ∪ {c} holds if and only if c ∈ y ∪ {c} and B ⊆ y ∪ {c}. The first condition is always true, and because c ∉ B, the second is equivalent to B ⊆ y.
uses
insert_subset_iff,mem_insert_self,False.elim,mem_insert_of_memunfold chi have he : insert c B ⊆ insert c y ↔ B ⊆ y := by rw [insert_subset_iff] simp only [mem_insert_self, true_and] constructor · intro hs i hi rcases mem_insert.mp (hs hi) with he | he · exact False.elim (h (he ▸ hi)) · exact he · exact fun hs i hi => mem_insert_of_mem (hs hi) simp only [he]
For any set A not containing n, the moment of A with respect to step n S equals its moment with respect to S.
Applying the structural summation identity to the indicator f = chi A, the main sum reduces to moment S A by chi_insert_old. The two negative boundary terms cancel with chi A {n-2} and chi A {n-2, n-1}, and the remaining two boundary terms sum to 2 * chi A {n-1}, which is 0 modulo 2.
uses
structural,chi_insert_old,Finset.pair_commhave hs := (structural n hn S h).2.2.2.2.2.2 (chi A) change moment (step n S) A = _ at hs simp only [chi_insert_old A _ n hc] at hs have h1 : chi A {n-2,n} = chi A {n-2} := by rw [Finset.pair_comm]; exact chi_insert_old A {n-2} n hc have h2 : chi A {n-2,n-1,n} = chi A {n-2,n-1} := by have he : ({n-2,n-1,n} : Finset ℕ) = insert n {n-2,n-1} := by ext i; simp; tauto rw [he]; exact chi_insert_old A {n-2,n-1} n hc have h3 : chi A {n-1,n} = chi A {n-1} := by rw [Finset.pair_comm]; exact chi_insert_old A {n-1} n hc rw [h1,h2,h3] at hs change moment (step n S) A = moment S A rw [hs] change moment S A - _ - _ + _ + _ + _ + _ = moment S A have hz : (2 : ZMod 2) = 0 := by decide linear_combination hz * chi A {n-1}
For any set B not containing n, the moment of B ∪ {n} in step n S equals moment S B - chi B {n-2} - chi B {n-2, n-1} + chi B {n-1}.
Applying the summation identity to f = chi (B ∪ {n}), the sum over S becomes moment S B by chi_insert_new. Any boundary set not containing n cannot contain B ∪ {n}, so those terms vanish. For the boundary sets containing n, chi_insert_new simplifies each evaluation to the indicator of B in the set with n removed.
uses
structural,chi_insert_new,if_neg,mem_insert_self,Finset.pair_commhave hs := (structural n hn S h).2.2.2.2.2.2 (chi (insert n B)) change moment (step n S) (insert n B) = _ at hs simp only [chi_insert_new B _ n hc] at hs have hzero (y : Finset ℕ) (hy : n ∉ y) : chi (insert n B) y = 0 := by unfold chi rw [if_neg] exact fun hh => hy (hh (mem_insert_self _ _)) have ha : n ∉ ({n-2} : Finset ℕ) := by simp; omega have hab : n ∉ ({n-2,n-1} : Finset ℕ) := by simp; omega have hb : n ∉ ({n-1} : Finset ℕ) := by simp; omega rw [hzero _ ha, hzero _ hab, hzero _ hb] at hs have e1 : chi (insert n B) {n-2,n} = chi B {n-2} := by rw [Finset.pair_comm]; exact chi_insert_new B {n-2} n hc have e2 : chi (insert n B) {n-2,n-1,n} = chi B {n-2,n-1} := by have he : ({n-2,n-1,n} : Finset ℕ) = insert n {n-2,n-1} := by ext i; simp; tauto rw [he]; exact chi_insert_new B {n-2,n-1} n hc have e3 : chi (insert n B) {n-1,n} = chi B {n-1} := by rw [Finset.pair_comm]; exact chi_insert_new B {n-1} n hc simpa only [e1,e2,e3,add_zero, moment] using hs
The size, boundedness, and boundary membership conditions of the Good invariant hold at stage n+1 for step n S.
The structural theorem provides boundedness by n+1, non-emptiness, and size 2(n+1)+1. The boundary conditions translate to {(n+1)-2} = {n-1} ∈ step n S, {(n+1)-2, (n+1)-1} = {n-1, n} ∈ step n S, and {(n+1)-1} = {n} ∉ step n S, all of which were established in structural.
uses
structuralobtain ⟨hb,he,hc,hl,hp,hr,hs⟩ := structural n hn S h have e1 : n+1-2 = n-1 := by omega have e2 : n+1-1 = n := by omega refine ⟨hb,he,hc,?_,?_,?_,?_,?_,?_⟩ · simpa only [e1] using hl · simpa only [e1,e2] using hp · simpa only [e2] using hr
Every singleton {i} with i < n+1 has moment zero in step n S.
If i < n, n ∉ {i}, so moment_old gives moment S {i} = 0. If i = n, {n} = ∅ ∪ {n}, and moment_new with B = ∅ evaluates to moment S ∅ - 1 - 1 + 1. Since |S| = 2n+1 is odd, moment S ∅ = 1, so 1 - 1 - 1 + 1 = 0 in ZMod 2.
uses
moment_old,moment_new,Nat.cast_add,Nat.cast_mul· intro i hi by_cases hin : i < n · rw [moment_old n hn S h {i} (by simp; omega)] exact h.one i hin · have ei : i = n := by omega subst i have hm := moment_new n hn S h ∅ (by simp) have ht : (2 : ZMod 2) = 0 := by decide have hz : moment S ∅ = 1 := by simp [moment, chi, h.size, Nat.cast_add, Nat.cast_mul, ht] simpa [hz, chi, show (1 : ZMod 2)+1=0 by decide] using hm
Every pair {i, j} with i < j < n+1 has moment zero in step n S. automation
If j < n, n ∉ {i, j}, so moment_old gives moment S {i, j} = 0. If j = n, moment_new with B = {i} yields moment S {i} - chi {i} {n-2} - chi {i} {n-2, n-1} + chi {i} {n-1}. The first term is 0 by the stage n invariant, and automated case analysis on whether i = n-2, i = n-1, or i < n-2 confirms the boundary evaluations sum to 0 modulo 2 in all cases.
uses
moment_old,moment_new· intro j hj i hi by_cases hjn : j < n · rw [moment_old n hn S h {i,j} (by simp; omega)] exact h.two j hjn i hi · have ej : j = n := by omega subst j have hm := moment_new n hn S h {i} (by simp; omega) have ee : ({i,n} : Finset ℕ) = insert n {i} := by ext x; simp; tauto rw [ee, hm, h.one i hi] simp only [chi, singleton_subset_iff, mem_insert, mem_singleton] split_ifs <;> first | decide | omega · intro k hk j hj i hi
Every triple {i, j, k} with i < j < k < n+1 has moment 1 if j = i+1 and k = i+2, and 0 otherwise. automation
If k < n, the moment is preserved from stage n by moment_old. If k = n, moment_new with B = {i, j} yields moment S {i, j} - chi {i, j} {n-2} - chi {i, j} {n-2, n-1} + chi {i, j} {n-1}. The pair moment is 0, and the size-two set {i, j} cannot be contained in the singletons {n-2} or {n-1}. It is contained in {n-2, n-1} if and only if i = n-2 and j = n-1, which matches the consecutive triple condition j = i+1 and n = i+2.
uses
moment_old,moment_newby_cases hkn : k < n · rw [moment_old n hn S h {i,j,k} (by simp; omega)] exact h.three k hkn j hj i hi · have ek : k = n := by omega subst k have hm := moment_new n hn S h {i,j} (by simp; omega) have ee : ({i,j,n} : Finset ℕ) = insert n {i,j} := by ext x; simp; tauto rw [ee, hm, h.two j hj i hi] simp only [chi, insert_subset_iff, singleton_subset_iff, mem_insert, mem_singleton] split_ifs <;> first | decide | omega
The boundary extension step preserves the Good invariant from stage n to stage n+1.
The result is an immediate application of LineBuild.good_step.
uses
LineBuild.good_stepexact LineBuild.good_step n hn S h
congrArg- Applying a function to equal inputs produces equal outputs: if a₁ = a₂, then f(a₁) = f(a₂).
Finset.card- The number of elements in a finite set.
boundary_distinct- For pairwise distinct natural numbers a, b, c, the four sets {a}, {a, b}, {b}, and {b, c} are mutually distinct.
mem_insert_self- An element always belongs to the set obtained by inserting it: a ∈ insert a s.
Ne.symm- Inequality is symmetric: if a ≠ b, then b ≠ a.
erase_insert- Erasing an element from an insertion yields the original set if the element was not originally present.
card_erase_of_mem- Erasing an element present in a finite set decreases its cardinality by 1.
card_union_of_disjoint- The cardinality of the union of two disjoint finite sets is the sum of their cardinalities.
card_image_of_injOn- The cardinality of the image of a finite set under an injective map equals the cardinality of the original set.
sum_union- The sum of a function over the union of two disjoint finite sets is the sum of the sums over each set.
sum_image- The sum of a function over the image of an injective map equals the sum of the composed function over the domain.
sum_erase_add- The sum of a function over an erased set plus its value at the erased element equals the sum over the original set.
sum_insert- Inserting a new element into a finite set adds the evaluation at that element to the sum over the set.
sum_singleton- The sum of a function over a singleton set is simply the evaluation of the function at that element.
propext- Two propositions are equal if and only if they are logically equivalent (propositional extensionality).
False.elim- From False, any proposition follows (ex falso quodlibet).
mem_insert_of_mem- If an element belongs to a finite set s, it also belongs to insert b s.
insert_subset_iff- A set insert a s is a subset of t if and only if a ∈ t and s ⊆ t.
structural- The step construction produces a family bounded by n+1 of non-empty sets with size 2(n+1)+1, correct boundary memberships, and a general summation identity.
chi_insert_old- The indicator of A ⊆ y is unchanged when adjoining an element c to y, provided c ∉ A.
Finset.pair_comm- The unordered pair {a, b} equals {b, a}.
chi_insert_new- The indicator of B ∪ {c} ⊆ y ∪ {c} equals the indicator of B ⊆ y when c ∉ B.
if_neg- If the condition of an if-then-else is false, the expression evaluates to the else branch.
moment_old- The moment of any test set disjoint from {n} is unchanged between S and step n S.
moment_new- The moment of B ∪ {n} in step n S expresses in terms of moments and boundary indicators in S.
Nat.cast_add- The natural number cast to a ring preserves addition: ↑(m + n) = ↑m + ↑n.
Nat.cast_mul- The natural number cast to a semiring preserves multiplication: ↑(m * n) = ↑m * ↑n.
LineBuild.good_step- If a family S satisfies the Good invariant at stage n ≥ 5, then step n S satisfies the Good invariant at stage n+1.
- The moment preservation checks for pairs and triples involving the newly adjoined element n (lines 244-245 and 254-255) delegate case analysis across index conditions to Lean automation (split_ifs together with decide and omega).
- Calculations in ZMod 2 implicitly rely on 2 = 0 to eliminate doubled terms such as 2 * chi A {n-1}.
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.
set_option maxHeartbeats 4000000set_option maxRecDepth 4096namespace LineBuildopen Finsetdef chi (A y : Finset ℕ) : ZMod 2 := if A ⊆ y then 1 else 0def moment (S : Finset (Finset ℕ)) (A : Finset ℕ) : ZMod 2 := ∑ y ∈ S, chi A ydef boundary (a b c : ℕ) : Finset (Finset ℕ) := {{a}, {a,b}, {b}, {b,c}}def step (n : ℕ) (S : Finset (Finset ℕ)) : Finset (Finset ℕ) := ((S.erase {n-2}).erase {n-2,n-1}).image (insert n) ∪ boundary (n-2) (n-1) nstructure Good (n : ℕ) (S : Finset (Finset ℕ)) : Prop where bounded : ∀ y ∈ S, ∀ i ∈ y, i < n nonempty : ∀ y ∈ S, y.Nonempty size : S.card = 2*n+1 left : {n-2} ∈ S pair : {n-2,n-1} ∈ S right : {n-1} ∉ S one : ∀ i < n, moment S {i} = 0 two : ∀ j < n, ∀ i < j, moment S {i,j} = 0 three : ∀ k < n, ∀ j < k, ∀ i < j, moment S {i,j,k} = if j=i+1 ∧ k=i+2 then 1 else 0theorem boundary_distinct {a b c : ℕ} (hab : a ≠ b) (hac : a ≠ c) (hbc : b ≠ c) : ({a} : Finset ℕ) ≠ {a,b} ∧ ({a} : Finset ℕ) ≠ {b} ∧ ({a} : Finset ℕ) ≠ {b,c} ∧ ({a,b} : Finset ℕ) ≠ {b} ∧ ({a,b} : Finset ℕ) ≠ {b,c} ∧ ({b} : Finset ℕ) ≠ {b,c} := by have h1 : ({a} : Finset ℕ) ≠ {a,b} := by intro h; have := congrArg Finset.card h; simp [hab] at this have h2 : ({a} : Finset ℕ) ≠ {b} := by simpa using hab have h3 : ({a} : Finset ℕ) ≠ {b,c} := by intro h; have := congrArg Finset.card h; simp [hbc] at this have h4 : ({a,b} : Finset ℕ) ≠ {b} := by intro h; have := congrArg Finset.card h; simp [hab] at this have h5 : ({a,b} : Finset ℕ) ≠ {b,c} := by intro h have hh : a ∈ ({b,c} : Finset ℕ) := h ▸ (by simp) simpa [hab, hac] using hh have h6 : ({b} : Finset ℕ) ≠ {b,c} := by intro h; have := congrArg Finset.card h; simp [hbc] at this exact ⟨h1,h2,h3,h4,h5,h6⟩theorem structural (n : ℕ) (hn : 5 ≤ n) (S : Finset (Finset ℕ)) (h : Good n S) : (∀ y ∈ step n S, ∀ i ∈ y, i < n+1) ∧ (∀ y ∈ step n S, y.Nonempty) ∧ (step n S).card = 2*(n+1)+1 ∧ {n-1} ∈ step n S ∧ {n-1,n} ∈ step n S ∧ {n} ∉ step n S ∧ (∀ f : Finset ℕ → ZMod 2, (∑ y ∈ step n S, f y) = (∑ y ∈ S, f (insert n y)) - f {n-2,n} - f {n-2,n-1,n} + f {n-2} + f {n-2,n-1} + f {n-1} + f {n-1,n}) := by classical let a := n-2 let b := n-1 let T := (S.erase {a}).erase {a,b} have hab : a ≠ b := by dsimp [a,b]; omega have han : a ≠ n := by dsimp [a]; omega have hbn : b ≠ n := by dsimp [b]; omega obtain ⟨h1,h2,h3,h4,h5,h6⟩ := boundary_distinct hab han hbn have hTS : T ⊆ S := fun y hy => (mem_erase.mp (mem_erase.mp hy).2).2 have hnc (y) (hy : y ∈ S) : n ∉ y := by intro hm; have := h.bounded y hy n hm; omega have hinj : Set.InjOn (insert n) (↑T : Set (Finset ℕ)) := by intro x hx y hy he have hh := congrArg (erase · n) he simpa [hnc x (hTS hx), hnc y (hTS hy)] using hh have hdisj : Disjoint (T.image (insert n)) (boundary a b n) := by apply disjoint_left.mpr intro z hz hr obtain ⟨y,hy,rfl⟩ := mem_image.mp hz have hmem : n ∈ insert n y := mem_insert_self _ _ simp only [boundary, mem_insert, mem_singleton] at hr rcases hr with hr | hr | hr | hr · rw [hr] at hmem; simpa [Ne.symm han] using hmem · rw [hr] at hmem; simpa [Ne.symm han, Ne.symm hbn] using hmem · rw [hr] at hmem; simpa [Ne.symm hbn] using hmem · have hh := congrArg (erase · n) hr have hbr : ({b,n} : Finset ℕ).erase n = {b} := by ext i; simp; omega have he : y = {b} := by simpa only [erase_insert (hnc y (hTS hy)), hbr] using hh exact h.right (he ▸ hTS hy) have habmem : ({a,b} : Finset ℕ) ∈ S.erase {a} := by exact mem_erase.mpr ⟨Ne.symm h1, h.pair⟩ have hTcard : T.card = S.card - 2 := by dsimp [T] rw [card_erase_of_mem habmem, card_erase_of_mem h.left] omega have hRcard : (boundary a b n).card = 4 := by simp [boundary, h1,h2,h3,h4,h5,h6] have he : step n S = T.image (insert n) ∪ boundary a b n := rfl refine ⟨?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ · intro y hy i hi rw [he] at hy rcases mem_union.mp hy with hy | hy · obtain ⟨z,hz,rfl⟩ := mem_image.mp hy rcases mem_insert.mp hi with rfl | hi · omega · have := h.bounded z (hTS hz) i hi; omega · simp only [boundary, mem_insert, mem_singleton] at hy rcases hy with rfl | rfl | rfl | rfl <;> simp only [mem_insert, mem_singleton] at hi <;> dsimp [a,b] at * <;> omega · intro y hy rw [he] at hy rcases mem_union.mp hy with hy | hy · obtain ⟨z,hz,rfl⟩ := mem_image.mp hy exact ⟨n, by simp⟩ · simp only [boundary, mem_insert, mem_singleton] at hy rcases hy with rfl | rfl | rfl | rfl <;> simp · rw [he, card_union_of_disjoint hdisj, card_image_of_injOn hinj, hTcard, hRcard, h.size] omega · rw [he]; simp [boundary, b] · rw [he]; simp [boundary, b] · intro hm rw [he] at hm rcases mem_union.mp hm with hm | hm · obtain ⟨y,hy,heq⟩ := mem_image.mp hm have hh := congrArg (erase · n) heq have hempty : y = ∅ := by simpa [hnc y (hTS hy)] using hh exact (h.nonempty y (hTS hy)).ne_empty hempty · simp only [boundary, mem_insert, mem_singleton] at hm rcases hm with hm | hm | hm | hm · have hh := congrArg (fun z : Finset ℕ => n ∈ z) hm simp [Ne.symm han] at hh · have hh := congrArg (fun z : Finset ℕ => n ∈ z) hm simp [Ne.symm han, Ne.symm hbn] at hh · have hh := congrArg (fun z : Finset ℕ => n ∈ z) hm simp [Ne.symm hbn] at hh · have hh := congrArg (fun z : Finset ℕ => b ∈ z) hm simp [hbn] at hh · intro f rw [he, sum_union hdisj, sum_image hinj] have e1 := sum_erase_add (s := S) (f := fun y => f (insert n y)) h.left have e2 := sum_erase_add (s := S.erase {a}) (f := fun y => f (insert n y)) habmem change (∑ y ∈ T, f (insert n y)) + _ = _ rw [← e1, ← e2] simp only [boundary, sum_insert, mem_insert, mem_singleton, h1,h2,h3,h4,h5,h6, not_false_eq_true, sum_singleton] have e3 : insert n ({a} : Finset ℕ) = {a,n} := by ext i; simp; tauto have e4 : insert n ({a,b} : Finset ℕ) = {a,b,n} := by ext i; simp; tauto dsimp only [a,b] at e3 e4 rw [e3,e4] dsimp only [a,b] at * simp [boundary, h1,h2,h3,h4,h5,h6] ringtheorem chi_insert_old (A y : Finset ℕ) (c : ℕ) (h : c ∉ A) : chi A (insert c y) = chi A y := by unfold chi congr 1 apply propext constructor · intro hs i hi rcases mem_insert.mp (hs hi) with he | he · exact False.elim (h (he ▸ hi)) · exact he · exact fun hs i hi => mem_insert_of_mem (hs hi)theorem chi_insert_new (B y : Finset ℕ) (c : ℕ) (h : c ∉ B) : chi (insert c B) (insert c y) = chi B y := by unfold chi have he : insert c B ⊆ insert c y ↔ B ⊆ y := by rw [insert_subset_iff] simp only [mem_insert_self, true_and] constructor · intro hs i hi rcases mem_insert.mp (hs hi) with he | he · exact False.elim (h (he ▸ hi)) · exact he · exact fun hs i hi => mem_insert_of_mem (hs hi) simp only [he]theorem moment_old (n : ℕ) (hn : 5 ≤ n) (S : Finset (Finset ℕ)) (h : Good n S) (A : Finset ℕ) (hc : n ∉ A) : moment (step n S) A = moment S A := by have hs := (structural n hn S h).2.2.2.2.2.2 (chi A) change moment (step n S) A = _ at hs simp only [chi_insert_old A _ n hc] at hs have h1 : chi A {n-2,n} = chi A {n-2} := by rw [Finset.pair_comm]; exact chi_insert_old A {n-2} n hc have h2 : chi A {n-2,n-1,n} = chi A {n-2,n-1} := by have he : ({n-2,n-1,n} : Finset ℕ) = insert n {n-2,n-1} := by ext i; simp; tauto rw [he]; exact chi_insert_old A {n-2,n-1} n hc have h3 : chi A {n-1,n} = chi A {n-1} := by rw [Finset.pair_comm]; exact chi_insert_old A {n-1} n hc rw [h1,h2,h3] at hs change moment (step n S) A = moment S A rw [hs] change moment S A - _ - _ + _ + _ + _ + _ = moment S A have hz : (2 : ZMod 2) = 0 := by decide linear_combination hz * chi A {n-1}theorem moment_new (n : ℕ) (hn : 5 ≤ n) (S : Finset (Finset ℕ)) (h : Good n S) (B : Finset ℕ) (hc : n ∉ B) : moment (step n S) (insert n B) = moment S B - chi B {n-2} - chi B {n-2,n-1} + chi B {n-1} := by have hs := (structural n hn S h).2.2.2.2.2.2 (chi (insert n B)) change moment (step n S) (insert n B) = _ at hs simp only [chi_insert_new B _ n hc] at hs have hzero (y : Finset ℕ) (hy : n ∉ y) : chi (insert n B) y = 0 := by unfold chi rw [if_neg] exact fun hh => hy (hh (mem_insert_self _ _)) have ha : n ∉ ({n-2} : Finset ℕ) := by simp; omega have hab : n ∉ ({n-2,n-1} : Finset ℕ) := by simp; omega have hb : n ∉ ({n-1} : Finset ℕ) := by simp; omega rw [hzero _ ha, hzero _ hab, hzero _ hb] at hs have e1 : chi (insert n B) {n-2,n} = chi B {n-2} := by rw [Finset.pair_comm]; exact chi_insert_new B {n-2} n hc have e2 : chi (insert n B) {n-2,n-1,n} = chi B {n-2,n-1} := by have he : ({n-2,n-1,n} : Finset ℕ) = insert n {n-2,n-1} := by ext i; simp; tauto rw [he]; exact chi_insert_new B {n-2,n-1} n hc have e3 : chi (insert n B) {n-1,n} = chi B {n-1} := by rw [Finset.pair_comm]; exact chi_insert_new B {n-1} n hc simpa only [e1,e2,e3,add_zero, moment] using hstheorem good_step (n : ℕ) (hn : 5 ≤ n) (S : Finset (Finset ℕ)) (h : Good n S) : Good (n+1) (step n S) := by obtain ⟨hb,he,hc,hl,hp,hr,hs⟩ := structural n hn S h have e1 : n+1-2 = n-1 := by omega have e2 : n+1-1 = n := by omega refine ⟨hb,he,hc,?_,?_,?_,?_,?_,?_⟩ · simpa only [e1] using hl · simpa only [e1,e2] using hp · simpa only [e2] using hr · intro i hi by_cases hin : i < n · rw [moment_old n hn S h {i} (by simp; omega)] exact h.one i hin · have ei : i = n := by omega subst i have hm := moment_new n hn S h ∅ (by simp) have ht : (2 : ZMod 2) = 0 := by decide have hz : moment S ∅ = 1 := by simp [moment, chi, h.size, Nat.cast_add, Nat.cast_mul, ht] simpa [hz, chi, show (1 : ZMod 2)+1=0 by decide] using hm · intro j hj i hi by_cases hjn : j < n · rw [moment_old n hn S h {i,j} (by simp; omega)] exact h.two j hjn i hi · have ej : j = n := by omega subst j have hm := moment_new n hn S h {i} (by simp; omega) have ee : ({i,n} : Finset ℕ) = insert n {i} := by ext x; simp; tauto rw [ee, hm, h.one i hi] simp only [chi, singleton_subset_iff, mem_insert, mem_singleton] split_ifs <;> first | decide | omega · intro k hk j hj i hi by_cases hkn : k < n · rw [moment_old n hn S h {i,j,k} (by simp; omega)] exact h.three k hkn j hj i hi · have ek : k = n := by omega subst k have hm := moment_new n hn S h {i,j} (by simp; omega) have ee : ({i,j,n} : Finset ℕ) = insert n {i,j} := by ext x; simp; tauto rw [ee, hm, h.two j hj i hi] simp only [chi, insert_subset_iff, singleton_subset_iff, mem_insert, mem_singleton] split_ifs <;> first | decide | omegaend LineBuildtheorem line_cubic_boundary_extension (n : ℕ) (hn : 5 ≤ n) (S : Finset (Finset ℕ)) (h : LineBuild.Good n S) : LineBuild.Good (n+1) (LineBuild.step n S) := by exact LineBuild.good_step n hn S h