Documentation

ClassicalInfo.Prob

Probabilities #

This defines a type Prob, which is simply any real number in the interval O to 1. This then comes with additional statements such as its application to convex sets, and it makes useful type alias for functions that only make sense on probabilities.

A significant application is in the Mixable typeclass, also in this file, which is a general notion of convex combination that applies to types as opposed to sets; elements are Mixable.mixed using Probs.

@[reducible]
def Prob :

Prob is a real number in the interval [0,1]. Similar to NNReal in many definitions, but this allows other nice things more 'safely' such as convex combination.

Equations
Instances For
    Equations
    Equations
    Equations
    @[simp]
    theorem Prob.val_zero :
    0 = 0
    @[simp]
    theorem Prob.val_one :
    1 = 1
    @[simp]
    theorem Prob.val_mul (x y : Prob) :
    ↑(x * y) = x * y
    @[simp]
    theorem Prob.val_inf (x y : Prob) :
    ↑(x y) = x y
    @[simp]
    theorem Prob.val_sup (x y : Prob) :
    ↑(x y) = x y
    Equations
    • One or more equations did not get rendered due to their size.
    Equations

    Coercion Prob → ℝ.

    Equations
    Instances For
      @[simp]
      theorem Prob.zero_le_coe {p : Prob} :
      0 p
      @[simp]
      theorem Prob.coe_le_one {p : Prob} :
      p 1
      @[simp]
      theorem Prob.zero_le {p : Prob} :
      0 p
      @[simp]
      theorem Prob.le_one {p : Prob} :
      p 1
      @[simp]
      theorem Prob.val_eq_coe (n : Prob) :
      n = n
      instance Prob.canLift :
      CanLift Prob toReal fun (r : ) => 0 r r 1
      theorem Prob.eq {n m : Prob} :
      n = mn = m
      theorem Prob.ne_iff {x y : Prob} :
      x y x y
      @[simp]
      theorem Prob.toReal_mk {x : } {hx : 0 x x 1} :
      x, hx = x
      @[simp]
      theorem Prob.toReal_zero :
      0 = 0
      @[simp]
      theorem Prob.toReal_one :
      1 = 1
      @[simp]
      theorem Prob.toReal_mul (x y : Prob) :
      ↑(x * y) = x * y

      Coercion Prob → ℝ≥0.

      Equations
      • p = p,
      Instances For
        @[simp]
        theorem Prob.toNNReal_mk {x : } {hx : 0 x x 1} :
        x, hx = x,
        theorem Prob.eq_iff_nnreal (n m : Prob) :
        n = m n = m
        @[simp]
        theorem Prob.toNNReal_zero :
        0 = 0
        @[simp]
        theorem Prob.toNNReal_one :
        1 = 1
        def Prob.NNReal.asProb (p : NNReal) (hp : p 1) :
        Equations
        Instances For
          def Prob.NNReal.asProb' (p : NNReal) (hp : p 1) :
          Equations
          Instances For
            Equations
            Instances For
              @[simp]
              theorem Prob.val_one_minus (p : Prob) :
              p.one_minus = 1 - p
              @[simp]
              theorem Prob.coe_one_minus (p : Prob) :
              p.one_minus = 1 - p
              @[simp]
              theorem Prob.add_one_minus (p : Prob) :
              p + p.one_minus = 1
              class Mixable (U : outParam (Type u)) (T : Type v) [AddCommMonoid U] [Module U] :
              Type (max u v)

              A Mixable T typeclass instance gives a compact way of talking about the action of probabilities for forming linear combinations in convex spaces. The notation p [ x₁ ↔ x₂ ] means to take a convex combination, equal to x₁ if p=1 and to x₂ if p=0.

              Mixable is defined by an "underlying" data type U with addition and scalar multiplication, and a bijection between the T and a convex set of U. For instance, in Mixable (Distribution (Fin n)), U is n-element vectors (which form the probability simplex, degenerate in one dimension). For QuantumInfo.Finite.MState density matrices in quantum mechanics, which are PSD matrices of trace 1, U is the underlying matrix.

              Why not just stick with existing notions of Convex? Convex requires that the type already forms an AddCommMonoid and Module. But many types, such as Distribution, are not: there is no good notion of "multiplying a probability distribution by 0.3" to get another distribution. We can coerce the distribution into, say, a vector or a function, but then we are not doing arithmetic with distributions. Accordingly, the expression 0.3 * distA + 0.7 * distB cannot represent a distribution on its own.

              • to_U : TU

                Getter for the underlying data

              • to_U_inj {T₁ T₂ : T} : to_U T₁ = to_U T₂T₁ = T₂

                Proof that this getter is injective

              • Proof that this image is convex

              • mkT {u : U} : (∃ (t : T), to_U t = u){ t : T // to_U t = u }

                Function to get a T from a proof that U is in the set.

              Instances
                @[reducible]
                def Mixable.mix_ab {T : Type u_1} {U : Type u_2} [AddCommMonoid U] [Module U] [inst : Mixable U T] {a b : } (ha : 0 a) (hb : 0 b) (hab : a + b = 1) (x₁ x₂ : T) :
                T
                Equations
                Instances For
                  def Mixable.mix {T : Type u_1} {U : Type u_2} [AddCommMonoid U] [Module U] [inst : Mixable U T] (p : Prob) (x₁ x₂ : T) :
                  T

                  Mixable.mix represents the notion of "convex combination" on the type T, afforded by the Mixable instance. It takes a Prob, that is, a Real between 0 and 1. For working directly with a Real, use mix_ab.

                  Equations
                  Instances For
                    @[simp]
                    theorem Mixable.to_U_of_mkT {T : Type u_1} {U : Type u_2} [AddCommMonoid U] [Module U] [inst : Mixable U T] (u : U) {h : ∃ (t : T), to_U t = u} :
                    to_U (mkT h) = u
                    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
                        @[simp]
                        theorem Mixable.mix_zero {T : Type u_1} {U : Type u_2} [AddCommMonoid U] [Module U] [inst : Mixable U T] (x₁ x₂ : T) :
                        0[x₁x₂] = x₂
                        instance Mixable.instUniv {T : Type u_1} [AddCommMonoid T] [Module T] :

                        When T is the whole space, and T is a suitable vector space over ℝ, we get a Mixable instance.

                        Equations
                        • Mixable.instUniv = { to_U := id, to_U_inj := , convex := , mkT := fun {u : T} (x : ∃ (t : T), id t = u) => u, }
                        @[simp]
                        theorem Mixable.mkT_instUniv {T : Type u_1} [AddCommMonoid T] [Module T] {t : T} (h : ∃ (t' : T), to_U t' = t) :
                        mkT h = t,
                        @[simp]
                        theorem Mixable.to_U_instUniv {T : Type u_1} [AddCommMonoid T] [Module T] {t : T} :
                        to_U t = t
                        instance Mixable.instPi {D : Type u_3} {T : DType u_4} {U : DType u_5} [(i : D) → AddCommMonoid (U i)] [(i : D) → Module (U i)] [inst : (i : D) → Mixable (U i) (T i)] :
                        Mixable ((i : D) → U i) ((i : D) → T i)

                        Mixable instance on Pi types.

                        Equations
                        • One or more equations did not get rendered due to their size.
                        @[simp]
                        theorem Mixable.val_mkT_instPi {T : Type u_1} {U : Type u_2} [AddCommMonoid U] [Module U] (D : Type u_3) [inst : Mixable U T] {u : DU} (h : ∃ (t : DT), to_U t = u) :
                        (mkT h) = fun (d : D) => (mkT )
                        @[simp]
                        theorem Mixable.to_U_instPi {T : Type u_1} {U : Type u_2} [AddCommMonoid U] [Module U] (D : Type u_3) [inst : Mixable U T] {t : DT} :
                        to_U t = fun (d : D) => to_U (t d)
                        def Mixable.instSubtype {U : Type u_2} [AddCommMonoid U] [Module U] {T : Type u_3} {P : TProp} (inst : Mixable U T) (h : ∀ {x y : T} ⦃a b : ⦄ (ha : 0 a) (hb : 0 b) (hab : a + b = 1), P xP yP (mix_ab ha hb hab x y)) :
                        Mixable U { t : T // P t }

                        Mixable instances on subtypes (of other mixable types), assuming that they have the correct closure properties.

                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For

                          Probabilities Prob themselves are convex.

                          Equations
                          @[simp]
                          theorem Prob.to_U_mixable {T : Type u_1} [AddCommMonoid T] [SMul T] (t : Prob) :
                          @[simp]
                          theorem Prob.mkT_mixable (u : ) (h : ∃ (t : Prob), Mixable.to_U t = u) :
                          Mixable.mkT h = u, ,
                          @[reducible, inline]
                          abbrev Prob.mix {U : Type u_1} {T : Type u_2} [AddCommMonoid U] [Module U] [inst : Mixable U T] (p : Prob) (x₁ x₂ : T) :
                          T

                          Prob.mix is an alias of Mixable.mix so it can be accessed from a probability with dot notation, e.g. p.mix x y.

                          Equations
                          Instances For