Lean / Reader
Lean reader

Erdos506CatalogueCheck.lean

55 lines13 declarationsno sorryimports Erdos506.Canonical

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

  1. import Erdos506.Canonical
  2. open EuclideanGeometry
  3. abbrev Plane506 := EuclideanSpace ℝ (Fin 2)
  4. namespace Independent506
  5. noncomputable def count (P : Set Plane506) : ℕ :=
  6. Set.ncard { s : Sphere Plane506 | 3 ≤ {p ∈ P | p ∈ s}.ncard }
  7. example : count = Erdos506.numCircles := rfl
  8. def answer (n : ℕ) : ℕ :=
  9. if n=6 then 8 else if n=7 then 11 else if n=8 then 17
  10. else (n-1).choose 2 + 1 - (n-1)/2
  11. theorem agree (n : ℕ) : answer n = Erdos506.v1Target n := by
  12. unfold answer Erdos506.v1Target Erdos506.v1UniformTarget
  13. split_ifs <;> omega
  14. theorem full (n : ℕ) (hn : 4 ≤ n) :
  15. IsLeast {k : ℕ | ∃ P : Finset Plane506, P.card = n ∧
  16. ¬ Collinear ℝ (P : Set Plane506) ∧ ¬ Cospherical (P : Set Plane506) ∧
  17. count (P : Set Plane506) = k} (answer n) := by
  18. rw [agree]
  19. exact Erdos506.erdos_506 n hn
  20. theorem small (n : ℕ) (hn : 4 ≤ n) (_ : n ≤ 393) :
  21. IsLeast {k : ℕ | ∃ P : Finset Plane506, P.card = n ∧
  22. ¬ Collinear ℝ (P : Set Plane506) ∧ ¬ Cospherical (P : Set Plane506) ∧
  23. count (P : Set Plane506) = k} (answer n) := full n hn
  24. #print axioms Erdos506.erdos_506
  25. #print axioms Independent506.full
  26. #print axioms Independent506.small
  27. end Independent506
  28. namespace Upstream506
  29. open EuclideanGeometry
  30. local notation "ℝ²" => EuclideanSpace ℝ (Fin 2)
  31. noncomputable def numCircles (P : Set ℝ²) : ℕ :=
  32. Set.ncard { s : Sphere ℝ² | 3 ≤ {p ∈ P | p ∈ s}.ncard }
  33. example : numCircles = Erdos506.numCircles := rfl
  34. def erdos_506.answer := Independent506.answer
  35. def erdos_506.variants.small_n.answer := Independent506.answer
  36. theorem erdos_506 (n : ℕ) (hn : 4 ≤ n) :
  37. IsLeast { k : ℕ | ∃ P : Finset ℝ²,
  38. P.card = n ∧ ¬ Collinear ℝ (P : Set ℝ²) ∧ ¬ Cospherical (P : Set ℝ²) ∧
  39. numCircles (P : Set ℝ²) = k }
  40. (erdos_506.answer n) := by
  41. exact Independent506.full n hn
  42. #print axioms erdos_506
  43. theorem erdos_506.variants.small_n (n : ℕ) (hn : 4 ≤ n) (hn' : n ≤ 393) :
  44. IsLeast { k : ℕ | ∃ P : Finset ℝ²,
  45. P.card = n ∧ ¬ Collinear ℝ (P : Set ℝ²) ∧ ¬ Cospherical (P : Set ℝ²) ∧
  46. numCircles (P : Set ℝ²) = k }
  47. (erdos_506.variants.small_n.answer n) := by
  48. exact Independent506.small n hn hn'
  49. #print axioms erdos_506.variants.small_n
  50. end Upstream506