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 A, B, Conditional, ExprTuple, Function, Lambda, Omega, Q, Qx, f, fx, g, gy, x, y
from proveit.logic import And, Bijections, Equals, InSet, Injections
from proveit.statistics import ProbOfAll
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [gy]
expr = ExprTuple(Lambda([f, g], Conditional(Equals(ProbOfAll(instance_param_or_params = [x], instance_element = fx, domain = A, condition = Qx), ProbOfAll(instance_param_or_params = [y], instance_element = Function(f, sub_expr1), domain = B, condition = Function(Q, sub_expr1))), And(InSet(f, Injections(A, Omega)), InSet(g, Bijections(B, A))))))
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(f, g\right) \mapsto \left\{\left[\textrm{Prob}_{x \in A~|~Q\left(x\right)}~f\left(x\right)\right] = \left[\textrm{Prob}_{y \in B~|~Q\left(g\left(y\right)\right)}~f\left(g\left(y\right)\right)\right] \textrm{ if } f \in \left[A \xrightarrow[]{\text{1-to-1}} \Omega\right] ,  g \in \left[B \xrightarrow[\text{onto}]{\text{1-to-1}} A\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
1Lambdaparameters: 2
body: 3
2ExprTuple34, 51
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operands: 7
5Operationoperator: 35
operands: 8
6Literal
7ExprTuple9, 10
8ExprTuple11, 12
9Operationoperator: 14
operand: 18
10Operationoperator: 14
operand: 19
11Operationoperator: 43
operands: 16
12Operationoperator: 43
operands: 17
13ExprTuple18
14Literal
15ExprTuple19
16ExprTuple34, 20
17ExprTuple51, 21
18Lambdaparameter: 48
body: 22
19Lambdaparameter: 53
body: 23
20Operationoperator: 24
operands: 25
21Operationoperator: 26
operands: 27
22Conditionalvalue: 28
condition: 29
23Conditionalvalue: 30
condition: 31
24Literal
25ExprTuple47, 32
26Literal
27ExprTuple49, 47
28Operationoperator: 34
operand: 48
29Operationoperator: 35
operands: 33
30Operationoperator: 34
operand: 50
31Operationoperator: 35
operands: 36
32Variable
33ExprTuple37, 38
34Variable
35Literal
36ExprTuple39, 40
37Operationoperator: 43
operands: 41
38Operationoperator: 45
operand: 48
39Operationoperator: 43
operands: 44
40Operationoperator: 45
operand: 50
41ExprTuple48, 47
42ExprTuple48
43Literal
44ExprTuple53, 49
45Variable
46ExprTuple50
47Variable
48Variable
49Variable
50Operationoperator: 51
operand: 53
51Variable
52ExprTuple53
53Variable