Documentation

CslibFrontier.Foundations.Combinatorics.Digraph.Layered

Paths in layered digraphs #

A layered digraph is a digraph equipped with a natural-number layer for each vertex. Each edge advances exactly one layer. Paths use Mathlib's Quiver.Path, with one arrow for each adjacent pair, so parallel edges are excluded.

Main results #

structure Cslib.LayeredDigraph (V : Type u_1) extends Digraph V :
Type u_1

A digraph whose edges advance exactly one layer.

  • Adj : V → V → Prop
  • layer : V → ℕ

    The layer of each vertex.

  • layer_adj {a b : V} : self.Adj a b → self.layer b = self.layer a + 1

    Every edge goes to the next layer.

@[reducible, inline]

The quiver with one arrow for each adjacent pair.

@[reducible, inline]
abbrev Cslib.LayeredDigraph.Path {V : Type u_1} (G : LayeredDigraph V) (a b : V) :
Type u_1

Directed paths in the underlying quiver of a layered digraph.

Instances For
    @[reducible, inline]
    abbrev Cslib.LayeredDigraph.Path.length {V : Type u_1} {G : LayeredDigraph V} {a b : V} (p : G.Path a b) :

    The number of edges of a path.

    @[reducible, inline]
    abbrev Cslib.LayeredDigraph.Path.vertices {V : Type u_1} {G : LayeredDigraph V} {a b : V} (p : G.Path a b) :

    The vertices of a path in order, including both endpoints.

    @[reducible, inline]
    abbrev Cslib.LayeredDigraph.Path.comp {V : Type u_1} {G : LayeredDigraph V} {a b c : V} (p : G.Path a b) (q : G.Path b c) :
    G.Path a c

    Concatenate paths with a common endpoint.

    @[reducible, inline]
    abbrev Cslib.LayeredDigraph.Path.ofAdj {V : Type u_1} {G : LayeredDigraph V} {a b : V} (h : G.Adj a b) :
    G.Path a b

    An edge viewed as a length-one path.

    theorem Cslib.LayeredDigraph.Path.layer_end {V : Type u_1} {G : LayeredDigraph V} {a b : V} (p : G.Path a b) :
    G.layer b = G.layer a + p.length

    The last layer of a path is its first layer plus its length.

    theorem Cslib.LayeredDigraph.Path.exists_eq_comp_of_layer {V : Type u_1} {G : LayeredDigraph V} {a b : V} (p : G.Path a b) {k : ℕ} (ha : G.layer a ≤ k) (hb : k ≤ G.layer b) :
    ∃ (v : V) (q : G.Path a v) (r : G.Path v b), p = q.comp r ∧ G.layer v = k

    A path splits at any layer in its closed endpoint interval.

    theorem Cslib.LayeredDigraph.Path.layer_getElem_vertices {V : Type u_1} {G : LayeredDigraph V} {a b : V} (p : G.Path a b) (i : ℕ) (hi : i < p.vertices.length) :
    G.layer p.vertices[i] = G.layer a + i

    The vertex at position i lies i layers after the source.

    theorem Cslib.LayeredDigraph.Path.existsUnique_vertex {V : Type u_1} {G : LayeredDigraph V} {a b : V} (p : G.Path a b) {k : ℕ} (ha : G.layer a ≤ k) (hb : k ≤ G.layer b) :
    ∃! v : V, v ∈ p.vertices ∧ G.layer v = k

    A path visits exactly one vertex in each layer between its endpoints.

    instance Cslib.LayeredDigraph.Path.instFinite {V : Type u_1} {G : LayeredDigraph V} {a b : V} [Finite V] :
    Finite (G.Path a b)
    theorem Cslib.LayeredDigraph.Path.eq_of_layer_le_succ {V : Type u_1} {G : LayeredDigraph V} {a b : V} (h : G.layer b ≤ G.layer a + 1) (p q : G.Path a b) :
    p = q

    With at most one edge between the endpoint layers, any two paths coincide.

    def Cslib.LayeredDigraph.Path.internalVertices {V : Type u_1} {G : LayeredDigraph V} {a b : V} (p : G.Path a b) :

    The vertices strictly between the endpoints, in path order.

    theorem Cslib.LayeredDigraph.Path.mem_internalVertices_iff {V : Type u_1} {G : LayeredDigraph V} {a b : V} (p : G.Path a b) {v : V} :

    On an internal layer, the unique vertex on the path belongs to its internal list.

    theorem Cslib.LayeredDigraph.Path.internalVertices_comp {V : Type u_1} {G : LayeredDigraph V} {a b c : V} (p : G.Path a b) (q : G.Path b c) (hp : G.layer a < G.layer b) (hq : G.layer b < G.layer c) :

    The internal vertices of a concatenation are those of the first path, the common endpoint, and those of the second path, in that order.

    def Cslib.LayeredDigraph.Path.internalWeight {V : Type u_1} {G : LayeredDigraph V} {a b : V} {M : Type u_2} [AddMonoid M] (weight : V → M) (p : G.Path a b) :
    M

    The sum of the weights of the internal vertices.

    theorem Cslib.LayeredDigraph.Path.internalWeight_comp {V : Type u_1} {G : LayeredDigraph V} {a b c : V} {M : Type u_2} [AddMonoid M] (weight : V → M) (p : G.Path a b) (q : G.Path b c) (hp : G.layer a < G.layer b) (hq : G.layer b < G.layer c) :
    internalWeight weight (p.comp q) = internalWeight weight p + weight b + internalWeight weight q

    At an internal split, the common endpoint contributes its weight exactly once.

    def Cslib.LayeredDigraph.Path.vertexAtLayer {V : Type u_1} {G : LayeredDigraph V} {a b : V} (p : G.Path a b) (k : ℕ) :
    V

    The vertex visited at a layer, with the source as the default outside the path.

    theorem Cslib.LayeredDigraph.Path.vertexAtLayer_eq {V : Type u_1} {G : LayeredDigraph V} {a b : V} (p : G.Path a b) {k : ℕ} {v : V} (hv : v ∈ p.vertices) (hk : G.layer v = k) :

    Within the path's layer interval, the lookup returns the unique vertex at that layer.

    theorem Cslib.LayeredDigraph.Path.internalWeight_eq_sum_layers {V : Type u_1} {G : LayeredDigraph V} {a b : V} {M : Type u_2} [AddCommMonoid M] (weight : V → M) (p : G.Path a b) :
    internalWeight weight p = ∑ k ∈ Finset.Icc (G.layer a + 1) (G.layer b - 1), weight (p.vertexAtLayer k)

    Sum internal weights in order of layer.