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
    instance Prob.canLift :
    CanLift Prob Subtype.val fun (r : ) => 0 r r 1
    Equations
    @[simp]
    theorem Prob.coe_zero :
    0 = 0
    @[simp]
    theorem Prob.coe_one :
    1 = 1
    @[simp]
    theorem Prob.coe_mul (x y : Prob) :
    ↑(x * y) = x * y
    @[simp]
    theorem Prob.coe_inf (x y : Prob) :
    (min x y) = min x y
    @[simp]
    theorem Prob.coe_sup (x y : Prob) :
    (max x y) = max x y
    Equations
    • One or more equations did not get rendered due to their size.
    Equations
    • One or more equations did not get rendered due to their size.
    @[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
    theorem Prob.eq {n m : Prob} :
    n = mn = m
    theorem Prob.eq_iff {n m : Prob} :
    n = m n = m
    theorem Prob.ne_iff {x y : Prob} :
    x y x y
    @[simp]
    theorem Prob.toReal_mul (x y : Prob) :
    ↑(x * y) = x * y

    Coercion Prob → ℝ≥0.

    Equations
    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
          theorem Prob.zero_lt_coe {p : Prob} (hp : p 0) :
          0 < p

          Subtract a probability from another. Truncates to zero, so this is often not great to work with, for the same reason that Nat subtraction is a pain. But, it lets you write 1 - p, which is sufficiently useful on its own that this seems worth having.

          Equations
          theorem Prob.coe_sub (p q : Prob) :
          ↑(p - q) = max (p - q) 0
          @[simp]
          theorem Prob.coe_one_minus (p : Prob) :
          ↑(1 - p) = 1 - p
          theorem Prob.add_one_minus (p : Prob) :
          p + ↑(1 - p) = 1
          @[simp]
          theorem Prob.one_minus_inv (p : Prob) :
          1 - (1 - p) = p
          @[simp]
          theorem Prob.coe_iInf {ι : Type u_1} [Nonempty ι] (f : ιProb) :
          (⨅ (t : ι), f t) = ⨅ (t : ι), (f t)
          @[simp]
          theorem Prob.top_eq_one :
          = 1
          @[simp]
          theorem Prob.sub_zero (p : Prob) :
          p - 0 = p
          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
                    @[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
                    theorem Mixable.instPi.lem_1 {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)] {u : (i : D) → U i} (h : ∃ (t : (i : D) → T i), (fun (d : D) => to_U (t d)) = u) (d : D) :
                    ∃ (t : T d), to_U t = u d
                    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) :
                      @[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
                        noncomputable def Prob.negLog :

                        Map a probability [0,1] to [0,+∞] with -log p. Special case that 0 maps to +∞ (not 0, as Real.log does). This makes it Antitone.

                        Equations
                        Instances For
                          @[simp]
                          @[simp]
                          theorem Prob.negLog_one :
                          negLog 1 = 0
                          @[simp]
                          theorem Prob.negLog_eq_top_iff {p : Prob} :
                          p.negLog = p = 0
                          theorem Prob.negLog_pos_ENNReal {p : Prob} (hp : p 0) :
                          p.negLog = -Real.log p,
                          @[simp]
                          theorem Prob.negLog_ne_top {p : Prob} (hp : 0 < p) :
                          theorem Prob.negLog_eq_neg_ENNReal_log (p : Prob) :
                          p.negLog = -(↑p).log
                          @[simp]
                          theorem Prob.zero_lt_negLog {p : Prob} :
                          0 < p.negLog p 1