The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V07. Linear algebra

Mathlib.LinearAlgebra.Matrix.Stochastic

33 declarations. Mathlib docs · Source

Row- and Column-stochastic matrices

A square matrix M is row-stochastic if all its entries are non-negative and M *ᵥ 1 = 1. Likewise, M is column-stochastic if all its entries are non-negative and 1 ᵥ* M = 1. This file defines these concepts and provides basic API for them.

Note that doubly stochastic matrices (i.e. matrices that are both row- and column-stochastic) are defined in Mathlib/Analysis/Convex/DoublyStochasticMatrix.lean.

Main definitions

  • rowStochastic: row-stochastic matrices indexed by n with entries in R, as a submonoid of Matrix n n R.
  • colStochastic R n: column-stochastic matrices indexed by n with entries in R, as a submonoid of Matrix n n R.

theorem Matrix.rowStochastic.congr_simp E1 #

∀ (R : Type u_3) (n : Type u_4) [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : Semiring R]
  [inst_3 : PartialOrder R] [inst_4 : IsOrderedRing R], Matrix.rowStochastic R n = Matrix.rowStochastic R n

theorem Matrix.colStochastic.congr_simp E1 #

∀ (R : Type u_3) (n : Type u_4) [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : Semiring R]
  [inst_3 : PartialOrder R] [inst_4 : IsOrderedRing R], Matrix.colStochastic R n = Matrix.colStochastic R n

def Matrix.rowStochastic E3 #

(R : Type u_3) →
  (n : Type u_4) →
    [inst : Fintype n] →
      [inst_1 : DecidableEq n] →
        [inst_2 : Semiring R] → [inst_3 : PartialOrder R] → [IsOrderedRing R] → Submonoid (Matrix n n R)

A square matrix is row stochastic iff all entries are nonnegative, and right multiplication by the vector of all 1s gives the vector of all 1s.

theorem Matrix.mem_rowStochastic E0 #

∀ {R : Type u_1} {n : Type u_2} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : Semiring R]
  [inst_3 : PartialOrder R] [inst_4 : IsOrderedRing R] {M : Matrix n n R},
  M ∈ Matrix.rowStochastic R n ↔ (∀ (i j : n), 0 ≤ M i j) ∧ M.mulVec 1 = 1

theorem Matrix.mem_rowStochastic_iff_sum E0 #

∀ {R : Type u_1} {n : Type u_2} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : Semiring R]
  [inst_3 : PartialOrder R] [inst_4 : IsOrderedRing R] {M : Matrix n n R},
  M ∈ Matrix.rowStochastic R n ↔ (∀ (i j : n), 0 ≤ M i j) ∧ ∀ (i : n), ∑ j, M i j = 1

A square matrix is row stochastic if each element is non-negative and row sums to one.

theorem Matrix.nonneg_of_mem_rowStochastic E1 #

∀ {R : Type u_1} {n : Type u_2} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : Semiring R]
  [inst_3 : PartialOrder R] [inst_4 : IsOrderedRing R] {M : Matrix n n R},
  M ∈ Matrix.rowStochastic R n → ∀ {i j : n}, 0 ≤ M i j

Every entry of a row stochastic matrix is nonnegative.

theorem Matrix.sum_row_of_mem_rowStochastic E1 #

∀ {R : Type u_1} {n : Type u_2} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : Semiring R]
  [inst_3 : PartialOrder R] [inst_4 : IsOrderedRing R] {M : Matrix n n R},
  M ∈ Matrix.rowStochastic R n → ∀ (i : n), ∑ j, M i j = 1

Each row sum of a row stochastic matrix is 1.

theorem Matrix.one_vecMul_of_mem_rowStochastic E1 #

∀ {R : Type u_1} {n : Type u_2} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : Semiring R]
  [inst_3 : PartialOrder R] [inst_4 : IsOrderedRing R] {M : Matrix n n R}, M ∈ Matrix.rowStochastic R n → M.mulVec 1 = 1

The all-ones column vector multiplied with a row stochastic matrix is 1.

theorem Matrix.le_one_of_mem_rowStochastic E1 #

∀ {R : Type u_1} {n : Type u_2} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : Semiring R]
  [inst_3 : PartialOrder R] [inst_4 : IsOrderedRing R] {M : Matrix n n R},
  M ∈ Matrix.rowStochastic R n → ∀ {i j : n}, M i j ≤ 1

Every entry of a row stochastic matrix is less than or equal to 1.

theorem Matrix.nonneg_vecMul_of_mem_rowStochastic E1 #

∀ {R : Type u_1} {n : Type u_2} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : Semiring R]
  [inst_3 : PartialOrder R] [inst_4 : IsOrderedRing R] {M : Matrix n n R} {x : n → R},
  M ∈ Matrix.rowStochastic R n → (∀ (i : n), 0 ≤ x i) → ∀ (j : n), 0 ≤ Matrix.vecMul x M j

Left multiplication of a row stochastic matrix by a non-negative vector gives a non-negative vector

theorem Matrix.nonneg_mulVec_of_mem_rowStochastic E1 #

∀ {R : Type u_1} {n : Type u_2} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : Semiring R]
  [inst_3 : PartialOrder R] [inst_4 : IsOrderedRing R] {M : Matrix n n R} {x : n → R},
  M ∈ Matrix.rowStochastic R n → (∀ (i : n), 0 ≤ x i) → ∀ (j : n), 0 ≤ M.mulVec x j

Right multiplication of a row stochastic matrix by a non-negative vector gives a non-negative vector

theorem Matrix.vecMul_dotProduct_one_eq_one_rowStochastic E1 #

∀ {R : Type u_1} {n : Type u_2} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : Semiring R]
  [inst_3 : PartialOrder R] [inst_4 : IsOrderedRing R] {M : Matrix n n R} {x : n → R},
  M ∈ Matrix.rowStochastic R n → x ⬝ᵥ 1 = 1 → Matrix.vecMul x M ⬝ᵥ 1 = 1

Left left-multiplication by row stochastic preserves ℓ₁ norm

theorem Matrix.convex_rowStochastic E1 #

∀ {R : Type u_1} {n : Type u_2} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : Semiring R]
  [inst_3 : PartialOrder R] [inst_4 : IsOrderedRing R], Convex R ↑(Matrix.rowStochastic R n)

The set of row stochastic matrices is convex.

theorem Matrix.permMatrix_mem_rowStochastic E0 #

∀ {R : Type u_1} {n : Type u_2} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : Semiring R]
  [inst_3 : PartialOrder R] [inst_4 : IsOrderedRing R] {σ : Equiv.Perm n},
  Equiv.Perm.permMatrix R σ ∈ Matrix.rowStochastic R n

Any permutation matrix is row stochastic.

def Matrix.colStochastic E1 #

(R : Type u_3) →
  (n : Type u_4) →
    [inst : Fintype n] →
      [inst_1 : DecidableEq n] →
        [inst_2 : Semiring R] → [inst_3 : PartialOrder R] → [IsOrderedRing R] → Submonoid (Matrix n n R)

A square matrix is column stochastic iff all entries are nonnegative, and left multiplication by the vector of all 1s gives the vector of all 1s.

theorem Matrix.mem_colStochastic E0 #

∀ {R : Type u_1} {n : Type u_2} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : Semiring R]
  [inst_3 : PartialOrder R] [inst_4 : IsOrderedRing R] {M : Matrix n n R},
  M ∈ Matrix.colStochastic R n ↔ (∀ (i j : n), 0 ≤ M i j) ∧ Matrix.vecMul 1 M = 1

theorem Matrix.mem_colStochastic_iff_sum E0 #

∀ {R : Type u_1} {n : Type u_2} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : Semiring R]
  [inst_3 : PartialOrder R] [inst_4 : IsOrderedRing R] {M : Matrix n n R},
  M ∈ Matrix.colStochastic R n ↔ (∀ (i j : n), 0 ≤ M i j) ∧ ∀ (j : n), ∑ i, M i j = 1

A matrix is column stochastic if each column sums to one.

theorem Matrix.nonneg_of_mem_colStochastic E1 #

∀ {R : Type u_1} {n : Type u_2} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : Semiring R]
  [inst_3 : PartialOrder R] [inst_4 : IsOrderedRing R] {M : Matrix n n R},
  M ∈ Matrix.colStochastic R n → ∀ {i j : n}, 0 ≤ M i j

Every entry of a column stochastic matrix is nonnegative.

theorem Matrix.sum_col_of_mem_colStochastic E1 #

∀ {R : Type u_1} {n : Type u_2} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : Semiring R]
  [inst_3 : PartialOrder R] [inst_4 : IsOrderedRing R] {M : Matrix n n R},
  M ∈ Matrix.colStochastic R n → ∀ (i : n), ∑ j, M j i = 1

Each column sum of a column stochastic matrix is 1.

theorem Matrix.one_vecMul_of_mem_colStochastic E1 #

∀ {R : Type u_1} {n : Type u_2} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : Semiring R]
  [inst_3 : PartialOrder R] [inst_4 : IsOrderedRing R] {M : Matrix n n R},
  M ∈ Matrix.colStochastic R n → Matrix.vecMul 1 M = 1

The all-ones column vector multiplied with a column stochastic matrix is 1.

theorem Matrix.le_one_of_mem_colStochastic E1 #

∀ {R : Type u_1} {n : Type u_2} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : Semiring R]
  [inst_3 : PartialOrder R] [inst_4 : IsOrderedRing R] {M : Matrix n n R},
  M ∈ Matrix.colStochastic R n → ∀ {i j : n}, M j i ≤ 1

Every entry of a column stochastic matrix is less than or equal to 1.

theorem Matrix.nonneg_mulVec_of_mem_colStochastic E1 #

∀ {R : Type u_1} {n : Type u_2} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : Semiring R]
  [inst_3 : PartialOrder R] [inst_4 : IsOrderedRing R] {M : Matrix n n R} {x : n → R},
  M ∈ Matrix.colStochastic R n → (∀ (i : n), 0 ≤ x i) → ∀ (j : n), 0 ≤ M.mulVec x j

Right multiplication of a column stochastic matrix by a non-negative vector gives a non-negative vector.

theorem Matrix.nonneg_vecMul_of_mem_colStochastic E1 #

∀ {R : Type u_1} {n : Type u_2} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : Semiring R]
  [inst_3 : PartialOrder R] [inst_4 : IsOrderedRing R] {M : Matrix n n R} {x : n → R},
  M ∈ Matrix.colStochastic R n → (∀ (i : n), 0 ≤ x i) → ∀ (j : n), 0 ≤ Matrix.vecMul x M j

Left multiplication of a column stochastic matrix by a non-negative vector gives a non-negative vector.

theorem Matrix.mulVec_dotProduct_one_eq_one_colStochastic E1 #

∀ {R : Type u_1} {n : Type u_2} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : Semiring R]
  [inst_3 : PartialOrder R] [inst_4 : IsOrderedRing R] {M : Matrix n n R} {x : n → R},
  M ∈ Matrix.colStochastic R n → 1 ⬝ᵥ x = 1 → 1 ⬝ᵥ M.mulVec x = 1

Left left-multiplication by column stochastic preserves ℓ₁ norm

theorem Matrix.sum_mulVec_of_mem_colStochastic E1 #

∀ {R : Type u_1} {n : Type u_2} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : Semiring R]
  [inst_3 : PartialOrder R] [inst_4 : IsOrderedRing R] {M : Matrix n n R} {x : n → R},
  M ∈ Matrix.colStochastic R n → ∑ i, M.mulVec x i = ∑ i, x i

Applying a column-stochastic matrix to a vector preserves its sum.

theorem Matrix.convex_colStochastic E1 #

∀ {R : Type u_1} {n : Type u_2} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : Semiring R]
  [inst_3 : PartialOrder R] [inst_4 : IsOrderedRing R], Convex R ↑(Matrix.colStochastic R n)

The set of column stochastic matrices is convex.

theorem Matrix.permMatrix_mem_colStochastic E0 #

∀ {R : Type u_1} {n : Type u_2} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : Semiring R]
  [inst_3 : PartialOrder R] [inst_4 : IsOrderedRing R] {σ : Equiv.Perm n},
  Equiv.Perm.permMatrix R σ ∈ Matrix.colStochastic R n

Any permutation matrix is column stochastic.

theorem Matrix.transpose_mem_rowStochastic_iff_mem_colStochastic E1 #

∀ {R : Type u_1} {n : Type u_2} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : Semiring R]
  [inst_3 : PartialOrder R] [inst_4 : IsOrderedRing R] {M : Matrix n n R},
  M.transpose ∈ Matrix.rowStochastic R n ↔ M ∈ Matrix.colStochastic R n

The transpose of a matrix is row stochastic matrix if it is column stochastic.

theorem Matrix.transpose_mem_colStochastic_iff_mem_rowStochastic E1 #

∀ {R : Type u_1} {n : Type u_2} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : Semiring R]
  [inst_3 : PartialOrder R] [inst_4 : IsOrderedRing R] {M : Matrix n n R},
  M.transpose ∈ Matrix.colStochastic R n ↔ M ∈ Matrix.rowStochastic R n

The transpose of a matrix is column stochastic matrix if it is row stochastic.

theorem Matrix.reindex_mem_rowStochastic E1 #

∀ {R : Type u_1} {n : Type u_2} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : Semiring R]
  [inst_3 : PartialOrder R] [inst_4 : IsOrderedRing R] {m : Type u_3} [inst_5 : Fintype m] [inst_6 : DecidableEq m]
  {M : Matrix n n R} {e₁ e₂ : n ≃ m}, M ∈ Matrix.rowStochastic R n → (Matrix.reindex e₁ e₂) M ∈ Matrix.rowStochastic R m

Reindexing a matrix preserves row-stochasticity.

theorem Matrix.reindex_mem_rowStochastic_iff E0 #

∀ {R : Type u_1} {n : Type u_2} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : Semiring R]
  [inst_3 : PartialOrder R] [inst_4 : IsOrderedRing R] {m : Type u_3} [inst_5 : Fintype m] [inst_6 : DecidableEq m]
  {M : Matrix n n R} {e₁ e₂ : n ≃ m}, (Matrix.reindex e₁ e₂) M ∈ Matrix.rowStochastic R m ↔ M ∈ Matrix.rowStochastic R n

Reindexing a matrix preserves row-stochasticity.

theorem Matrix.reindex_mem_colStochastic_iff E0 #

∀ {R : Type u_1} {n : Type u_2} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : Semiring R]
  [inst_3 : PartialOrder R] [inst_4 : IsOrderedRing R] {m : Type u_3} [inst_5 : Fintype m] [inst_6 : DecidableEq m]
  {M : Matrix n n R} {e₁ e₂ : n ≃ m}, (Matrix.reindex e₁ e₂) M ∈ Matrix.colStochastic R m ↔ M ∈ Matrix.colStochastic R n

Reindexing a matrix preserves column-stochasticity.

theorem Matrix.reindex_mem_colStochastic E1 #

∀ {R : Type u_1} {n : Type u_2} [inst : Fintype n] [inst_1 : DecidableEq n] [inst_2 : Semiring R]
  [inst_3 : PartialOrder R] [inst_4 : IsOrderedRing R] {m : Type u_3} [inst_5 : Fintype m] [inst_6 : DecidableEq m]
  {M : Matrix n n R} {e₁ e₂ : n ≃ m}, M ∈ Matrix.colStochastic R n → (Matrix.reindex e₁ e₂) M ∈ Matrix.colStochastic R m

Reindexing a matrix preserves column-stochasticity.