@@ -57,6 +57,24 @@ lemma takeUntil_first (p : G.Walk u v) :
5757lemma nil_takeUntil (p : G.Walk u v) (hwp : w ∈ p.support) :
5858 (p.takeUntil w hwp).Nil ↔ u = w := ⟨Nil.eq, (by cases ·; simp)⟩
5959
60+ lemma takeUntil_eq_take (p : G.Walk u v) (h : w ∈ p.support) :
61+ p.takeUntil w h = (p.take <| p.support.idxOf w).copy rfl (p.getVert_support_idxOf h) := by
62+ apply ext_support
63+ induction p with
64+ | nil =>
65+ simp only [takeUntil, eq_mpr_eq_cast, support_nil, getVert_nil, take, support_copy]
66+ grind [mem_support_nil_iff, support_nil]
67+ | @cons a _ _ _ p ih =>
68+ by_cases! h' : w = a
69+ · grind [List.idxOf_cons_self, take_zero, copy_rfl_rfl, support_nil, takeUntil_first]
70+ · rw [take_cons_eq _ _ _ (by grind), takeUntil_cons (List.mem_of_ne_of_mem h' h) h'.symm,
71+ support_cons, support_copy, ih (by grind)]
72+ grind
73+
74+ lemma length_takeUntil (p : G.Walk u v) (h : w ∈ p.support) :
75+ (p.takeUntil w h).length = p.support.idxOf w := by
76+ simp [takeUntil_eq_take, Nat.le_iff_lt_add_one, ← length_support, List.idxOf_lt_length_of_mem h]
77+
6078/-- Given a vertex in the support of a path, give the path from (and including) that vertex to
6179the end. In other words, drop vertices from the front of a path until (and not including)
6280that vertex. -/
@@ -85,6 +103,29 @@ theorem take_spec {u v w : V} (p : G.Walk v w) (h : u ∈ p.support) :
85103 · simp! only
86104 split_ifs with h' <;> subst_vars <;> simp [*]
87105
106+ @[simp]
107+ lemma dropUntil_first (p : G.Walk u v) (h : u ∈ p.support) : p.dropUntil u h = p := by
108+ unfold dropUntil
109+ split <;> simp
110+
111+ lemma dropUntil_eq_drop (p : G.Walk u v) (h : w ∈ p.support) :
112+ p.dropUntil w h = (p.drop <| p.support.idxOf w).copy (p.getVert_support_idxOf h) rfl := by
113+ apply ext_support
114+ induction p with
115+ | nil =>
116+ simp only [dropUntil, eq_mpr_eq_cast, support_nil, getVert_nil, drop, support_copy]
117+ grind [mem_support_nil_iff, support_nil]
118+ | @cons a _ _ _ p ih =>
119+ by_cases! h' : w = a
120+ · subst h'
121+ simp [dropUntil_first, drop_support_eq_support_drop_min]
122+ · rw [drop_cons_eq _ _ _ (by grind), support_copy, dropUntil]
123+ grind
124+
125+ lemma length_dropUntil (p : G.Walk u v) (h : w ∈ p.support) :
126+ (p.dropUntil w h).length = p.length - p.support.idxOf w := by
127+ simp [dropUntil_eq_drop]
128+
88129theorem isSubwalk_takeUntil (p : G.Walk u v) (h : w ∈ p.support) : (p.takeUntil w h).IsSubwalk p :=
89130 ⟨nil, p.dropUntil w h, by simp⟩
90131
0 commit comments