Lean / Reader
Lean reader

PairPaths.lean

136 lines7 declarationsno sorryimports CutVertex Mathlib.Algebra.Order.BigOperators.Group.Finset Mathlib.Data.Finset.Powerset

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

  1. import CutVertex
  2. import Mathlib.Algebra.Order.BigOperators.Group.Finset
  3. import Mathlib.Data.Finset.Powerset
  4. open SimpleGraph SimpleGraph.Walk
  5. namespace TerminalCycles
  6. variable {V : Type*}
  7. theorem identified_strict_size [Finite V] (s t : V) (ne : s ≠ t) :
  8. Nat.card (Option (Interior s t)) < Nat.card V := by
  9. classical
  10. letI := Fintype.ofFinite V
  11. let f : Option (Interior s t) → V := fun x => x.elim s Subtype.val
  12. have injective : Function.Injective f := by
  13. rintro (_|a) (_|b) e
  14. · rfl
  15. · exact (b.property.1 e.symm).elim
  16. · exact (a.property.1 e).elim
  17. · exact congrArg some (Subtype.ext e)
  18. simp only [Nat.card_eq_fintype_card]
  19. apply Fintype.card_lt_of_injective_of_notMem f injective (b := t)
  20. rintro ⟨(_|a),e⟩
  21. · exact ne e
  22. · exact a.property.2 e
  23. /-- Two distinct vertices have at most one common neighbor in a graph
  24. without a four-cycle. -/
  25. theorem common_neighbors_unique (G : SimpleGraph V) {s t : V} (ne : s ≠ t)
  26. (absent : ¬ hasPowerCycle G) {a b : V} (sa : G.Adj s a) (ta : G.Adj t a)
  27. (sb : G.Adj s b) (tb : G.Adj t b) : a = b := by
  28. by_contra ab
  29. let p : G.Walk a b := cons ta.symm (cons tb nil)
  30. have simple : p.IsPath := by simp [p,cons_isPath_iff,ta.ne.symm,ab,tb.ne]
  31. have fresh : s ∉ p.support := by simp [p,sa.ne,ne,sb.ne]
  32. exact absent ⟨2,s,_,by decide,close_internal p simple ab fresh sa sb.symm,rfl⟩
  33. theorem outer_degree_ge_three [Finite V] (G : SimpleGraph V) {s t : V}
  34. (ne : s ≠ t) (absent : ¬ hasPowerCycle G)
  35. (from_s : 2 ≤ (G.neighborSet s \ {t}).ncard)
  36. (from_t : 2 ≤ (G.neighborSet t \ {s}).ncard) : 3 ≤ (outerNeighbors G s t).ncard := by
  37. let A := G.neighborSet s \ {t}
  38. let B := G.neighborSet t \ {s}
  39. have small : (A ∩ B).ncard ≤ 1 := by
  40. apply Set.ncard_le_one_iff_subsingleton.mpr
  41. intro a ha b hb
  42. exact common_neighbors_unique G ne absent ha.1.1 ha.2.1 hb.1.1 hb.2.1
  43. have size := Set.ncard_union_add_ncard_inter A B
  44. change 2 ≤ A.ncard at from_s
  45. change 2 ≤ B.ncard at from_t
  46. change 3 ≤ (A ∪ B).ncard
  47. omega
  48. /-- For any two distinct vertices of a minimum-order counterexample, a
  49. common cubic neighbor is the only possible obstruction to the dyadic path. -/
  50. theorem dyadic_path_unless_cubic_common [Finite V] (G : SimpleGraph V) {s t : V}
  51. (ne : s ≠ t) (deg : ∀ v, 3 ≤ valence G v)
  52. (absent : ¬ hasPowerCycle G) (minimal : smaller_graphs_have_cycle G)
  53. (shared : ∀ v, G.Adj v s → G.Adj v t → 4 ≤ valence G v) :
  54. ∃ k ≥ 2, ∃ p : G.Walk s t, p.IsPath ∧ p.length = 2^k := by
  55. have outer (a b : V) : 2 ≤ (G.neighborSet a \ {b}).ncard := by
  56. have h := Set.ncard_le_ncard_diff_add_ncard (G.neighborSet a) {b}
  57. rw [Set.ncard_singleton] at h
  58. have degree : 3 ≤ (G.neighborSet a).ncard := deg a
  59. omega
  60. apply identification_forces_dyadic_path G s t ne absent
  61. apply minimal _ _ (identified_strict_size s t ne)
  62. exact identified_minimum_shared G s t (outer_degree_ge_three G ne absent (outer s t) (outer t s))
  63. (fun v _ _ => deg v) shared
  64. /-- Even in a biconnected minimum-order counterexample, every pair at
  65. distance at least three must occur as the ends of a simple dyadic path. -/
  66. theorem dyadic_path_of_dist_three [Finite V] (G : SimpleGraph V) (s t : V)
  67. (far : 3 ≤ G.dist s t) (deg : ∀ v, 3 ≤ valence G v)
  68. (absent : ¬ hasPowerCycle G) (minimal : smaller_graphs_have_cycle G) :
  69. ∃ k ≥ 2, ∃ p : G.Walk s t, p.IsPath ∧ p.length = 2^k := by
  70. have ne : s ≠ t := by rintro rfl; simp at far
  71. have missing : ¬ G.Adj s t := by
  72. intro e
  73. have bound := SimpleGraph.dist_le (cons e nil)
  74. simp at bound
  75. omega
  76. have disj : ∀ v, G.Adj v s → G.Adj v t → False := by
  77. intro v vs vt
  78. have bound := SimpleGraph.dist_le (cons vs.symm (cons vt nil))
  79. simp at bound
  80. omega
  81. have ds := deg s
  82. have dt := deg t
  83. apply identification_forces_dyadic_path G s t ne absent
  84. apply minimal _ _ (identified_strict_size s t ne)
  85. exact identified_minimum G s t missing disj (by omega) (by omega) (fun v _ _ => deg v)
  86. /-- Unordered pairs of distinct vertices without a simple path of length
  87. 4, 8, 16, ... . The pair is represented by its two-element vertex set. -/
  88. noncomputable def exceptionalPairs [Fintype V] (G : SimpleGraph V) : Finset (Finset V) := by
  89. classical
  90. exact (Finset.univ.powersetCard 2).filter fun P =>
  91. ∃ s t : V, P = {s,t} ∧ s ≠ t ∧ ¬ ∃ k ≥ 2, ∃ p : G.Walk s t, p.IsPath ∧ p.length = 2^k
  92. theorem exceptional_pair_bound [Fintype V] (G : SimpleGraph V)
  93. (deg : ∀ v, 3 ≤ valence G v) (absent : ¬ hasPowerCycle G) (minimal : smaller_graphs_have_cycle G) :
  94. (exceptionalPairs G).card ≤ 3 * (Finset.univ.filter (fun v => valence G v = 3)).card := by
  95. classical
  96. let C := Finset.univ.filter (fun v => valence G v = 3)
  97. let wedges := fun v : V => (G.neighborFinset v).powersetCard 2
  98. have covered : exceptionalPairs G ⊆ C.biUnion wedges := by
  99. intro P hP
  100. obtain ⟨size,s,t,rfl,ne,fail⟩ := Finset.mem_filter.mp hP
  101. have center : ∃ v, G.Adj v s ∧ G.Adj v t ∧ valence G v = 3 := by
  102. by_contra missing
  103. apply fail
  104. apply dyadic_path_unless_cubic_common G ne deg absent minimal
  105. intro v a b
  106. have h := deg v
  107. have not_three : valence G v ≠ 3 := fun e => missing ⟨v,a,b,e⟩
  108. omega
  109. obtain ⟨v,vs,vt,three⟩ := center
  110. apply Finset.mem_biUnion.mpr
  111. refine ⟨v,by simp [C,three],Finset.mem_powersetCard.mpr ⟨?_,(Finset.mem_powersetCard.mp size).2⟩⟩
  112. intro u hu
  113. rcases (Finset.mem_insert.mp hu) with rfl | hu
  114. · exact (G.mem_neighborFinset _ _).mpr vs
  115. · have eq := Finset.mem_singleton.mp hu
  116. exact (G.mem_neighborFinset _ _).mpr (eq ▸ vt)
  117. have cap := Finset.card_biUnion_le_card_mul C wedges 3 (by
  118. intro v hv
  119. have three : valence G v = 3 := (Finset.mem_filter.mp hv).2
  120. rw [valence_eq_degree] at three
  121. simp [wedges, Finset.card_powersetCard, G.card_neighborFinset_eq_degree, three])
  122. exact (Finset.card_le_card covered).trans (by simpa [C,Nat.mul_comm] using cap)
  123. end TerminalCycles