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 Lambda, Omega, X, Y, f, fx, g, gx, x
from proveit.logic import Bijections, Equals, Forall, Implies, InClass
from proveit.statistics import Prob, SampleSpaces
In [2]:
# build up the expression from sub-expressions
expr = Lambda([X, Y], Forall(instance_param_or_params = [f, g], instance_expr = Implies(Forall(instance_param_or_params = [x], instance_expr = Equals(Prob(fx), Prob(gx)), domain = X), InClass(Y, SampleSpaces)).with_wrapping_at(1), domains = [Bijections(X, Omega), Bijections(X, Y)]))
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(X, Y\right) \mapsto \left[\forall_{f \in \left[X \xrightarrow[\text{onto}]{\text{1-to-1}} \Omega\right], g \in \left[X \xrightarrow[\text{onto}]{\text{1-to-1}} Y\right]}~\left(\begin{array}{c} \begin{array}{l} \left[\forall_{x \in X}~\left(\textrm{Pr}\left(f\left(x\right)\right) = \textrm{Pr}\left(g\left(x\right)\right)\right)\right] \\  \Rightarrow \left(Y \underset{{\scriptscriptstyle c}}{\in} \textrm{SampleSpaces}\right) \end{array} \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
0Lambdaparameters: 29
body: 1
1Operationoperator: 16
operand: 3
2ExprTuple3
3Lambdaparameters: 4
body: 5
4ExprTuple46, 47
5Conditionalvalue: 6
condition: 7
6Operationoperator: 8
operands: 9
7Operationoperator: 10
operands: 11
8Literal
9ExprTuple12, 13
10Literal
11ExprTuple14, 15
12Operationoperator: 16
operand: 22
13Operationoperator: 18
operands: 19
14Operationoperator: 36
operands: 20
15Operationoperator: 36
operands: 21
16Literal
17ExprTuple22
18Literal
19ExprTuple33, 23
20ExprTuple46, 24
21ExprTuple47, 25
22Lambdaparameter: 49
body: 26
23Literal
24Operationoperator: 28
operands: 27
25Operationoperator: 28
operands: 29
26Conditionalvalue: 30
condition: 31
27ExprTuple40, 32
28Literal
29ExprTuple40, 33
30Operationoperator: 34
operands: 35
31Operationoperator: 36
operands: 37
32Variable
33Variable
34Literal
35ExprTuple38, 39
36Literal
37ExprTuple49, 40
38Operationoperator: 42
operand: 44
39Operationoperator: 42
operand: 45
40Variable
41ExprTuple44
42Literal
43ExprTuple45
44Operationoperator: 46
operand: 49
45Operationoperator: 47
operand: 49
46Variable
47Variable
48ExprTuple49
49Variable