Lean / Reader
Lean reader

Erdos824Cycle.lean

62 lines2 declarationsno sorryimports Mathlib.Algebra.BigOperators.Associated Mathlib.Data.Nat.Prime.Basic Mathlib.Tactic
  1. import Mathlib.Algebra.BigOperators.Associated
  2. import Mathlib.Data.Nat.Prime.Basic
  3. import Mathlib.Tactic
  4. namespace Erdos824Cycle
  5. private lemma tag_dvd_iff_mem {k i p : ℕ} (f : ℕ → ℕ) {S : Finset ℕ}
  6. (hS : S ⊆ Finset.range k) (hp : p.Prime) (htag : ∀ j<k, p ∣ f j ↔ j=i) :
  7. p ∣ ∏ j ∈ S, f j ↔ i∈S := by
  8. rw [hp.prime.dvd_finsetProd_iff]
  9. constructor
  10. · rintro ⟨j,hj,hdiv⟩
  11. rwa [← (htag j (Finset.mem_range.mp (hS hj))).mp hdiv]
  12. · intro hi
  13. exact ⟨i,hi,(htag i (Finset.mem_range.mp (hS hi))).mpr rfl⟩
  14. /-- If two lists of shifted primes have the column tags and successive row
  15. tags of an alternating cycle, the only subproducts equal across the lists
  16. are the empty and the full products. The final wrap-around edge is redundant
  17. in this direction, since the path already forces constant membership. -/
  18. theorem equal_subproducts_trivial (k : ℕ) (f g cols rows : ℕ → ℕ)
  19. (hcols : ∀ i<k, (cols i).Prime)
  20. (hcf : ∀ i<k, ∀ j<k, cols i ∣ f j ↔ j=i)
  21. (hcg : ∀ i<k, ∀ j<k, cols i ∣ g j ↔ j=i)
  22. (hrows : ∀ i, i+1<k → (rows (i+1)).Prime)
  23. (hrf : ∀ i, i+1<k → ∀ j<k, rows (i+1) ∣ f j ↔ j=i+1)
  24. (hrg : ∀ i, i+1<k → ∀ j<k, rows (i+1) ∣ g j ↔ j=i)
  25. (S T : Finset ℕ) (hS : S⊆Finset.range k) (hT : T⊆Finset.range k)
  26. (he : (∏ i ∈ S, f i)=∏ j ∈ T, g j) :
  27. (S=∅ ∧ T=∅) ∨ (S=Finset.range k ∧ T=Finset.range k) := by
  28. have hc : ∀ i<k, i∈S ↔ i∈T := by
  29. intro i hi
  30. rw [← tag_dvd_iff_mem f hS (hcols i hi) (hcf i hi),
  31. ← tag_dvd_iff_mem g hT (hcols i hi) (hcg i hi),he]
  32. have hST : S=T := by
  33. ext i
  34. by_cases hi : i<k
  35. · exact hc i hi
  36. · have hnot : i ∉ Finset.range k := by simpa using hi
  37. exact ⟨fun h ↦ False.elim (hnot (hS h)), fun h ↦ False.elim (hnot (hT h))⟩
  38. have step : ∀ i, i+1<k → (i+1∈S ↔ i∈S) := by
  39. intro i hi
  40. rw [← tag_dvd_iff_mem f hS (hrows i hi) (hrf i hi),
  41. (hc i (by omega)),← tag_dvd_iff_mem g hT (hrows i hi) (hrg i hi),he]
  42. have constant : ∀ i<k, i∈S ↔ 0∈S := by
  43. intro i
  44. induction i with
  45. | zero => simp
  46. | succ i ih => intro hi; exact (step i hi).trans (ih (by omega))
  47. by_cases h0 : 0∈S
  48. · right
  49. have hfull : S=Finset.range k := Finset.Subset.antisymm hS (by
  50. intro i hi; exact (constant i (Finset.mem_range.mp hi)).mpr h0)
  51. exact ⟨hfull,hST.symm.trans hfull⟩
  52. · left
  53. have hempty : S=∅ := Finset.eq_empty_iff_forall_notMem.mpr (by
  54. intro i hi; exact h0 ((constant i (Finset.mem_range.mp (hS hi))).mp hi))
  55. exact ⟨hempty,hST.symm.trans hempty⟩
  56. #print axioms equal_subproducts_trivial
  57. end Erdos824Cycle