Lean / Reader
Lean reader

TwoCopy.lean

124 lines16 declarationsno sorryimports TwoSideTests

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

  1. import TwoSideTests
  2. open SimpleGraph SimpleGraph.Walk
  3. namespace TerminalCycles
  4. universe u
  5. variable {V W Z : Type u} [Finite V] [Finite W]
  6. private abbrev Bit : Type u := ULift.{u} Bool
  7. private abbrev first : Bit.{u} := ⟨false⟩
  8. private abbrev last : Bit.{u} := ⟨true⟩
  9. private abbrev edgeGraph : SimpleGraph Bit.{u} := ⊤
  10. private theorem bit_deg (v : Bit.{u}) : valence edgeGraph v = 1 := by
  11. rw [valence_eq_degree]
  12. simp [Bit,Fintype.card_ulift]
  13. private theorem bit_path (p : edgeGraph.Walk first.{u} last) (simple : p.IsPath) : p.length=1 := by
  14. have upper := simple.length_lt
  15. have n : Fintype.card Bit.{u} = 2 := by simp [Bit]
  16. have low : p.length ≠ 0 := fun h => (by decide : first.{u} ≠ last) (eq_of_length_eq_zero h)
  17. omega
  18. private theorem bit_absent : ¬ hasPowerCycle edgeGraph.{u} := by
  19. rintro ⟨k,v,p,hk,hp,len⟩
  20. cases p with
  21. | nil => exact hp.ne_nil rfl
  22. | cons h q =>
  23. have simple := ((cons_isCycle_iff _ _).mp hp).1
  24. have upper := simple.length_lt
  25. have n : Fintype.card Bit.{u} = 2 := by simp [Bit]
  26. have pow := Nat.pow_le_pow_right (by decide : 0 < 2) hk
  27. simp only [length_cons] at len
  28. omega
  29. abbrev LeafGraph (B : SimpleGraph W) (b : W) := wedge edgeGraph B first b
  30. abbrev leafVertex {b : W} : WedgeVertex Bit b := Sum.inl last
  31. abbrev leafEnd {b : W} (y : ExceptRoot b) : WedgeVertex Bit b := Sum.inr y
  32. theorem leaf_side (B : SimpleGraph W) {b y : W} (right : TerminalSide B b y) (db : 2 ≤ valence B b) :
  33. TerminalSide (LeafGraph B b) leafVertex (leafEnd ⟨y,right.distinct⟩) ∧
  34. 1 ≤ valence (LeafGraph B b) leafVertex := by
  35. let yi : ExceptRoot b := ⟨y,right.distinct⟩
  36. let L := wedge edgeGraph B first b
  37. let leaf : WedgeVertex Bit b := Sum.inl last
  38. let endV : WedgeVertex Bit b := Sum.inr yi
  39. have leaf1 : 1 ≤ valence L leaf := (bit_deg last).symm.le.trans (wedge_left_degree edgeGraph B first b last)
  40. have dy := wedge_right_degree edgeGraph B first b yi
  41. have newSide : TerminalSide L leaf endV := by
  42. refine ⟨Sum.inr_ne_inl,right.target.trans dy,?_,?_⟩
  43. · rintro (v|v) vl ve
  44. · have eq : v=first := by
  45. rcases v with ⟨(_|_)⟩
  46. · rfl
  47. · exact (vl rfl).elim
  48. subst v
  49. have cap := wedge_root_degree edgeGraph B first b
  50. have tiny := bit_deg first.{u}
  51. change 3 ≤ valence (wedge edgeGraph B first b) (Sum.inl first)
  52. omega
  53. · exact (right.others v.val v.property (fun e => ve (congrArg Sum.inr (Subtype.ext e)))).trans
  54. (wedge_right_degree edgeGraph B first b v)
  55. · intro yes
  56. exact (wedge_cycle_from_side edgeGraph B first b yes).elim bit_absent right.noCycle
  57. exact ⟨newSide,leaf1⟩
  58. theorem leaf_order (b : W) : Nat.card (WedgeVertex Bit.{u} b) = Nat.card W + 1 := by
  59. have space := wedge_order (V:=Bit.{u}) b
  60. have card : Nat.card Bit.{u} = 2 := by simp [Bit,Nat.card_eq_fintype_card]
  61. omega
  62. omit [Finite W] in
  63. theorem leaf_path (B : SimpleGraph W) {b : W} (y : ExceptRoot b)
  64. (q : (LeafGraph B b).Walk leafVertex (leafEnd y)) (hq : q.IsPath) :
  65. ∃ r : B.Walk b y.val, r.IsPath ∧ r.length+1=q.length := by
  66. obtain ⟨e,r,he,hr,paths⟩ := wedge_terminal_split edgeGraph B first b last y q hq
  67. have one := bit_path e he
  68. exact ⟨r,hr,by omega⟩
  69. /-- Joining both pairs of corresponding terminals by edges forces the
  70. sum of two terminal path lengths plus two to be a power of two. -/
  71. theorem two_join_sum (A : SimpleGraph V) (B : SimpleGraph W) (G : SimpleGraph Z)
  72. {a x : V} {b y : W} (left : TerminalSide A a x) (right : TerminalSide B b y)
  73. (da : 2 ≤ valence A a) (db : 2 ≤ valence B b)
  74. (small : Nat.card V + Nat.card W < Nat.card Z) (minimal : smaller_graphs_have_cycle G) :
  75. ∃ k ≥ 2, ∃ (l : A.Walk a x) (r : B.Walk b y), l.IsPath ∧ r.IsPath ∧ l.length+r.length+2=2^k := by
  76. let yi : ExceptRoot b := ⟨y,right.distinct⟩
  77. let L := LeafGraph B b
  78. obtain ⟨newSide,leaf1⟩ := leaf_side B right db
  79. change 1 ≤ valence L leafVertex at leaf1
  80. have space := leaf_order b
  81. have sz : Nat.card V + Nat.card (WedgeVertex Bit b) ≤ Nat.card Z := by omega
  82. obtain ⟨k,hk,p,q,hp,hq,len⟩ := one_join_sum A L G left newSide (by omega) sz minimal
  83. obtain ⟨r,hr,paths⟩ := leaf_path B yi q hq
  84. exact ⟨k,hk,p,r,hp,hr,by omega⟩
  85. /-- The three offsets hold for two independent sides, even if they are
  86. nonisomorphic or have different sets of terminal path lengths. -/
  87. theorem mixed_sum_tests (A : SimpleGraph V) (B : SimpleGraph W) (G : SimpleGraph Z)
  88. {a x : V} {b y : W} (left : TerminalSide A a x) (right : TerminalSide B b y)
  89. (da : 2 ≤ valence A a) (db : 2 ≤ valence B b)
  90. (small : Nat.card V + Nat.card W < Nat.card Z) (minimal : smaller_graphs_have_cycle G) :
  91. ∀ d ≤ 2, ∃ i ∈ lengths A a x, ∃ j ∈ lengths B b y, ∃ k ≥ 2, i+j+d = 2^k := by
  92. intro d hd
  93. have spec : ∃ k ≥ 2, ∃ (p : A.Walk a x) (q : B.Walk b y), p.IsPath ∧ q.IsPath ∧ p.length+q.length+d = 2^k := by
  94. interval_cases d
  95. · simpa using zero_join_sum A B G left right (by omega) small.le minimal
  96. · exact one_join_sum A B G left right (by omega) small.le minimal
  97. · exact two_join_sum A B G left right da db small minimal
  98. obtain ⟨k,hk,p,q,hp,hq,len⟩ := spec
  99. exact ⟨p.length,⟨p,hp,rfl⟩,q.length,⟨q,hq,rfl⟩,k,hk,len⟩
  100. /-- The original two-copy sum test of iis:2611.00573, specialized to a
  101. balanced cut side from Ducoffe and Dumitru's structure theorem. -/
  102. theorem cut_side_sum_tests (A : SimpleGraph V) (G : SimpleGraph Z) (f : A ↪g G) {a x : V}
  103. (ne : x ≠ a) (da : 2 ≤ valence A a) (dx : 2 ≤ valence A x)
  104. (rest : ∀ v, v ≠ a → v ≠ x → 3 ≤ valence A v) (balanced : Nat.card Z = 2*Nat.card V+1)
  105. (absent : ¬ hasPowerCycle G) (minimal : smaller_graphs_have_cycle G) : sumTests (lengths A a x) := by
  106. have side : TerminalSide A a x := ⟨ne,dx,rest,absent_below f absent⟩
  107. exact mixed_sum_tests A A G side side da da (by omega) minimal
  108. end TerminalCycles