Lean / Reader
Lean reader

TriangularStatement.lean

64 lines9 declarationsno sorryimports TriangularCertificate

Lean 4 Web has Mathlib, so it can check files that import only Mathlib. This one also imports TriangularCertificate, which it does not have: you can read it there, but it will not check. Build the project itself to check it.

  1. import TriangularCertificate
  2. namespace TriangularRamsey
  3. /-- The intrinsic patch has rows of lengths nine, eight, …, one. -/
  4. abbrev T9 := {p : Point // p.1 + p.2 < 9}
  5. /-- Brouwer, Joe, Noble and Noble, Question 2. -/
  6. theorem no_proper_three_coloring (color : T9 → Fin 3) :
  7. ∃ p q r : T9, equilateral p.val q.val r.val ∧ color p = color q ∧ color p = color r := by
  8. let f (p : Point) := if h : p.1 + p.2 < 9 then color ⟨p,h⟩ else 0
  9. obtain ⟨p,q,r,⟨hp,hq,hr,he⟩,hpq,hpr⟩ := nine_row_triangle f
  10. unfold grid at hp hq hr
  11. exact ⟨⟨p,hp⟩,⟨q,hq⟩,⟨r,hr⟩,he,by simpa [f,hp,hq,grid] using hpq,
  12. by simpa [f,hp,hr,grid] using hpr⟩
  13. /-- Four color classes, written in the coordinate encoding `9*x+y`. -/
  14. private def classes : Fin 4 → List ℕ
  15. | 0 => [1,2,6,11,20,21,31,36,48,55,56,63,72]
  16. | 1 => [0,3,5,12,14,24,32,37,38,39,54,64]
  17. | 2 => [4,7,16,18,19,23,40,45,46,47]
  18. | 3 => [8,9,10,13,15,22,27,28,29,30]
  19. private def encode (p : Point) := 9*p.1+p.2
  20. private theorem decode_encode (p : T9) : decode (encode p.val) = p.val := by
  21. obtain ⟨⟨x,y⟩,h⟩ := p
  22. change x+y<9 at h
  23. apply Prod.ext <;> simp [encode,decode] <;> omega
  24. private theorem covered (p : T9) : ∃ c : Fin 4, encode p.val ∈ classes c := by
  25. have h : ∀ x y : Fin 9, x.val+y.val<9 → ∃ c : Fin 4, 9*x.val+y.val ∈ classes c := by
  26. decide +kernel
  27. obtain ⟨⟨x,y⟩,hp⟩ := p
  28. change x+y<9 at hp
  29. exact h ⟨x,by omega⟩ ⟨y,by omega⟩ hp
  30. private instance (p q r : Point) : Decidable (equilateral p q r) := by
  31. unfold equilateral; infer_instance
  32. private theorem independent (c : Fin 4) (x y z : ℕ)
  33. (hx : x ∈ classes c) (hy : y ∈ classes c) (hz : z ∈ classes c) :
  34. ¬equilateral (decode x) (decode y) (decode z) := by
  35. have h : ∀ d : Fin 4, (classes d).all (fun i => (classes d).all (fun j =>
  36. (classes d).all (fun k => decide (¬equilateral (decode i) (decode j) (decode k))))) = true := by
  37. decide +kernel
  38. simpa using List.all_eq_true.mp (List.all_eq_true.mp (List.all_eq_true.mp (h c) x hx) y hy) z hz
  39. /-- A matching four-coloring certifies the exact chromatic number. -/
  40. theorem proper_four_coloring : ∃ color : T9 → Fin 4, ∀ p q r : T9,
  41. equilateral p.val q.val r.val → ¬(color p = color q ∧ color p = color r) := by
  42. classical
  43. let color (p : T9) := Classical.choose (covered p)
  44. have hc (p : T9) : encode p.val ∈ classes (color p) := Classical.choose_spec (covered p)
  45. refine ⟨color,?_⟩
  46. rintro p q r he ⟨hpq,hpr⟩
  47. apply independent (color p) (encode p.val) (encode q.val) (encode r.val) (hc p)
  48. (hpq ▸ hc q) (hpr ▸ hc r)
  49. simpa only [decode_encode] using he
  50. #print axioms no_proper_three_coloring
  51. #print axioms proper_four_coloring
  52. end TriangularRamsey