Documentation

CslibFrontier.Foundations.LinearAlgebra.Matrix.CoinStep

Transition matrices of coin-driven maps #

A map next : α → Bool → α moves a state to one of two successors, selected by a coin. On a finite set s of states closed under next, its count matrix Matrix.coinStepMatrix next s has as entry (x, y) the number of coins that move x to y. Its powers count coin strings (Matrix.coinStepMatrix_pow_mulVec): (N ^ t *ᵥ f) x is the sum of f over the endpoints of the 2 ^ t coin strings of length t replayed from x. Halving the entries gives the stochastic matrix of the fair-coin random walk.

Keeping only the rows of the live states gives Matrix.liveCoinStepMatrix live next s, which counts coin strings along which every state before the last is live (Matrix.liveCoinStepMatrix_pow_mulVec). When the other states are fixed by next, the walk stops at the first state that is not live, and every coin string is counted by the time it stops (Matrix.coinStepMatrix_pow_mulVec_eq_sum). When the live walks have bounded length, the live matrix is nilpotent, and 1 - S has the inverse ∑ i < n, S ^ i (Matrix.inv_one_sub_eq_sum_pow).

Main definitions #

Main results #

def Matrix.coinStepMatrix {α : Type u_1} {R : Type u_2} [DecidableEq α] [CommSemiring R] (next : α → Bool → α) (s : Finset α) :
Matrix (↥s) (↥s) R

The count matrix of a coin-driven map on a finite set s: the entry at (x, y) is the number of coins b with next x b = y.

def Matrix.liveCoinStepMatrix {α : Type u_1} {R : Type u_2} [DecidableEq α] [CommSemiring R] (next : α → Bool → α) (s : Finset α) (live : α → Prop) [DecidablePred live] :
Matrix (↥s) (↥s) R

The live count matrix: the rows of Matrix.coinStepMatrix at states satisfying live, and zero rows at the other states.

theorem Matrix.coinStepMatrix_mulVec {α : Type u_1} {R : Type u_2} [DecidableEq α] [CommSemiring R] {next : α → Bool → α} {s : Finset α} (hs : ∀ x ∈ s, ∀ (b : Bool), next x b ∈ s) (g : ↥s → R) (x : ↥s) :
(coinStepMatrix next s).mulVec g x = ∑ b : Bool, g ⟨next (↑x) b, ⋯⟩

A row of the count matrix, applied to a vector, sums the two coin successors.

theorem Matrix.liveCoinStepMatrix_mulVec {α : Type u_1} {R : Type u_2} [DecidableEq α] [CommSemiring R] {next : α → Bool → α} {s : Finset α} {live : α → Prop} [DecidablePred live] (hs : ∀ x ∈ s, ∀ (b : Bool), next x b ∈ s) (g : ↥s → R) (x : ↥s) :
(liveCoinStepMatrix next s live).mulVec g x = if live ↑x then ∑ b : Bool, g ⟨next (↑x) b, ⋯⟩ else 0

A row of the live count matrix sums the two coin successors at a live state and vanishes elsewhere.

theorem Matrix.coinStepMatrix_pow_mulVec {α : Type u_1} {R : Type u_2} [DecidableEq α] [CommSemiring R] {next : α → Bool → α} {s : Finset α} (hs : ∀ x ∈ s, ∀ (b : Bool), next x b ∈ s) (f : α → R) (t : ℕ) (x : ↥s) :
(coinStepMatrix next s ^ t).mulVec (fun (y : ↥s) => f ↑y) x = ∑ w : Fin t → Bool, f (List.foldl next (↑x) (List.ofFn w))

Powers of the count matrix sum over coin strings: (N ^ t *ᵥ f) x is the sum of f over the states reached from x by the 2 ^ t coin strings of length t.

theorem Matrix.liveCoinStepMatrix_pow_mulVec {α : Type u_1} {R : Type u_2} [DecidableEq α] [CommSemiring R] {next : α → Bool → α} {s : Finset α} {live : α → Prop} [DecidablePred live] (hs : ∀ x ∈ s, ∀ (b : Bool), next x b ∈ s) (f : α → R) (t : ℕ) (x : ↥s) :
(liveCoinStepMatrix next s live ^ t).mulVec (fun (y : ↥s) => f ↑y) x = ∑ w : Fin t → Bool, if ∀ (i : Fin t), live (List.foldl next (↑x) (List.take (↑i) (List.ofFn w))) then f (List.foldl next (↑x) (List.ofFn w)) else 0

Powers of the live count matrix sum over live coin strings: (S ^ t *ᵥ f) x is the sum of f over the states reached from x by those coin strings of length t along which every state before the last is live.

theorem Matrix.coinStepMatrix_pow_mulVec_eq_sum {α : Type u_1} {R : Type u_2} [DecidableEq α] [CommSemiring R] {next : α → Bool → α} {s : Finset α} {live : α → Prop} [DecidablePred live] (hs : ∀ x ∈ s, ∀ (b : Bool), next x b ∈ s) (hfix : ∀ (x : α), ¬live x → ∀ (b : Bool), next x b = x) {f : α → R} (hf : ∀ (x : α), live x → f x = 0) (T : ℕ) (x : ↥s) :
(coinStepMatrix next s ^ T).mulVec (fun (y : ↥s) => f ↑y) x = ∑ t ∈ Finset.range (T + 1), 2 ^ (T - t) * (liveCoinStepMatrix next s live ^ t).mulVec (fun (y : ↥s) => f ↑y) x

First-stop decomposition. If the states that are not live are fixed by next, and f vanishes at live states, then counting the coin strings of length T by f at their endpoint is the same as counting, for each t ≤ T, the live coin strings of length t by f, each weighted by the 2 ^ (T - t) continuations after the walk has stopped.

theorem Matrix.liveCoinStepMatrix_pow_eq_zero {α : Type u_1} {R : Type u_2} [DecidableEq α] [CommSemiring R] {next : α → Bool → α} {s : Finset α} {live : α → Prop} [DecidablePred live] (hs : ∀ x ∈ s, ∀ (b : Bool), next x b ∈ s) {n : ℕ} (h : ∀ x ∈ s, ∀ (w : Fin n → Bool), ∃ (i : Fin n), ¬live (List.foldl next x (List.take (↑i) (List.ofFn w)))) :
liveCoinStepMatrix next s live ^ n = 0

Bounded live walks make the live matrix nilpotent: if along every coin string of length n from a state of s some state before the last is not live, then S ^ n = 0.

theorem Matrix.inv_one_sub_eq_sum_pow {R : Type u_2} {ι : Type u_3} [Fintype ι] [DecidableEq ι] [CommRing R] {S : Matrix ι ι R} {n : ℕ} (h : S ^ n = 0) :
(1 - S)⁻¹ = ∑ i ∈ Finset.range n, S ^ i

Inverse of 1 - S for nilpotent S: if S ^ n = 0, then 1 - S is invertible with inverse the truncated geometric series ∑ i < n, S ^ i.