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, Q, Qx, X, f, fx, x
from proveit.logic import Equals, Forall, Functions, SetOfAll
from proveit.statistics import Prob, ProbOfAll
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
expr = Lambda(X, Forall(instance_param_or_params = [f], instance_expr = Forall(instance_param_or_params = [Q], instance_expr = Equals(ProbOfAll(instance_param_or_params = sub_expr1, instance_element = fx, domain = X, condition = Qx), Prob(SetOfAll(instance_param_or_params = sub_expr1, instance_element = fx, domain = X, condition = Qx))).with_wrapping_at(2)), domain = Functions(X, Omega)))
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())
X \mapsto \left[\forall_{f \in \left[X \rightarrow \Omega\right]}~\left[\forall_{Q}~\left(\begin{array}{c} \begin{array}{l} \left[\textrm{Prob}_{x \in X~|~Q\left(x\right)}~f\left(x\right)\right] =  \\ \textrm{Pr}\left(\left\{f\left(x\right)~|~Q\left(x\right)\right\}_{x \in X}\right) \end{array} \end{array}\right)\right]\right]
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 42
body: 2
1ExprTuple42
2Operationoperator: 9
operand: 4
3ExprTuple4
4Lambdaparameter: 33
body: 6
5ExprTuple33
6Conditionalvalue: 7
condition: 8
7Operationoperator: 9
operand: 12
8Operationoperator: 38
operands: 11
9Literal
10ExprTuple12
11ExprTuple33, 13
12Lambdaparameter: 40
body: 15
13Operationoperator: 16
operands: 17
14ExprTuple40
15Operationoperator: 18
operands: 19
16Literal
17ExprTuple42, 20
18Literal
19ExprTuple21, 22
20Variable
21Operationoperator: 23
operand: 29
22Operationoperator: 24
operand: 26
23Literal
24Literal
25ExprTuple26
26Operationoperator: 27
operand: 29
27Literal
28ExprTuple29
29Lambdaparameter: 43
body: 30
30Conditionalvalue: 31
condition: 32
31Operationoperator: 33
operand: 43
32Operationoperator: 34
operands: 35
33Variable
34Literal
35ExprTuple36, 37
36Operationoperator: 38
operands: 39
37Operationoperator: 40
operand: 43
38Literal
39ExprTuple43, 42
40Variable
41ExprTuple43
42Variable
43Variable