Documentation

LeanPool.FullyDynamicMatching.FD1D.Markov

Markov #

Finite inventory Markov chains #

This file uses elementary finite sums throughout. A FiniteKernel is a row-stochastic matrix, and FiniteLaw.step is left multiplication by that matrix. The inventory chain near the end of the file removes one item and then adds an independent uniformly distributed item.

Finite laws and stochastic kernels #

theorem FD1D.FiniteLaw.ext {α : Type u_1} [Fintype α] {μ ν : FiniteLaw α} (h : ∀ (x : α), μ.mass x = ν.mass x) :
μ = ν
theorem FD1D.FiniteLaw.ext_iff {α : Type u_1} [Fintype α] {μ ν : FiniteLaw α} :
μ = ν ↔ ∀ (x : α), μ.mass x = ν.mass x
def FD1D.FiniteLaw.dirac {α : Type u_1} [Fintype α] [DecidableEq α] (x : α) :

The point mass at x.

Equations
Instances For
    @[simp]
    theorem FD1D.FiniteLaw.mass_dirac {α : Type u_1} [Fintype α] [DecidableEq α] (x y : α) :
    (dirac x).mass y = if y = x then 1 else 0
    noncomputable def FD1D.FiniteLaw.uniform {α : Type u_1} [Fintype α] [Nonempty α] :

    The uniform law on a nonempty finite type.

    Equations
    Instances For
      @[simp]
      theorem FD1D.FiniteLaw.mass_uniform {α : Type u_1} [Fintype α] [Nonempty α] (x : α) :
      def FD1D.FiniteLaw.map {α : Type u_1} {β : Type u_2} [Fintype α] [Fintype β] [DecidableEq β] (f : α → β) (μ : FiniteLaw α) :

      Push a finite law forward along a map.

      Equations
      Instances For
        @[simp]
        theorem FD1D.FiniteLaw.mass_map {α : Type u_1} {β : Type u_2} [Fintype α] [Fintype β] [DecidableEq β] (f : α → β) (μ : FiniteLaw α) (y : β) :
        (map f μ).mass y = ∑ x : α with f x = y, μ.mass x
        structure FD1D.FiniteKernel (α : Type u_1) [Fintype α] :
        Type u_1

        A stochastic kernel on a finite state space.

        • trans : α → α → ℝ

          One-step transition probability from the first state to the second.

        • trans_nonneg (x y : α) : 0 ≤ self.trans x y
        • sum_trans (x : α) : ∑ y : α, self.trans x y = 1
        Instances For
          def FD1D.FiniteKernel.matrix {α : Type u_1} [Fintype α] (K : FiniteKernel α) :
          Matrix α α ℝ

          The row-stochastic matrix of a finite kernel.

          Equations
          Instances For
            def FD1D.FiniteKernel.step {α : Type u_1} [Fintype α] (K : FiniteKernel α) (μ : FiniteLaw α) :

            Advance a law by one step of the kernel.

            Equations
            • K.step μ = { mass := fun (y : α) => ∑ x : α, μ.mass x * K.trans x y, mass_nonneg := ⋯, sum_mass := ⋯ }
            Instances For
              @[simp]
              theorem FD1D.FiniteKernel.mass_step {α : Type u_1} [Fintype α] (K : FiniteKernel α) (μ : FiniteLaw α) (y : α) :
              (K.step μ).mass y = ∑ x : α, μ.mass x * K.trans x y
              def FD1D.FiniteKernel.iterate {α : Type u_1} [Fintype α] (K : FiniteKernel α) :
              ℕ → FiniteLaw α → FiniteLaw α

              The law after n steps.

              Equations
              Instances For
                @[simp]
                theorem FD1D.FiniteKernel.iterate_zero {α : Type u_1} [Fintype α] (K : FiniteKernel α) (μ : FiniteLaw α) :
                K.iterate 0 μ = μ
                @[simp]
                theorem FD1D.FiniteKernel.iterate_succ {α : Type u_1} [Fintype α] (K : FiniteKernel α) (n : ℕ) (μ : FiniteLaw α) :
                K.iterate (n + 1) μ = K.step (K.iterate n μ)
                theorem FD1D.FiniteKernel.iterate_add {α : Type u_1} [Fintype α] (K : FiniteKernel α) (m n : ℕ) (μ : FiniteLaw α) :
                K.iterate (m + n) μ = K.iterate m (K.iterate n μ)
                def FD1D.FiniteKernel.pow {α : Type u_1} [Fintype α] [DecidableEq α] (K : FiniteKernel α) (n : ℕ) (x y : α) :

                The n-step transition probability.

                Equations
                Instances For
                  @[simp]
                  theorem FD1D.FiniteKernel.pow_zero {α : Type u_1} [Fintype α] [DecidableEq α] (K : FiniteKernel α) (x y : α) :
                  K.pow 0 x y = if x = y then 1 else 0
                  @[simp]
                  theorem FD1D.FiniteKernel.pow_one {α : Type u_1} [Fintype α] [DecidableEq α] (K : FiniteKernel α) (x y : α) :
                  K.pow 1 x y = K.trans x y
                  theorem FD1D.FiniteKernel.pow_nonneg {α : Type u_1} [Fintype α] [DecidableEq α] (K : FiniteKernel α) (n : ℕ) (x y : α) :
                  0 ≤ K.pow n x y
                  theorem FD1D.FiniteKernel.sum_pow {α : Type u_1} [Fintype α] [DecidableEq α] (K : FiniteKernel α) (n : ℕ) (x : α) :
                  ∑ y : α, K.pow n x y = 1
                  theorem FD1D.FiniteKernel.pow_add {α : Type u_1} [Fintype α] [DecidableEq α] (K : FiniteKernel α) (m n : ℕ) (x z : α) :
                  K.pow (m + n) x z = ∑ y : α, K.pow m x y * K.pow n y z
                  theorem FD1D.FiniteKernel.mass_iterate {α : Type u_1} [Fintype α] [DecidableEq α] (K : FiniteKernel α) (n : ℕ) (μ : FiniteLaw α) (y : α) :
                  (K.iterate n μ).mass y = ∑ x : α, μ.mass x * K.pow n x y
                  theorem FD1D.FiniteKernel.iterate_dirac {α : Type u_1} [Fintype α] [DecidableEq α] (K : FiniteKernel α) (n : ℕ) (x y : α) :
                  (K.iterate n (FiniteLaw.dirac x)).mass y = K.pow n x y
                  def FD1D.FiniteKernel.IsStationary {α : Type u_1} [Fintype α] (K : FiniteKernel α) (μ : FiniteLaw α) :

                  A law is stationary when one step leaves it unchanged.

                  Equations
                  Instances For
                    theorem FD1D.FiniteKernel.IsStationary.iterate {α : Type u_1} [Fintype α] {K : FiniteKernel α} {μ : FiniteLaw α} (h : K.IsStationary μ) (n : ℕ) :
                    K.iterate n μ = μ

                    Existence of a stationary law #

                    def FD1D.FiniteKernel.orbit {α : Type u_1} [Fintype α] [DecidableEq α] (K : FiniteKernel α) (μ : FiniteLaw α) (n : ℕ) :
                    α → ℝ

                    The mass vector after n steps, written as a matrix product.

                    Equations
                    Instances For
                      theorem FD1D.FiniteKernel.orbit_eq_iterate {α : Type u_1} [Fintype α] [DecidableEq α] (K : FiniteKernel α) (μ : FiniteLaw α) (n : ℕ) (x : α) :
                      K.orbit μ n x = (K.iterate n μ).mass x
                      theorem FD1D.FiniteKernel.orbit_nonneg {α : Type u_1} [Fintype α] [DecidableEq α] (K : FiniteKernel α) (μ : FiniteLaw α) (n : ℕ) (x : α) :
                      0 ≤ K.orbit μ n x
                      theorem FD1D.FiniteKernel.orbit_le_one {α : Type u_1} [Fintype α] [DecidableEq α] (K : FiniteKernel α) (μ : FiniteLaw α) (n : ℕ) (x : α) :
                      K.orbit μ n x ≤ 1
                      theorem FD1D.FiniteKernel.sum_orbit {α : Type u_1} [Fintype α] [DecidableEq α] (K : FiniteKernel α) (μ : FiniteLaw α) (n : ℕ) :
                      ∑ x : α, K.orbit μ n x = 1
                      theorem FD1D.FiniteKernel.orbit_succ {α : Type u_1} [Fintype α] [DecidableEq α] (K : FiniteKernel α) (μ : FiniteLaw α) (n : ℕ) :
                      K.orbit μ (n + 1) = Matrix.vecMul (K.orbit μ n) K.matrix
                      noncomputable def FD1D.FiniteKernel.cesaroVec {α : Type u_1} [Fintype α] [DecidableEq α] (K : FiniteKernel α) (μ : FiniteLaw α) (n : ℕ) :
                      α → ℝ

                      The average of the first n+1 orbit vectors.

                      Equations
                      Instances For
                        noncomputable def FD1D.FiniteKernel.cesaroLaw {α : Type u_1} [Fintype α] [DecidableEq α] (K : FiniteKernel α) (μ : FiniteLaw α) (n : ℕ) :

                        Cesaro averages remain probability laws.

                        Equations
                        Instances For
                          theorem FD1D.FiniteKernel.cesaro_step_sub {α : Type u_1} [Fintype α] [DecidableEq α] (K : FiniteKernel α) (μ : FiniteLaw α) (n : ℕ) :
                          Matrix.vecMul (K.cesaroVec μ n) K.matrix - K.cesaroVec μ n = (↑(n + 1))⁻¹ • (K.orbit μ (n + 1) - K.orbit μ 0)

                          The one-step error of a Cesaro average is its final endpoint minus its initial endpoint, divided by the averaging length.

                          theorem FD1D.FiniteKernel.exists_stationary {α : Type u_1} [Fintype α] [Nonempty α] (K : FiniteKernel α) :
                          ∃ (μ : FiniteLaw α), K.IsStationary μ

                          Every finite stochastic kernel on a nonempty state space has a stationary law. The proof takes a convergent subsequence of Cesaro averages in the compact finite probability simplex.

                          def FD1D.FiniteKernel.Reaches {α : Type u_1} [Fintype α] [DecidableEq α] (K : FiniteKernel α) (x y : α) :

                          Reachability by a positive-probability path.

                          Equations
                          Instances For

                            Every state can be reached from every other state.

                            Equations
                            Instances For
                              theorem FD1D.FiniteKernel.reaches_refl {α : Type u_1} [Fintype α] [DecidableEq α] (K : FiniteKernel α) (x : α) :
                              K.Reaches x x
                              theorem FD1D.FiniteKernel.reaches_of_pos {α : Type u_1} [Fintype α] [DecidableEq α] (K : FiniteKernel α) {x y : α} (h : 0 < K.trans x y) :
                              K.Reaches x y
                              theorem FD1D.FiniteKernel.reaches_trans {α : Type u_1} [Fintype α] [DecidableEq α] (K : FiniteKernel α) {x y z : α} (hxy : K.Reaches x y) (hyz : K.Reaches y z) :
                              K.Reaches x z
                              theorem FD1D.FiniteKernel.stationary_mass_pos {α : Type u_1} [Fintype α] [DecidableEq α] {K : FiniteKernel α} (hirr : K.Irreducible) {μ : FiniteLaw α} (hμ : K.IsStationary μ) (y : α) :
                              0 < μ.mass y

                              Every state has positive mass under a stationary law of an irreducible finite kernel.

                              theorem FD1D.FiniteKernel.stationary_unique {α : Type u_1} [Fintype α] [DecidableEq α] [Nonempty α] {K : FiniteKernel α} (hirr : K.Irreducible) {μ ν : FiniteLaw α} (hμ : K.IsStationary μ) (hν : K.IsStationary ν) :
                              μ = ν

                              An irreducible finite kernel has at most one stationary law.

                              Strictly positive one-step self-loops.

                              Equations
                              Instances For

                                Equivariance and invariant laws #

                                def FD1D.FiniteKernel.Equivariant {α : Type u_1} [Fintype α] (K : FiniteKernel α) (e : Equiv.Perm α) :

                                Equivariance of a kernel under a permutation of its state space.

                                Equations
                                Instances For
                                  def FD1D.FiniteKernel.LawInvariant {α : Type u_1} [Fintype α] (μ : FiniteLaw α) (e : Equiv.Perm α) :

                                  Invariance of a law under a permutation of its state space.

                                  Equations
                                  Instances For
                                    theorem FD1D.FiniteKernel.step_lawInvariant {α : Type u_1} [Fintype α] {K : FiniteKernel α} {μ : FiniteLaw α} {e : Equiv.Perm α} (hK : K.Equivariant e) (hμ : LawInvariant μ e) :
                                    theorem FD1D.FiniteKernel.iterate_lawInvariant {α : Type u_1} [Fintype α] {K : FiniteKernel α} {μ : FiniteLaw α} {e : Equiv.Perm α} (hK : K.Equivariant e) (hμ : LawInvariant μ e) (n : ℕ) :
                                    def FD1D.FiniteKernel.GroupInvariant {α : Type u_1} [Fintype α] {G : Type u_3} [Group G] (ρ : G →* Equiv.Perm α) (μ : FiniteLaw α) :

                                    A finite group action preserves a law.

                                    Equations
                                    Instances For
                                      def FD1D.FiniteKernel.GroupEquivariant {α : Type u_1} [Fintype α] {G : Type u_3} [Group G] (ρ : G →* Equiv.Perm α) (K : FiniteKernel α) :

                                      A finite kernel is equivariant for a group action.

                                      Equations
                                      Instances For
                                        theorem FD1D.FiniteKernel.step_groupInvariant {α : Type u_1} [Fintype α] {G : Type u_3} [Group G] (ρ : G →* Equiv.Perm α) {K : FiniteKernel α} {μ : FiniteLaw α} (hK : GroupEquivariant ρ K) (hμ : GroupInvariant ρ μ) :
                                        theorem FD1D.FiniteKernel.iterate_groupInvariant {α : Type u_1} [Fintype α] {G : Type u_3} [Group G] (ρ : G →* Equiv.Perm α) {K : FiniteKernel α} {μ : FiniteLaw α} (hK : GroupEquivariant ρ K) (hμ : GroupInvariant ρ μ) (n : ℕ) :
                                        theorem FD1D.FiniteKernel.cesaroLaw_groupInvariant {α : Type u_1} [Fintype α] [DecidableEq α] {G : Type u_3} [Group G] (ρ : G →* Equiv.Perm α) {K : FiniteKernel α} {μ : FiniteLaw α} (hK : GroupEquivariant ρ K) (hμ : GroupInvariant ρ μ) (n : ℕ) :
                                        theorem FD1D.FiniteKernel.exists_stationary_groupInvariant {α : Type u_1} [Fintype α] [Nonempty α] {G : Type u_3} [Group G] (ρ : G →* Equiv.Perm α) (K : FiniteKernel α) (hK : GroupEquivariant ρ K) :
                                        ∃ (μ : FiniteLaw α), K.IsStationary μ ∧ GroupInvariant ρ μ

                                        A finite equivariant Markov kernel has a stationary law invariant under the entire finite group action.

                                        Inventory vectors and delete/arrive dynamics #

                                        @[reducible, inline]
                                        abbrev FD1D.InventoryState (ι : Type u_1) [Fintype ι] (m : ℕ) :
                                        Type u_1

                                        Leaf-count vectors with fixed total inventory m.

                                        Equations
                                        Instances For
                                          theorem FD1D.InventoryState.ext {ι : Type u_1} [Fintype ι] {m : ℕ} {x y : InventoryState ι m} (h : ∀ (i : ι), ↑x i = ↑y i) :
                                          x = y
                                          theorem FD1D.InventoryState.ext_iff {ι : Type u_1} [Fintype ι] {m : ℕ} {x y : InventoryState ι m} :
                                          x = y ↔ ∀ (i : ι), ↑x i = ↑y i
                                          @[instance_reducible]
                                          noncomputable instance FD1D.InventoryState.instFintype {ι : Type u_1} [Fintype ι] [DecidableEq ι] (m : ℕ) :
                                          Equations
                                          @[instance_reducible]
                                          noncomputable instance FD1D.InventoryState.instDecidableEq {ι : Type u_1} [Fintype ι] (m : ℕ) :
                                          Equations
                                          def FD1D.InventoryState.move {ι : Type u_1} [Fintype ι] [DecidableEq ι] {m : ℕ} (x : InventoryState ι m) (d a : ι) :

                                          The count vector after deleting at d and arriving at a. If d is empty, this is defined to be the original state.

                                          Equations
                                          Instances For
                                            @[simp]
                                            theorem FD1D.InventoryState.move_empty {ι : Type u_1} [Fintype ι] [DecidableEq ι] {m : ℕ} (x : InventoryState ι m) {d a : ι} (hd : ↑x d = 0) :
                                            x.move d a = x
                                            @[simp]
                                            theorem FD1D.InventoryState.move_self {ι : Type u_1} [Fintype ι] [DecidableEq ι] {m : ℕ} (x : InventoryState ι m) (d : ι) :
                                            x.move d d = x
                                            theorem FD1D.InventoryState.move_apply_of_pos {ι : Type u_1} [Fintype ι] [DecidableEq ι] {m : ℕ} (x : InventoryState ι m) {d a i : ι} (hd : 0 < ↑x d) :
                                            ↑(x.move d a) i = (↑x i + if i = a then 1 else 0) - if i = d then 1 else 0
                                            structure FD1D.DeletionRule (ι : Type u_1) [Fintype ι] (m : ℕ) :
                                            Type u_1

                                            A deletion rule chooses an occupied leaf, assigning every occupied leaf strictly positive probability.

                                            Instances For
                                              noncomputable def FD1D.DeletionRule.kernel {ι : Type u_1} [Fintype ι] [DecidableEq ι] [Nonempty ι] {m : ℕ} (R : DeletionRule ι m) :

                                              Transition probability: delete according to R, then independently arrive at a uniformly chosen leaf.

                                              Equations
                                              Instances For
                                                @[simp]
                                                theorem FD1D.DeletionRule.kernel_apply {ι : Type u_1} [Fintype ι] [DecidableEq ι] [Nonempty ι] {m : ℕ} (R : DeletionRule ι m) (x y : InventoryState ι m) :
                                                R.kernel.trans x y = ∑ d : ι, ∑ a : ι, if x.move d a = y then R.prob x d * (1 / ↑(Fintype.card ι)) else 0
                                                theorem FD1D.DeletionRule.kernel_move_pos {ι : Type u_1} [Fintype ι] [DecidableEq ι] [Nonempty ι] {m : ℕ} (R : DeletionRule ι m) (x : InventoryState ι m) {d a : ι} (hd : 0 < ↑x d) :
                                                0 < R.kernel.trans x (x.move d a)

                                                Every legal delete/arrive move has positive one-step probability.

                                                theorem FD1D.DeletionRule.one_div_card_le_kernel_self {ι : Type u_1} [Fintype ι] [DecidableEq ι] [Nonempty ι] {m : ℕ} (R : DeletionRule ι m) (x : InventoryState ι m) :
                                                1 / ↑(Fintype.card ι) ≤ R.kernel.trans x x

                                                The self-loop probability is at least the uniform arrival mass.

                                                theorem FD1D.DeletionRule.kernel_expectation_eq_delete_arrive {ι : Type u_1} [Fintype ι] [DecidableEq ι] [Nonempty ι] {m : ℕ} (R : DeletionRule ι m) (x : InventoryState ι m) (f : InventoryState ι m → ℝ) :
                                                ∑ y : InventoryState ι m, R.kernel.trans x y * f y = ∑ deleted : ι, ∑ arrived : ι, R.prob x deleted * (1 / ↑(Fintype.card ι)) * f (x.move deleted arrived)

                                                Integrating against a deletion kernel amounts to summing over its two moves.