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, Q, Qx, R, Rx, X, fx, x
from proveit.logic import Forall, Implies
from proveit.numbers import LessEq
from proveit.statistics import ProbOfAll
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
expr = Lambda([Q, R], Implies(Forall(instance_param_or_params = sub_expr1, instance_expr = Rx, domain = X, condition = Qx), LessEq(ProbOfAll(instance_param_or_params = sub_expr1, instance_element = fx, domain = X, condition = Qx), ProbOfAll(instance_param_or_params = sub_expr1, instance_element = fx, domain = X, condition = Rx)).with_wrapping_at(2)).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())
\left(Q, R\right) \mapsto \left(\begin{array}{c} \begin{array}{l} \left[\forall_{x \in X~|~Q\left(x\right)}~R\left(x\right)\right] \Rightarrow  \\ \left(\begin{array}{c} \begin{array}{l} \left[\textrm{Prob}_{x \in X~|~Q\left(x\right)}~f\left(x\right)\right] \leq  \\ \left[\textrm{Prob}_{x \in X~|~R\left(x\right)}~f\left(x\right)\right] \end{array} \end{array}\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
0Lambdaparameters: 1
body: 2
1ExprTuple32, 35
2Operationoperator: 3
operands: 4
3Literal
4ExprTuple5, 6
5Operationoperator: 7
operand: 11
6Operationoperator: 9
operands: 10
7Literal
8ExprTuple11
9Literal
10ExprTuple12, 13
11Lambdaparameter: 38
body: 14
12Operationoperator: 16
operand: 18
13Operationoperator: 16
operand: 19
14Conditionalvalue: 31
condition: 22
15ExprTuple18
16Literal
17ExprTuple19
18Lambdaparameter: 38
body: 20
19Lambdaparameter: 38
body: 21
20Conditionalvalue: 23
condition: 22
21Conditionalvalue: 23
condition: 24
22Operationoperator: 27
operands: 25
23Operationoperator: 26
operand: 38
24Operationoperator: 27
operands: 28
25ExprTuple30, 29
26Variable
27Literal
28ExprTuple30, 31
29Operationoperator: 32
operand: 38
30Operationoperator: 33
operands: 34
31Operationoperator: 35
operand: 38
32Variable
33Literal
34ExprTuple38, 37
35Variable
36ExprTuple38
37Variable
38Variable