logo

Expression of type ExprTuple

from the theory of proveit.statistics

In [1]:
import proveit
# Automation is not needed when building an expression:
proveit.defaults.automation = False # This will speed things up.
proveit.defaults.inline_pngs = False # Makes files smaller.
%load_expr # Load the stored expression as 'stored_expr'
# import Expression classes needed to build the expression
from proveit import Conditional, ExprTuple, Lambda, Omega, Q, Qx, X, f, fx, x
from proveit.logic import Equals, Forall, InClass, Injections
from proveit.numbers import Sum
from proveit.statistics import Prob, ProbOfAll, SampleSpaces
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
expr = ExprTuple(Lambda(Omega, Conditional(Forall(instance_param_or_params = [X], instance_expr = Forall(instance_param_or_params = [f], instance_expr = Forall(instance_param_or_params = [Q], instance_expr = Equals(ProbOfAll(instance_param_or_params = sub_expr1, instance_element = fx, domain = X, condition = Qx), Sum(index_or_indices = sub_expr1, summand = Prob(fx), domain = X, condition = Qx)).with_wrapping_at(2)), domain = Injections(X, Omega))), InClass(Omega, SampleSpaces))))
expr:
In [3]:
# check that the built expression is the same as the stored expression
assert expr == stored_expr
assert expr._style_id == stored_expr._style_id
print("Passed sanity check: expr matches stored_expr")
Passed sanity check: expr matches stored_expr
In [4]:
# Show the LaTeX representation of the expression for convenience if you need it.
print(stored_expr.latex())
\left(\Omega \mapsto \left\{\forall_{X}~\left[\forall_{f \in \left[X \xrightarrow[]{\text{1-to-1}} \Omega\right]}~\left[\forall_{Q}~\left(\begin{array}{c} \begin{array}{l} \left[\textrm{Prob}_{x \in X~|~Q\left(x\right)}~f\left(x\right)\right] =  \\ \left[\sum_{x \in X~|~Q\left(x\right)}~\textrm{Pr}\left(f\left(x\right)\right)\right] \end{array} \end{array}\right)\right]\right] \textrm{ if } \Omega \underset{{\scriptscriptstyle c}}{\in} \textrm{SampleSpaces}\right..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameter: 30
body: 3
2ExprTuple30
3Conditionalvalue: 4
condition: 5
4Operationoperator: 19
operand: 9
5Operationoperator: 7
operands: 8
6ExprTuple9
7Literal
8ExprTuple30, 10
9Lambdaparameter: 55
body: 12
10Literal
11ExprTuple55
12Operationoperator: 19
operand: 14
13ExprTuple14
14Lambdaparameter: 50
body: 16
15ExprTuple50
16Conditionalvalue: 17
condition: 18
17Operationoperator: 19
operand: 22
18Operationoperator: 51
operands: 21
19Literal
20ExprTuple22
21ExprTuple50, 23
22Lambdaparameter: 53
body: 25
23Operationoperator: 26
operands: 27
24ExprTuple53
25Operationoperator: 28
operands: 29
26Literal
27ExprTuple55, 30
28Literal
29ExprTuple31, 32
30Variable
31Operationoperator: 33
operand: 37
32Operationoperator: 35
operand: 38
33Literal
34ExprTuple37
35Literal
36ExprTuple38
37Lambdaparameter: 56
body: 39
38Lambdaparameter: 56
body: 40
39Conditionalvalue: 47
condition: 42
40Conditionalvalue: 41
condition: 42
41Operationoperator: 43
operand: 47
42Operationoperator: 45
operands: 46
43Literal
44ExprTuple47
45Literal
46ExprTuple48, 49
47Operationoperator: 50
operand: 56
48Operationoperator: 51
operands: 52
49Operationoperator: 53
operand: 56
50Variable
51Literal
52ExprTuple56, 55
53Variable
54ExprTuple56
55Variable
56Variable