logo

Expression of type ExprTuple

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, ExprTuple, Lambda, 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 = ExprTuple(Lambda(Omega, 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(\Omega \mapsto \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..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameter: 29
body: 3
2ExprTuple29
3Conditionalvalue: 4
condition: 5
4Operationoperator: 32
operand: 9
5Operationoperator: 7
operands: 8
6ExprTuple9
7Literal
8ExprTuple29, 10
9Lambdaparameter: 80
body: 12
10Literal
11ExprTuple80
12Operationoperator: 32
operand: 14
13ExprTuple14
14Lambdaparameter: 71
body: 16
15ExprTuple71
16Conditionalvalue: 17
condition: 18
17Operationoperator: 32
operand: 21
18Operationoperator: 76
operands: 20
19ExprTuple21
20ExprTuple71, 22
21Lambdaparameters: 23
body: 24
22Operationoperator: 25
operands: 26
23ExprTuple65, 78
24Operationoperator: 27
operands: 28
25Literal
26ExprTuple80, 29
27Literal
28ExprTuple30, 31
29Variable
30Operationoperator: 32
operand: 35
31Operationoperator: 46
operands: 34
32Literal
33ExprTuple35
34ExprTuple36, 37
35Lambdaparameter: 68
body: 38
36Operationoperator: 58
operand: 43
37Operationoperator: 40
operands: 41
38Conditionalvalue: 42
condition: 61
39ExprTuple43
40Literal
41ExprTuple44, 45
42Operationoperator: 46
operands: 47
43Lambdaparameter: 68
body: 48
44Literal
45Operationoperator: 49
operand: 54
46Literal
47ExprTuple62, 51
48Conditionalvalue: 52
condition: 53
49Literal
50ExprTuple54
51Operationoperator: 55
operand: 60
52Operationoperator: 71
operand: 68
53Operationoperator: 72
operands: 57
54Operationoperator: 58
operand: 63
55Literal
56ExprTuple60
57ExprTuple61, 62
58Literal
59ExprTuple63
60Operationoperator: 78
operand: 68
61Operationoperator: 76
operands: 64
62Operationoperator: 65
operand: 68
63Lambdaparameter: 81
body: 67
64ExprTuple68, 80
65Variable
66ExprTuple68
67Conditionalvalue: 69
condition: 70
68Variable
69Operationoperator: 71
operand: 81
70Operationoperator: 72
operands: 73
71Variable
72Literal
73ExprTuple74, 75
74Operationoperator: 76
operands: 77
75Operationoperator: 78
operand: 81
76Literal
77ExprTuple81, 80
78Variable
79ExprTuple81
80Variable
81Variable