Skip to content

Commit 49a37b5

Browse files
committed
feat: Add getVert_append and getVert_reverse (#11787)
1 parent 7bcbba0 commit 49a37b5

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Mathlib/Combinatorics/SimpleGraph/Connectivity.lean

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,28 @@ theorem exists_length_eq_zero_iff {u v : V} : (∃ p : G.Walk u v, p.length = 0)
430430
theorem length_eq_zero_iff {u : V} {p : G.Walk u u} : p.length = 0 ↔ p = nil := by cases p <;> simp
431431
#align simple_graph.walk.length_eq_zero_iff SimpleGraph.Walk.length_eq_zero_iff
432432

433+
theorem getVert_append {u v w : V} (p : G.Walk u v) (q : G.Walk v w) (i : ℕ) :
434+
(p.append q).getVert i = if i < p.length then p.getVert i else q.getVert (i - p.length) := by
435+
induction p generalizing i with
436+
| nil => simp
437+
| cons h p ih => cases i <;> simp [getVert, ih, Nat.succ_lt_succ_iff]
438+
439+
theorem getVert_reverse {u v : V} (p : G.Walk u v) (i : ℕ) :
440+
p.reverse.getVert i = p.getVert (p.length - i) := by
441+
induction p with
442+
| nil => rfl
443+
| cons h p ih =>
444+
simp only [reverse_cons, getVert_append, length_reverse, ih, length_cons]
445+
split_ifs
446+
next hi =>
447+
rw [Nat.succ_sub hi.le]
448+
simp [getVert]
449+
next hi =>
450+
obtain rfl | hi' := Nat.eq_or_lt_of_not_lt hi
451+
· simp [getVert]
452+
· rw [Nat.eq_add_of_sub_eq (Nat.sub_pos_of_lt hi') rfl, Nat.sub_eq_zero_of_le hi']
453+
simp [getVert]
454+
433455
section ConcatRec
434456

435457
variable {motive : ∀ u v : V, G.Walk u v → Sort*} (Hnil : ∀ {u : V}, motive u u nil)

0 commit comments

Comments
 (0)