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, Qx, X, f, fx, x
from proveit.logic import Equals, InSet, Injections
from proveit.numbers import Add
from proveit.statistics import ProbOfAll
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
expr = Lambda(f, Conditional(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))), InSet(f, Injections(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\{\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) \textrm{ if } f \in \left[X \xrightarrow[]{\text{1-to-1}} \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: 5
operands: 6
4Operationoperator: 45
operands: 7
5Literal
6ExprTuple8, 9
7ExprTuple37, 10
8Operationoperator: 23
operand: 16
9Operationoperator: 12
operands: 13
10Operationoperator: 14
operands: 15
11ExprTuple16
12Literal
13ExprTuple17, 18
14Literal
15ExprTuple19, 20
16Lambdaparameter: 51
body: 21
17Operationoperator: 23
operand: 26
18Operationoperator: 23
operand: 27
19Variable
20Variable
21Conditionalvalue: 33
condition: 25
22ExprTuple26
23Literal
24ExprTuple27
25Operationoperator: 38
operands: 28
26Lambdaparameter: 51
body: 29
27Lambdaparameter: 51
body: 30
28ExprTuple31, 43
29Conditionalvalue: 33
condition: 32
30Conditionalvalue: 33
condition: 34
31Operationoperator: 45
operands: 35
32Operationoperator: 38
operands: 36
33Operationoperator: 37
operand: 51
34Operationoperator: 38
operands: 39
35ExprTuple51, 40
36ExprTuple41, 43
37Variable
38Literal
39ExprTuple42, 43
40Variable
41Operationoperator: 45
operands: 44
42Operationoperator: 45
operands: 46
43Operationoperator: 47
operand: 51
44ExprTuple51, 49
45Literal
46ExprTuple51, 50
47Variable
48ExprTuple51
49Variable
50Variable
51Variable