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 Disjoint, Equals, Forall, InClass, Injections, SubsetEq, Union
from proveit.numbers import Add
from proveit.statistics import ProbOfAll, SampleSpaces
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
expr = ExprTuple(Lambda(Omega, Conditional(Forall(instance_param_or_params = [A, B, C, X, Q], instance_expr = 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)), conditions = [SubsetEq(C, X), Equals(C, Union(A, B)), Disjoint(A, B)]).with_wrapping(), InClass(Omega, SampleSpaces))))
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(\Omega \mapsto \left\{\begin{array}{l}\forall_{A, B, C, X, Q~|~C \subseteq X, C = \left(A \cup B\right), \textrm{disjoint}\left(A, B\right)}~\\
\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)\right]\end{array} \textrm{ if } \Omega \underset{{\scriptscriptstyle c}}{\in} \textrm{SampleSpaces}\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: 48
body: 3
2ExprTuple48
3Conditionalvalue: 4
condition: 5
4Operationoperator: 15
operand: 9
5Operationoperator: 7
operands: 8
6ExprTuple9
7Literal
8ExprTuple48, 10
9Lambdaparameters: 11
body: 12
10Literal
11ExprTuple77, 78, 68, 47, 75
12Conditionalvalue: 13
condition: 14
13Operationoperator: 15
operand: 18
14Operationoperator: 66
operands: 17
15Literal
16ExprTuple18
17ExprTuple19, 20, 21
18Lambdaparameter: 65
body: 23
19Operationoperator: 24
operands: 25
20Operationoperator: 31
operands: 26
21Operationoperator: 27
operands: 35
22ExprTuple65
23Conditionalvalue: 28
condition: 29
24Literal
25ExprTuple68, 47
26ExprTuple68, 30
27Literal
28Operationoperator: 31
operands: 32
29Operationoperator: 73
operands: 33
30Operationoperator: 34
operands: 35
31Literal
32ExprTuple36, 37
33ExprTuple65, 38
34Literal
35ExprTuple77, 78
36Operationoperator: 51
operand: 44
37Operationoperator: 40
operands: 41
38Operationoperator: 42
operands: 43
39ExprTuple44
40Literal
41ExprTuple45, 46
42Literal
43ExprTuple47, 48
44Lambdaparameter: 79
body: 49
45Operationoperator: 51
operand: 54
46Operationoperator: 51
operand: 55
47Variable
48Variable
49Conditionalvalue: 61
condition: 53
50ExprTuple54
51Literal
52ExprTuple55
53Operationoperator: 66
operands: 56
54Lambdaparameter: 79
body: 57
55Lambdaparameter: 79
body: 58
56ExprTuple59, 71
57Conditionalvalue: 61
condition: 60
58Conditionalvalue: 61
condition: 62
59Operationoperator: 73
operands: 63
60Operationoperator: 66
operands: 64
61Operationoperator: 65
operand: 79
62Operationoperator: 66
operands: 67
63ExprTuple79, 68
64ExprTuple69, 71
65Variable
66Literal
67ExprTuple70, 71
68Variable
69Operationoperator: 73
operands: 72
70Operationoperator: 73
operands: 74
71Operationoperator: 75
operand: 79
72ExprTuple79, 77
73Literal
74ExprTuple79, 78
75Variable
76ExprTuple79
77Variable
78Variable
79Variable