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, 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 = ExprTuple(Lambda(f, 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(f \mapsto \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..\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: 58
body: 3
2ExprTuple58
3Conditionalvalue: 4
condition: 5
4Operationoperator: 19
operand: 8
5Operationoperator: 63
operands: 7
6ExprTuple8
7ExprTuple58, 9
8Lambdaparameters: 10
body: 11
9Operationoperator: 12
operands: 13
10ExprTuple52, 65
11Operationoperator: 14
operands: 15
12Literal
13ExprTuple67, 16
14Literal
15ExprTuple17, 18
16Variable
17Operationoperator: 19
operand: 22
18Operationoperator: 33
operands: 21
19Literal
20ExprTuple22
21ExprTuple23, 24
22Lambdaparameter: 55
body: 25
23Operationoperator: 45
operand: 30
24Operationoperator: 27
operands: 28
25Conditionalvalue: 29
condition: 48
26ExprTuple30
27Literal
28ExprTuple31, 32
29Operationoperator: 33
operands: 34
30Lambdaparameter: 55
body: 35
31Literal
32Operationoperator: 36
operand: 41
33Literal
34ExprTuple49, 38
35Conditionalvalue: 39
condition: 40
36Literal
37ExprTuple41
38Operationoperator: 42
operand: 47
39Operationoperator: 58
operand: 55
40Operationoperator: 59
operands: 44
41Operationoperator: 45
operand: 50
42Literal
43ExprTuple47
44ExprTuple48, 49
45Literal
46ExprTuple50
47Operationoperator: 65
operand: 55
48Operationoperator: 63
operands: 51
49Operationoperator: 52
operand: 55
50Lambdaparameter: 68
body: 54
51ExprTuple55, 67
52Variable
53ExprTuple55
54Conditionalvalue: 56
condition: 57
55Variable
56Operationoperator: 58
operand: 68
57Operationoperator: 59
operands: 60
58Variable
59Literal
60ExprTuple61, 62
61Operationoperator: 63
operands: 64
62Operationoperator: 65
operand: 68
63Literal
64ExprTuple68, 67
65Variable
66ExprTuple68
67Variable
68Variable