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, R, Rx, X, f, fx, x
from proveit.logic import Forall, Functions, 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(X, Forall(instance_param_or_params = [f], instance_expr = Forall(instance_param_or_params = [Q, R], instance_expr = 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)), domain = Functions(X, Omega)).with_wrapping())
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[\begin{array}{l}\forall_{f \in \left[X \rightarrow \Omega\right]}~\\
\left[\forall_{Q, R}~\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)\right]\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: 52
body: 2
1ExprTuple52
2Operationoperator: 22
operand: 4
3ExprTuple4
4Lambdaparameter: 41
body: 6
5ExprTuple41
6Conditionalvalue: 7
condition: 8
7Operationoperator: 22
operand: 11
8Operationoperator: 48
operands: 10
9ExprTuple11
10ExprTuple41, 12
11Lambdaparameters: 13
body: 14
12Operationoperator: 15
operands: 16
13ExprTuple47, 50
14Operationoperator: 17
operands: 18
15Literal
16ExprTuple52, 19
17Literal
18ExprTuple20, 21
19Variable
20Operationoperator: 22
operand: 26
21Operationoperator: 24
operands: 25
22Literal
23ExprTuple26
24Literal
25ExprTuple27, 28
26Lambdaparameter: 53
body: 29
27Operationoperator: 31
operand: 33
28Operationoperator: 31
operand: 34
29Conditionalvalue: 46
condition: 37
30ExprTuple33
31Literal
32ExprTuple34
33Lambdaparameter: 53
body: 35
34Lambdaparameter: 53
body: 36
35Conditionalvalue: 38
condition: 37
36Conditionalvalue: 38
condition: 39
37Operationoperator: 42
operands: 40
38Operationoperator: 41
operand: 53
39Operationoperator: 42
operands: 43
40ExprTuple45, 44
41Variable
42Literal
43ExprTuple45, 46
44Operationoperator: 47
operand: 53
45Operationoperator: 48
operands: 49
46Operationoperator: 50
operand: 53
47Variable
48Literal
49ExprTuple53, 52
50Variable
51ExprTuple53
52Variable
53Variable