Simple paths #
A SimplePath α is a SimpleWalk α whose vertices are pairwise distinct.
This file keeps paths as a subtype of simple walks, so every path can be used
where a simple walk is expected.
Main definitions #
SimpleWalk.IsPath— a simple walk with no repeated vertices.SimplePath— a simple walk bundled with a proof that its vertices are pairwise distinct.SimplePath.singleton,SimplePath.cycleErase— the two constructors: a one-vertex path, and the path underlying any simple walk.SimplePath.append,SimplePath.glue— join two paths, keeping resp. dropping the duplicated joining vertex.SimplePath.reverse,SimplePath.dropHead,SimplePath.dropTail,SimplePath.prefixUntil,SimplePath.suffixFrom,SimplePath.takeWhile,SimplePath.dropWhile,SimplePath.splitAt,SimplePath.map,SimplePath.zip,SimplePath.loopErase— theSimpleWalkoperations, lifted.
Every operation is the SimpleWalk one plus a proof that nodup survives.
A simple walk is a path when it has no repeated vertices.
Instances For
A simple path is a simple walk with no repeated vertex.
Equations
- SimplePath α = { w : SimpleWalk α // w.IsPath }
Instances For
Basic accessors #
The underlying simple walk.
Instances For
The underlying vertex sequence.
Instances For
The list of vertices visited by the path.
Instances For
The unordered edges traversed by the path.
Instances For
The directed arcs traversed by the path.
Instances For
The first vertex of the path.
Instances For
The last vertex of the path.
Instances For
The number of edges in the path.
Instances For
A path has no repeated vertices.
A simple path is, in particular, a simple walk.
Equations
Constructors #
The singleton path at v: a single vertex and no edges.
Equations
Instances For
The vertex sequence of a singleton path. This is the bridge that lets simp
see through SimplePath.singleton down to the VertexSeq layer, where the
singleton API lives.
Cycle erasure of any simple walk produces a simple path.
Equations
- SimplePath.cycleErase w = ⟨w.cycleErase, ⋯⟩
Instances For
dropHead, dropTail #
Drop the first vertex of a path. Removing an endpoint preserves nodup.
Instances For
Drop the last vertex of a path. Removing an endpoint preserves nodup.
Instances For
append, glue #
Concatenate two vertex-disjoint paths, keeping both joining vertices.
The disjointness hypothesis is what preserves nodup; it also rules out a
stall at the junction.
Instances For
The vertex sequence of an append is the append of the vertex sequences. This
is the bridge that lets simp see through SimplePath.append down to the
VertexSeq layer, where head_append / tail_append / length_append /
mem_append live.
Concatenate two paths meeting at a shared vertex, dropping the duplicated
joining vertex. When p is nontrivial its remaining vertices must be disjoint
from q; when p is a single vertex the result is just q, so no disjointness
is required. Guarding the hypothesis by length ≠ 0 keeps the singleton-left
case usable, since dropTail leaves a singleton unchanged.
Instances For
reverse #
Reverse a path. Reversal preserves nodup.
Instances For
prefixUntil, suffixFrom #
The prefix of a path ending at the first occurrence of v. A contiguous
prefix of a path is a path.
Equations
- p.prefixUntil v h = ⟨p.val.prefixUntil v h, ⋯⟩
Instances For
The suffix of a path starting at the first occurrence of v. A contiguous
suffix of a path is a path.
Equations
- p.suffixFrom v h = ⟨p.val.suffixFrom v h, ⋯⟩
Instances For
map #
Map a path through an injective function. Injectivity preserves distinct vertices.
Equations
- SimplePath.map f hf p = ⟨SimpleWalk.map f hf p.val, ⋯⟩
Instances For
takeWhile, dropWhile #
Take a contiguous prefix of a path, including the first failure if any.
Instances For
Drop the longest prefix of a path on which q holds. The result is a
contiguous suffix, hence a path.
Instances For
splitAt #
Split a path at every occurrence of v. Every produced piece is a
contiguous subpath.
Equations
Instances For
zip #
Zip two paths into a path of pairs. Pairwise distinct first components are enough to make the pairs pairwise distinct.
Instances For
loopErase #
Remove immediate stalls from a path. Since a path has no repeated vertices,
this preserves nodup.
Instances For
edges #
The number of traversed edges equals the path's length.
A path traverses each edge at most once (a path is a trail).
Reversal reverses the edge list.
Dropping the last vertex cannot introduce new edges.
Dropping the first vertex cannot introduce new edges.
Taking a prefix cannot introduce new edges.
Taking a suffix cannot introduce new edges.
arcs #
The number of traversed arcs equals the path's length.
A path traverses each directed arc at most once.
Dropping the last vertex cannot introduce new arcs.
Dropping the first vertex cannot introduce new arcs.
Taking a prefix cannot introduce new arcs.
Taking a suffix cannot introduce new arcs.