logo

Expression of type Lambda

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, 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 = 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())
\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..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 45
body: 2
1ExprTuple45
2Conditionalvalue: 3
condition: 4
3Operationoperator: 12
operand: 8
4Operationoperator: 6
operands: 7
5ExprTuple8
6Literal
7ExprTuple45, 9
8Lambdaparameters: 10
body: 11
9Literal
10ExprTuple60, 62, 58
11Operationoperator: 12
operand: 14
12Literal
13ExprTuple14
14Lambdaparameters: 15
body: 16
15ExprTuple47, 64
16Conditionalvalue: 17
condition: 18
17Operationoperator: 19
operands: 20
18Operationoperator: 48
operands: 21
19Literal
20ExprTuple22, 23
21ExprTuple24, 25
22Operationoperator: 27
operand: 31
23Operationoperator: 27
operand: 32
24Operationoperator: 56
operands: 29
25Operationoperator: 56
operands: 30
26ExprTuple31
27Literal
28ExprTuple32
29ExprTuple47, 33
30ExprTuple64, 34
31Lambdaparameter: 61
body: 35
32Lambdaparameter: 66
body: 36
33Operationoperator: 37
operands: 38
34Operationoperator: 39
operands: 40
35Conditionalvalue: 41
condition: 42
36Conditionalvalue: 43
condition: 44
37Literal
38ExprTuple60, 45
39Literal
40ExprTuple62, 60
41Operationoperator: 47
operand: 61
42Operationoperator: 48
operands: 46
43Operationoperator: 47
operand: 63
44Operationoperator: 48
operands: 49
45Variable
46ExprTuple50, 51
47Variable
48Literal
49ExprTuple52, 53
50Operationoperator: 56
operands: 54
51Operationoperator: 58
operand: 61
52Operationoperator: 56
operands: 57
53Operationoperator: 58
operand: 63
54ExprTuple61, 60
55ExprTuple61
56Literal
57ExprTuple66, 62
58Variable
59ExprTuple63
60Variable
61Variable
62Variable
63Operationoperator: 64
operand: 66
64Variable
65ExprTuple66
66Variable