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, Functions, InClass, SetOfAll
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), Prob(SetOfAll(instance_param_or_params = sub_expr1, instance_element = fx, domain = X, condition = Qx))).with_wrapping_at(2)), domain = Functions(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 \rightarrow \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] =  \\ \textrm{Pr}\left(\left\{f\left(x\right)~|~Q\left(x\right)\right\}_{x \in X}\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: 52
body: 12
10Literal
11ExprTuple52
12Operationoperator: 19
operand: 14
13ExprTuple14
14Lambdaparameter: 43
body: 16
15ExprTuple43
16Conditionalvalue: 17
condition: 18
17Operationoperator: 19
operand: 22
18Operationoperator: 48
operands: 21
19Literal
20ExprTuple22
21ExprTuple43, 23
22Lambdaparameter: 50
body: 25
23Operationoperator: 26
operands: 27
24ExprTuple50
25Operationoperator: 28
operands: 29
26Literal
27ExprTuple52, 30
28Literal
29ExprTuple31, 32
30Variable
31Operationoperator: 33
operand: 39
32Operationoperator: 34
operand: 36
33Literal
34Literal
35ExprTuple36
36Operationoperator: 37
operand: 39
37Literal
38ExprTuple39
39Lambdaparameter: 53
body: 40
40Conditionalvalue: 41
condition: 42
41Operationoperator: 43
operand: 53
42Operationoperator: 44
operands: 45
43Variable
44Literal
45ExprTuple46, 47
46Operationoperator: 48
operands: 49
47Operationoperator: 50
operand: 53
48Literal
49ExprTuple53, 52
50Variable
51ExprTuple53
52Variable
53Variable