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 Conditional, Omega, Q, Qx, R, Rx, Ry, X, f, fx, fy, x, y
from proveit.logic import Bijections, Equals, Forall, Implies, InSet, 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 = Conditional(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)), InSet(f, 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())
\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) \textrm{ if } f \in \left[X \xrightarrow[\text{onto}]{\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: 16
operand: 5
2Operationoperator: 60
operands: 4
3ExprTuple5
4ExprTuple55, 6
5Lambdaparameters: 7
body: 8
6Operationoperator: 9
operands: 10
7ExprTuple49, 62
8Operationoperator: 11
operands: 12
9Literal
10ExprTuple64, 13
11Literal
12ExprTuple14, 15
13Variable
14Operationoperator: 16
operand: 19
15Operationoperator: 30
operands: 18
16Literal
17ExprTuple19
18ExprTuple20, 21
19Lambdaparameter: 52
body: 22
20Operationoperator: 42
operand: 27
21Operationoperator: 24
operands: 25
22Conditionalvalue: 26
condition: 45
23ExprTuple27
24Literal
25ExprTuple28, 29
26Operationoperator: 30
operands: 31
27Lambdaparameter: 52
body: 32
28Literal
29Operationoperator: 33
operand: 38
30Literal
31ExprTuple46, 35
32Conditionalvalue: 36
condition: 37
33Literal
34ExprTuple38
35Operationoperator: 39
operand: 44
36Operationoperator: 55
operand: 52
37Operationoperator: 56
operands: 41
38Operationoperator: 42
operand: 47
39Literal
40ExprTuple44
41ExprTuple45, 46
42Literal
43ExprTuple47
44Operationoperator: 62
operand: 52
45Operationoperator: 60
operands: 48
46Operationoperator: 49
operand: 52
47Lambdaparameter: 65
body: 51
48ExprTuple52, 64
49Variable
50ExprTuple52
51Conditionalvalue: 53
condition: 54
52Variable
53Operationoperator: 55
operand: 65
54Operationoperator: 56
operands: 57
55Variable
56Literal
57ExprTuple58, 59
58Operationoperator: 60
operands: 61
59Operationoperator: 62
operand: 65
60Literal
61ExprTuple65, 64
62Variable
63ExprTuple65
64Variable
65Variable