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 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 = 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\{\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()
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
operand: 6
2Operationoperator: 54
operands: 5
3Literal
4ExprTuple6
5ExprTuple7, 8, 9
6Lambdaparameter: 53
body: 11
7Operationoperator: 12
operands: 13
8Operationoperator: 19
operands: 14
9Operationoperator: 15
operands: 23
10ExprTuple53
11Conditionalvalue: 16
condition: 17
12Literal
13ExprTuple56, 35
14ExprTuple56, 18
15Literal
16Operationoperator: 19
operands: 20
17Operationoperator: 61
operands: 21
18Operationoperator: 22
operands: 23
19Literal
20ExprTuple24, 25
21ExprTuple53, 26
22Literal
23ExprTuple65, 66
24Operationoperator: 39
operand: 32
25Operationoperator: 28
operands: 29
26Operationoperator: 30
operands: 31
27ExprTuple32
28Literal
29ExprTuple33, 34
30Literal
31ExprTuple35, 36
32Lambdaparameter: 67
body: 37
33Operationoperator: 39
operand: 42
34Operationoperator: 39
operand: 43
35Variable
36Variable
37Conditionalvalue: 49
condition: 41
38ExprTuple42
39Literal
40ExprTuple43
41Operationoperator: 54
operands: 44
42Lambdaparameter: 67
body: 45
43Lambdaparameter: 67
body: 46
44ExprTuple47, 59
45Conditionalvalue: 49
condition: 48
46Conditionalvalue: 49
condition: 50
47Operationoperator: 61
operands: 51
48Operationoperator: 54
operands: 52
49Operationoperator: 53
operand: 67
50Operationoperator: 54
operands: 55
51ExprTuple67, 56
52ExprTuple57, 59
53Variable
54Literal
55ExprTuple58, 59
56Variable
57Operationoperator: 61
operands: 60
58Operationoperator: 61
operands: 62
59Operationoperator: 63
operand: 67
60ExprTuple67, 65
61Literal
62ExprTuple67, 66
63Variable
64ExprTuple67
65Variable
66Variable
67Variable