Physlib Documentation

QuantumInfo.ClassicalInfo.Distribution

Distributions on finite sets #

We define the type Distribution α on a Fintype α. By restricting ourselves to distributoins on finite types, a lot of notation and casts are greatly simplified. This suffices for (most) finite-dimensional quantum theory.

def ProbDistribution (α : Type u) [Fintype α] :

We define our own (discrete) probability distribution notion here, instead of using PMF from Mathlib, because that uses ENNReals everywhere to maintain compatibility with MeasureTheory.Measure.

The probabilities internal to a Distribution are NNReals. This lets us more easily write the statement that they sum to 1, since NNReals can be added. (Probabilities, on their own, cannot.) But the FunLike instance gives Prob out, which carry the information that they are all in the range [0,1].

Equations
Instances For
    def ProbDistribution.mk' {α : Type u_1} [Fintype α] (f : α) (h₁ : ∀ (i : α), 0 f i) (hN : i : α, f i = 1) :

    Make a distribution, proving only that the values are nonnegative and that the sum is 1. The fact that the values are at most 1 is derived as a consequence.

    Equations
    Instances For
      Equations
      @[simp]
      theorem ProbDistribution.normalized {α : Type u_1} [Fintype α] (d : ProbDistribution α) :
      i : α, (d i) = 1
      @[reducible, inline]
      abbrev ProbDistribution.prob {α : Type u_1} [Fintype α] (d : ProbDistribution α) (a : α) :
      Equations
      Instances For
        @[simp]
        theorem ProbDistribution.fun_eq_val {α : Type u_1} [Fintype α] (d : ProbDistribution α) :
        d = d
        @[simp]
        theorem ProbDistribution.funlike_apply {α : Type u_1} [Fintype α] (d : αProb) (h : i : α, (d i) = 1) (x : α) :
        d, h x = d x
        theorem ProbDistribution.ext {α : Type u_1} [Fintype α] {p q : ProbDistribution α} (h : ∀ (x : α), p x = q x) :
        p = q
        theorem ProbDistribution.ext_iff {α : Type u_1} [Fintype α] {p q : ProbDistribution α} :
        p = q ∀ (x : α), p x = q x
        theorem ProbDistribution.nonempty {α : Type u_1} [Fintype α] (d : ProbDistribution α) :

        A distribution provides a witness that d is nonempty.

        def ProbDistribution.constant {α : Type u_1} [Fintype α] (x : α) :

        Make an constant distribution: supported on a single element. This is also called, variously, a "One-point distribution", a "Degenerate distribution", a "Deterministic distribution", a "Delta function", or a "Point mass distribution".

        Equations
        Instances For
          theorem ProbDistribution.constant_def {α : Type u_1} [Fintype α] (x : α) :
          (constant x) = fun (y : α) => if x = y then 1 else 0
          @[simp]
          theorem ProbDistribution.constant_eq {α : Type u_1} [Fintype α] {y : α} (x : α) :
          (constant x) y = if x = y then 1 else 0
          @[simp]
          theorem ProbDistribution.constant_def' {α : Type u_1} [Fintype α] (x y : α) :
          (constant x) y = if x = y then 1 else 0
          theorem ProbDistribution.constant_of_exists_one {α : Type u_1} [Fintype α] {D : ProbDistribution α} {x : α} (h : D x = 1) :

          If a distribution has an element with probability 1, the distribution has a constant.

          Make an uniform distribution.

          Equations
          Instances For
            @[simp]
            theorem ProbDistribution.uniform_def {α : Type u_1} [Fintype α] [Nonempty α] (y : α) :
            (uniform y) = 1 / Finset.univ.card
            def ProbDistribution.prod {α : Type u_1} {β : Type u_2} [Fintype α] [Fintype β] (d1 : ProbDistribution α) (d2 : ProbDistribution β) :

            Make a distribution on a product of two Fintypes.

            Equations
            Instances For
              @[simp]
              theorem ProbDistribution.prod_def {α : Type u_1} {β : Type u_2} [Fintype α] [Fintype β] {d1 : ProbDistribution α} {d2 : ProbDistribution β} (x : α) (y : β) :
              (d1.prod d2) (x, y) = d1 x * d2 y
              def ProbDistribution.extend_right {α : Type u_1} {β : Type u_2} [Fintype α] [Fintype β] (d : ProbDistribution α) :

              Given a distribution on α, extend it to a distribution on Sum α β by giving it no support on β.

              Equations
              Instances For
                def ProbDistribution.extend_left {α : Type u_1} {β : Type u_2} [Fintype α] [Fintype β] (d : ProbDistribution α) :

                Given a distribution on α, extend it to a distribution on Sum β α by giving it no support on β.

                Equations
                Instances For
                  instance ProbDistribution.instMixable {α : Type u_1} [Fintype α] :

                  Make a convex mixture of two distributions on the same set.

                  Equations
                  def ProbDistribution.relabel {α : Type u_1} {β : Type u_2} [Fintype α] [Fintype β] (d : ProbDistribution α) (σ : β α) :

                  Given a distribution on type α and an equivalence to type β, get the corresponding distribution on type β.

                  Equations
                  Instances For
                    def ProbDistribution.congr {α : Type u_1} {β : Type u_2} [Fintype α] [Fintype β] (σ : α β) :

                    ProbDistribution on α and β are equivalent for equivalent types α ≃ β.

                    Equations
                    Instances For
                      @[simp]
                      theorem ProbDistribution.congr_apply {α : Type u_1} {β : Type u_2} [Fintype α] [Fintype β] (σ : α β) (d : ProbDistribution α) (j : β) :
                      ((congr σ) d) j = d (σ.symm j)
                      @[simp]
                      theorem ProbDistribution.congr_symm_apply {α : Type u_1} {β : Type u_2} [Fintype α] [Fintype β] (σ : α β) :

                      The inverse and congruence operations for distributions commute

                      The distribution on Fin 2 corresponding to a coin with probability p. Chance p of 1, 1-p of 0.

                      Equations
                      Instances For
                        @[simp]
                        theorem ProbDistribution.coin_val_zero (p : Prob) :
                        (coin p) 0 = p
                        @[simp]
                        theorem ProbDistribution.coin_val_one (p : Prob) :
                        (coin p) 1 = 1 - p

                        Every distribution on two variable is some coin.

                        structure ProbDistribution.RandVar (α : Type u_3) [Fintype α] (T : Type u_4) :
                        Type (max u_3 u_4)

                        A T-valued random variable over α is a map var : α → T along with a probability distribution distr : Distribution α.

                        Instances For
                          Equations
                          def ProbDistribution.expect_val {α : Type u_1} [Fintype α] {T : Type u_3} {U : Type u_4} [AddCommGroup U] [Module U] [inst : Mixable U T] (X : RandVar α T) :
                          T

                          Distribution.exp_val is the expectation value of a random variable X. Under the hood, it is the "convex combination over a finite family" on the type T, afforded by the Mixable instance, with the probability distribution of X as weights.

                          Equations
                          Instances For
                            theorem ProbDistribution.expect_val_eq_mixable_mix {T : Type u_3} {U : Type u_4} [AddCommGroup U] [Module U] [inst : Mixable U T] (d : ProbDistribution (Fin 2)) (x₁ x₂ : T) :
                            expect_val { var := ![x₁, x₂], distr := d } = d 0[x₁x₂]

                            The expectation value of a random variable over α = Fin 2 is the same as Mixable.mix with probabiliy weight X.distr 0

                            theorem ProbDistribution.expect_val_constant {α : Type u_1} [Fintype α] {T : Type u_3} {U : Type u_4} [AddCommGroup U] [Module U] [inst : Mixable U T] (x : α) (f : αT) :
                            expect_val { var := f, distr := constant x } = f x

                            The expectation value of a random variable with constant probability distribution constant x is its value at x

                            theorem ProbDistribution.zero_le_expect_val {α : Type u_1} [Fintype α] (d : ProbDistribution α) (f : α) (hpos : 0 f) :
                            0 expect_val { var := f, distr := d }

                            The expectation value of a nonnegative real random variable is also nonnegative

                            def ProbDistribution.congrRandVar {α : Type u_1} {β : Type u_2} [Fintype α] [Fintype β] {T : Type u_3} (σ : α β) :
                            RandVar α T RandVar β T

                            T-valued random variables on α and β are equivalent if α ≃ β

                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For
                              def ProbDistribution.map_congr_eq_congr_map {α : Type u_1} {β : Type u_2} [Fintype α] [Fintype β] {T : Type u_3} {U : Type u_4} [AddCommGroup U] [Module U] {S : Type u_3} [Mixable U S] (f : TS) (σ : α β) (X : RandVar α T) :
                              f <$> (congrRandVar σ) X = (congrRandVar σ) (f <$> X)

                              Given a T-valued random variable X over α, mapping over T commutes with the equivalence over α

                              Equations
                              • =
                              Instances For
                                @[simp]
                                theorem ProbDistribution.expect_val_congr_eq_expect_val {α : Type u_1} {β : Type u_2} [Fintype α] [Fintype β] {T : Type u_3} {U : Type u_4} [AddCommGroup U] [Module U] [inst : Mixable U T] (σ : α β) (X : RandVar α T) :

                                The expectation value is invariant under equivalence of random variables