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, Q, Qx, R, Rx, X, f, fx, x
from proveit.logic import Forall, Functions, Implies, InSet
from proveit.numbers import LessEq
from proveit.statistics import ProbOfAll
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
expr = Lambda(f, Conditional(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)), InSet(f, 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())
f \mapsto \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) \textrm{ if } f \in \left[X \rightarrow \Omega\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: 37
body: 2
1ExprTuple37
2Conditionalvalue: 3
condition: 4
3Operationoperator: 18
operand: 7
4Operationoperator: 44
operands: 6
5ExprTuple7
6ExprTuple37, 8
7Lambdaparameters: 9
body: 10
8Operationoperator: 11
operands: 12
9ExprTuple43, 46
10Operationoperator: 13
operands: 14
11Literal
12ExprTuple48, 15
13Literal
14ExprTuple16, 17
15Variable
16Operationoperator: 18
operand: 22
17Operationoperator: 20
operands: 21
18Literal
19ExprTuple22
20Literal
21ExprTuple23, 24
22Lambdaparameter: 49
body: 25
23Operationoperator: 27
operand: 29
24Operationoperator: 27
operand: 30
25Conditionalvalue: 42
condition: 33
26ExprTuple29
27Literal
28ExprTuple30
29Lambdaparameter: 49
body: 31
30Lambdaparameter: 49
body: 32
31Conditionalvalue: 34
condition: 33
32Conditionalvalue: 34
condition: 35
33Operationoperator: 38
operands: 36
34Operationoperator: 37
operand: 49
35Operationoperator: 38
operands: 39
36ExprTuple41, 40
37Variable
38Literal
39ExprTuple41, 42
40Operationoperator: 43
operand: 49
41Operationoperator: 44
operands: 45
42Operationoperator: 46
operand: 49
43Variable
44Literal
45ExprTuple49, 48
46Variable
47ExprTuple49
48Variable
49Variable