import Std /-! Algebraic certificates for the sharp six-point fourth moment. The names below apply to arbitrary commutative rings, or ordered rings as indicated. The ten chosen triples contain vertex 1; their complements give the other ten. -/ namespace SixPoint open Lean.Grind Std section Identities variable {R : Type} [CommRing R] def halfTriples (a b c d e f : R) : List R := [a+b+c, a+b+d, a+b+e, a+b+f, a+c+d, a+c+e, a+c+f, a+d+e, a+d+f, a+e+f] def moment (p : Nat) (entries : List R) : R := (entries.map (· ^ p)).foldr (· + ·) 0 theorem second_moment (a b c d e : R) : let f := -(a + b + c + d + e) moment 2 (halfTriples a b c d e f) = 3 * moment 2 [a,b,c,d,e,f] := by simp [moment, halfTriples] grind theorem fourth_moment (a b c d e : R) : let f := -(a + b + c + d + e) moment 4 (halfTriples a b c d e f) = 3 * ((moment 2 [a,b,c,d,e,f])^2 - moment 4 [a,b,c,d,e,f]) := by simp [moment, halfTriples] grind def pairGaps (entries : List R) : List R := match entries with | [] => [] | a :: rest => (rest.map (a - ·)) ++ pairGaps rest /-- For a representative triple containing a,b,c. Vertex relabelling gives every triple. -/ theorem coordinate_gap (a b c d e : R) : let f := -(a + b + c + d + e) 3 * moment 2 [a,b,c,d,e,f] - 2*(a+b+c)^2 = moment 2 (pairGaps [a,b,c]) + moment 2 (pairGaps [d,e,f]) := by simp [moment, pairGaps] grind theorem fourth_gap (a b c d e f : R) : 6*moment 4 [a,b,c,d,e,f] - (moment 2 [a,b,c,d,e,f])^2 = moment 2 (pairGaps [a^2,b^2,c^2,d^2,e^2,f^2]) := by simp [moment, pairGaps] grind /-- The equality witness has one pair of exceptional triples, and eighteen mixed triples of value +1 or -1. M is the positive square root of 44. -/ theorem equality_witness (m : R) (hm : m^2 = 44) : (m+3)^2 + (m-3)^2 + 18 = 124 ∧ (m+3)^4 + (m-3)^4 + 18 = 8804 := by constructor <;> grind end Identities section Order variable {R : Type} [CommRing R] [LE R] [LT R] [LawfulOrderLT R] [IsLinearOrder R] [OrderedRing R] /-- The final deduction in the paper, written without denominators. -/ theorem sharp_bound (a b c d e : R) (hc : c ≤ a^2) (hd : 2*d ≤ a*b) (he : 18*e ≤ 5*b^2) : 62*(c+6*d+e) ≤ 71*(a+b)^2 := by have hs : 0 ≤ (9*a - 22*b)^2 := OrderedRing.sq_nonneg grind theorem second_nonneg (s : List R) : 0 ≤ moment 2 s := by induction s with | nil => simp [moment] | cons a s ih => change 0 ≤ a^2 + moment 2 s have : 0 ≤ a^2 := OrderedRing.sq_nonneg grind theorem fourth_le_second_sq (s : List R) : moment 4 s ≤ (moment 2 s)^2 := by induction s with | nil => simp [moment]; grind | cons a s ih => change a^4 + moment 4 s ≤ (a^2 + moment 2 s)^2 have ht := second_nonneg s have ha : 0 ≤ a^2 := OrderedRing.sq_nonneg have := OrderedRing.mul_nonneg ha ht grind def mixed (p : List (R × R)) : R := (p.map (fun q => q.1^2 * q.2^2)).foldr (· + ·) 0 theorem mixed_bound (p : List (R × R)) (b : R) (h : ∀ q ∈ p, 2*q.2^2 ≤ b) : 2*mixed p ≤ moment 2 (p.map Prod.fst) * b := by induction p with | nil => simp [mixed,moment]; grind | cons q s ih => have ht := ih (fun z hz => h z (by simp [hz])) have hq := h q (by simp) have ha : 0 ≤ q.1^2 := OrderedRing.sq_nonneg have := OrderedRing.mul_nonneg ha (OrderedAdd.sub_nonneg_iff.mpr hq) change 2*(q.1^2 * q.2^2 + mixed s) ≤ (q.1^2+moment 2 (s.map Prod.fst))*b grind def joinPairs (p : List (R × R)) : List R := p.flatMap (fun q => [q.1+q.2,q.1-q.2]) omit [LE R] [LT R] [LawfulOrderLT R] [IsLinearOrder R] [OrderedRing R] in theorem paired_second (p : List (R × R)) : moment 2 (joinPairs p) = 2*(moment 2 (p.map Prod.fst)+moment 2 (p.map Prod.snd)) := by induction p with | nil => simp [joinPairs, moment]; grind | cons q s ih => change (q.1+q.2)^2 + ((q.1-q.2)^2 + moment 2 (joinPairs s)) = 2*((q.1^2 + moment 2 (s.map Prod.fst))+(q.2^2 + moment 2 (s.map Prod.snd))) grind omit [LE R] [LT R] [LawfulOrderLT R] [IsLinearOrder R] [OrderedRing R] in theorem paired_fourth (p : List (R × R)) : moment 4 (joinPairs p) = 2*(moment 4 (p.map Prod.fst)+6*mixed p+moment 4 (p.map Prod.snd)) := by induction p with | nil => simp [joinPairs, moment,mixed]; grind | cons q s ih => change (q.1+q.2)^4 + ((q.1-q.2)^4 + moment 4 (joinPairs s)) = 2*((q.1^4 + moment 4 (s.map Prod.fst))+6*(q.1^2*q.2^2+mixed s) +(q.2^4+moment 4 (s.map Prod.snd))) grind private theorem coord (a b c d e f : R) (h : a+b+c+d+e+f=0) : 2*(a+b+c)^2 ≤ 3*moment 2 [a,b,c,d,e,f] := by have h1 := second_nonneg (pairGaps [a,b,c]) have h2 := second_nonneg (pairGaps [d,e,f]) have hf : f = -(a+b+c+d+e) := by grind have eqn := coordinate_gap a b c d e rw [← hf] at eqn grind theorem max_coordinate (a b c d e f : R) (h : a+b+c+d+e+f=0) : ∀ y ∈ halfTriples a b c d e f, 2*y^2 ≤ 3*moment 2 [a,b,c,d,e,f] := by have aux (p q r s t u : R) (hs : p+q+r+s+t+u=0) := coord p q r s t u hs have h1 := aux a b c d e f (by grind) have h2 := aux a b d c e f (by grind) have h3 := aux a b e c d f (by grind) have h4 := aux a b f c d e (by grind) have h5 := aux a c d b e f (by grind) have h6 := aux a c e b d f (by grind) have h7 := aux a c f b d e (by grind) have h8 := aux a d e b c f (by grind) have h9 := aux a d f b c e (by grind) have h10 := aux a e f b c d (by grind) simp only [moment, List.map_cons, List.map_nil, List.foldr_cons, List.foldr_nil] at h1 h2 h3 h4 h5 h6 h7 h8 h9 h10 ⊢ intro y hy simp [halfTriples] at hy rcases hy with h|h|h|h|h|h|h|h|h|h <;> subst y <;> grind theorem six_point_bound (p : List (R × R)) (a b c d e f : R) (h : a+b+c+d+e+f=0) (hl : p.map Prod.snd = halfTriples a b c d e f) : 124*moment 4 (joinPairs p) ≤ 71*(moment 2 (joinPairs p))^2 := by have hf : f = -(a+b+c+d+e) := by grind have h2 := second_moment a b c d e have h4 := fourth_moment a b c d e dsimp only at h2 h4 rw [← hf, ← hl] at h2 h4 have hc := fourth_le_second_sq (p.map Prod.fst) have hd := mixed_bound p (moment 2 (p.map Prod.snd)) (by intro q hq have mem : q.2 ∈ p.map Prod.snd := List.mem_map.mpr ⟨q,hq,rfl⟩ rw [hl] at mem rw [h2] exact max_coordinate a b c d e f h _ mem) have hg := fourth_gap a b c d e f have hp := second_nonneg (pairGaps [a^2,b^2,c^2,d^2,e^2,f^2]) have he : 18 * moment 4 (p.map Prod.snd) ≤ 5*(moment 2 (p.map Prod.snd))^2 := by rw [h2,h4] rw [← hg] at hp clear h2 h4 hc hd hg hf hl h grind only have bound := sharp_bound _ _ _ _ _ hc hd he rw [paired_second, paired_fourth] grind end Order structure EdgeWeights (R : Type) where ab : R ac : R ad : R ae : R af : R bc : R bd : R be : R bf : R cd : R ce : R cf : R de : R df : R ef : R section Edges variable {R : Type} [CommRing R] /-- All triples paired with their complements. The first triple contains a. -/ def readings (e : EdgeWeights R) : List (R × R) := [(e.ab+e.ac+e.bc,e.de+e.df+e.ef), (e.ab+e.ad+e.bd,e.ce+e.cf+e.ef), (e.ab+e.ae+e.be,e.cd+e.cf+e.df), (e.ab+e.af+e.bf,e.cd+e.ce+e.de), (e.ac+e.ad+e.cd,e.be+e.bf+e.ef), (e.ac+e.ae+e.ce,e.bd+e.bf+e.df), (e.ac+e.af+e.cf,e.bd+e.be+e.de), (e.ad+e.ae+e.de,e.bc+e.bf+e.cf), (e.ad+e.af+e.df,e.bc+e.be+e.ce), (e.ae+e.af+e.ef,e.bc+e.bd+e.cd)] def unpack (p : List (R × R)) : List R := p.flatMap (fun q => [q.1,q.2]) def changeCoordinates (p : List (R × R)) : List (R × R) := p.map (fun q => (3*(q.1+q.2),3*(q.1-q.2))) theorem scaled_second (p : List (R × R)) : moment 2 (joinPairs (changeCoordinates p)) = 36*moment 2 (unpack p) := by induction p with | nil => simp [joinPairs,changeCoordinates,unpack,moment]; grind | cons q s ih => change (3*(q.1+q.2)+3*(q.1-q.2))^2+((3*(q.1+q.2)-3*(q.1-q.2))^2 +moment 2 (joinPairs (changeCoordinates s))) = 36*(q.1^2+(q.2^2+moment 2 (unpack s))) grind theorem scaled_fourth (p : List (R × R)) : moment 4 (joinPairs (changeCoordinates p)) = 1296*moment 4 (unpack p) := by induction p with | nil => simp [joinPairs,changeCoordinates,unpack,moment]; grind | cons q s ih => change (3*(q.1+q.2)+3*(q.1-q.2))^4+((3*(q.1+q.2)-3*(q.1-q.2))^4 +moment 4 (joinPairs (changeCoordinates s))) = 1296*(q.1^4+(q.2^4+moment 4 (unpack s))) grind def witnessEdges (m : R) : EdgeWeights R := let inner := 2*(m+3) let outer := 2*(m-3) let cross := -m ⟨inner,inner,cross,cross,cross,inner,cross,cross,cross,cross,cross,cross,outer,outer,outer⟩ theorem witness_reading (m : R) (hm : m^2 = 44) : moment 2 (unpack (readings (witnessEdges m))) = 36*124 ∧ moment 4 (unpack (readings (witnessEdges m))) = 1296*8804 := by simp [moment, unpack, readings, witnessEdges] constructor <;> grind variable [LE R] [LT R] [LawfulOrderLT R] [IsLinearOrder R] [OrderedRing R] /-- Sharp upper bound from the fifteen arbitrary original edge weights. -/ theorem edge_bound (w : EdgeWeights R) : 124 * moment 4 (unpack (readings w)) ≤ 71 * (moment 2 (unpack (readings w)))^2 := by let t := w.ab+w.ac+w.ad+w.ae+w.af+w.bc+w.bd+w.be+w.bf+w.cd+w.ce+w.cf+w.de+w.df+w.ef let a := 3*(w.ab+w.ac+w.ad+w.ae+w.af)-t let b := 3*(w.ab+w.bc+w.bd+w.be+w.bf)-t let c := 3*(w.ac+w.bc+w.cd+w.ce+w.cf)-t let d := 3*(w.ad+w.bd+w.cd+w.de+w.df)-t let e := 3*(w.ae+w.be+w.ce+w.de+w.ef)-t let f := 3*(w.af+w.bf+w.cf+w.df+w.ef)-t have hz : a+b+c+d+e+f=0 := by dsimp [a,b,c,d,e,f,t] grind only have hl : (changeCoordinates (readings w)).map Prod.snd = halfTriples a b c d e f := by simp [changeCoordinates, readings, halfTriples, a,b,c,d,e,f,t] repeat' apply And.intro <;> grind only have bound := six_point_bound _ a b c d e f hz hl rw [scaled_second,scaled_fourth] at bound clear hl hz grind only end Edges #print axioms second_moment #print axioms fourth_moment #print axioms coordinate_gap #print axioms fourth_gap #print axioms equality_witness #print axioms sharp_bound #print axioms edge_bound #print axioms witness_reading end SixPoint