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, Injections
from proveit.numbers import Sum
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), Sum(index_or_indices = sub_expr1, summand = Prob(fx), domain = X, condition = Qx)).with_wrapping_at(2)), domain = Injections(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 \xrightarrow[]{\text{1-to-1}} \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] =  \\ \left[\sum_{x \in X~|~Q\left(x\right)}~\textrm{Pr}\left(f\left(x\right)\right)\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: 46
body: 3
2ExprTuple46
3Operationoperator: 10
operand: 5
4ExprTuple5
5Lambdaparameter: 41
body: 7
6ExprTuple41
7Conditionalvalue: 8
condition: 9
8Operationoperator: 10
operand: 13
9Operationoperator: 42
operands: 12
10Literal
11ExprTuple13
12ExprTuple41, 14
13Lambdaparameter: 44
body: 16
14Operationoperator: 17
operands: 18
15ExprTuple44
16Operationoperator: 19
operands: 20
17Literal
18ExprTuple46, 21
19Literal
20ExprTuple22, 23
21Variable
22Operationoperator: 24
operand: 28
23Operationoperator: 26
operand: 29
24Literal
25ExprTuple28
26Literal
27ExprTuple29
28Lambdaparameter: 47
body: 30
29Lambdaparameter: 47
body: 31
30Conditionalvalue: 38
condition: 33
31Conditionalvalue: 32
condition: 33
32Operationoperator: 34
operand: 38
33Operationoperator: 36
operands: 37
34Literal
35ExprTuple38
36Literal
37ExprTuple39, 40
38Operationoperator: 41
operand: 47
39Operationoperator: 42
operands: 43
40Operationoperator: 44
operand: 47
41Variable
42Literal
43ExprTuple47, 46
44Variable
45ExprTuple47
46Variable
47Variable