logo

Expression of type Conditional

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, 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 = 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())
\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()
namedescriptiondefaultcurrent valuerelated methods
condition_delimiter'comma' or 'and'commacomma('with_comma_delimiter', 'with_conjunction_delimiter')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Conditionalvalue: 1
condition: 2
1Operationoperator: 3
operands: 4
2Operationoperator: 43
operands: 5
3Literal
4ExprTuple6, 7
5ExprTuple35, 8
6Operationoperator: 21
operand: 14
7Operationoperator: 10
operands: 11
8Operationoperator: 12
operands: 13
9ExprTuple14
10Literal
11ExprTuple15, 16
12Literal
13ExprTuple17, 18
14Lambdaparameter: 49
body: 19
15Operationoperator: 21
operand: 24
16Operationoperator: 21
operand: 25
17Variable
18Variable
19Conditionalvalue: 31
condition: 23
20ExprTuple24
21Literal
22ExprTuple25
23Operationoperator: 36
operands: 26
24Lambdaparameter: 49
body: 27
25Lambdaparameter: 49
body: 28
26ExprTuple29, 41
27Conditionalvalue: 31
condition: 30
28Conditionalvalue: 31
condition: 32
29Operationoperator: 43
operands: 33
30Operationoperator: 36
operands: 34
31Operationoperator: 35
operand: 49
32Operationoperator: 36
operands: 37
33ExprTuple49, 38
34ExprTuple39, 41
35Variable
36Literal
37ExprTuple40, 41
38Variable
39Operationoperator: 43
operands: 42
40Operationoperator: 43
operands: 44
41Operationoperator: 45
operand: 49
42ExprTuple49, 47
43Literal
44ExprTuple49, 48
45Variable
46ExprTuple49
47Variable
48Variable
49Variable