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 And, Bijections, Equals, InSet, Injections
from proveit.statistics import ProbOfAll
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [gy]
expr = Lambda([f, g], Conditional(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))), And(InSet(f, Injections(A, Omega)), InSet(g, Bijections(B, A)))))
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(f, g\right) \mapsto \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] \textrm{ if } f \in \left[A \xrightarrow[]{\text{1-to-1}} \Omega\right] ,  g \in \left[B \xrightarrow[\text{onto}]{\text{1-to-1}} A\right]\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
1ExprTuple33, 50
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 34
operands: 7
5Literal
6ExprTuple8, 9
7ExprTuple10, 11
8Operationoperator: 13
operand: 17
9Operationoperator: 13
operand: 18
10Operationoperator: 42
operands: 15
11Operationoperator: 42
operands: 16
12ExprTuple17
13Literal
14ExprTuple18
15ExprTuple33, 19
16ExprTuple50, 20
17Lambdaparameter: 47
body: 21
18Lambdaparameter: 52
body: 22
19Operationoperator: 23
operands: 24
20Operationoperator: 25
operands: 26
21Conditionalvalue: 27
condition: 28
22Conditionalvalue: 29
condition: 30
23Literal
24ExprTuple46, 31
25Literal
26ExprTuple48, 46
27Operationoperator: 33
operand: 47
28Operationoperator: 34
operands: 32
29Operationoperator: 33
operand: 49
30Operationoperator: 34
operands: 35
31Variable
32ExprTuple36, 37
33Variable
34Literal
35ExprTuple38, 39
36Operationoperator: 42
operands: 40
37Operationoperator: 44
operand: 47
38Operationoperator: 42
operands: 43
39Operationoperator: 44
operand: 49
40ExprTuple47, 46
41ExprTuple47
42Literal
43ExprTuple52, 48
44Variable
45ExprTuple49
46Variable
47Variable
48Variable
49Operationoperator: 50
operand: 52
50Variable
51ExprTuple52
52Variable