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, Ry, X, f, fx, fy, x, y
from proveit.logic import Bijections, Equals, Forall, Implies, Not
from proveit.numbers import one, subtract
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 = Equals(Qx, Not(Rx)), domain = X), Equals(ProbOfAll(instance_param_or_params = sub_expr1, instance_element = fx, domain = X, condition = Qx), subtract(one, ProbOfAll(instance_param_or_params = [y], instance_element = fy, domain = X, condition = Ry))).with_wrapping_at(2)).with_wrapping_at(2)), domain = Bijections(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 \xrightarrow[\text{onto}]{\text{1-to-1}} \Omega\right]}~\left[\forall_{Q, R}~\left(\begin{array}{c} \begin{array}{l} \left[\forall_{x \in X}~\left(Q\left(x\right) = (\lnot R\left(x\right))\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] =  \\ \left(1 - \left[\textrm{Prob}_{y \in X~|~R\left(y\right)}~f\left(y\right)\right]\right) \end{array} \end{array}\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: 70
body: 2
1ExprTuple70
2Operationoperator: 22
operand: 4
3ExprTuple4
4Lambdaparameter: 61
body: 6
5ExprTuple61
6Conditionalvalue: 7
condition: 8
7Operationoperator: 22
operand: 11
8Operationoperator: 66
operands: 10
9ExprTuple11
10ExprTuple61, 12
11Lambdaparameters: 13
body: 14
12Operationoperator: 15
operands: 16
13ExprTuple55, 68
14Operationoperator: 17
operands: 18
15Literal
16ExprTuple70, 19
17Literal
18ExprTuple20, 21
19Variable
20Operationoperator: 22
operand: 25
21Operationoperator: 36
operands: 24
22Literal
23ExprTuple25
24ExprTuple26, 27
25Lambdaparameter: 58
body: 28
26Operationoperator: 48
operand: 33
27Operationoperator: 30
operands: 31
28Conditionalvalue: 32
condition: 51
29ExprTuple33
30Literal
31ExprTuple34, 35
32Operationoperator: 36
operands: 37
33Lambdaparameter: 58
body: 38
34Literal
35Operationoperator: 39
operand: 44
36Literal
37ExprTuple52, 41
38Conditionalvalue: 42
condition: 43
39Literal
40ExprTuple44
41Operationoperator: 45
operand: 50
42Operationoperator: 61
operand: 58
43Operationoperator: 62
operands: 47
44Operationoperator: 48
operand: 53
45Literal
46ExprTuple50
47ExprTuple51, 52
48Literal
49ExprTuple53
50Operationoperator: 68
operand: 58
51Operationoperator: 66
operands: 54
52Operationoperator: 55
operand: 58
53Lambdaparameter: 71
body: 57
54ExprTuple58, 70
55Variable
56ExprTuple58
57Conditionalvalue: 59
condition: 60
58Variable
59Operationoperator: 61
operand: 71
60Operationoperator: 62
operands: 63
61Variable
62Literal
63ExprTuple64, 65
64Operationoperator: 66
operands: 67
65Operationoperator: 68
operand: 71
66Literal
67ExprTuple71, 70
68Variable
69ExprTuple71
70Variable
71Variable