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, Q, Qx, R, Rx, Ry, X, fx, fy, x, y
from proveit.logic import 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([Q, R], 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)))
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(\left(Q, R\right) \mapsto \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)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameters: 2
body: 3
2ExprTuple41, 54
3Operationoperator: 4
operands: 5
4Literal
5ExprTuple6, 7
6Operationoperator: 8
operand: 11
7Operationoperator: 22
operands: 10
8Literal
9ExprTuple11
10ExprTuple12, 13
11Lambdaparameter: 44
body: 14
12Operationoperator: 34
operand: 19
13Operationoperator: 16
operands: 17
14Conditionalvalue: 18
condition: 37
15ExprTuple19
16Literal
17ExprTuple20, 21
18Operationoperator: 22
operands: 23
19Lambdaparameter: 44
body: 24
20Literal
21Operationoperator: 25
operand: 30
22Literal
23ExprTuple38, 27
24Conditionalvalue: 28
condition: 29
25Literal
26ExprTuple30
27Operationoperator: 31
operand: 36
28Operationoperator: 47
operand: 44
29Operationoperator: 48
operands: 33
30Operationoperator: 34
operand: 39
31Literal
32ExprTuple36
33ExprTuple37, 38
34Literal
35ExprTuple39
36Operationoperator: 54
operand: 44
37Operationoperator: 52
operands: 40
38Operationoperator: 41
operand: 44
39Lambdaparameter: 57
body: 43
40ExprTuple44, 56
41Variable
42ExprTuple44
43Conditionalvalue: 45
condition: 46
44Variable
45Operationoperator: 47
operand: 57
46Operationoperator: 48
operands: 49
47Variable
48Literal
49ExprTuple50, 51
50Operationoperator: 52
operands: 53
51Operationoperator: 54
operand: 57
52Literal
53ExprTuple57, 56
54Variable
55ExprTuple57
56Variable
57Variable