Lean / Reader
Lean reader

SixPoint.lean

287 lines28 declarationsno sorryimports Std
  1. import Std
  2. /-! Algebraic certificates for the sharp six-point fourth moment. The names
  3. below apply to arbitrary commutative rings, or ordered rings as indicated.
  4. The ten chosen triples contain vertex 1; their complements give the other ten. -/
  5. namespace SixPoint
  6. open Lean.Grind Std
  7. section Identities
  8. variable {R : Type} [CommRing R]
  9. def halfTriples (a b c d e f : R) : List R :=
  10. [a+b+c, a+b+d, a+b+e, a+b+f, a+c+d, a+c+e, a+c+f,
  11. a+d+e, a+d+f, a+e+f]
  12. def moment (p : Nat) (entries : List R) : R :=
  13. (entries.map (· ^ p)).foldr (· + ·) 0
  14. theorem second_moment (a b c d e : R) :
  15. let f := -(a + b + c + d + e)
  16. moment 2 (halfTriples a b c d e f) = 3 * moment 2 [a,b,c,d,e,f] := by
  17. simp [moment, halfTriples]
  18. grind
  19. theorem fourth_moment (a b c d e : R) :
  20. let f := -(a + b + c + d + e)
  21. moment 4 (halfTriples a b c d e f) =
  22. 3 * ((moment 2 [a,b,c,d,e,f])^2 - moment 4 [a,b,c,d,e,f]) := by
  23. simp [moment, halfTriples]
  24. grind
  25. def pairGaps (entries : List R) : List R :=
  26. match entries with
  27. | [] => []
  28. | a :: rest => (rest.map (a - ·)) ++ pairGaps rest
  29. /-- For a representative triple containing a,b,c. Vertex relabelling gives every triple. -/
  30. theorem coordinate_gap (a b c d e : R) :
  31. let f := -(a + b + c + d + e)
  32. 3 * moment 2 [a,b,c,d,e,f] - 2*(a+b+c)^2 =
  33. moment 2 (pairGaps [a,b,c]) + moment 2 (pairGaps [d,e,f]) := by
  34. simp [moment, pairGaps]
  35. grind
  36. theorem fourth_gap (a b c d e f : R) :
  37. 6*moment 4 [a,b,c,d,e,f] - (moment 2 [a,b,c,d,e,f])^2 =
  38. moment 2 (pairGaps [a^2,b^2,c^2,d^2,e^2,f^2]) := by
  39. simp [moment, pairGaps]
  40. grind
  41. /-- The equality witness has one pair of exceptional triples, and eighteen
  42. mixed triples of value +1 or -1. M is the positive square root of 44. -/
  43. theorem equality_witness (m : R) (hm : m^2 = 44) :
  44. (m+3)^2 + (m-3)^2 + 18 = 124 ∧
  45. (m+3)^4 + (m-3)^4 + 18 = 8804 := by
  46. constructor <;> grind
  47. end Identities
  48. section Order
  49. variable {R : Type} [CommRing R] [LE R] [LT R] [LawfulOrderLT R]
  50. [IsLinearOrder R] [OrderedRing R]
  51. /-- The final deduction in the paper, written without denominators. -/
  52. theorem sharp_bound (a b c d e : R)
  53. (hc : c ≤ a^2) (hd : 2*d ≤ a*b) (he : 18*e ≤ 5*b^2) :
  54. 62*(c+6*d+e) ≤ 71*(a+b)^2 := by
  55. have hs : 0 ≤ (9*a - 22*b)^2 := OrderedRing.sq_nonneg
  56. grind
  57. theorem second_nonneg (s : List R) : 0 ≤ moment 2 s := by
  58. induction s with
  59. | nil => simp [moment]
  60. | cons a s ih =>
  61. change 0 ≤ a^2 + moment 2 s
  62. have : 0 ≤ a^2 := OrderedRing.sq_nonneg
  63. grind
  64. theorem fourth_le_second_sq (s : List R) : moment 4 s ≤ (moment 2 s)^2 := by
  65. induction s with
  66. | nil => simp [moment]; grind
  67. | cons a s ih =>
  68. change a^4 + moment 4 s ≤ (a^2 + moment 2 s)^2
  69. have ht := second_nonneg s
  70. have ha : 0 ≤ a^2 := OrderedRing.sq_nonneg
  71. have := OrderedRing.mul_nonneg ha ht
  72. grind
  73. def mixed (p : List (R × R)) : R :=
  74. (p.map (fun q => q.1^2 * q.2^2)).foldr (· + ·) 0
  75. theorem mixed_bound (p : List (R × R)) (b : R)
  76. (h : ∀ q ∈ p, 2*q.2^2 ≤ b) :
  77. 2*mixed p ≤ moment 2 (p.map Prod.fst) * b := by
  78. induction p with
  79. | nil => simp [mixed,moment]; grind
  80. | cons q s ih =>
  81. have ht := ih (fun z hz => h z (by simp [hz]))
  82. have hq := h q (by simp)
  83. have ha : 0 ≤ q.1^2 := OrderedRing.sq_nonneg
  84. have := OrderedRing.mul_nonneg ha (OrderedAdd.sub_nonneg_iff.mpr hq)
  85. change 2*(q.1^2 * q.2^2 + mixed s) ≤ (q.1^2+moment 2 (s.map Prod.fst))*b
  86. grind
  87. def joinPairs (p : List (R × R)) : List R :=
  88. p.flatMap (fun q => [q.1+q.2,q.1-q.2])
  89. omit [LE R] [LT R] [LawfulOrderLT R] [IsLinearOrder R] [OrderedRing R] in
  90. theorem paired_second (p : List (R × R)) :
  91. moment 2 (joinPairs p) = 2*(moment 2 (p.map Prod.fst)+moment 2 (p.map Prod.snd)) := by
  92. induction p with
  93. | nil => simp [joinPairs, moment]; grind
  94. | cons q s ih =>
  95. change (q.1+q.2)^2 + ((q.1-q.2)^2 + moment 2 (joinPairs s)) =
  96. 2*((q.1^2 + moment 2 (s.map Prod.fst))+(q.2^2 + moment 2 (s.map Prod.snd)))
  97. grind
  98. omit [LE R] [LT R] [LawfulOrderLT R] [IsLinearOrder R] [OrderedRing R] in
  99. theorem paired_fourth (p : List (R × R)) :
  100. moment 4 (joinPairs p) =
  101. 2*(moment 4 (p.map Prod.fst)+6*mixed p+moment 4 (p.map Prod.snd)) := by
  102. induction p with
  103. | nil => simp [joinPairs, moment,mixed]; grind
  104. | cons q s ih =>
  105. change (q.1+q.2)^4 + ((q.1-q.2)^4 + moment 4 (joinPairs s)) =
  106. 2*((q.1^4 + moment 4 (s.map Prod.fst))+6*(q.1^2*q.2^2+mixed s)
  107. +(q.2^4+moment 4 (s.map Prod.snd)))
  108. grind
  109. private theorem coord (a b c d e f : R) (h : a+b+c+d+e+f=0) :
  110. 2*(a+b+c)^2 ≤ 3*moment 2 [a,b,c,d,e,f] := by
  111. have h1 := second_nonneg (pairGaps [a,b,c])
  112. have h2 := second_nonneg (pairGaps [d,e,f])
  113. have hf : f = -(a+b+c+d+e) := by grind
  114. have eqn := coordinate_gap a b c d e
  115. rw [← hf] at eqn
  116. grind
  117. theorem max_coordinate (a b c d e f : R) (h : a+b+c+d+e+f=0) :
  118. ∀ y ∈ halfTriples a b c d e f, 2*y^2 ≤ 3*moment 2 [a,b,c,d,e,f] := by
  119. 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
  120. have h1 := aux a b c d e f (by grind)
  121. have h2 := aux a b d c e f (by grind)
  122. have h3 := aux a b e c d f (by grind)
  123. have h4 := aux a b f c d e (by grind)
  124. have h5 := aux a c d b e f (by grind)
  125. have h6 := aux a c e b d f (by grind)
  126. have h7 := aux a c f b d e (by grind)
  127. have h8 := aux a d e b c f (by grind)
  128. have h9 := aux a d f b c e (by grind)
  129. have h10 := aux a e f b c d (by grind)
  130. simp only [moment, List.map_cons, List.map_nil, List.foldr_cons, List.foldr_nil]
  131. at h1 h2 h3 h4 h5 h6 h7 h8 h9 h10 ⊢
  132. intro y hy
  133. simp [halfTriples] at hy
  134. rcases hy with h|h|h|h|h|h|h|h|h|h <;> subst y <;> grind
  135. theorem six_point_bound (p : List (R × R)) (a b c d e f : R)
  136. (h : a+b+c+d+e+f=0) (hl : p.map Prod.snd = halfTriples a b c d e f) :
  137. 124*moment 4 (joinPairs p) ≤ 71*(moment 2 (joinPairs p))^2 := by
  138. have hf : f = -(a+b+c+d+e) := by grind
  139. have h2 := second_moment a b c d e
  140. have h4 := fourth_moment a b c d e
  141. dsimp only at h2 h4
  142. rw [← hf, ← hl] at h2 h4
  143. have hc := fourth_le_second_sq (p.map Prod.fst)
  144. have hd := mixed_bound p (moment 2 (p.map Prod.snd)) (by
  145. intro q hq
  146. have mem : q.2 ∈ p.map Prod.snd := List.mem_map.mpr ⟨q,hq,rfl⟩
  147. rw [hl] at mem
  148. rw [h2]
  149. exact max_coordinate a b c d e f h _ mem)
  150. have hg := fourth_gap a b c d e f
  151. have hp := second_nonneg (pairGaps [a^2,b^2,c^2,d^2,e^2,f^2])
  152. have he : 18 * moment 4 (p.map Prod.snd) ≤ 5*(moment 2 (p.map Prod.snd))^2 := by
  153. rw [h2,h4]
  154. rw [← hg] at hp
  155. clear h2 h4 hc hd hg hf hl h
  156. grind only
  157. have bound := sharp_bound _ _ _ _ _ hc hd he
  158. rw [paired_second, paired_fourth]
  159. grind
  160. end Order
  161. structure EdgeWeights (R : Type) where
  162. ab : R
  163. ac : R
  164. ad : R
  165. ae : R
  166. af : R
  167. bc : R
  168. bd : R
  169. be : R
  170. bf : R
  171. cd : R
  172. ce : R
  173. cf : R
  174. de : R
  175. df : R
  176. ef : R
  177. section Edges
  178. variable {R : Type} [CommRing R]
  179. /-- All triples paired with their complements. The first triple contains a. -/
  180. def readings (e : EdgeWeights R) : List (R × R) :=
  181. [(e.ab+e.ac+e.bc,e.de+e.df+e.ef), (e.ab+e.ad+e.bd,e.ce+e.cf+e.ef),
  182. (e.ab+e.ae+e.be,e.cd+e.cf+e.df), (e.ab+e.af+e.bf,e.cd+e.ce+e.de),
  183. (e.ac+e.ad+e.cd,e.be+e.bf+e.ef), (e.ac+e.ae+e.ce,e.bd+e.bf+e.df),
  184. (e.ac+e.af+e.cf,e.bd+e.be+e.de), (e.ad+e.ae+e.de,e.bc+e.bf+e.cf),
  185. (e.ad+e.af+e.df,e.bc+e.be+e.ce), (e.ae+e.af+e.ef,e.bc+e.bd+e.cd)]
  186. def unpack (p : List (R × R)) : List R := p.flatMap (fun q => [q.1,q.2])
  187. def changeCoordinates (p : List (R × R)) : List (R × R) :=
  188. p.map (fun q => (3*(q.1+q.2),3*(q.1-q.2)))
  189. theorem scaled_second (p : List (R × R)) :
  190. moment 2 (joinPairs (changeCoordinates p)) = 36*moment 2 (unpack p) := by
  191. induction p with
  192. | nil => simp [joinPairs,changeCoordinates,unpack,moment]; grind
  193. | cons q s ih =>
  194. change (3*(q.1+q.2)+3*(q.1-q.2))^2+((3*(q.1+q.2)-3*(q.1-q.2))^2
  195. +moment 2 (joinPairs (changeCoordinates s))) = 36*(q.1^2+(q.2^2+moment 2 (unpack s)))
  196. grind
  197. theorem scaled_fourth (p : List (R × R)) :
  198. moment 4 (joinPairs (changeCoordinates p)) = 1296*moment 4 (unpack p) := by
  199. induction p with
  200. | nil => simp [joinPairs,changeCoordinates,unpack,moment]; grind
  201. | cons q s ih =>
  202. change (3*(q.1+q.2)+3*(q.1-q.2))^4+((3*(q.1+q.2)-3*(q.1-q.2))^4
  203. +moment 4 (joinPairs (changeCoordinates s))) = 1296*(q.1^4+(q.2^4+moment 4 (unpack s)))
  204. grind
  205. def witnessEdges (m : R) : EdgeWeights R :=
  206. let inner := 2*(m+3)
  207. let outer := 2*(m-3)
  208. let cross := -m
  209. ⟨inner,inner,cross,cross,cross,inner,cross,cross,cross,cross,cross,cross,outer,outer,outer⟩
  210. theorem witness_reading (m : R) (hm : m^2 = 44) :
  211. moment 2 (unpack (readings (witnessEdges m))) = 36*124 ∧
  212. moment 4 (unpack (readings (witnessEdges m))) = 1296*8804 := by
  213. simp [moment, unpack, readings, witnessEdges]
  214. constructor <;> grind
  215. variable [LE R] [LT R] [LawfulOrderLT R] [IsLinearOrder R] [OrderedRing R]
  216. /-- Sharp upper bound from the fifteen arbitrary original edge weights. -/
  217. theorem edge_bound (w : EdgeWeights R) :
  218. 124 * moment 4 (unpack (readings w)) ≤ 71 * (moment 2 (unpack (readings w)))^2 := by
  219. 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
  220. let a := 3*(w.ab+w.ac+w.ad+w.ae+w.af)-t
  221. let b := 3*(w.ab+w.bc+w.bd+w.be+w.bf)-t
  222. let c := 3*(w.ac+w.bc+w.cd+w.ce+w.cf)-t
  223. let d := 3*(w.ad+w.bd+w.cd+w.de+w.df)-t
  224. let e := 3*(w.ae+w.be+w.ce+w.de+w.ef)-t
  225. let f := 3*(w.af+w.bf+w.cf+w.df+w.ef)-t
  226. have hz : a+b+c+d+e+f=0 := by
  227. dsimp [a,b,c,d,e,f,t]
  228. grind only
  229. have hl : (changeCoordinates (readings w)).map Prod.snd = halfTriples a b c d e f := by
  230. simp [changeCoordinates, readings, halfTriples, a,b,c,d,e,f,t]
  231. repeat' apply And.intro <;> grind only
  232. have bound := six_point_bound _ a b c d e f hz hl
  233. rw [scaled_second,scaled_fourth] at bound
  234. clear hl hz
  235. grind only
  236. end Edges
  237. #print axioms second_moment
  238. #print axioms fourth_moment
  239. #print axioms coordinate_gap
  240. #print axioms fourth_gap
  241. #print axioms equality_witness
  242. #print axioms sharp_bound
  243. #print axioms edge_bound
  244. #print axioms witness_reading
  245. end SixPoint