Documentation

Probability.Basic

def indicator (cond : Bool) :

Boolean indicator function

Equations
Instances For
    @[reducible, inline]
    abbrev 𝕀 :
    Bool
    Equations
    Instances For
      theorem ind_zero_one {τ : Type} {ω : τ} (cond : τBool) :
      (𝕀 cond) ω = 1 (𝕀 cond) ω = 0

      Indicator is 0 or 1

      @[reducible, inline]
      abbrev Prob (p : ) :

      states that p is a valid probability value

      Equations
      Instances For
        @[simp]
        theorem Prob.of_complement {p : } (hp : Prob p) :
        Prob (1 - p)
        @[simp]
        theorem Prob.complement_inv_nneg {p : } (hp : Prob p) :
        0 (1 - p)⁻¹
        theorem Prob.lower_bound_fst {p x y : } (hp : Prob p) (h : x y) :
        x p * x + (1 - p) * y
        theorem Prob.lower_bound_snd {p x y : } (hp : Prob p) (h : y x) :
        y p * x + (1 - p) * y
        theorem Prob.upper_bound_fst {p x y : } (hp : Prob p) (h : y x) :
        p * x + (1 - p) * y x
        theorem Prob.upper_bound_snd {p x y : } (hp : Prob p) (h : x y) :
        p * x + (1 - p) * y y
        def List.scale (L : List ) (c : ) :
        Equations
        Instances For
          @[simp]
          theorem List.scale_sum {L : List } {c : } :
          (L.scale c).sum = c * L.sum
          @[simp]
          theorem List.scale_length {L : List } {c : } :
          theorem List.scale_nneg_of_nneg {L : List } {c : } (h : lL, 0 l) (h1 : 0 c) (l : ) :
          l L.scale c0 l
          theorem List.append_nneg_of_nneg {L : List } {p : } (h : lL, 0 l) (h1 : 0 p) (l : ) :
          l p :: L0 l
          def List.grow (L : List ) (p : ) :

          adds a new probability to a list and renormalizes the rest -

          Equations
          Instances For
            theorem List.grow_sum {L : List } {p : } :
            (L.grow p).sum = L.sum * (1 - p) + p

            Removes head and rescales

            Equations
            Instances For
              @[simp]
              theorem List.shrink_sum {L : List } (npt : L []) (h : L.head npt < 1) :
              L.shrink.sum = L.tail.sum / (1 - L.head npt)
              theorem List.shrink_ge0 {L : List } (h1 : lL, Prob l) (l : ) :
              l L.shrink0 l
              structure LSimplex (L : List ) :

              Self-normalizing list of probabilities -

              Instances For
                @[simp]
                theorem LSimplex.nonempty {L : List } (S : LSimplex L) :

                cannot define a simplex on an empty set

                @[simp, reducible, inline]
                abbrev LSimplex.npt {L : List } :
                LSimplex LL []
                Equations
                • =
                Instances For
                  def LSimplex.phead {L : List } (h : LSimplex L) :
                  Equations
                  Instances For

                    all probability in the head element

                    Equations
                    Instances For
                      @[reducible]
                      Equations
                      Instances For
                        @[simp]
                        theorem LSimplex.mem_prob {L : List } (S : LSimplex L) (p : ) :
                        p LProb p
                        theorem LSimplex.phead_inpr {L : List } (S : LSimplex L) :
                        @[simp]
                        theorem LSimplex.phead_prob {L : List } (S : LSimplex L) :
                        theorem LSimplex.phead_supp {L : List } (S : LSimplex L) (supp : S.supported = true) :
                        S.phead < 1
                        theorem LSimplex.supported_head_lt_one {L : List } (S : LSimplex L) (supp : S.supported = true) :
                        L.head < 1
                        @[simp]
                        theorem LSimplex.List.grow_ge0 {p : } {L : List } (h1 : lL, 0 l) (h2 : Prob p) (l : ) :
                        l L.grow p0 l
                        @[simp]
                        theorem LSimplex.grow {L : List } (S : LSimplex L) {p : } (prob : Prob p) :
                        theorem LSimplex.false_of_p_comp1_zero_p_less_one {p : } (h1 : 1 - p = 0) (h2 : p < 1) :
                        @[simp]
                        theorem LSimplex.tail_sum {L : List } (S : LSimplex L) :
                        L.tail.sum = 1 - L.head
                        theorem LSimplex.degenerate_tail_zero {L : List } (S : LSimplex L) (degen : S.degenerate = true) (p : ) :
                        p L.tailp = 0
                        theorem LSimplex.shrink {L : List } (S : LSimplex L) (supp : S.supported = true) :
                        theorem LSimplex.grow_of_shrink {L : List } (S : LSimplex L) (supp : S.supported = true) :
                        S =
                        structure Findist (N : ) :

                        Finite probability distribution on a set-like list (non-duplicates)

                        Instances For
                          @[reducible, inline]
                          abbrev Findist.Delta :
                          Type
                          Equations
                          Instances For
                            @[reducible, inline]
                            abbrev Findist.Δ :
                            Type
                            Equations
                            Instances For
                              @[reducible, inline]
                              abbrev Findist.degenerate {N : } (F : Findist N) :
                              Equations
                              Instances For
                                @[reducible, inline]
                                abbrev Findist.supported {N : } (F : Findist N) :
                                Equations
                                Instances For
                                  @[simp]
                                  theorem Findist.nonempty {N : } (F : Findist N) :
                                  N 1
                                  @[simp]
                                  theorem Findist.nonempty_P {N : } (F : Findist N) :
                                  def Findist.grow {N : } (F : Findist N) {p : } (prob : Prob p) :
                                  Findist (N + 1)

                                  add a new head

                                  Equations
                                  Instances For
                                    def Findist.shrink {N : } (F : Findist N) (supp : F.supported = true) :
                                    Findist (N - 1)

                                    if nondegenenrate then construct a tail distribution

                                    Equations
                                    Instances For
                                      Equations
                                      Instances For
                                        @[reducible, inline]
                                        abbrev Findist.phead {N : } (F : Findist N) :
                                        Equations
                                        Instances For
                                          @[simp]
                                          theorem Findist.phead_inpr {N : } (F : Findist N) :
                                          @[simp]
                                          theorem Findist.phead_prob {N : } (F : Findist N) :
                                          theorem Findist.nondegenerate_head {N : } (F : Findist N) (supp : F.supported = true) :
                                          F.phead < 1
                                          theorem Findist.grow_shrink_type {N : } (F : Findist N) :
                                          F.supported = trueFindist (N - 1 + 1) = Findist N
                                          def Findist.growshrink {N : } (F : Findist N) (supp : F.supported = true) :
                                          Findist (N - 1 + 1)
                                          Equations
                                          Instances For
                                            theorem Findist.grow_of_shrink_2 {N : } (F : Findist N) (supp : F.supported = true) :
                                            F.growshrink supp = .mpr F
                                            structure Finprob :

                                            Finite probability space. See Finsample for the definition of the sample space.

                                            Instances For
                                              theorem List.unique_head_notin_tail {τ : Type} (L : List τ) (ne : L []) (nodup : L.Nodup) :
                                              L.head neL.tail
                                              Equations
                                              Instances For
                                                Equations
                                                Instances For
                                                  def Finprob.grow (P : Finprob) {p : } (prob : Prob p) :
                                                  Equations
                                                  Instances For
                                                    @[reducible, inline]

                                                    all probability in the head

                                                    Equations
                                                    Instances For
                                                      @[reducible, inline]
                                                      Equations
                                                      Instances For
                                                        Equations
                                                        Instances For
                                                          theorem Finprob.shrink_length (P : Finprob) (supp : P.supported = true) :
                                                          (P.shrink supp).length = P.length - 1
                                                          Equations
                                                          Instances For
                                                            Equations
                                                            Instances For
                                                              theorem Finprob.shrink_shorter (P : Finprob) (supp : P.supported = true) :
                                                              (P.shrink supp).length = P.length - 1
                                                              theorem Finprob.grow_of_shrink (P : Finprob) (supp : P.supported = true) :
                                                              P = (P.shrink supp).grow

                                                              Shows that growing an shrink probability will create the same probability space

                                                              @[irreducible]
                                                              def Finprob.induction {motive : FinprobProp} (degenerate : ∀ {fp : Finprob}, fp.degenerate = truemotive fp) (composite : ∀ (tail : Finprob) {p : } (inP : Prob p), motive tailmotive (tail.grow inP)) (P : Finprob) :
                                                              motive P

                                                              induction principle for finite probabilities. Works as "induction P"

                                                              Equations
                                                              • =
                                                              Instances For
                                                                def FinRV (ρ : Type) :

                                                                Random variable defined on a finite probability space (bijection to ℕ)

                                                                Equations
                                                                Instances For
                                                                  Equations
                                                                  Instances For
                                                                    Equations
                                                                    Instances For
                                                                      Equations
                                                                      Instances For
                                                                        def FinRV.eq {η : Type} [DecidableEq η] (Y : FinRV η) (y : η) :
                                                                        Equations
                                                                        Instances For
                                                                          def FinRV.leq {η : Type} [LE η] [DecidableLE η] (Y : FinRV η) (y : η) :
                                                                          Equations
                                                                          Instances For
                                                                            theorem FinRV.le_of_le_eq (D : FinRV ) (n : ) :

                                                                            Shows equivalence when extending the random variable to another element.

                                                                            def List.iprodb ( : List ) (B : FinRV Bool) :

                                                                            Probability of a random variable. Does not enforce normalization

                                                                            Equations
                                                                            Instances For
                                                                              theorem List.scale_innerprod (B : FinRV Bool) (L : List ) (x : ) :
                                                                              (L.scale x).iprodb B = x * L.iprodb B
                                                                              theorem List.decompose_supp (B : FinRV Bool) (L : List ) (h : L []) (ne1 : L.head h 1) :
                                                                              L.iprodb B = Bool.rec 0 (L.head h) (B (L.length - 1)) + (1 - L.head h) * L.shrink.iprodb B
                                                                              theorem List.iprod_eq_zero_of_zeros (B : FinRV Bool) (L : List ) (hz : pL, p = 0) :
                                                                              L.iprodb B = 0
                                                                              theorem List.iprod_first_of_tail_zero (B : FinRV Bool) (L : List ) (hn : L []) (hz : pL.tail, p = 0) :
                                                                              L.iprodb B = Bool.rec 0 (L.head hn) (B L.tail.length)
                                                                              theorem List.iprodb_true_sum (L : List ) :
                                                                              (L.iprodb fun (x : ) => true) = L.sum
                                                                              def probability (P : Finprob) (B : FinRV Bool) :

                                                                              Probability of B

                                                                              Equations
                                                                              Instances For
                                                                                Equations
                                                                                • One or more equations did not get rendered due to their size.
                                                                                Instances For
                                                                                  def probability_cnd (P : Finprob) (B C : FinRV Bool) :

                                                                                  Conditional probability of B

                                                                                  Equations
                                                                                  Instances For
                                                                                    theorem Finprob.decompose_supp (P : Finprob) (B : FinRV Bool) (supp : P.supported = true) :
                                                                                    ℙ[B//P] = Bool.rec 0 P.phead (B P.ωhead) + (1 - P.phead) * ℙ[B//P.shrink supp]

                                                                                    If supported then can be decomposed to the immediate probability and the remaining probability

                                                                                    @[irreducible]
                                                                                    theorem Finprob.in_prob (B : FinRV Bool) (P : Finprob) :
                                                                                    theorem Prob.ge_zero (P : Finprob) (B : FinRV Bool) :
                                                                                    theorem Prob.le_one (P : Finprob) (B : FinRV Bool) :
                                                                                    theorem Prob.true_one (P : Finprob) :
                                                                                    ℙ[fun (x : ) => true//P] = 1
                                                                                    Equations
                                                                                    • One or more equations did not get rendered due to their size.
                                                                                    Instances For
                                                                                      def List.iprod ( : List ) (X : FinRV ) :
                                                                                      Equations
                                                                                      Instances For
                                                                                        def expect (P : Finprob) (X : FinRV ) :
                                                                                        Equations
                                                                                        Instances For
                                                                                          Equations
                                                                                          • One or more equations did not get rendered due to their size.
                                                                                          Instances For
                                                                                            Equations
                                                                                            • One or more equations did not get rendered due to their size.
                                                                                            Instances For
                                                                                              def expect_cnd (P : Finprob) (X : FinRV ) (B : FinRV Bool) :
                                                                                              Equations
                                                                                              Instances For
                                                                                                Equations
                                                                                                • One or more equations did not get rendered due to their size.
                                                                                                Instances For
                                                                                                  Equations
                                                                                                  • One or more equations did not get rendered due to their size.
                                                                                                  Instances For
                                                                                                    Equations
                                                                                                    • One or more equations did not get rendered due to their size.
                                                                                                    Instances For
                                                                                                      theorem List.law_of_total_expectations (L : List ) (X : FinRV ) (B : FinRV Bool) :
                                                                                                      L.iprod X = (L.iprod fun (ω : ) => if B ω = true then X ω else 0) + L.iprod fun (ω : ) => if ¬B ω = true then X ω else 0

                                                                                                      Represents the generator of the sample space of a Finprob. Each element is mapped to a single generator. Note that different Finsample definitions may induce equivalent sample spaces. Also there is no guarantee that there will not be a generator with zero probability.

                                                                                                      Equations
                                                                                                      Instances For
                                                                                                        instance instCoeOutSampleMapFinRVFin {P : Finprob} {m : } :
                                                                                                        Equations
                                                                                                        def FinRV.MeasurableRV {ρ : Type} {P : Finprob} {m : } (X Y : FinRV ρ) ( : P.SampleMap m) :

                                                                                                        Defines that the random variable X is measurable with respect to a map and a reduced random variable Y #

                                                                                                        Equations
                                                                                                        Instances For

                                                                                                          Defines the aggregated probability in the compacted space -

                                                                                                          Equations
                                                                                                          Instances For