Physlib

QuantumInfo.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.mix`ed using `Prob`s.

77 declarations

definition

The type of probabilities p∈[0,1]p \in [0, 1]

`Prob` is the type of real numbers p∈Rp \in \mathbb{R} such that 0≤p≤10 \le p \le 1. It is defined as a subtype of the real numbers consisting of all elements in the closed unit interval [0,1][0, 1].

instance

Coercion from `Prob` to R\mathbb{R}

There is a natural coercion from the type of probabilities `Prob` (the unit interval [0,1][0, 1]) to the real numbers R\mathbb{R}, which maps a probability pp to its underlying real value.

instance

Real numbers in [0,1][0, 1] can be lifted to `Prob`

Any real number rr such that 0≤r≤10 \le r \le 1 can be lifted to (or identified as) an element of the type `Prob`. Here, `Prob` represents the subtype of real numbers in the unit interval [0,1][0, 1].

instance

The value 00 as a probability p∈[0,1]p \in [0, 1]

The type `Prob`, representing real numbers in the interval [0,1][0, 1], has an additive identity element (zero), defined as the real number 00.

instance

The value 11 as a probability p∈[0,1]p \in [0, 1]

The type `Prob`, representing real numbers in the unit interval [0,1][0, 1], has a multiplicative identity element (one), defined as the real number 11.

instance

Multiplication of probabilities in [0,1][0, 1]

The multiplication operation on the type `Prob` (the closed interval [0,1]⊆R[0, 1] \subseteq \mathbb{R}) is defined by the multiplication of the underlying real numbers. For any two probabilities p,q∈[0,1]p, q \in [0, 1], their product p⋅qp \cdot q is also in the interval [0,1][0, 1].

theorem

The value of 0∈Prob0 \in \text{Prob} is 00

Let Prob\text{Prob} be the type representing real numbers in the interval [0,1][0, 1]. The numerical value of the probability constant 0∈Prob0 \in \text{Prob} is equal to the real number 00.

theorem

(1:Prob).val=1(1 : \text{Prob}).\text{val} = 1

The numerical value of the identity element 11 in the type Prob\text{Prob} is equal to the real number 11. Here, Prob\text{Prob} represents the interval [0,1]⊆R[0, 1] \subseteq \mathbb{R}, and val\text{val} denotes the mapping from Prob\text{Prob} to the real numbers.

theorem

(x⋅y).val=x.val⋅y.val(x \cdot y).\text{val} = x.\text{val} \cdot y.\text{val}

For any two probability values x,y∈Probx, y \in \text{Prob}, the numerical value of their product is equal to the product of their individual numerical values, یعنی (x⋅y).val=x.val⋅y.val(x \cdot y).\text{val} = x.\text{val} \cdot y.\text{val}. Here, Prob\text{Prob} denotes the interval [0,1]⊆R[0, 1] \subseteq \mathbb{R}.

theorem

(x⊓y).val=x.val⊓y.val(x \sqcap y).\text{val} = x.\text{val} \sqcap y.\text{val}

For any two probabilities x,y∈Probx, y \in \text{Prob}, the numerical value of their infimum (minimum) is equal to the infimum of their individual numerical values, expressed as (x⊓y).val=x.val⊓y.val(x \sqcap y).\text{val} = x.\text{val} \sqcap y.\text{val}. Here, Prob\text{Prob} is the type of real numbers in the interval [0,1][0, 1], and val\text{val} denotes the coercion or map from Prob\text{Prob} to the real numbers R\mathbb{R}.

theorem

(x⊔y).val=x.val⊔y.val(x \sqcup y).\text{val} = x.val \sqcup y.val

For any two probabilities x,y∈Probx, y \in \text{Prob}, the numerical value of their supremum (maximum) is equal to the supremum of their individual numerical values, which is expressed as (x⊔y).val=x.val⊔y.val(x \sqcup y).\text{val} = x.\text{val} \sqcup y.\text{val}. Here, Prob\text{Prob} denotes the type of real numbers in the interval [0,1][0, 1], and val\text{val} represents the coercion or map from Prob\text{Prob} to the real numbers R\mathbb{R}.

instance

The interval [0,1][0, 1] is a commutative monoid with zero under multiplication

The type Prob\text{Prob}, representing the interval [0,1]⊆R[0, 1] \subseteq \mathbb{R}, forms a commutative monoid with zero under multiplication. Specifically, this structure provides: 1. An identity element 1∈[0,1]1 \in [0, 1]. 2. A zero element 0∈[0,1]0 \in [0, 1]. 3. A multiplication operation that is associative (a⋅(b⋅c)=(a⋅b)⋅ca \cdot (b \cdot c) = (a \cdot b) \cdot c), commutative (a⋅b=b⋅aa \cdot b = b \cdot a), satisfies identity laws (1⋅a=a1 \cdot a = a), and acts as an annihilator for zero (0⋅a=00 \cdot a = 0).

instance

The interval [0,1][0, 1] is Densely Ordered

The type `Prob`, representing the closed unit interval [0,1]⊆R[0, 1] \subseteq \mathbb{R}, is a densely ordered set. This means that for any two probabilities p,q∈Probp, q \in \text{Prob} such that p<qp < q, there exists a probability r∈Probr \in \text{Prob} such that p<r<qp < r < q.

instance

Complete linear order structure of `Prob`

The type `Prob`, representing the interval [0,1]⊆R[0, 1] \subseteq \mathbb{R}, forms a complete linear order. This means that for every subset S⊆ProbS \subseteq \text{Prob}, there exists a supremum sup⁡S\sup S and an infimum inf⁡S\inf S within the interval [0,1][0, 1]. Furthermore, for any two elements p,q∈Probp, q \in \text{Prob}, the relation p≤qp \le q or q≤pq \le p always holds, consistent with the standard ordering of real numbers.

instance

Default probability 0∈Prob0 \in \text{Prob}

The type `Prob`, representing real numbers in the unit interval [0,1][0, 1], is provided with a default element, which is the probability 00.

instance

Linear ordered commutative monoid with zero structure of `Prob`

The type `Prob`, representing real numbers in the unit interval [0,1][0, 1], forms a linearly ordered commutative monoid with zero. This structure inherits the standard multiplication from real numbers as the monoid operation, ensuring that for any a,b,c∈[0,1]a, b, c \in [0, 1], if a<ba < b and 0<c0 < c, then ca<cbca < cb. The order is the standard ≤\le relation on the real numbers restricted to the interval [0,1][0, 1], where the zero element 00 is the least element.

theorem

0≤p0 \le p for any p∈Probp \in \text{Prob}

For any probability p∈Probp \in \text{Prob}, where Prob\text{Prob} denotes the set of real numbers in the unit interval [0,1][0, 1], its representation as a real number satisfies 0≤p0 \le p.

theorem

p≤1p \leq 1 for any p∈Probp \in \text{Prob}

For any probability p∈Probp \in \text{Prob}, its representation as a real number satisfies p≤1p \leq 1.

theorem

0≤p0 \leq p for any p∈Probp \in \text{Prob}

For any probability pp in the interval [0,1][0, 1], it holds that 0≤p0 \leq p.

theorem

p≤1p \leq 1 for any p∈Probp \in \text{Prob}

Let pp be an element of the type `Prob`, which represents the interval of real numbers [0,1][0, 1]. Then pp is less than or equal to 11, i.e., p≤1p \leq 1.

theorem

The equality of probabilities is determined by the equality of their real values

For any two probabilities n,m∈[0,1]n, m \in [0, 1], if their underlying real-number representations are equal, then nn and mm are equal as elements of the `Prob` type.

theorem

x≠yx \neq y as real numbers   ⟺  x≠y\iff x \neq y as probabilities

Let xx and yy be probabilities in the unit interval [0,1][0, 1]. The underlying real numbers represented by xx and yy are unequal if and only if xx and yy are unequal as elements of the type `Prob`.

theorem

(x⋅y)R=xR⋅yR(x \cdot y)_{\mathbb{R}} = x_{\mathbb{R}} \cdot y_{\mathbb{R}} for x,y∈[0,1]x, y \in [0, 1]

Let xx and yy be elements of the type `Prob`, which represents real numbers in the closed interval [0,1][0, 1]. The real value of the product of xx and yy within the `Prob` type is equal to the product of their corresponding real values: (x⋅y)R=xR⋅yR(x \cdot y)_{\mathbb{R}} = x_{\mathbb{R}} \cdot y_{\mathbb{R}}.

definition

Coercion of a probability p∈[0,1]p \in [0, 1] to a non-negative real R≥0\mathbb{R}_{\ge 0}

Let `Prob` denote the type of real numbers in the interval [0,1][0, 1]. The function `toNNReal` maps an element p∈[0,1]p \in [0, 1] to its corresponding value in the set of non-negative real numbers R≥0\mathbb{R}_{\ge 0}. Specifically, for p=(x,0≤x≤1)p = (x, 0 \le x \le 1), the function returns the non-negative real number xx.

theorem

The Value of `toNNReal` for a Probability xx is xx viewed as a Non-negative Real

Let xx be a real number and hxh_x be the proof that 0≤x≤10 \le x \le 1. For the probability value p={val:=x,property:=hx}p = \{ \text{val} := x, \text{property} := h_x \} in the interval [0,1][0, 1], its conversion to a non-negative real number (R≥0\mathbb{R}_{\ge 0}) is equal to the non-negative real number {val:=x,property:=x≥0}\{ \text{val} := x, \text{property} := x \ge 0 \}. In other words, the mapping from `Prob` to `NNReal` preserves the underlying value xx while simplifying the property constraint from 0≤x≤10 \le x \le 1 to x≥0x \ge 0.

instance

Coercion from `Prob` to R≥0\mathbb{R}_{\ge 0}

There exists a natural coercion from the type of probabilities `Prob` (the interval [0,1][0, 1]) to the type of non-negative real numbers R≥0\mathbb{R}_{\ge 0}, defined by mapping each probability pp to its underlying value in R≥0\mathbb{R}_{\ge 0}.

instance

Condition for Lifting R≥0\mathbb{R}_{\geq 0} to `Prob` is r≤1r \leq 1

A non-negative real number r∈R≥0r \in \mathbb{R}_{\geq 0} can be lifted to the type of probabilities `Prob` (the interval [0,1][0, 1]) if and only if r≤1r \leq 1. Here, the lifting is defined relative to the coercion (or projection) `toNNReal` from `Prob` to R≥0\mathbb{R}_{\geq 0}.

theorem

The `toNNReal` map sends 00 to 00

The representation of the probability 0∈[0,1]0 \in [0, 1] as a non-negative real number is equal to 0∈R≥00 \in \mathbb{R}_{\geq 0}.

theorem

The probability 11 equals 11 in R≥0\mathbb{R}_{\ge 0}

The representation of the probability 1∈[0,1]1 \in [0, 1] as a non-negative real number is equal to the non-negative real number 1∈R≥01 \in \mathbb{R}_{\ge 0}.

theorem

The extended non-negative real representation of a probability pp is consistent across R≥0\mathbb{R}_{\ge 0} and R\mathbb{R} pathways.

For any probability p∈[0,1]p \in [0, 1], let toNNReal(p)\text{toNNReal}(p) be its representation as a non-negative real number. The conversion of this non-negative real value to an extended non-negative real number (R‾≥0\overline{\mathbb{R}}_{\ge 0}) is equal to the conversion of the probability pp, viewed as a real number, directly to an extended non-negative real number. That is, ENNReal.ofNNReal(toNNReal(p))=ENNReal.ofReal(p)\text{ENNReal.ofNNReal}(\text{toNNReal}(p)) = \text{ENNReal.ofReal}(p).

definition

Construction of a probability from p∈R≥0p \in \mathbb{R}_{\geq 0} where p≤1p \leq 1

Given a non-negative real number p∈R≥0p \in \mathbb{R}_{\geq 0} and a proof hphp that p≤1p \leq 1, this function constructs an element of the type `Prob`, representing the value pp as a probability in the closed interval [0,1]⊂R[0, 1] \subset \mathbb{R}.

definition

Construction of p∈Probp \in \text{Prob} from p∈R≥0p \in \mathbb{R}_{\geq 0} such that p≤1p \leq 1

Given a non-negative real number p∈R≥0p \in \mathbb{R}_{\geq 0} and a condition hphp that its underlying value (as a real number) is less than or equal to 11, this function constructs an element of the type `Prob`. This represents the value pp as a probability within the closed interval [0,1][0, 1].

theorem

If p≠0p \neq 0 for p∈Probp \in \text{Prob}, then 0<p0 < p

Let pp be a probability, defined as a real number in the interval [0,1]⊂R[0, 1] \subset \mathbb{R}. If pp is not equal to 00, then pp is strictly greater than 00 when treated as a real number.

instance

Truncated subtraction on `Prob`

Subtraction on the type `Prob` (the set of real numbers in the unit interval [0,1][0, 1]) is defined for any two probabilities p,q∈[0,1]p, q \in [0, 1] as p−q=max⁡(p−q,0)p - q = \max(p - q, 0). This operation ensures the result remains within the interval [0,1][0, 1] by truncating negative results to 00.

theorem

The real value of p−qp - q for probabilities p,qp, q is (p−q)⊔0(p - q) \sqcup 0

Let pp and qq be probabilities, represented as real numbers in the interval [0,1][0, 1]. The real value of the difference p−qp - q (defined within the space of probabilities) is equal to the maximum of p−qp - q and 00 in the real numbers, denoted as (p−q)⊔0(p - q) \sqcup 0.

theorem

The real value of 1−p1 - p for a probability pp is 1−pR1 - p_{\mathbb{R}}

Let pp be a probability, defined as a real number in the interval [0,1][0, 1]. Then the real-valued representation of the complement 1−p1 - p (where subtraction is defined within the space of probabilities) is equal to 1−p1 - p calculated in the real numbers R\mathbb{R}.

theorem

p+(1−p)=1p + (1 - p) = 1 for any probability pp

Let pp be a probability, defined as a real number in the unit interval [0,1][0, 1]. Let p.valp.val denote its representation as a real number R\mathbb{R}. Then the sum of pp and its complement 1−p1 - p (where subtraction is defined within the space of probabilities) satisfies p.val+(1−p).val=1p.val + (1 - p).val = 1.

theorem

1−(1−p)=p1 - (1 - p) = p for any probability pp

Let pp be a probability, defined as a real number in the interval [0,1][0, 1]. Then the complement of its complement is itself, i.e., 1−(1−p)=p1 - (1 - p) = p, where the subtraction is defined within the space of probabilities.

instance

The type of probabilities `Prob` has an Order Topology

The type `Prob`, representing the interval [0,1]⊆R[0, 1] \subseteq \mathbb{R}, is equipped with the order topology. This means the topology on `Prob` is generated by the open intervals (a,b)(a, b), [0,a)[0, a), and (a,1](a, 1] for all a,b∈Proba, b \in \text{Prob}.

theorem

The infimum in Prob\text{Prob} commutes with the coercion to R\mathbb{R}

Let Prob\text{Prob} be the type of probabilities represented by the closed unit interval [0,1]⊆R[0, 1] \subseteq \mathbb{R}. For any non-empty index type ι\iota and any function f:ι→Probf: \iota \to \text{Prob}, the coercion of the infimum of ff in Prob\text{Prob} to the real numbers is equal to the infimum of the coerced values in R\mathbb{R}. That is, (inf⁡t∈ιf(t))R=inf⁡t∈ι(f(t)R) \left( \inf_{t \in \iota} f(t) \right)_{\mathbb{R}} = \inf_{t \in \iota} (f(t)_{\mathbb{R}}) where (⋅)R(\cdot)_{\mathbb{R}} denotes the natural embedding from [0,1][0, 1] into R\mathbb{R}.

instance

The type of probabilities `Prob` is nontrivial (Prob\text{Prob} is nontrivial)

The type `Prob`, which represents the closed interval [0,1]⊆R[0, 1] \subseteq \mathbb{R}, is nontrivial. That is, it contains at least two distinct elements. Specifically, since `Prob` possesses both a zero element (00) and a one element (11) as defined by its instances, this theorem implies 0≠10 \neq 1 within the space of probabilities.

theorem

⊤=1\top = 1 in Prob\text{Prob}

In the space of probabilities Prob\text{Prob} (defined as the interval [0,1]⊂R[0, 1] \subset \mathbb{R}), the greatest element ⊤\top under the canonical linear order is equal to 11.

theorem

p−0=pp - 0 = p for any p∈Probp \in \text{Prob}

For any probability p∈[0,1]p \in [0, 1], subtracting the zero probability from pp results in pp itself, where the subtraction on the type `Prob` is defined such that for p,q∈[0,1]p, q \in [0, 1], p−q=max⁡(pval−qval,0)p - q = \max(p_{val} - q_{val}, 0).

theorem

The Map from `Prob` to R≥0\mathbb{R}_{\ge 0} is Continuous

The function toNNReal:Prob→R≥0\text{toNNReal} : \text{Prob} \to \mathbb{R}_{\ge 0}, which maps a probability pp (a real number in the interval [0,1][0, 1]) to its representation as a non-negative real number, is a continuous function.

theorem

p⋅q=1  ⟺  p=1 and q=1p \cdot q = 1 \iff p = 1 \text{ and } q = 1 for p,q∈[0,1]p, q \in [0, 1]

Let pp and qq be probabilities, defined as real numbers in the interval [0,1][0, 1]. Then the product p⋅qp \cdot q is equal to 11 if and only if both p=1p = 1 and q=1q = 1.

definition

Convex combination of x1,x2∈Tx_1, x_2 \in T with weights a,ba, b where a+b=1a+b=1

Given a type TT that satisfies the `Mixable` property relative to a type UU, for any two elements x1,x2∈Tx_1, x_2 \in T and any real numbers a,b∈Ra, b \in \mathbb{R} such that a≥0a \ge 0, b≥0b \ge 0, and a+b=1a + b = 1, the function mix_ab\text{mix\_ab} returns an element in TT representing the convex combination of x1x_1 and x2x_2 with weights aa and bb.

definition

Convex combination of x1,x2∈Tx_1, x_2 \in T with probability pp

Let TT be a type equipped with a `Mixable` instance and p∈[0,1]p \in [0, 1] be a probability. The function `Mixable.mix` defines the convex combination of two elements x1,x2∈Tx_1, x_2 \in T weighted by pp. Specifically, it is defined as the convex combination ax1+bx2a x_1 + b x_2 where a=pa = p and b=1−pb = 1 - p, satisfying the conditions a,b≥0a, b \ge 0 and a+b=1a + b = 1.

theorem

to_U(mkT(u))=u\text{to\_U} (\text{mkT}(u)) = u

Let TT be a type that is `Mixable` with respect to a type UU. For any element u∈Uu \in U and a proof hh that uu satisfies the property required to be an element of TT, let (x,h′)(x, h') be the result of the constructor mkT\text{mkT} applied to uu. Then, the mapping of xx back to the type UU via the `to_U` function is equal to the original element uu.

definition

Notation p[x1↔x2]p [x_1 \leftrightarrow x_2] for the convex combination `mix p x₁ x₂`

Let pp be an element of type `Prob` (representing a value in the interval [0,1][0, 1]) and let x1,x2x_1, x_2 be elements of a type TT equipped with a `Mixable` instance. The notation p[x1↔x2]p [x_1 \leftrightarrow x_2] denotes the convex combination of x1x_1 and x2x_2 weighted by pp, which is defined as `mix p x₁ x₂`. This corresponds to the mathematical expression px1+(1−p)x2p x_1 + (1 - p) x_2.

definition

Notation for Convex Mix p[x1↔x2:M]p[x_1 \leftrightarrow x_2 : M]

This definition introduces a notation for the convex combination (mixing) of two elements x1x_1 and x2x_2 in a type equipped with a `Mixable` instance MM. Given a probability p∈[0,1]p \in [0, 1], the expression p[x1↔x2:M]p[x_1 \leftrightarrow x_2 : M] represents the result p⋅x1+(1−p)⋅x2p \cdot x_1 + (1 - p) \cdot x_2 as defined by the mixing operation in MM.

theorem

The convex combination of x1,x2x_1, x_2 with p=0p=0 is x2x_2

Let TT be a type equipped with a `Mixable` instance. For any two elements x1,x2∈Tx_1, x_2 \in T, the convex combination of x1x_1 and x2x_2 with probability 00 is equal to x2x_2. That is, 0⋅x1+(1−0)⋅x2=x20 \cdot x_1 + (1 - 0) \cdot x_2 = x_2.

instance

`Mixable` instance for a real module TT over itself

Let TT be an additive commutative monoid that is also a module over the real numbers R\mathbb{R}. There exists an instance of the `Mixable` typeclass for TT where the underlying vector space representation of an element is the element itself (via the identity map). In this instance, the set of representable elements is the entire space TT, which is convex. For any two elements x1,x2∈Tx_1, x_2 \in T and a probability p∈[0,1]p \in [0, 1], the mixing operation is defined as the convex combination p⋅x1+(1−p)⋅x2p \cdot x_1 + (1 - p) \cdot x_2.

theorem

Construction of `Mixable` elements in the universal instance `instUniv` for a real module TT equals ⟨t,rfl⟩\langle t, \text{rfl} \rangle

Let TT be an additive commutative monoid that is also a module over the real numbers R\mathbb{R}. For any element t∈Tt \in T, if there exists an element t′t' in the subtype defined by the universal `Mixable` instance such that its representation in the vector space is tt, then the result of constructing an element of the `Mixable` type from this witness hh is simply the pair consisting of tt and the trivial proof of its representation.

theorem

The representation to_U\text{to\_U} for `instUniv` is the identity map

Let TT be an additive commutative monoid that is also a module over the real numbers R\mathbb{R}. For the `Mixable` instance where TT represents itself (via `instUniv`), the underlying vector space representation to_U\text{to\_U} of any element t∈Tt \in T is equal to the element tt itself.

theorem

Pointwise Existence of Pre-images in Product Mixable Types

Let DD be a type, and for each i∈Di \in D, let TiT_i and UiU_i be types such that UiU_i is a real vector space (specifically, an additive commutative monoid and a module over R\mathbb{R}) and there is a `Mixable` instance between UiU_i and TiT_i. Let uu be a dependent function mapping each i∈Di \in D to an element u(i)∈Uiu(i) \in U_i. If there exists a dependent function tt mapping each i∈Di \in D to an element t(i)∈Tit(i) \in T_i such that the projection of t(i)t(i) to the universal type UiU_i (denoted to_U(t(i))\text{to\_U}(t(i))) equals u(i)u(i) for all ii, then for any specific d∈Dd \in D, there exists an element td∈Tdt_d \in T_d such that to_U(td)=u(d)\text{to\_U}(t_d) = u(d).

instance

Pointwise `Mixable` instance for Pi types ∏i∈DTi\prod_{i \in D} T_i into ∏i∈DUi\prod_{i \in D} U_i

Let DD be an index set, and for each i∈Di \in D, let TiT_i and UiU_i be types such that UiU_i is a real vector space (specifically, an additive commutative monoid and an R\mathbb{R}-module) and TiT_i is "mixable" into UiU_i. The definition provides a `Mixable` instance for the product types (Pi types), mapping the dependent function type ∏i∈DTi\prod_{i \in D} T_i into the function space ∏i∈DUi\prod_{i \in D} U_i. Specifically, the mapping to_Uto\_U is defined pointwise by (to_Uf)(d)=to_U(f(d))(to\_U f)(d) = to\_U(f(d)). Under this mapping, the image of ∏Ti\prod T_i in ∏Ui\prod U_i is shown to be convex, meaning that for any f1,f2∈∏Tif_1, f_2 \in \prod T_i and any probabilities a,b≥0a, b \ge 0 with a+b=1a + b = 1, the convex combination a⋅to_U(f1)+b⋅to_U(f2)a \cdot to\_U(f_1) + b \cdot to\_U(f_2) corresponds to an element in the product of the mixable types.

theorem

Pointwise evaluation of lifted functions in `Mixable` function spaces

Let TT and UU be types such that TT is mixable into UU (denoted by the instance `Mixable U T`), where UU is a real vector space. Consider the function space D→UD \to U for some type DD, which inherits a mixable structure from the pointwise mixability of UU. For any function u:D→Uu: D \to U that is in the image of the mapping from D→TD \to T (i.e., there exists some t:D→Tt: D \to T such that to_U∘t=uto\_U \circ t = u), let mkT(h)mkT(h) denote the lifting of uu to the subtype of mixable elements in the function space. Then, for every d∈Dd \in D, the value of this lifted function at dd is equal to the result of lifting the local value u(d)u(d) to TT using the pointwise mixability instance.

theorem

The Map to UU for Functions is Defined Pointwise

Let DD be a type, and let TT and UU be types such that TT is mixable into UU (via an instance of the `Mixable` typeclass). For any function t:D→Tt: D \to T, the representation of tt in the function space D→UD \to U is given by the pointwise application of the representation map to each value t(d)t(d). That is, (to_UinstPi t)(d)=to_Uinst(t(d))(\text{to\_U}_{\text{instPi}} \, t)(d) = \text{to\_U}_{\text{inst}}(t(d)) for all d∈Dd \in D.

definition

Subtype of a `Mixable` type is `Mixable` if the predicate PP is closed under convex combinations

Let UU be a type and TT be a type that is `Mixable` into UU. Let P:T→PropP: T \to \text{Prop} be a predicate on TT. If the subset defined by PP is convex under the mixing operation of TT—that is, for any x,y∈Tx, y \in T such that P(x)P(x) and P(y)P(y) hold, and for any non-negative real numbers a,b∈Ra, b \in \mathbb{R} with a+b=1a + b = 1, the convex combination mix_ab(a,b,x,y)\text{mix\_ab}(a, b, x, y) also satisfies PP—then the subtype {t∈T∣P(t)}\{t \in T \mid P(t)\} is also `Mixable` into UU. The `Mixable` structure on the subtype is inherited from TT, where the representation in UU is given by the composition of the subtype inclusion and the original mapping from TT to UU.

instance

`Prob` is `Mixable` over R\mathbb{R}

The type `Prob`, representing real numbers in the interval [0,1][0, 1], is equipped with an instance of the `Mixable` typeclass over the real numbers R\mathbb{R}. This is defined by taking the underlying real value of a probability (the inclusion map into R\mathbb{R}), ensuring this mapping is injective via the extensionality of probabilities, and proving that the set [0,1][0, 1] is convex. Specifically, for any x,y∈[0,1]x, y \in [0, 1] and non-negative a,b∈Ra, b \in \mathbb{R} such that a+b=1a + b = 1, the convex combination ax+byax + by also belongs to [0,1][0, 1].

theorem

`Mixable.to_U` of t∈t \in `Prob` equals t.valt.\text{val}

Let `Prob` denote the type of real numbers in the interval [0,1][0, 1]. For any element t∈Probt \in \text{Prob}, the value obtained by applying the `Mixable.to_U` projection (associated with the `Mixable` instance for real numbers) to tt is equal to the underlying real value t.valt.\text{val}.

theorem

Mixable.mkT\text{Mixable.mkT} for ProbProb preserves the underlying value uu

Let ProbProb be the type of real numbers in the interval [0,1][0, 1]. For any u∈Ru \in \mathbb{R}, if there exists a probability t∈Probt \in Prob such that its underlying value Mixable.to_U(t)\text{Mixable.to\_U}(t) is equal to uu, then the constructed mixable element Mixable.mkT(h)\text{Mixable.mkT}(h) (where hh is the proof of existence) is equal to a term whose value is uu and whose membership proof in the interval [0,1][0, 1] is derived from tt.

abbrev

Convex combination of x1,x2∈Tx_1, x_2 \in T weighted by probability pp

Let ProbProb be the type of real numbers in the interval [0,1][0, 1]. For a type TT that satisfies the `Mixable` property with respect to a real vector space UU, the function `Prob.mix` takes a probability p∈[0,1]p \in [0, 1] and two elements x1,x2∈Tx_1, x_2 \in T, and returns their convex combination, denoted as p⋅x1+(1−p)⋅x2p \cdot x_1 + (1 - p) \cdot x_2. This is an alias for `Mixable.mix` provided to enable dot notation on probability values.

definition

Negative logarithm of a probability p∈[0,1]p \in [0, 1] as an extended non-negative real R‾≥0\overline{\mathbb{R}}_{\geq 0}

Let ProbProb be the type of real numbers in the interval [0,1][0, 1]. The function `negLog` maps a probability p∈[0,1]p \in [0, 1] to an extended non-negative real number R‾≥0\overline{\mathbb{R}}_{\geq 0} defined by: negLog(p)={∞if p=0−log⁡(p)if p>0 \text{negLog}(p) = \begin{cases} \infty & \text{if } p = 0 \\ -\log(p) & \text{if } p > 0 \end{cases} where log⁡\log denotes the natural logarithm. For p>0p > 0, since p∈(0,1]p \in (0, 1], the value −log⁡(p)-\log(p) is guaranteed to be non-negative, allowing it to be cast into the extended non-negative real numbers.

definition

Notation `—log` for the negative logarithm of a probability

A scoped notation used within the `Prob` namespace where the prefix symbol `—log` denotes the negative logarithm function `negLog`, which maps a probability p∈[0,1]p \in [0, 1] to its corresponding value in the extended non-negative real numbers R‾≥0\overline{\mathbb{R}}_{\geq 0}.

theorem

The negative logarithm of a probability is antitone

The function −log⁡:Prob→R‾≥0-\log : \text{Prob} \to \overline{\mathbb{R}}_{\ge 0}, which assigns a probability p∈[0,1]p \in [0, 1] to its negative logarithm (information content) in the extended non-negative real numbers, is antitone. That is, for any probabilities p,q∈[0,1]p, q \in [0, 1], if p≤qp \le q, then −log⁡(p)≥−log⁡(q)-\log(p) \ge -\log(q).

theorem

−log⁡(0)=∞-\log(0) = \infty

The negative logarithm of the probability 00 is equal to infinity (∞\infty), where the probability is treated as an element of the closed unit interval [0,1][0, 1] and the result is in the extended non-negative real numbers R‾≥0\overline{\mathbb{R}}_{\ge 0}.

theorem

−log⁡1=0-\log 1 = 0 for probabilities

The negative logarithm of the probability 1∈[0,1]1 \in [0, 1] is equal to 00. Let negLog\text{negLog} be the function mapping a probability p∈[0,1]p \in [0, 1] to the extended non-negative real numbers R‾≥0\overline{\mathbb{R}}_{\geq 0}, then negLog(1)=0\text{negLog}(1) = 0.

theorem

−log⁡p=∞  ⟺  p=0-\log p = \infty \iff p = 0

For any probability p∈[0,1]p \in [0, 1], the negative logarithm −log⁡p-\log p is equal to ∞\infty (top) if and only if p=0p = 0.

theorem

Calculation of −log⁡p-\log p for p≠0p \neq 0 as an extended non-negative real number

Let pp be a probability, defined as a real number in the interval [0,1][0, 1]. If p≠0p \neq 0, then the negative logarithm of pp, denoted as −log⁡p-\log p and taking values in the extended non-negative real numbers R‾≥0\overline{\mathbb{R}}_{\ge 0}, is equal to the non-negative real number −ln⁡p-\ln p (where ln⁡\ln is the natural logarithm).

theorem

The real part of —log p\text{—log } p equals −log⁡p-\log p

Let p∈[0,1]p \in [0, 1] be a probability. The real-valued part of its negative logarithm in the extended non-negative real numbers, denoted as (—log p).toReal(\text{—log } p).\text{toReal}, is equal to the negative of the natural logarithm of pp, denoted as −log⁡p-\log p.

theorem

p≤e−xp \le e^{-x} implies x≤—log⁡px \le —\log p

Let pp be a probability, represented as a real number in the interval [0,1][0, 1]. For any real number x∈Rx \in \mathbb{R}, if p≤e−xp \le e^{-x}, then the expression of xx as an extended non-negative real number is less than or equal to the negative logarithm of pp (denoted as —log⁡p—\log p).

theorem

The negative log of a positive probability p>0p > 0 is not infinite (≠∞\neq \infty).

Let pp be a probability, defined as a real number in the interval [0,1][0, 1], and let its value be denoted by p.valp.val. If p.val>0p.val > 0, then its negative logarithm (denoted as —log⁡p—\log p) is not equal to infinity (∞\infty) in the extended non-negative real numbers (R‾≥0\overline{\mathbb{R}}_{\geq 0}).

theorem

−log⁡p=−ENNReal.log p-\log p = -\text{ENNReal.log } p for p∈Probp \in \text{Prob}

For any probability p∈[0,1]p \in [0, 1], its negative logarithm −log⁡p-\log p (defined as an extended non-negative real internal to the `Prob` namespace) is equal to the negative of the logarithm of pp as defined for extended non-negative reals, denoted by −ENNReal.log(p)-\text{ENNReal.log}(p).

theorem

−log⁡p=ofReal(−log⁡p)-\log p = \text{ofReal}(-\log p) for p>0p > 0

Let pp be a probability, defined as a real number in the interval [0,1][0, 1]. If p>0p > 0, then the negative logarithm of pp in the extended non-negative real numbers (denoted as −log⁡p-\log p) is equal to the representation of the real number −log⁡(p)-\log(p) in the extended non-negative real numbers via the map ENNReal.ofReal\text{ENNReal.ofReal}.

theorem

−log⁡p>0  ⟺  p≠1-\log p > 0 \iff p \neq 1 for p∈[0,1]p \in [0, 1]

For any probability p∈[0,1]p \in [0, 1], the negative logarithm of pp (denoted as −log⁡p-\log p) is strictly greater than 00 if and only if pp is not equal to 11. Here, the negative logarithm maps from the interval [0,1][0, 1] to the extended non-negative real numbers R‾≥0\overline{\mathbb{R}}_{\ge 0}.

theorem

The Negative Logarithm of a Probability is Continuous

The function −log⁡:Prob→ENNReal-\log : \text{Prob} \to \text{ENNReal}, which maps a probability p∈[0,1]p \in [0, 1] to its negative logarithm (information content) in the extended non-negative real numbers, is continuous.