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, 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 = 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(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]
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameters: 1
body: 2
1ExprTuple51, 53, 49
2Operationoperator: 3
operand: 5
3Literal
4ExprTuple5
5Lambdaparameters: 6
body: 7
6ExprTuple38, 55
7Conditionalvalue: 8
condition: 9
8Operationoperator: 10
operands: 11
9Operationoperator: 39
operands: 12
10Literal
11ExprTuple13, 14
12ExprTuple15, 16
13Operationoperator: 18
operand: 22
14Operationoperator: 18
operand: 23
15Operationoperator: 47
operands: 20
16Operationoperator: 47
operands: 21
17ExprTuple22
18Literal
19ExprTuple23
20ExprTuple38, 24
21ExprTuple55, 25
22Lambdaparameter: 52
body: 26
23Lambdaparameter: 57
body: 27
24Operationoperator: 28
operands: 29
25Operationoperator: 30
operands: 31
26Conditionalvalue: 32
condition: 33
27Conditionalvalue: 34
condition: 35
28Literal
29ExprTuple51, 36
30Literal
31ExprTuple53, 51
32Operationoperator: 38
operand: 52
33Operationoperator: 39
operands: 37
34Operationoperator: 38
operand: 54
35Operationoperator: 39
operands: 40
36Variable
37ExprTuple41, 42
38Variable
39Literal
40ExprTuple43, 44
41Operationoperator: 47
operands: 45
42Operationoperator: 49
operand: 52
43Operationoperator: 47
operands: 48
44Operationoperator: 49
operand: 54
45ExprTuple52, 51
46ExprTuple52
47Literal
48ExprTuple57, 53
49Variable
50ExprTuple54
51Variable
52Variable
53Variable
54Operationoperator: 55
operand: 57
55Variable
56ExprTuple57
57Variable