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, InClass
from proveit.numbers import LessEq
from proveit.statistics import ProbOfAll, SampleSpaces
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
expr = Lambda(Omega, Conditional(Forall(instance_param_or_params = [X], instance_expr = 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()), InClass(Omega, SampleSpaces)))
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\{\forall_{X}~\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] \textrm{ if } \Omega \underset{{\scriptscriptstyle c}}{\in} \textrm{SampleSpaces}\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 28
body: 2
1ExprTuple28
2Conditionalvalue: 3
condition: 4
3Operationoperator: 31
operand: 8
4Operationoperator: 6
operands: 7
5ExprTuple8
6Literal
7ExprTuple28, 9
8Lambdaparameter: 61
body: 11
9Literal
10ExprTuple61
11Operationoperator: 31
operand: 13
12ExprTuple13
13Lambdaparameter: 50
body: 15
14ExprTuple50
15Conditionalvalue: 16
condition: 17
16Operationoperator: 31
operand: 20
17Operationoperator: 57
operands: 19
18ExprTuple20
19ExprTuple50, 21
20Lambdaparameters: 22
body: 23
21Operationoperator: 24
operands: 25
22ExprTuple56, 59
23Operationoperator: 26
operands: 27
24Literal
25ExprTuple61, 28
26Literal
27ExprTuple29, 30
28Variable
29Operationoperator: 31
operand: 35
30Operationoperator: 33
operands: 34
31Literal
32ExprTuple35
33Literal
34ExprTuple36, 37
35Lambdaparameter: 62
body: 38
36Operationoperator: 40
operand: 42
37Operationoperator: 40
operand: 43
38Conditionalvalue: 55
condition: 46
39ExprTuple42
40Literal
41ExprTuple43
42Lambdaparameter: 62
body: 44
43Lambdaparameter: 62
body: 45
44Conditionalvalue: 47
condition: 46
45Conditionalvalue: 47
condition: 48
46Operationoperator: 51
operands: 49
47Operationoperator: 50
operand: 62
48Operationoperator: 51
operands: 52
49ExprTuple54, 53
50Variable
51Literal
52ExprTuple54, 55
53Operationoperator: 56
operand: 62
54Operationoperator: 57
operands: 58
55Operationoperator: 59
operand: 62
56Variable
57Literal
58ExprTuple62, 61
59Variable
60ExprTuple62
61Variable
62Variable