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 A, B, C, Conditional, Lambda, Omega, Q, Qx, X, f, fx, x
from proveit.logic import And, Disjoint, Equals, Forall, Injections, SubsetEq, Union
from proveit.numbers import Add
from proveit.statistics import ProbOfAll
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
expr = Lambda([A, B, C, X, Q], Conditional(Forall(instance_param_or_params = [f], instance_expr = Equals(ProbOfAll(instance_param_or_params = sub_expr1, instance_element = fx, domain = C, condition = Qx), Add(ProbOfAll(instance_param_or_params = sub_expr1, instance_element = fx, domain = A, condition = Qx), ProbOfAll(instance_param_or_params = sub_expr1, instance_element = fx, domain = B, condition = Qx))), domain = Injections(X, Omega)), And(SubsetEq(C, X), Equals(C, Union(A, B)), Disjoint(A, B))))
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(A, B, C, X, Q\right) \mapsto \left\{\forall_{f \in \left[X \xrightarrow[]{\text{1-to-1}} \Omega\right]}~\left(\left[\textrm{Prob}_{x \in C~|~Q\left(x\right)}~f\left(x\right)\right] = \left(\left[\textrm{Prob}_{x \in A~|~Q\left(x\right)}~f\left(x\right)\right] + \left[\textrm{Prob}_{x \in B~|~Q\left(x\right)}~f\left(x\right)\right]\right)\right) \textrm{ if } C \subseteq X ,  C = \left(A \cup B\right) ,  \textrm{disjoint}\left(A, B\right)\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
1ExprTuple67, 68, 58, 37, 65
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 56
operands: 7
5Literal
6ExprTuple8
7ExprTuple9, 10, 11
8Lambdaparameter: 55
body: 13
9Operationoperator: 14
operands: 15
10Operationoperator: 21
operands: 16
11Operationoperator: 17
operands: 25
12ExprTuple55
13Conditionalvalue: 18
condition: 19
14Literal
15ExprTuple58, 37
16ExprTuple58, 20
17Literal
18Operationoperator: 21
operands: 22
19Operationoperator: 63
operands: 23
20Operationoperator: 24
operands: 25
21Literal
22ExprTuple26, 27
23ExprTuple55, 28
24Literal
25ExprTuple67, 68
26Operationoperator: 41
operand: 34
27Operationoperator: 30
operands: 31
28Operationoperator: 32
operands: 33
29ExprTuple34
30Literal
31ExprTuple35, 36
32Literal
33ExprTuple37, 38
34Lambdaparameter: 69
body: 39
35Operationoperator: 41
operand: 44
36Operationoperator: 41
operand: 45
37Variable
38Variable
39Conditionalvalue: 51
condition: 43
40ExprTuple44
41Literal
42ExprTuple45
43Operationoperator: 56
operands: 46
44Lambdaparameter: 69
body: 47
45Lambdaparameter: 69
body: 48
46ExprTuple49, 61
47Conditionalvalue: 51
condition: 50
48Conditionalvalue: 51
condition: 52
49Operationoperator: 63
operands: 53
50Operationoperator: 56
operands: 54
51Operationoperator: 55
operand: 69
52Operationoperator: 56
operands: 57
53ExprTuple69, 58
54ExprTuple59, 61
55Variable
56Literal
57ExprTuple60, 61
58Variable
59Operationoperator: 63
operands: 62
60Operationoperator: 63
operands: 64
61Operationoperator: 65
operand: 69
62ExprTuple69, 67
63Literal
64ExprTuple69, 68
65Variable
66ExprTuple69
67Variable
68Variable
69Variable