Journal of Mathematics and Statistics

Original Research Paper Formalizing Probability Concepts in a

Farida Kachapova

Department of Mathematical Sciences, Auckland University of Technology, New Zealand

Article history Abstract: In this paper we formalize some fundamental concepts of Received: 22-09-2018 probability theory such as the axiomatic definition of probability Revised: 01-11-2018 space, random variables and their characteristics, in the Calculus of Accepted: 10-11-2018 Inductive Constructions, which is a variant of type theory and the

Email: [email protected] foundation for the COQ. In a type theory every term and proposition should have a type, so in our formalizations we assign an appropriate type to each object in order to create a framework where further development of formalized probability theory will be possible. Our formalizations are based on mathematical results developed in the COQ standard library; we use mainly the parts with logic and formalized real analysis. In the future we aim to create COQ coding for our formalizations of probability concepts and theorems. In this paper the definitions and some proofs are presented as flag-style derivations while other proofs are more informal.

Keywords: Type Theory, Kolmogorov's Axiomatics, Probability Theory, Calculus of Inductive Constructions, Flag-Style Derivation

1. Introduction except some fragments such as finite probability distributions in (Moreira, 2012). In this paper we Formalizing mathematics in an axiomatic theory formalize the general axiomatic approach to probability makes mathematical results and applications more reliable developed by Kolmogorov (1950); a more recent and provides assurance of their validity. In recent years presentation of this approach can be found, for example, several parts of mathematics were formalized in type in (Rosenthal, 2006). theories. One of the books on types theories is Formalizing mathematical topics in COQ starts with (Nederpelt and Geuvers, 2014); it describes formal formalizing them in the underlying theory COIC; then λ theories from -calculus to the calculus of computer coding follows. In this paper we formalize in constructions and contains examples of formalizing COIC some fundamental probability concepts; coding mathematics in such theories. Type theories underlie proof the results in COQ is a task for the future. The assistants, so formalizing mathematics in a type theory developments in this paper are based on the concepts and enables the use of computers for checking the correctness theorems that are already formalized in COIC/COQ and of mathematical proofs. There exist several proof assistants. Here we consider the proof assistant COQ presented in the Library. Logical connectives and the ⊥ (named after its creator Thierry Coquand) and the formal constant False are defined in COIC/COQ; we denote = type theory Calculus of Inductive Constructions (COIC), False . In particular, ¬P denotes ( P→⊥) and we have: which is the foundation of COQ. COQ and COIC are described in the book (Bertot and Casteran, 2014) and False_:: ind∀ P Prop , ⊥→ P . (1) the COQ website (Coq Development Team). The website contains, among other things, a reference manual One of the main ideas in type theories is that every and the COQ standard library (which we will further call object has a type. In this paper we endeavour to assign just the Library). The Library contains formalizations of appropriate types to fundamental probability concepts in a significant part of mathematics in COQ, including order to create a framework where further development logic, natural numbers, integers, real numbers, limits, of formalized probability theory will be possible. series, Riemann integral, algebraic structures etc. In Section 2 we axiomatically define a probability Probability theory has not been developed in COIC space, in Section 3 we give formal definitions of

© 2018 Farida Kachapova. This open access article is distributed under a Creative Commons Attribution (CC-BY) 3.0 license. Farida Kachapova / Journal of Mathematics and Statistics 2018, Volume 14: 209.218 DOI: 10.3844/jmssp.2018.209.218 random variables and related concepts. In Section 4 ext::_,∀ BCPsetU( ) B ⊆∧⊆→= C B B C . (2) we formalize concepts related to discrete random variables, including their numerical characteristics. In As in the book (Nederpelt and Geuvers, 2014) we Section 5 we study random vectors and their will use the notation { x: S | Ax } for λx: S.Ax , where A is numerical characteristics and in Section 6 we look at a predicate. continuous random variables. All this is done within the theory COIC. For better readability our Lemma 2.1 presentation of results is not strictly formal. In c definitions and some proofs we use the flag-style 1) Ω = ∅. c c derivation described in (Nederpelt and Geuvers, 2) ∀B: P_set (U), ( B ) = B. 2014), while other proofs are more informal. Often we Proof use implicit variables as is done in COIC/COQ and in (Nederpelt and Geuvers, 2014). 1) In the first part of the following flag-style derivation we use the rule (1) for False elimination and 2. Probability Space in the second part the Extensionality axiom (2).

2.1. Some Facts about Sets We fix a non-empty universal set U that denotes the sample space (the set of all outcomes):

The variable ω will be used for objects of type U (outcomes). The Library introduces subsets of U as objects of type U→ Prop , that is predicates on U.

Here T denotes ⊥→⊥. This flag-style diagram defines the power set P_set (U) of U, a complement Ac of a set A, the empty set ∅ and the full set Ω. In a type theory every object should have a type. So when we introduce a variable or a constant we indicate its type immediately after its name (the type is separated from the name by a colon). The Library has definitions of set operations such as Union (B C), Intersection (B C) and Setminus (B C), which In the second to last step we used the rule for we denote B∪C, B∩C and B\C, respectively. conjunction introduction. As usual, B⊆C means ∀ω: U, (ω∈B → ω∈C), that is 2) Clearly, this statement does not hold in a ∀ω: U, ( Bω→Cω). The Extensionality axiom from constructive theory. So in the second part of the COIC/COQ can be written as: following derivation we use a classical logic.

210 Farida Kachapova / Journal of Mathematics and Statistics 2018, Volume 14: 209.218 DOI: 10.3844/jmssp.2018.209.218

c c Thus, ∪ An is defined as ∩ ()An , which means n∈N ( n∈N ) we are using a classical logic. Lemma 2.3

c c 1) ∩An= ∪ λ nnatAn: . () . ( n∈N) n ∈ N () c c 2) ∪An= ∩ λ nnatAn: . () . ( n∈N) n ∈ N () Proof Follows from the definitions. ■ We will use the expression " An are disjoint" as an abbreviation for (∀i j: nat , i ≠ j → Ai ∩ Aj = ∅). 2.1. Definition of Probability Space In the Kolmogorov's axiomatics a probability space is defined as a triple ( U, F, P), where U is a sample space, F is a sigma-field of subsets of U and P is a probability measure on ( U, F). So first we define a sigma-field F as a collection of subsets of U In the line with a4 we are using the classical axiom for satisfying three given conditions: elimination of double negation, dne : ∀A: Prop , ¬¬ A→A. In the last line we are using the Extensionality axiom (2). ■ Lemma 2.2 1) ∅c = Ω. 2) ∀B: P_set (U), B∪Bc = Ω. 3) ∀B: P_set (U), B∩Bc = ∅. 4) ∀B C : P_set (U), (B∪C)c = Bc∩Cc. 5) ∀B C : P_set (U), (B∩C)c = Bc∪Cc.

Proof Similarly to the previous lemma, the proofs are derived by using definitions and lemmas from the Ensembles sub-library of the Library. ■ Next we define a countable intersection ∩ An and a n∈N countable union ∪ An : n∈N

211 Farida Kachapova / Journal of Mathematics and Statistics 2018, Volume 14: 209.218 DOI: 10.3844/jmssp.2018.209.218

Theorem 2.4. Properties of a Sigma-Field. Theorem 2.5. Properties of a Probability Measure. Suppose F is a sigma-field on U. Then the Suppose ( U, F, P) is a probability space. Then the following hold. following hold:

1) ∅∈F. 1) P(∅) = 1. 2) ∀B C : P_set (U), B∈F ∧ C∈F → B∩C∈F. 3) ∀B C : P_set (U), B∈F ∧C∈F→B\C∈F. 2) ∀B C : P_set (U); ( B∈F ∧ C∈F ∧ B∩C = ∅) 4) ∀A: nat → P_set (U), (∀n: nat , An ∈F)→ ∪ An ∈ F. → P(B∪C) = P(B) + P(C). n∈N n n n  ΛBF ∈ ∧ΛΛ BB ∩ =∅  5) ∀B C : P_set (U), B∈F∧C∈F→B∪C∈F. 3) ∀B1,..., Bn: P_set (U), i i j i=1 i = 1 j = 1 ()  j≠ i  Proof → P(B1∪... ∪Bn) = P(B1) + ... + P(Bn).

1) Follows from the sigma _1 and sigma _2 conditions c 4) ∀B: P_set (U), B∈F→ P(B ) = 1 - P(B). and Lemma 2.1.1). 2) Suppose B∈F ∧ C∈F. Denote A0 = B and An = C 5) ∀B C : P_set (U), B∈F ∧ C∈F for n ≥ 1. Then (∀n: nat , An ∈ F) and by the sigma _3 → P(B∪C) = P(B) + P(C) - P(B∩C). condition ∩ An ∈F, that is B∩C∈F. n∈N 6) ∀A: nat → P_set (U), (∀n: nat, An ∈F) ∧ 3) Follows from the sigma _2 condition and part 2), P An= lim P AN c (∀n: nat , A(n + 1) ⊆ An ) → ∩ () . since B\C = B∩C . ( n∈N ) N →∞ 4) This is proven using the sigma _2 and sigma _3 c Proof c conditions, since ∪An= ∩ () An . n∈N( n ∈ N ) 1) Denote A0 = Ω and An = ∅ for n ≥ 1. Then 5) Suppose B∈F ∧ C∈F. Then Bc∈F and Cc∈F. By (∀n: nat, An ∈F) and An are disjoint. We have: part 2) and Lemma 2.2.4), ( B∪C)c ∈ F, so (( B∪C)c)c∈F Ω = ∪ An and by Lemma 2.1.2), B∪C ∈ F. ■ n∈N

In the following diagram we define a probability and by the prob _1 and prob _3 conditions: measure on ( U, F) and a probability space ( U, F, P) following the Kolmogorov's axiomatic definition. ∞ ∞ 1=Ω=P()()()()∑ PAnP =Ω+ ∑ P ∅ , so n=0 n = 1 ∞ 1= 1 +∑ P() ∅ . n=1

Since P(∅) ≥ 0, we get P(∅) = 0. 2) Denote A0 = B, A1 = C and An = ∅ for n > 1. Then An are disjoint and (∀n: nat , An ∈ F). We have:

B∪ C = ∪ An , n∈N

so by the prob _3 condition:

∞ PBC()()()()()()∪=∑ PAn = PB + PC +=0 PB + PC , n=0

since P(∅) = 0 by part 1). 3) This is proven by an external induction on n using part 2). 4) By Lemma 2.2.2), 3), B∪Bc = Ω and B∩Bc = ∅. By part 2),

PB+ PBc =Ω= P soPB c =− PB ( ) ( ) ( ) 1,( ) 1( ) .

212 Farida Kachapova / Journal of Mathematics and Statistics 2018, Volume 14: 209.218 DOI: 10.3844/jmssp.2018.209.218

5) C = ( B∩C)∪(C\B) and ( B∩C)∩(C\B) = ∅. By part 3. Random Variables 2), P(C) = P(B∩C) + P(C\B) and As in the rigorous probability theory, we define a random variable X in the following diagram as a real- PCB( \) = PC( ) − PB( ∩ C ) . (3) valued function of outcomes such that each set of the form {ω : U | Xω ≤ x} is an event (an element of the B∪C = B∪(C\B) and B∩(C\B) = ∅. So by part 2) and sigma-field F). (3),

PB( ∪= C) PB( ) + PCB( \) = PB( ) + PC( ) −∩ PB( C ) .

6) Denote B = λn: nat .(An )c and C = λn: nat .(Bn \B(n- 1)) with C0 = B0. Then Cn are disjoint and

c c   ∪∪∪Cn= Bn =() An =  ∩ An  , nnn∈∈∈NNN n ∈ N 

c As was mentioned in subsection 2.1, {ω : U | Xω ≤   ∪Cn=  ∩ An  . (4) x} is the notation for the predicate ( λω :U. Xω ≤ x) of n∈N n ∈ N  type U→ Prop .

Similarly, Theorem 3.1. Properties of a Random Variable. Suppose F is a sigma-field on U, X is a random N N c   c x ∈ R ∪Cn= ∩ An  = () AN , (5) variable and . Then the following hold: n=0 n = 0  1) {ω : U | Xω > x}∈F. since each A(n + 1) ⊆ An. 2) {ω : U | Xω ≥ x}∈F. 3) {ω : U | Xω < x}∈F. By (4), (5), parts 3), 4), and the definition of 4) {ω : U | Xω = x}∈F. probability measure, Proof c       ∞ 1−P An = P An  = P Cn = P Cn 1) This is proven by applying the sigma _2 condition, ∩  ∩    ∪  ∑ () n∈N  n ∈ N    n ∈ N  n=0 since N N   c c =limP Cn = lim P Cn = lim P AN ω:|UX ω> x = ω :| UX ω ≤ x . N→∞∑ ()() N →∞∪  N →∞ () {}{} n=0 n=0 

=1 − limP AN . N →∞ () 2) Follows from the sigma _3 condition and part 1), since

1  So ωω:|UXx≥= ωω :| UXx >−  . {} ∩ n   n∈N +1  1−=−P An 1 lim P AN and P An = lim P AN . ∩N →∞ ()()  ∩ N →∞ n∈N n ∈ N 3) Follows from the sigma _2 condition and part 2), since ■

The following diagram defines independence of two c events in a probability space. {}{}ω:|UX ω< x = ω :| UX ω ≥ x .

4) Follows from part 2) and Theorem 2.4.2) because

{ωω:|UX== x} { ωω :| UX ≤∩ x} { ωω :| UX ≥ x } . ■

In the following diagram we formally define the (cumulative ) distribution function FX of a random variable X.

213 Farida Kachapova / Journal of Mathematics and Statistics 2018, Volume 14: 209.218 DOI: 10.3844/jmssp.2018.209.218

This definition says: a random variable X is discrete if there exist a function g: U → nat and an injective function f: nat → R such that X = f○g. In other words, the set of values of X is {fi | i∈ image (g)}, which is a finite set or a countable set, depending on the cardinality of the subset image (g) of N . The function mX is called the mass function of the discrete random variable X. Clearly, if x is not a value of X, then

Theorem 3.2. Properties of a Distribution Function . {ω : U | Xω = x} = ∅ and mX(x) = 0. Suppose ( U, F, P) is a probability space and X is a random variable. Then the following hold. Theorem 4.1. Properties of a Discrete Random Variable. R 1) ∀x: , 0 ≤ FX (x) ≤ 1. Suppose Discr_var (X, f, g ) as in the previous R 2) ∀x y: , x < y → FX (x) ≤ FX (y), that is the definition. Then the following hold. function FX is non-decreasing. 3) lim FX (x) = 0. R x → − ∞ 1) ∀x: , 0 ≤ mX (x) ≤ 1. ∞ ∞ 4) lim FX (x) = 1. = x→ ∞ 2) ∑mX () fn ∑ P ({ω : U | Xω = fn }) = 1. n=0 n = 0 5) ∀x: R , lim FX (t) = FX (x), that is the function FX is ∞ t→ x + 3) ∀x: R , FX (x) = ∑ P ({ω : U | Xω = fn ∧ fn ≤ x}). right-continuous. n=0 6) ∀x: R , P({ω : U | Xω < x}) = lim FX (t). t→ x − Proof 7) ∀x y : R , x < y → P({ω : U | x < Xω ≤ y}) = FX (y) − FX (x). 1) Follows from Theorem 3.1.4) and the prob _1 condition, since 8) ∀x: R , P({ω : U | Xω = x}) = FX (x) − lim FX (t). t→ x − 9) ∀x: R , P({ω : U | Xω > x}) = 1 − FX (x). mxP=ω UX ω = x X ( ) ({ : |}) . Proof 2) Denote A = λn: nat .{ ω : U | Xω = fn }. Since f is The theorem is proven using the definitions, ω ω Theorem 3.1 and the theory of real numbers injective, An are disjoint. For any : U, X = fn for n = developed in the Library. ■ gω, so we have Ω = ∪ An and by the prob _3 condition: n∈N

4. Discrete Random Variables ∞ ∞ ∞ =Ω= =ω ω == 1P()(){}∑ PAn ∑ P() :| UX fn ∑ mfnX () . 4.1. Definition of a Discrete Random Variable n=0 n = 0 n = 0

A random variable X is discrete if its set of values is 3) Denote B = {ω : U | Xω ≤ x}. Clearly, finite or countable. This is formally expressed in the Ω =∪{ω:U | X ω = fn } and diagram below: n∈N

BB=∩Ω=∪( B ∩{ω: UX | ω = fn}) = ∪ Cn , n∈N n ∈ N

where Cn = {ω : U | Xω = fn ∧ fn ≤ x}. Since Cn are disjoint, ∞ ∞ == =ω ω =∧≤ FxX ()()(){} PB∑ PCn ∑ P(): UX | fnfnx . n=0 n = 0 ■ 4.2. Numerical Characteristics of Discrete Random Variables In the following diagram we define the expectation, variance and standard deviation of a discrete random variable X.

214 Farida Kachapova / Journal of Mathematics and Statistics 2018, Volume 14: 209.218 DOI: 10.3844/jmssp.2018.209.218

In ordinary mathematical notations: E(X +Y) = E(X) + E(Y).

4) ∀y: R , Exp D (X, y) ∧ (∀ω : U, Xω ≥ 0) → y ≥ 0. In ordinary mathematical notations: X ≥ 0 → E(X) ≥ 0.

5) ∀x y : R , Exp D (X, x) ∧ Exp D (Y, y) ∧ (∀ω : U, Xω ≤ Yω) → x ≤ y. In ordinary mathematical notations: X ≤ Y→E(X) ≤ E(Y). Proof Follows from the definitions and properties of sums and series of real numbers. ■ Theorem 4.4. Properties of Variance. Suppose ( U, F, P) is a probability space and X is a discrete random variable. Then the following hold.

1) ∀y: R , Var D (X, y) → y ≥ 0. In ordinary mathematical notations: Var (X) ≥ 0.

2) ∀c: R , Var D (λω : U.c, 0). In ordinary mathematical notations: Var (c) = 0.

3) ∀y c : R , Var D (X, y) → Var D (λω : U.(Xω + c), y). The notations Exp D(X, y), Var D(X, z) and In ordinary mathematical notations: Var (X + c) = Var (X). D St _dev (X, s) mean: y is the expectation, z is the 2 4) ∀y c : R , Var D (X, y) → Var D (λω : U.(c⋅Xω), c ⋅y). variance and s is the standard deviation of the discrete 2 random variable X, respectively. In ordinary mathematical notations: Var (cX ) = c Var (X).

2 5) ∀y z : R , Exp D (X, y) ∧ Exp D (λω : U. (Xω) , z) Theorem 4.2. Expectation Property of a Discrete 2 Variable. → Var D (X, z - y ).

In ordinary mathematical notations: Var (X) = E(X 2) - Suppose ( U, F, P) is a probability space and 2 Discr_var (X, f, g ). Then (E(X) ).

Proof ∀h:R → R ,[ Discr _ varh(  Xh ,,  fg ) → Follows from the definition of variance and ∀R  → z:,( ExpD () h Xz , Theorem 4.3. ■ ∞ z=∑ h() fn ⋅ P({ω : U | X ω = fn }))]. Theorem 4.5. Properties of Standard Deviation. n=0 Suppose ( U, F, P) is a probability space and X is a discrete random variable. Then the following hold. Proof Follows from the definitions. ■ 1) ∀s: R , St _dev D (X, s) → s ≥ 0. In ordinary mathematical notations: σ(X) ≥ 0. Theorem 4.3. Properties of Expectation. 2) ∀c: R , St_dev D (λω : U.c, 0). Suppose ( U, F, P) is a probability space and X is a In ordinary mathematical notations: σ(c) = 0. discrete random variable. Then the following hold. 3) ∀s c : R , St _dev D (X, s) R 1) ∀y c : , Exp D (X, y)→ Exp D (λω : U.(c⋅Xω), c⋅y). → St _dev D (λω : U.(Xω + c), s). In ordinary mathematical notations: E(cX ) = cE (X). In ordinary mathematical notations: σ(X + c) = σ(X). 2) ∀c: R , Exp D (λω : U.c, c). In ordinary mathematical notations: E(c) = c. 4) ∀s c : R , St _dev D (X, s) → St _dev D (λω : U.(c⋅Xω), |c|⋅s). 3) ∀x y : R , Exp D (X, x) ∧ Exp D (Y, y) → Exp D (X + Y, x + y). In ordinary mathematical notations: σ(cX ) = |c|σ(X).

215 Farida Kachapova / Journal of Mathematics and Statistics 2018, Volume 14: 209.218 DOI: 10.3844/jmssp.2018.209.218

R Proof ∀yza:,[0 a >∧ ExpD( Xy ,) ∧ Var D ( Xz , ) Follows from the definition and previous theorem. ■ →ω ω −≥≤ z P(){}: UX | | ya |2 ]. Theorem 4.6. Markov Inequality. a Suppose ( U, F, P) is a probability space and X is a Proof discrete random variable. Then Assume all the hypotheses. 2 Denote Y = λω : U.(Xω - y) . Then Y is also a discrete ∀R >∧ ∧∀ω ω ≥ y c:,[0 c ExpD ( X , y) ( :, U X 0 ) random variable and by the definition of variance, we y have Exp D (Y, z). Applying the Markov inequality →P(){}ω:| UX ω ≥ c ≤ ]. 2 c (Theorem 4.6) to Y and a we get:

z Proof Pω: UY | ω ≥ a 2 ≤ . (){} a2 (7) Assume all the hypotheses. Then

2 2 2 ≥ ≥ ∞ The inequality Yω a is equivalent to ( Xω - y) a ≥ y=∑ fnP ⋅(){}ω: UX | ω = fn , so and to |Xω - y| a, so n=0 2 ∞ P({ωω:| UY≥= a}) P{} ω :|| UX ω −≥ ya | y= fnP ⋅ω: UX | ω = fn ∑ (){} n=0 fn≥ c and from (7): ∞ + ⋅ω ω = ∑ fnP(){}: UX | fn ω ω − ≥ ≤ z n=0 (6) P(){}:|| UX ya |2 . ■ 0≤fn < c a ∞ +∑ fnP ⋅(){}ω: UX | ω = fn . 5. Random Vectors n=0 fn <0 5.1. Joint Distribution

We have (∀ω : U, Xω ≥ 0), so for any fn < 0, In the following diagram we define the joint distribution function FXY of two random variables X {ω : U | Xω = fn } = ∅ and all probabilities in the last and Y; in the same diagram we define the sum in (6) equal 0. Clearly, independence of X and Y.

∞ ∑ fn⋅ P(){}ω:| U X ω = fn ≥ 0. n=0 0≤fn < c

Since f is injective by the definition of a discrete random variable, the events {ω : U | Xω = fn } are disjoint and as in Theorem 4.1.3), we have for the first sum in (6):

∞ ∞ ∑fnP⋅(){}ωω:| UX =≥ fn c ∑ P(){} ωω :| UX = fn n=0 n = 0 fn≥ c fn≥ c ∞ The joint distribution function of n random variables =cPωω:| UX =∧≥= fnfnc cP ωω :|. UX ≥ c ∑ (){} (){} X1, X2, ..., Xn can be defined similarly. n=0 Theorem 5.1. Properties of a Joint Distribution Therefore y ≥ cP ({ω : U | Xω ≥ c}) and P({ω : U | Function. y Xω ≥ c}) ≤ . ■ c Suppose ( U, F, P) is a probability space, X and Y are random variables. Then the following hold. Theorem 4.7. Chebychev Inequality. 1) ∀x y : R , 0≤ FXY (x, y) ≤ 1. Suppose ( U, F, P) is a probability space and X is a 2) ∀y: R, lim FXY (x, y) = 0. discrete random variable. Then: x → − ∞

216 Farida Kachapova / Journal of Mathematics and Statistics 2018, Volume 14: 209.218 DOI: 10.3844/jmssp.2018.209.218

3) ∀x: R, lim FXY (x, y) = 0. 6) ∀y z : R , Cov D (X, Y, y) ∧ Cov D (X, Z, z) y → − ∞ → Cov D (X, Y + Z, y + z). 4) ∀y: R, lim FXY (x, y) = FY (y). x → ∞ In ordinary mathematical notations: Cov (X, Y + Z)

5) ∀x: R, lim FXY (x, y) = FX (x). = Cov (X, Y) + Cov (X, Z). y → ∞ 7) ∀x y z : R , St _dev D (X, x) ∧ St _dev D (Y, y) Proof ∧ Cov D (X, Y, z) → |z| ≤ x⋅y. The theorem is proven using the definitions and the In ordinary mathematical notations: |Cov (X, Y)| ≤ σ(X)⋅σ(Y). theory of real numbers developed in the Library. ■ 5.2. Covariance and Correlation Coefficient 8) ∀x y z : R , Var D(X, x) ∧ Var D (Y, y) ∧ Cov D (X, Y, z) → Var D (X + Y, x + y + 2 z). In the following diagram we define the covariance In ordinary mathematical notations: Var (X + Y) and correlation coefficient of two discrete random = Var (X) + Var (Y) + 2 Cov (X, Y). variables. 9) Indep _var (X, Y) → ∀z: R , (Cov D (X, Y, z) → z = 0) ∧∀x y : R , [Var D (X, x) ∧ Var D (Y, y) → Var D (X + Y, x + y)].

In ordinary mathematical notations: for independent X and Y, Cov (X, Y) = 0 and Var (X + Y) = Var (X) + Var (Y).

10) ∀x y z : R , Exp D (X, x) ∧ Exp D (Y, y) ∧ Exp D(X⋅Y, z) → Cov D (X, Y, z − x⋅y).

In ordinary mathematical notations: Cov (X, Y) = E(X⋅Y) − E(X)⋅E(Y). Proof Follows from the definitions and previous theorems about variance and standard deviation. ■ Theorem 5.3. Properties of Correlation Coefficient. Suppose ( U, F, P) is a probability space, X and Y are random variables. Then the following hold.

1) ∀r: R , Cor _ct D (X, Y, r) → Cor _ct D (Y, X, r). Theorem 5.2. Properties of Covariance In ordinary mathematical notations: ρ (X, Y) = ρ (Y, X).

Suppose ( U, F, P) is a probability space, X, Y and Z 2) ∀y: R , Var D (X, y) ∧ y > 0 → Cor _ct D (X, X, 1). are random variables. Then the following hold. In ordinary mathematical notations: ρ (X, X) = 1.

1) ∀y: R , Cov D (X, Y, z) → Cov D (Y, X, z). 3) ∀r: R , Cor _ct D (X, Y, r) → −1 ≤ r ≤ 1. In ordinary mathematical notations: In ordinary mathematical notations: −1 ≤ ρ (X, Y) ≤ 1. Cov (X, Y) = Cov (Y, X).

4) Indep _var (X, Y)→∀r: R , [ Cor _ct D (X, Y, r)→ r = 0]. 2) ∀z: R ,Cov D (X, X, z) ↔ Var D (X, z). In ordinary mathematical notations: for independent X In ordinary mathematical notations: Cov (X, X) = Var (X). and Y, ρ (X, Y) = 0. ∀ R → 3) z c : , Cov D (X, λω : U.c, z) z = 0. Proof In ordinary mathematical notations: Cov (X, c) = 0. Follows from the previous theorem. ■ 4) ∀z c : R , Cov D (X, Y, z)→Cov D (X, λω:U.(Yω + c), z). In ordinary mathematical notations: C ov (X, Y + c) = Cov (X, Y). 6. Continuous Random Variables 6.1. Definition of a Continuous Random Variable 5) ∀z c : R , Cov D (X, Y, z) → Cov D (X, λω: U.(c⋅Yω), c⋅z). A random variable X is continuous if it has a density In ordinary mathematical notations: Cov (X, cY ) = function. This is formally expressed in the following cCov (X, Y). diagram.

217 Farida Kachapova / Journal of Mathematics and Statistics 2018, Volume 14: 209.218 DOI: 10.3844/jmssp.2018.209.218

distribution function and also the concepts of a discrete random variable and a continuous random variable. We formally introduce the expectation of a random variable, separately for the discrete and continuous cases. We also give formal definitions of other numerical characteristics: variance, standard deviation, covariance and correlation coefficient. We study their properties in detail for the discrete case but not for the continuous case (though most properties should be the same in both cases). We formalize the Markov and Chebychev inequalities. The definitions and initial proofs are presented in the form of flag-style derivations, as in (Nederpelt and 6.2. Numerical Characteristics of Continuous Geuvers, 2014). The rest of the proofs, for readability, Random Variables are made more informal and brief. In the future we are planning to use a universal In the following diagram we define the expectation approach and formally define the expectation of an Exp C (X) of a continuous random variable X. arbitrary random variable (not necessarily discrete or

continuous) using a Lebesgue integral, when the Lebesgue integral is formalized in the COQ library. Other possible directions of future research are producing COQ codes for our formalizations and developing other parts of probability theory within COIC.

Acknowledgment The author thanks the journal’s Editor in Chief for his valuable support of this article.

Other numerical characteristics can be given the same Ethics definitions as for discrete random variables and vectors. This is a mathematical article; no ethical issues can The numerical characteristics of continuous random arise after its publication. variables and vectors should have the same properties as in the discrete case, including the Markov and Chebychev inequalities (and excluding Theorem 4.2). But the proofs References need more work. A better approach would be to use Bertot, Y. and P. Casteran, 2014. Interactive Theorem Lebesgue integral to define an expectation of an arbitrary Proving and Program Development: Coq’Art: The random variable. However, the definition and theory of Calculus of Inductive Constructions. 1st Edn., Lebesgue integral are not developed in COIC/COQ yet, as Springer, ISBN-10: 3662079658, pp: 472. far as we know. It is a task for the future. When Lebesgue Coq Development Team. Reference manual. Standard integral is adequately introduced we will be able to have a Library. https://coq.inria.fr/. universal approach to random variables, instead of Kolmogorov, A.N., 1950. Foundations of the Theory of considering only discrete and continuous variables and Probability. 2nd Edn., Chelsea Publishing Company, using different techniques in defining their expectations. pp: 71. Moreira, D.A.C.V., 2012. Finite probability distributions 7. Conclusion in Coq. In this paper we follow the Kolmogorov's axiomatic mei.di.uminho.pt/sites/default/files/dissertacoes//eeu approach and formalize in the COIC some fundamental m_di_dissertacao_pg16019.pdf concepts of probability theory. First we give a formal Nederpelt, R. and H. Geuvers, 2014. Type Theory and definition of a probability space as a triple of a sample Formal Proof. 1st Edn., Cambridge University space of outcomes, a sigma-field of events and a Press, ISBN-10: 110703650X, pp: 436. probability measure on these events. We derive usual Rosenthal, J.S., 2006. A First Look at Rigorous basic properties of a probability space. Next we Probability Theory. 2nd Edn., World Scientific, formalize the concepts of a random variable and its Singapore, ISBN-10: 9812703713, pp: 219.

218