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 A, B, C, Conditional, ExprTuple, Lambda, Omega, Qx, X, f, fx, x
from proveit.logic import Equals, InSet, Injections
from proveit.numbers import Add
from proveit.statistics import ProbOfAll
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
expr = ExprTuple(Lambda(f, Conditional(Equals(ProbOfAll(instance_param_or_params = sub_expr1, instance_element = fx, domain = C, condition = Qx), Add(ProbOfAll(instance_param_or_params = sub_expr1, instance_element = fx, domain = A, condition = Qx), ProbOfAll(instance_param_or_params = sub_expr1, instance_element = fx, domain = B, condition = Qx))), 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\{\left[\textrm{Prob}_{x \in C~|~Q\left(x\right)}~f\left(x\right)\right] = \left(\left[\textrm{Prob}_{x \in A~|~Q\left(x\right)}~f\left(x\right)\right] + \left[\textrm{Prob}_{x \in B~|~Q\left(x\right)}~f\left(x\right)\right]\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: 38
body: 3
2ExprTuple38
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operands: 7
5Operationoperator: 46
operands: 8
6Literal
7ExprTuple9, 10
8ExprTuple38, 11
9Operationoperator: 24
operand: 17
10Operationoperator: 13
operands: 14
11Operationoperator: 15
operands: 16
12ExprTuple17
13Literal
14ExprTuple18, 19
15Literal
16ExprTuple20, 21
17Lambdaparameter: 52
body: 22
18Operationoperator: 24
operand: 27
19Operationoperator: 24
operand: 28
20Variable
21Variable
22Conditionalvalue: 34
condition: 26
23ExprTuple27
24Literal
25ExprTuple28
26Operationoperator: 39
operands: 29
27Lambdaparameter: 52
body: 30
28Lambdaparameter: 52
body: 31
29ExprTuple32, 44
30Conditionalvalue: 34
condition: 33
31Conditionalvalue: 34
condition: 35
32Operationoperator: 46
operands: 36
33Operationoperator: 39
operands: 37
34Operationoperator: 38
operand: 52
35Operationoperator: 39
operands: 40
36ExprTuple52, 41
37ExprTuple42, 44
38Variable
39Literal
40ExprTuple43, 44
41Variable
42Operationoperator: 46
operands: 45
43Operationoperator: 46
operands: 47
44Operationoperator: 48
operand: 52
45ExprTuple52, 50
46Literal
47ExprTuple52, 51
48Variable
49ExprTuple52
50Variable
51Variable
52Variable