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, Qx, Rx, Ry, X, fx, fy, x, y
from proveit.logic import Equals, Forall, 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(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))
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_{x \in X}~\left(Q\left(x\right) = (\lnot R\left(x\right))\right), \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)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
wrap_positionsposition(s) at which wrapping is to occur; 'n' is after the nth comma.()()('with_wrapping_at',)
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'leftleft('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1, 2
1Operationoperator: 3
operand: 6
2Operationoperator: 17
operands: 5
3Literal
4ExprTuple6
5ExprTuple7, 8
6Lambdaparameter: 39
body: 9
7Operationoperator: 29
operand: 14
8Operationoperator: 11
operands: 12
9Conditionalvalue: 13
condition: 32
10ExprTuple14
11Literal
12ExprTuple15, 16
13Operationoperator: 17
operands: 18
14Lambdaparameter: 39
body: 19
15Literal
16Operationoperator: 20
operand: 25
17Literal
18ExprTuple33, 22
19Conditionalvalue: 23
condition: 24
20Literal
21ExprTuple25
22Operationoperator: 26
operand: 31
23Operationoperator: 42
operand: 39
24Operationoperator: 43
operands: 28
25Operationoperator: 29
operand: 34
26Literal
27ExprTuple31
28ExprTuple32, 33
29Literal
30ExprTuple34
31Operationoperator: 49
operand: 39
32Operationoperator: 47
operands: 35
33Operationoperator: 36
operand: 39
34Lambdaparameter: 52
body: 38
35ExprTuple39, 51
36Variable
37ExprTuple39
38Conditionalvalue: 40
condition: 41
39Variable
40Operationoperator: 42
operand: 52
41Operationoperator: 43
operands: 44
42Variable
43Literal
44ExprTuple45, 46
45Operationoperator: 47
operands: 48
46Operationoperator: 49
operand: 52
47Literal
48ExprTuple52, 51
49Variable
50ExprTuple52
51Variable
52Variable