op874_shortest_directed_tail
The tail of a shortest walk whose darts satisfy a predicate is shortest under the same predicate.
Statement
theorem op874_shortest_directed_tail {V : Type*} (G : SimpleGraph V) (P : G.Dart → Prop) {u v t : V} (huv : G.Adj u v) (w : G.Walk v t) (hfirst : P ⟨(u,v), huv⟩) (hmin : ∀ w' : G.Walk u t, (∀ e ∈ w'.darts, P e) → (SimpleGraph.Walk.cons huv w).length ≤ w'.length) : ∀ w' : G.Walk v t, (∀ e ∈ w'.darts, P e) → w.length ≤ w'.length
- Source
- A tail of a shortest directed walk is shortest.
- Verified
- 22 Nov 2026
- Axioms
Quot.soundpropext
The proof, explained
To show that the tail walk w is a shortest walk from v to t whose darts satisfy P, consider any competing walk w' from v to t whose darts all satisfy P. Prepending the edge (u, v) to w' yields a walk from u to t whose darts all satisfy P, since the initial dart satisfies P by assumption and the remaining darts come from w'. The minimality of the original walk cons(huv, w) then gives length(w) + 1 ≤ length(w') + 1, which immediately implies length(w) ≤ length(w').
Fix an arbitrary candidate walk w' from v to t whose darts all satisfy P.
To establish the universal claim that w is at least as short as any walk from v to t satisfying P, we introduce an arbitrary walk w' and the hypothesis that all of its darts satisfy P.
intro w' hw'Every dart in the prepended walk cons(huv, w') satisfies P.
Any dart in cons(huv, w') is either the newly prepended edge (u, v) or a dart belonging to w'. The edge (u, v) satisfies P by the hypothesis hfirst, and every dart of w' satisfies P by assumption on w'.
uses
SimpleGraph.Walk.darts_cons,List.mem_conshave hh : ∀ e ∈ (SimpleGraph.Walk.cons huv w').darts, P e := by intro e he simp only [SimpleGraph.Walk.darts_cons, List.mem_cons] at he rcases he with rfl | he · exact hfirst · exact hw' e he
The length of w is at most the length of w'.
Since cons(huv, w') satisfies P on all its darts, the minimality hypothesis hmin gives length(cons(huv, w)) ≤ length(cons(huv, w')). Since prepending an edge increases the walk length by 1, this rewrites to length(w) + 1 ≤ length(w') + 1, from which length(w) ≤ length(w') follows by linear arithmetic.
uses
SimpleGraph.Walk.length_conshave h := hmin (SimpleGraph.Walk.cons huv w') hh simp only [SimpleGraph.Walk.length_cons] at h omega
SimpleGraph.Walk.darts_cons- The list of darts of the walk cons(h, p) consists of the initial dart corresponding to edge h prepended to the list of darts of p.
List.mem_cons- An element belongs to a list b :: l if and only if it equals b or belongs to l.
SimpleGraph.Walk.length_cons- The length of the walk cons(h, p) is one greater than the length of p.
Written by a model (gemini-3.8-flash) from the Lean proof and the goal states Lean reported at each step. Lean verified the proof; this explanation is a reading aid and is not itself machine-checked.
Lean source view module on GitHub
Choose a tactic — a marked line — to see the goals Lean had before and after it, as in Lean’s infoview. Step with ← → or j k.
theorem op874_shortest_directed_tail {V : Type*} (G : SimpleGraph V) (P : G.Dart → Prop) {u v t : V} (huv : G.Adj u v) (w : G.Walk v t) (hfirst : P ⟨(u,v), huv⟩) (hmin : ∀ w' : G.Walk u t, (∀ e ∈ w'.darts, P e) → (SimpleGraph.Walk.cons huv w).length ≤ w'.length) : ∀ w' : G.Walk v t, (∀ e ∈ w'.darts, P e) → w.length ≤ w'.length := by intro w' hw' have hh : ∀ e ∈ (SimpleGraph.Walk.cons huv w').darts, P e := by intro e he simp only [SimpleGraph.Walk.darts_cons, List.mem_cons] at he rcases he with rfl | he · exact hfirst · exact hw' e he have h := hmin (SimpleGraph.Walk.cons huv w') hh simp only [SimpleGraph.Walk.length_cons] at h omega