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, Q, Qx, R, Rx, X, fx, x
from proveit.logic import Forall, 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([Q, R], 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)))
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(\left(Q, R\right) \mapsto \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)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameters: 2
body: 3
2ExprTuple33, 36
3Operationoperator: 4
operands: 5
4Literal
5ExprTuple6, 7
6Operationoperator: 8
operand: 12
7Operationoperator: 10
operands: 11
8Literal
9ExprTuple12
10Literal
11ExprTuple13, 14
12Lambdaparameter: 39
body: 15
13Operationoperator: 17
operand: 19
14Operationoperator: 17
operand: 20
15Conditionalvalue: 32
condition: 23
16ExprTuple19
17Literal
18ExprTuple20
19Lambdaparameter: 39
body: 21
20Lambdaparameter: 39
body: 22
21Conditionalvalue: 24
condition: 23
22Conditionalvalue: 24
condition: 25
23Operationoperator: 28
operands: 26
24Operationoperator: 27
operand: 39
25Operationoperator: 28
operands: 29
26ExprTuple31, 30
27Variable
28Literal
29ExprTuple31, 32
30Operationoperator: 33
operand: 39
31Operationoperator: 34
operands: 35
32Operationoperator: 36
operand: 39
33Variable
34Literal
35ExprTuple39, 38
36Variable
37ExprTuple39
38Variable
39Variable