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 Conditional, ExprTuple, Lambda, Omega, Q, Qx, X, f, fx, x
from proveit.logic import Equals, Forall, InSet, 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(f, Conditional(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)), InSet(f, 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(f \mapsto \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) \textrm{ if } f \in \left[X \xrightarrow[]{\text{1-to-1}} \Omega\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: 37
body: 3
2ExprTuple37
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 38
operands: 8
6Literal
7ExprTuple9
8ExprTuple37, 10
9Lambdaparameter: 40
body: 12
10Operationoperator: 13
operands: 14
11ExprTuple40
12Operationoperator: 15
operands: 16
13Literal
14ExprTuple42, 17
15Literal
16ExprTuple18, 19
17Variable
18Operationoperator: 20
operand: 24
19Operationoperator: 22
operand: 25
20Literal
21ExprTuple24
22Literal
23ExprTuple25
24Lambdaparameter: 43
body: 26
25Lambdaparameter: 43
body: 27
26Conditionalvalue: 34
condition: 29
27Conditionalvalue: 28
condition: 29
28Operationoperator: 30
operand: 34
29Operationoperator: 32
operands: 33
30Literal
31ExprTuple34
32Literal
33ExprTuple35, 36
34Operationoperator: 37
operand: 43
35Operationoperator: 38
operands: 39
36Operationoperator: 40
operand: 43
37Variable
38Literal
39ExprTuple43, 42
40Variable
41ExprTuple43
42Variable
43Variable