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 Bijections, Equals, Forall, Implies, InClass
from proveit.statistics import Prob, SampleSpaces
In [2]:
# build up the expression from sub-expressions
expr = Lambda(Omega, Conditional(Forall(instance_param_or_params = [X, Y], instance_expr = 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)])), 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_{X, Y}~\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] \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: 39
body: 2
1ExprTuple39
2Conditionalvalue: 3
condition: 4
3Operationoperator: 23
operand: 7
4Operationoperator: 25
operands: 6
5ExprTuple7
6ExprTuple39, 30
7Lambdaparameters: 36
body: 8
8Operationoperator: 23
operand: 10
9ExprTuple10
10Lambdaparameters: 11
body: 12
11ExprTuple53, 54
12Conditionalvalue: 13
condition: 14
13Operationoperator: 15
operands: 16
14Operationoperator: 17
operands: 18
15Literal
16ExprTuple19, 20
17Literal
18ExprTuple21, 22
19Operationoperator: 23
operand: 29
20Operationoperator: 25
operands: 26
21Operationoperator: 43
operands: 27
22Operationoperator: 43
operands: 28
23Literal
24ExprTuple29
25Literal
26ExprTuple40, 30
27ExprTuple53, 31
28ExprTuple54, 32
29Lambdaparameter: 56
body: 33
30Literal
31Operationoperator: 35
operands: 34
32Operationoperator: 35
operands: 36
33Conditionalvalue: 37
condition: 38
34ExprTuple47, 39
35Literal
36ExprTuple47, 40
37Operationoperator: 41
operands: 42
38Operationoperator: 43
operands: 44
39Variable
40Variable
41Literal
42ExprTuple45, 46
43Literal
44ExprTuple56, 47
45Operationoperator: 49
operand: 51
46Operationoperator: 49
operand: 52
47Variable
48ExprTuple51
49Literal
50ExprTuple52
51Operationoperator: 53
operand: 56
52Operationoperator: 54
operand: 56
53Variable
54Variable
55ExprTuple56
56Variable