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, X, f, fx, x
from proveit.logic import Equals, Forall, Functions, SetOfAll
from proveit.statistics import Prob, 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], 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))))
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[\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]\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: 43
body: 3
2ExprTuple43
3Operationoperator: 10
operand: 5
4ExprTuple5
5Lambdaparameter: 34
body: 7
6ExprTuple34
7Conditionalvalue: 8
condition: 9
8Operationoperator: 10
operand: 13
9Operationoperator: 39
operands: 12
10Literal
11ExprTuple13
12ExprTuple34, 14
13Lambdaparameter: 41
body: 16
14Operationoperator: 17
operands: 18
15ExprTuple41
16Operationoperator: 19
operands: 20
17Literal
18ExprTuple43, 21
19Literal
20ExprTuple22, 23
21Variable
22Operationoperator: 24
operand: 30
23Operationoperator: 25
operand: 27
24Literal
25Literal
26ExprTuple27
27Operationoperator: 28
operand: 30
28Literal
29ExprTuple30
30Lambdaparameter: 44
body: 31
31Conditionalvalue: 32
condition: 33
32Operationoperator: 34
operand: 44
33Operationoperator: 35
operands: 36
34Variable
35Literal
36ExprTuple37, 38
37Operationoperator: 39
operands: 40
38Operationoperator: 41
operand: 44
39Literal
40ExprTuple44, 43
41Variable
42ExprTuple44
43Variable
44Variable