Walk counting for a finite digraph (the power of a 0-1 matrix) #
For a decidable relation r on a finite type V (a finite directed graph) we count directed walks
by powers of its 0-1 adjacency matrix. This is the directed-graph analogue of
SimpleGraph.adjMatrix_pow_apply_eq_card_walk, which Mathlib provides for simple graphs. The file
also expresses trace (Mᵏ) as a sum over closed index sequences and proves its invariance under
cyclic rotation.
Main definitions #
Matrix.relMatrix r: theℕ-valued0-1adjacency matrix ofr.Matrix.relWalks r k i j: the finset of length-kdirectedr-walks fromitoj, as vertex lists.
Main results #
Matrix.relMatrix_pow_apply:((relMatrix r) ^ k) i j = (relWalks r k i j).card.Matrix.pow_apply_eq_sum,Matrix.trace_pow_eq_sum_closed: entries and trace ofMᵏas sums over index sequences.Matrix.trace_pow_eq_sum_cyclicProd: the same sum written with cyclic products, which are invariant under rotation (Matrix.cyclicProd_comp_finRotate).
The ℕ-valued 0-1 adjacency matrix of a decidable relation r.
Equations
- Matrix.relMatrix r i j = if r i j then 1 else 0
Instances For
The finset of length-k directed r-walks from i to j, encoded as the list of visited
vertices [i, …, j].
Equations
- Matrix.relWalks r 0 x✝¹ x✝ = if x✝¹ = x✝ then {[x✝¹]} else ∅
- Matrix.relWalks r k.succ x✝¹ x✝ = Finset.univ.biUnion fun (l : V) => if r x✝¹ l then Finset.map { toFun := List.cons x✝¹, inj' := ⋯ } (Matrix.relWalks r k l x✝) else ∅
Instances For
The (i, j) entry of Mᵏ as a sum, over length-k vertex walks i → j (encoded as
Fin (k+1) → V tuples with fixed endpoints), of the product of the edge weights.
The trace of Mᵏ counts closed walks. It is the sum, over closed length-k walks (tuples
p : Fin (k+1) → V with p 0 = p (last)), of the product of the edge weights.
Rotation invariance — toward closed geodesics #
The cyclic product of edge weights along a closed walk w : Fin (n+1) → V,
∏ₜ M (w t) (w (σ t)) where σ = finRotate (n+1) is the cyclic successor.
Instances For
Rotation invariance. The cyclic product is unchanged when the closed walk is rotated by the
cyclic shift finRotate. This is what makes the weight a class function on rotation orbits — the
structure that groups closed non-backtracking walks into (prime) geodesics.
Invariance under the whole rotation group. The cyclic product is unchanged by any iterate of
finRotate — i.e. it is a class function on the ℤ/(n+1) rotation orbits.
The cyclic trace formula. tr(M^(m+1)) is the sum, over all closed cyclic walks
w : Fin (m+1) → V, of the cyclic product of edge weights. Connects the closed-walk trace
(trace_pow_eq_sum_closed) to the rotation-equivariant cyclicProd.
Every walk in relWalks r k i j starts at i.
Powers of the 0-1 adjacency matrix count directed walks.