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
from proveit.logic import And, Equals, Forall, InClass, InSet
from proveit.numbers import Sum, one
from proveit.statistics import Prob, SampleSpaces, prob_domain
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
sub_expr2 = Prob(x)
expr = Lambda(Omega, Equals(InClass(Omega, SampleSpaces), And(Forall(instance_param_or_params = sub_expr1, instance_expr = InSet(sub_expr2, prob_domain), domain = Omega), Equals(Sum(index_or_indices = sub_expr1, summand = sub_expr2, domain = Omega), one))).with_wrapping_at(2))
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(\begin{array}{c} \begin{array}{l} \left(\Omega \underset{{\scriptscriptstyle c}}{\in} \textrm{SampleSpaces}\right) =  \\ \left(\left[\forall_{x \in \Omega}~\left(\textrm{Pr}\left(x\right) \in \left[0,1\right]\right)\right] \land \left(\left[\sum_{x \in \Omega}~\textrm{Pr}\left(x\right)\right] = 1\right)\right) \end{array} \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
0Lambdaparameter: 38
body: 2
1ExprTuple38
2Operationoperator: 15
operands: 3
3ExprTuple4, 5
4Operationoperator: 6
operands: 7
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple38, 10
8Literal
9ExprTuple11, 12
10Literal
11Operationoperator: 13
operand: 17
12Operationoperator: 15
operands: 16
13Literal
14ExprTuple17
15Literal
16ExprTuple18, 36
17Lambdaparameter: 37
body: 19
18Operationoperator: 20
operand: 23
19Conditionalvalue: 22
condition: 28
20Literal
21ExprTuple23
22Operationoperator: 33
operands: 24
23Lambdaparameter: 37
body: 25
24ExprTuple27, 26
25Conditionalvalue: 27
condition: 28
26Operationoperator: 29
operands: 30
27Operationoperator: 31
operand: 37
28Operationoperator: 33
operands: 34
29Literal
30ExprTuple35, 36
31Literal
32ExprTuple37
33Literal
34ExprTuple37, 38
35Literal
36Literal
37Variable
38Variable