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, Conditional, Function, Omega, Q, Qx, f, fx, g, gy, x, y
from proveit.logic import Bijections, Equals, Forall, InClass, Injections
from proveit.statistics import ProbOfAll, SampleSpaces
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [gy]
expr = Conditional(Forall(instance_param_or_params = [A, B, Q], instance_expr = Forall(instance_param_or_params = [f, g], instance_expr = Equals(ProbOfAll(instance_param_or_params = [x], instance_element = fx, domain = A, condition = Qx), ProbOfAll(instance_param_or_params = [y], instance_element = Function(f, sub_expr1), domain = B, condition = Function(Q, sub_expr1))), domains = [Injections(A, Omega), Bijections(B, A)]).with_wrapping()), 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_{A, B, Q}~\left[\begin{array}{l}\forall_{f \in \left[A \xrightarrow[]{\text{1-to-1}} \Omega\right], g \in \left[B \xrightarrow[\text{onto}]{\text{1-to-1}} A\right]}~\\
\left(\left[\textrm{Prob}_{x \in A~|~Q\left(x\right)}~f\left(x\right)\right] = \left[\textrm{Prob}_{y \in B~|~Q\left(g\left(y\right)\right)}~f\left(g\left(y\right)\right)\right]\right)\end{array}\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: 10
operand: 6
2Operationoperator: 4
operands: 5
3ExprTuple6
4Literal
5ExprTuple43, 7
6Lambdaparameters: 8
body: 9
7Literal
8ExprTuple58, 60, 56
9Operationoperator: 10
operand: 12
10Literal
11ExprTuple12
12Lambdaparameters: 13
body: 14
13ExprTuple45, 62
14Conditionalvalue: 15
condition: 16
15Operationoperator: 17
operands: 18
16Operationoperator: 46
operands: 19
17Literal
18ExprTuple20, 21
19ExprTuple22, 23
20Operationoperator: 25
operand: 29
21Operationoperator: 25
operand: 30
22Operationoperator: 54
operands: 27
23Operationoperator: 54
operands: 28
24ExprTuple29
25Literal
26ExprTuple30
27ExprTuple45, 31
28ExprTuple62, 32
29Lambdaparameter: 59
body: 33
30Lambdaparameter: 64
body: 34
31Operationoperator: 35
operands: 36
32Operationoperator: 37
operands: 38
33Conditionalvalue: 39
condition: 40
34Conditionalvalue: 41
condition: 42
35Literal
36ExprTuple58, 43
37Literal
38ExprTuple60, 58
39Operationoperator: 45
operand: 59
40Operationoperator: 46
operands: 44
41Operationoperator: 45
operand: 61
42Operationoperator: 46
operands: 47
43Variable
44ExprTuple48, 49
45Variable
46Literal
47ExprTuple50, 51
48Operationoperator: 54
operands: 52
49Operationoperator: 56
operand: 59
50Operationoperator: 54
operands: 55
51Operationoperator: 56
operand: 61
52ExprTuple59, 58
53ExprTuple59
54Literal
55ExprTuple64, 60
56Variable
57ExprTuple61
58Variable
59Variable
60Variable
61Operationoperator: 62
operand: 64
62Variable
63ExprTuple64
64Variable