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, X, Y, f, fx, g, gx, x
from proveit.logic import And, Bijections, Equals, Forall, Implies, InClass, InSet
from proveit.statistics import Prob, SampleSpaces
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda([f, g], Conditional(Implies(Forall(instance_param_or_params = [x], instance_expr = Equals(Prob(fx), Prob(gx)), domain = X), InClass(Y, SampleSpaces)).with_wrapping_at(1), And(InSet(f, Bijections(X, Omega)), InSet(g, Bijections(X, Y))))))
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\{\begin{array}{c} \begin{array}{l} \left[\forall_{x \in X}~\left(\textrm{Pr}\left(f\left(x\right)\right) = \textrm{Pr}\left(g\left(x\right)\right)\right)\right] \\  \Rightarrow \left(Y \underset{{\scriptscriptstyle c}}{\in} \textrm{SampleSpaces}\right) \end{array} \end{array} \textrm{ if } f \in \left[X \xrightarrow[\text{onto}]{\text{1-to-1}} \Omega\right] ,  g \in \left[X \xrightarrow[\text{onto}]{\text{1-to-1}} Y\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
2ExprTuple44, 45
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operands: 7
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10, 11
8Literal
9ExprTuple12, 13
10Operationoperator: 14
operand: 20
11Operationoperator: 16
operands: 17
12Operationoperator: 34
operands: 18
13Operationoperator: 34
operands: 19
14Literal
15ExprTuple20
16Literal
17ExprTuple31, 21
18ExprTuple44, 22
19ExprTuple45, 23
20Lambdaparameter: 47
body: 24
21Literal
22Operationoperator: 26
operands: 25
23Operationoperator: 26
operands: 27
24Conditionalvalue: 28
condition: 29
25ExprTuple38, 30
26Literal
27ExprTuple38, 31
28Operationoperator: 32
operands: 33
29Operationoperator: 34
operands: 35
30Variable
31Variable
32Literal
33ExprTuple36, 37
34Literal
35ExprTuple47, 38
36Operationoperator: 40
operand: 42
37Operationoperator: 40
operand: 43
38Variable
39ExprTuple42
40Literal
41ExprTuple43
42Operationoperator: 44
operand: 47
43Operationoperator: 45
operand: 47
44Variable
45Variable
46ExprTuple47
47Variable