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, Q, Qx, X, f, fx, x
from proveit.logic import And, Disjoint, Equals, Forall, Injections, SubsetEq, Union
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([A, B, C, X, Q], Conditional(Forall(instance_param_or_params = [f], instance_expr = 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))), domain = Injections(X, Omega)), And(SubsetEq(C, X), Equals(C, Union(A, B)), Disjoint(A, B)))))
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(\left(A, B, C, X, Q\right) \mapsto \left\{\forall_{f \in \left[X \xrightarrow[]{\text{1-to-1}} \Omega\right]}~\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)\right) \textrm{ if } C \subseteq X ,  C = \left(A \cup B\right) ,  \textrm{disjoint}\left(A, B\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
1Lambdaparameters: 2
body: 3
2ExprTuple68, 69, 59, 38, 66
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 57
operands: 8
6Literal
7ExprTuple9
8ExprTuple10, 11, 12
9Lambdaparameter: 56
body: 14
10Operationoperator: 15
operands: 16
11Operationoperator: 22
operands: 17
12Operationoperator: 18
operands: 26
13ExprTuple56
14Conditionalvalue: 19
condition: 20
15Literal
16ExprTuple59, 38
17ExprTuple59, 21
18Literal
19Operationoperator: 22
operands: 23
20Operationoperator: 64
operands: 24
21Operationoperator: 25
operands: 26
22Literal
23ExprTuple27, 28
24ExprTuple56, 29
25Literal
26ExprTuple68, 69
27Operationoperator: 42
operand: 35
28Operationoperator: 31
operands: 32
29Operationoperator: 33
operands: 34
30ExprTuple35
31Literal
32ExprTuple36, 37
33Literal
34ExprTuple38, 39
35Lambdaparameter: 70
body: 40
36Operationoperator: 42
operand: 45
37Operationoperator: 42
operand: 46
38Variable
39Variable
40Conditionalvalue: 52
condition: 44
41ExprTuple45
42Literal
43ExprTuple46
44Operationoperator: 57
operands: 47
45Lambdaparameter: 70
body: 48
46Lambdaparameter: 70
body: 49
47ExprTuple50, 62
48Conditionalvalue: 52
condition: 51
49Conditionalvalue: 52
condition: 53
50Operationoperator: 64
operands: 54
51Operationoperator: 57
operands: 55
52Operationoperator: 56
operand: 70
53Operationoperator: 57
operands: 58
54ExprTuple70, 59
55ExprTuple60, 62
56Variable
57Literal
58ExprTuple61, 62
59Variable
60Operationoperator: 64
operands: 63
61Operationoperator: 64
operands: 65
62Operationoperator: 66
operand: 70
63ExprTuple70, 68
64Literal
65ExprTuple70, 69
66Variable
67ExprTuple70
68Variable
69Variable
70Variable