op874_shortest_directed_walk_is_path
A shortest walk subject to a predicate on its oriented darts has no repeated vertices.
Statement
theorem op874_shortest_directed_walk_is_path {V : Type*} [DecidableEq V] (G : SimpleGraph V) (P : G.Dart → Prop) {u v : V} (w : G.Walk u v) (hdir : ∀ e ∈ w.darts, P e) (hmin : ∀ w' : G.Walk u v, (∀ e ∈ w'.darts, P e) → w.length ≤ w'.length) : w.IsPath
- Source
- Path bypass preserves oriented darts.
- Verified
- 22 Nov 2026
- Axioms
Classical.choiceQuot.soundpropext- Used by 1
- op874_exists_shortest_directed_pathIf a directed walk obeying a dart predicate exists, a shortest one exists and is simple.
The proof, explained
To show that a shortest walk $w$ satisfying a dart predicate $P$ is a path, we consider its bypass, which shortcuts any repeated vertices into a path whose darts are a subset of those of $w$. Because the darts of the bypass satisfy $P$, the minimality of $w$ implies that $w$ is no longer than its bypass. Hence $w$ must equal its bypass, which is already known to be a path.
Every dart in the bypass of $w$ satisfies the predicate $P$.
Let $e$ be a dart in the bypass $w.\mathrm{bypass}$. By `darts_bypass_subset_darts`, the darts of $w.\mathrm{bypass}$ are a subset of the darts of $w$, so $e$ is also a dart of $w$. Since every dart in $w$ satisfies $P$ by hypothesis `hdir`, $e$ satisfies $P$ as well.
uses
darts_bypass_subset_dartshave hdir' : ∀ e ∈ w.bypass.darts, P e := by intro e he exact hdir e (w.darts_bypass_subset_darts he)
The bypass of $w$ is equal to $w$ itself ($w.\mathrm{bypass} = w$).
The bypass $w.\mathrm{bypass}$ is a walk from $u$ to $v$ whose darts all satisfy $P$. By the minimality assumption on $w$ (`hmin`), the length of $w$ is at most the length of $w.\mathrm{bypass}$. A walk whose length is at most that of its bypass cannot have any bypassed cycles and must equal its bypass (`bypass_eq_self_of_length_le_length_bypass`).
uses
bypass_eq_self_of_length_le_length_bypasshave heq : w.bypass = w := w.bypass_eq_self_of_length_le_length_bypass (hmin w.bypass hdir')The walk $w$ is a path (it contains no repeated vertices).
Rewriting $w$ as $w.\mathrm{bypass}$ using the equality established in the previous step, it suffices to show that $w.\mathrm{bypass}$ is a path. This holds directly from `bypass_isPath`, which states that the bypass of any walk is always a path.
uses
bypass_isPathrw [← heq] exact w.bypass_isPath
darts_bypass_subset_darts- The darts (oriented edges) of the bypass of a walk form a subset of the darts of the original walk.
bypass_eq_self_of_length_le_length_bypass- If a walk has length less than or equal to the length of its bypass, then the bypass is equal to the walk itself.
bypass_isPath- The bypass of any walk is a path (a walk with no repeated vertices).
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_walk_is_path {V : Type*} [DecidableEq V] (G : SimpleGraph V) (P : G.Dart → Prop) {u v : V} (w : G.Walk u v) (hdir : ∀ e ∈ w.darts, P e) (hmin : ∀ w' : G.Walk u v, (∀ e ∈ w'.darts, P e) → w.length ≤ w'.length) : w.IsPath := by have hdir' : ∀ e ∈ w.bypass.darts, P e := by intro e he exact hdir e (w.darts_bypass_subset_darts he) have heq : w.bypass = w := w.bypass_eq_self_of_length_le_length_bypass (hmin w.bypass hdir') rw [← heq] exact w.bypass_isPath