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 ExprTuple, Lambda, Omega, Q, Qx, R, Rx, Ry, X, f, fx, fy, x, y
from proveit.logic import Bijections, Equals, Forall, Implies, 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 = ExprTuple(Lambda(X, 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))))
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(X \mapsto \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]\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: 71
body: 3
2ExprTuple71
3Operationoperator: 23
operand: 5
4ExprTuple5
5Lambdaparameter: 62
body: 7
6ExprTuple62
7Conditionalvalue: 8
condition: 9
8Operationoperator: 23
operand: 12
9Operationoperator: 67
operands: 11
10ExprTuple12
11ExprTuple62, 13
12Lambdaparameters: 14
body: 15
13Operationoperator: 16
operands: 17
14ExprTuple56, 69
15Operationoperator: 18
operands: 19
16Literal
17ExprTuple71, 20
18Literal
19ExprTuple21, 22
20Variable
21Operationoperator: 23
operand: 26
22Operationoperator: 37
operands: 25
23Literal
24ExprTuple26
25ExprTuple27, 28
26Lambdaparameter: 59
body: 29
27Operationoperator: 49
operand: 34
28Operationoperator: 31
operands: 32
29Conditionalvalue: 33
condition: 52
30ExprTuple34
31Literal
32ExprTuple35, 36
33Operationoperator: 37
operands: 38
34Lambdaparameter: 59
body: 39
35Literal
36Operationoperator: 40
operand: 45
37Literal
38ExprTuple53, 42
39Conditionalvalue: 43
condition: 44
40Literal
41ExprTuple45
42Operationoperator: 46
operand: 51
43Operationoperator: 62
operand: 59
44Operationoperator: 63
operands: 48
45Operationoperator: 49
operand: 54
46Literal
47ExprTuple51
48ExprTuple52, 53
49Literal
50ExprTuple54
51Operationoperator: 69
operand: 59
52Operationoperator: 67
operands: 55
53Operationoperator: 56
operand: 59
54Lambdaparameter: 72
body: 58
55ExprTuple59, 71
56Variable
57ExprTuple59
58Conditionalvalue: 60
condition: 61
59Variable
60Operationoperator: 62
operand: 72
61Operationoperator: 63
operands: 64
62Variable
63Literal
64ExprTuple65, 66
65Operationoperator: 67
operands: 68
66Operationoperator: 69
operand: 72
67Literal
68ExprTuple72, 71
69Variable
70ExprTuple72
71Variable
72Variable