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, ExprTuple, Function, Lambda, Omega, Q, Qx, f, fx, g, gy, x, y
from proveit.logic import Bijections, Equals, Forall, Injections
from proveit.statistics import ProbOfAll
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [gy]
expr = ExprTuple(Lambda([A, B, Q], 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()))
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, Q\right) \mapsto \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]\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
2ExprTuple52, 54, 50
3Operationoperator: 4
operand: 6
4Literal
5ExprTuple6
6Lambdaparameters: 7
body: 8
7ExprTuple39, 56
8Conditionalvalue: 9
condition: 10
9Operationoperator: 11
operands: 12
10Operationoperator: 40
operands: 13
11Literal
12ExprTuple14, 15
13ExprTuple16, 17
14Operationoperator: 19
operand: 23
15Operationoperator: 19
operand: 24
16Operationoperator: 48
operands: 21
17Operationoperator: 48
operands: 22
18ExprTuple23
19Literal
20ExprTuple24
21ExprTuple39, 25
22ExprTuple56, 26
23Lambdaparameter: 53
body: 27
24Lambdaparameter: 58
body: 28
25Operationoperator: 29
operands: 30
26Operationoperator: 31
operands: 32
27Conditionalvalue: 33
condition: 34
28Conditionalvalue: 35
condition: 36
29Literal
30ExprTuple52, 37
31Literal
32ExprTuple54, 52
33Operationoperator: 39
operand: 53
34Operationoperator: 40
operands: 38
35Operationoperator: 39
operand: 55
36Operationoperator: 40
operands: 41
37Variable
38ExprTuple42, 43
39Variable
40Literal
41ExprTuple44, 45
42Operationoperator: 48
operands: 46
43Operationoperator: 50
operand: 53
44Operationoperator: 48
operands: 49
45Operationoperator: 50
operand: 55
46ExprTuple53, 52
47ExprTuple53
48Literal
49ExprTuple58, 54
50Variable
51ExprTuple55
52Variable
53Variable
54Variable
55Operationoperator: 56
operand: 58
56Variable
57ExprTuple58
58Variable