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, R, Rx, X, f, fx, x
from proveit.logic import Forall, Functions, Implies, InClass
from proveit.numbers import LessEq
from proveit.statistics import 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, R], instance_expr = Implies(Forall(instance_param_or_params = sub_expr1, instance_expr = Rx, domain = X, condition = Qx), LessEq(ProbOfAll(instance_param_or_params = sub_expr1, instance_element = fx, domain = X, condition = Qx), ProbOfAll(instance_param_or_params = sub_expr1, instance_element = fx, domain = X, condition = Rx)).with_wrapping_at(2)).with_wrapping_at(2)), domain = Functions(X, Omega)).with_wrapping()), 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[\begin{array}{l}\forall_{f \in \left[X \rightarrow \Omega\right]}~\\
\left[\forall_{Q, R}~\left(\begin{array}{c} \begin{array}{l} \left[\forall_{x \in X~|~Q\left(x\right)}~R\left(x\right)\right] \Rightarrow  \\ \left(\begin{array}{c} \begin{array}{l} \left[\textrm{Prob}_{x \in X~|~Q\left(x\right)}~f\left(x\right)\right] \leq  \\ \left[\textrm{Prob}_{x \in X~|~R\left(x\right)}~f\left(x\right)\right] \end{array} \end{array}\right) \end{array} \end{array}\right)\right]\end{array}\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: 29
body: 3
2ExprTuple29
3Conditionalvalue: 4
condition: 5
4Operationoperator: 32
operand: 9
5Operationoperator: 7
operands: 8
6ExprTuple9
7Literal
8ExprTuple29, 10
9Lambdaparameter: 62
body: 12
10Literal
11ExprTuple62
12Operationoperator: 32
operand: 14
13ExprTuple14
14Lambdaparameter: 51
body: 16
15ExprTuple51
16Conditionalvalue: 17
condition: 18
17Operationoperator: 32
operand: 21
18Operationoperator: 58
operands: 20
19ExprTuple21
20ExprTuple51, 22
21Lambdaparameters: 23
body: 24
22Operationoperator: 25
operands: 26
23ExprTuple57, 60
24Operationoperator: 27
operands: 28
25Literal
26ExprTuple62, 29
27Literal
28ExprTuple30, 31
29Variable
30Operationoperator: 32
operand: 36
31Operationoperator: 34
operands: 35
32Literal
33ExprTuple36
34Literal
35ExprTuple37, 38
36Lambdaparameter: 63
body: 39
37Operationoperator: 41
operand: 43
38Operationoperator: 41
operand: 44
39Conditionalvalue: 56
condition: 47
40ExprTuple43
41Literal
42ExprTuple44
43Lambdaparameter: 63
body: 45
44Lambdaparameter: 63
body: 46
45Conditionalvalue: 48
condition: 47
46Conditionalvalue: 48
condition: 49
47Operationoperator: 52
operands: 50
48Operationoperator: 51
operand: 63
49Operationoperator: 52
operands: 53
50ExprTuple55, 54
51Variable
52Literal
53ExprTuple55, 56
54Operationoperator: 57
operand: 63
55Operationoperator: 58
operands: 59
56Operationoperator: 60
operand: 63
57Variable
58Literal
59ExprTuple63, 62
60Variable
61ExprTuple63
62Variable
63Variable