The entries of a matrix power as a sum over paths #
Category: 1-Mathlib (CSD-free; staged for upstream).
An entry of M ^ n is a sum over all index paths of n steps from the row to the column index,
each path weighted by the product of the entries it traverses. Mathlib carries this only for
adjacency matrices, as a count of walks (SimpleGraph.adjMatrix_pow_apply_eq_card_walk); this file
is the weighted form over a commutative semiring, in the shape the sum-over-paths reading of a
matrix exponential needs: the row and column indices fixed, the sum over the intermediate states.
Matrix.pathWeight M p— the weight of the pathp : Fin (n + 1) → ι, the product∏ k, M (p k) (p (k + 1))of the entries along itsnsteps;Matrix.pathWeight_cons— prepending a state multiplies the weight by the entry of the new first step;- ★
Matrix.pow_succ_apply_eq_sum_pathWeight— the sum over paths:(M ^ (n + 1)) i j = ∑ p : Fin n → ι, pathWeight M (Fin.cons i (Fin.snoc p j)), the sum over every choice of thenintermediate states of the path fromitojinn + 1steps.
Honest scope #
⚠️ Commutative scalars. The weight of a path is a Finset product, so the scalars are a
CommSemiring; over a noncommutative ring the product along a path is ordered and would be a
List.prod. The consumer (Analysis/Matrix/SumOverPaths.lean) works over ℂ.
References: Mathlib/Combinatorics/SimpleGraph/AdjMatrix.lean
(adjMatrix_pow_apply_eq_card_walk, the unweighted case); consumer
Analysis/Matrix/SumOverPaths.lean; specs/future-work.md, specs/BACKLOG.md #36.
The weight of an n-step path p through the index set, for the matrix M: the product of
the entries of M along the steps of p.
Equations
- M.pathWeight p = ∏ k : Fin n, M (p k.castSucc) (p k.succ)
Instances For
pathWeight, unfolded.
A path with no steps has weight one.
A one-step path has the weight of its one entry.
Prepending a state i to a path q multiplies the weight by the entry of the new first
step, from i to the first state of q.
★ The entries of a matrix power are sums over paths. The (i, j) entry of M ^ (n + 1) is
the sum, over every choice p of the n intermediate states, of the weight of the path
i, p 0, …, p (n - 1), j.