@@ -166,4 +166,39 @@ theorem cycleGraph.isCycle_cycle : (cycleGraph.cycle n).IsCycle :=
166166
167167end cycle
168168
169+ section IsContained
170+
171+ variable {V : Type *} {G : SimpleGraph V}
172+
173+ lemma cycleGraph_isContained_iff {n : ℕ} (hn : 2 < n) :
174+ cycleGraph n ⊑ G ↔ ∃ (v : V) (p : G.Walk v v), p.IsCycle ∧ p.length = n := by
175+ refine ⟨fun ⟨h⟩ ↦ ?_, fun h' ↦ ?_⟩
176+ · have : n = n - 3 + 3 := by lia
177+ rw [this] at h
178+ refine ⟨h.toHom ⟨0 , by lia⟩, Walk.map h.toHom <| cycleGraph.cycle (n - 3 ), ?_, ?_⟩
179+ · exact (map_isCycle_iff_of_injective h.injective).mpr cycleGraph.isCycle_cycle
180+ · simp [cycleGraph.length_cycle, ← this]
181+ · obtain ⟨a, p, hp₁, hp₂⟩ := h'
182+ refine ⟨⟨⟨fun n ↦ p.support[n.succ]'(?_), ?_⟩, ?_⟩⟩
183+ · grind [hp₁.three_le_length, length_tail_add_one, not_nil_iff_lt_length]
184+ · intro ⟨x, hx⟩ ⟨y, hy⟩ hab
185+ have hne : x ≠ y := fun _ ↦ by simp_all
186+ wlog hle : x > y
187+ · exact this hn a p hp₁ hp₂ y hy x hx hab.symm hne.symm (by lia) |>.symm
188+ rcases cycleGraph_adj'.mp hab with hab | hab
189+ · simp_rw [show x = y + 1 by grind [Fin.sub_val_of_le]]
190+ exact p.isChain_adj_support.getElem _ _ |>.symm
191+ · rw [Fin.coe_sub_iff_lt.mpr hle] at hab
192+ simp_rw [show x = n - 1 by lia, show y = 0 by lia, Fin.succ_mk, show n - 1 + 1 = n by lia]
193+ simp [← hp₂, p.adj_snd hp₁.not_nil]
194+ · have hlen : p.tail.support.length = n := by
195+ grind [length_tail_add_one, not_nil_iff_lt_length]
196+ have (m : Fin n) : p.support[m.succ]'(by grind) = p.tail.support[m] := by
197+ simp [p.support_tail_of_not_nil hp₁.not_nil]
198+ simp_rw [this]
199+ have := IsPath.mk' <| (support_tail_of_not_nil _ hp₁.not_nil) ▸ hp₁.support_nodup
200+ exact hlen ▸ (isPath_iff_injective_get_support _ |>.mp this)
201+
202+ end IsContained
203+
169204end SimpleGraph
0 commit comments