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, InClass, Not
from proveit.numbers import one, subtract
from proveit.statistics import ProbOfAll, SampleSpaces
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
expr = Conditional(Forall(instance_param_or_params = [X], instance_expr = Forall(instance_param_or_params = [f], instance_expr = 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)), domain = Bijections(X, Omega))), InClass(Omega, SampleSpaces))
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_{X}~\left[\forall_{f \in \left[X \xrightarrow[\text{onto}]{\text{1-to-1}} \Omega\right]}~\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)\right]\right] \textrm{ if } \Omega \underset{{\scriptscriptstyle c}}{\in} \textrm{SampleSpaces}\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: 29
operand: 6
2Operationoperator: 4
operands: 5
3ExprTuple6
4Literal
5ExprTuple26, 7
6Lambdaparameter: 77
body: 9
7Literal
8ExprTuple77
9Operationoperator: 29
operand: 11
10ExprTuple11
11Lambdaparameter: 68
body: 13
12ExprTuple68
13Conditionalvalue: 14
condition: 15
14Operationoperator: 29
operand: 18
15Operationoperator: 73
operands: 17
16ExprTuple18
17ExprTuple68, 19
18Lambdaparameters: 20
body: 21
19Operationoperator: 22
operands: 23
20ExprTuple62, 75
21Operationoperator: 24
operands: 25
22Literal
23ExprTuple77, 26
24Literal
25ExprTuple27, 28
26Variable
27Operationoperator: 29
operand: 32
28Operationoperator: 43
operands: 31
29Literal
30ExprTuple32
31ExprTuple33, 34
32Lambdaparameter: 65
body: 35
33Operationoperator: 55
operand: 40
34Operationoperator: 37
operands: 38
35Conditionalvalue: 39
condition: 58
36ExprTuple40
37Literal
38ExprTuple41, 42
39Operationoperator: 43
operands: 44
40Lambdaparameter: 65
body: 45
41Literal
42Operationoperator: 46
operand: 51
43Literal
44ExprTuple59, 48
45Conditionalvalue: 49
condition: 50
46Literal
47ExprTuple51
48Operationoperator: 52
operand: 57
49Operationoperator: 68
operand: 65
50Operationoperator: 69
operands: 54
51Operationoperator: 55
operand: 60
52Literal
53ExprTuple57
54ExprTuple58, 59
55Literal
56ExprTuple60
57Operationoperator: 75
operand: 65
58Operationoperator: 73
operands: 61
59Operationoperator: 62
operand: 65
60Lambdaparameter: 78
body: 64
61ExprTuple65, 77
62Variable
63ExprTuple65
64Conditionalvalue: 66
condition: 67
65Variable
66Operationoperator: 68
operand: 78
67Operationoperator: 69
operands: 70
68Variable
69Literal
70ExprTuple71, 72
71Operationoperator: 73
operands: 74
72Operationoperator: 75
operand: 78
73Literal
74ExprTuple78, 77
75Variable
76ExprTuple78
77Variable
78Variable