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, X, fx, x
from proveit.logic import Equals
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(Q, 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)))
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(Q \mapsto \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)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameter: 28
body: 3
2ExprTuple28
3Operationoperator: 4
operands: 5
4Literal
5ExprTuple6, 7
6Operationoperator: 8
operand: 12
7Operationoperator: 10
operand: 13
8Literal
9ExprTuple12
10Literal
11ExprTuple13
12Lambdaparameter: 31
body: 14
13Lambdaparameter: 31
body: 15
14Conditionalvalue: 22
condition: 17
15Conditionalvalue: 16
condition: 17
16Operationoperator: 18
operand: 22
17Operationoperator: 20
operands: 21
18Literal
19ExprTuple22
20Literal
21ExprTuple23, 24
22Operationoperator: 25
operand: 31
23Operationoperator: 26
operands: 27
24Operationoperator: 28
operand: 31
25Variable
26Literal
27ExprTuple31, 30
28Variable
29ExprTuple31
30Variable
31Variable