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, Conditional, ExprTuple, Function, Lambda, Omega, Q, Qx, f, fx, g, gy, x, y
from proveit.logic import Bijections, Equals, Forall, InClass, Injections
from proveit.statistics import ProbOfAll, SampleSpaces
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [gy]
expr = ExprTuple(Lambda(Omega, Conditional(Forall(instance_param_or_params = [A, B, Q], instance_expr = Forall(instance_param_or_params = [f, g], instance_expr = Equals(ProbOfAll(instance_param_or_params = [x], instance_element = fx, domain = A, condition = Qx), ProbOfAll(instance_param_or_params = [y], instance_element = Function(f, sub_expr1), domain = B, condition = Function(Q, sub_expr1))), domains = [Injections(A, Omega), Bijections(B, A)]).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\{\forall_{A, B, Q}~\left[\begin{array}{l}\forall_{f \in \left[A \xrightarrow[]{\text{1-to-1}} \Omega\right], g \in \left[B \xrightarrow[\text{onto}]{\text{1-to-1}} A\right]}~\\
\left(\left[\textrm{Prob}_{x \in A~|~Q\left(x\right)}~f\left(x\right)\right] = \left[\textrm{Prob}_{y \in B~|~Q\left(g\left(y\right)\right)}~f\left(g\left(y\right)\right)\right]\right)\end{array}\right] \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: 46
body: 3
2ExprTuple46
3Conditionalvalue: 4
condition: 5
4Operationoperator: 13
operand: 9
5Operationoperator: 7
operands: 8
6ExprTuple9
7Literal
8ExprTuple46, 10
9Lambdaparameters: 11
body: 12
10Literal
11ExprTuple61, 63, 59
12Operationoperator: 13
operand: 15
13Literal
14ExprTuple15
15Lambdaparameters: 16
body: 17
16ExprTuple48, 65
17Conditionalvalue: 18
condition: 19
18Operationoperator: 20
operands: 21
19Operationoperator: 49
operands: 22
20Literal
21ExprTuple23, 24
22ExprTuple25, 26
23Operationoperator: 28
operand: 32
24Operationoperator: 28
operand: 33
25Operationoperator: 57
operands: 30
26Operationoperator: 57
operands: 31
27ExprTuple32
28Literal
29ExprTuple33
30ExprTuple48, 34
31ExprTuple65, 35
32Lambdaparameter: 62
body: 36
33Lambdaparameter: 67
body: 37
34Operationoperator: 38
operands: 39
35Operationoperator: 40
operands: 41
36Conditionalvalue: 42
condition: 43
37Conditionalvalue: 44
condition: 45
38Literal
39ExprTuple61, 46
40Literal
41ExprTuple63, 61
42Operationoperator: 48
operand: 62
43Operationoperator: 49
operands: 47
44Operationoperator: 48
operand: 64
45Operationoperator: 49
operands: 50
46Variable
47ExprTuple51, 52
48Variable
49Literal
50ExprTuple53, 54
51Operationoperator: 57
operands: 55
52Operationoperator: 59
operand: 62
53Operationoperator: 57
operands: 58
54Operationoperator: 59
operand: 64
55ExprTuple62, 61
56ExprTuple62
57Literal
58ExprTuple67, 63
59Variable
60ExprTuple64
61Variable
62Variable
63Variable
64Operationoperator: 65
operand: 67
65Variable
66ExprTuple67
67Variable