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 Conditional, Lambda, Omega, X, Y, f, fx, g, gx, x
from proveit.logic import And, Bijections, Equals, Forall, Implies, InClass, InSet
from proveit.statistics import Prob, SampleSpaces
In [2]:
# build up the expression from sub-expressions
expr = Lambda([f, g], Conditional(Implies(Forall(instance_param_or_params = [x], instance_expr = Equals(Prob(fx), Prob(gx)), domain = X), InClass(Y, SampleSpaces)).with_wrapping_at(1), And(InSet(f, Bijections(X, Omega)), InSet(g, 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(f, g\right) \mapsto \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} \textrm{ if } 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]\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
1ExprTuple43, 44
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9, 10
7Literal
8ExprTuple11, 12
9Operationoperator: 13
operand: 19
10Operationoperator: 15
operands: 16
11Operationoperator: 33
operands: 17
12Operationoperator: 33
operands: 18
13Literal
14ExprTuple19
15Literal
16ExprTuple30, 20
17ExprTuple43, 21
18ExprTuple44, 22
19Lambdaparameter: 46
body: 23
20Literal
21Operationoperator: 25
operands: 24
22Operationoperator: 25
operands: 26
23Conditionalvalue: 27
condition: 28
24ExprTuple37, 29
25Literal
26ExprTuple37, 30
27Operationoperator: 31
operands: 32
28Operationoperator: 33
operands: 34
29Variable
30Variable
31Literal
32ExprTuple35, 36
33Literal
34ExprTuple46, 37
35Operationoperator: 39
operand: 41
36Operationoperator: 39
operand: 42
37Variable
38ExprTuple41
39Literal
40ExprTuple42
41Operationoperator: 43
operand: 46
42Operationoperator: 44
operand: 46
43Variable
44Variable
45ExprTuple46
46Variable