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, InSet
from proveit.numbers import LessEq
from proveit.statistics import ProbOfAll
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
expr = ExprTuple(Lambda(f, Conditional(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)), InSet(f, Functions(X, Omega)))))
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(f \mapsto \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) \textrm{ if } f \in \left[X \rightarrow \Omega\right]\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: 38
body: 3
2ExprTuple38
3Conditionalvalue: 4
condition: 5
4Operationoperator: 19
operand: 8
5Operationoperator: 45
operands: 7
6ExprTuple8
7ExprTuple38, 9
8Lambdaparameters: 10
body: 11
9Operationoperator: 12
operands: 13
10ExprTuple44, 47
11Operationoperator: 14
operands: 15
12Literal
13ExprTuple49, 16
14Literal
15ExprTuple17, 18
16Variable
17Operationoperator: 19
operand: 23
18Operationoperator: 21
operands: 22
19Literal
20ExprTuple23
21Literal
22ExprTuple24, 25
23Lambdaparameter: 50
body: 26
24Operationoperator: 28
operand: 30
25Operationoperator: 28
operand: 31
26Conditionalvalue: 43
condition: 34
27ExprTuple30
28Literal
29ExprTuple31
30Lambdaparameter: 50
body: 32
31Lambdaparameter: 50
body: 33
32Conditionalvalue: 35
condition: 34
33Conditionalvalue: 35
condition: 36
34Operationoperator: 39
operands: 37
35Operationoperator: 38
operand: 50
36Operationoperator: 39
operands: 40
37ExprTuple42, 41
38Variable
39Literal
40ExprTuple42, 43
41Operationoperator: 44
operand: 50
42Operationoperator: 45
operands: 46
43Operationoperator: 47
operand: 50
44Variable
45Literal
46ExprTuple50, 49
47Variable
48ExprTuple50
49Variable
50Variable