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 ExprTuple, Lambda, Omega, Q, Qx, R, Rx, X, f, fx, x
from proveit.logic import Forall, Functions, Implies
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(X, 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()))
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(X \mapsto \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]\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: 53
body: 3
2ExprTuple53
3Operationoperator: 23
operand: 5
4ExprTuple5
5Lambdaparameter: 42
body: 7
6ExprTuple42
7Conditionalvalue: 8
condition: 9
8Operationoperator: 23
operand: 12
9Operationoperator: 49
operands: 11
10ExprTuple12
11ExprTuple42, 13
12Lambdaparameters: 14
body: 15
13Operationoperator: 16
operands: 17
14ExprTuple48, 51
15Operationoperator: 18
operands: 19
16Literal
17ExprTuple53, 20
18Literal
19ExprTuple21, 22
20Variable
21Operationoperator: 23
operand: 27
22Operationoperator: 25
operands: 26
23Literal
24ExprTuple27
25Literal
26ExprTuple28, 29
27Lambdaparameter: 54
body: 30
28Operationoperator: 32
operand: 34
29Operationoperator: 32
operand: 35
30Conditionalvalue: 47
condition: 38
31ExprTuple34
32Literal
33ExprTuple35
34Lambdaparameter: 54
body: 36
35Lambdaparameter: 54
body: 37
36Conditionalvalue: 39
condition: 38
37Conditionalvalue: 39
condition: 40
38Operationoperator: 43
operands: 41
39Operationoperator: 42
operand: 54
40Operationoperator: 43
operands: 44
41ExprTuple46, 45
42Variable
43Literal
44ExprTuple46, 47
45Operationoperator: 48
operand: 54
46Operationoperator: 49
operands: 50
47Operationoperator: 51
operand: 54
48Variable
49Literal
50ExprTuple54, 53
51Variable
52ExprTuple54
53Variable
54Variable