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, Omega, X, Y, f, fx, g, gx, x
from proveit.logic import Bijections, Equals, Forall, Implies, InClass
from proveit.statistics import Prob, SampleSpaces
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda([X, Y], Forall(instance_param_or_params = [f, g], instance_expr = Implies(Forall(instance_param_or_params = [x], instance_expr = Equals(Prob(fx), Prob(gx)), domain = X), InClass(Y, SampleSpaces)).with_wrapping_at(1), domains = [Bijections(X, Omega), 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(X, Y\right) \mapsto \left[\forall_{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]}~\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}\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: 30
body: 2
2Operationoperator: 17
operand: 4
3ExprTuple4
4Lambdaparameters: 5
body: 6
5ExprTuple47, 48
6Conditionalvalue: 7
condition: 8
7Operationoperator: 9
operands: 10
8Operationoperator: 11
operands: 12
9Literal
10ExprTuple13, 14
11Literal
12ExprTuple15, 16
13Operationoperator: 17
operand: 23
14Operationoperator: 19
operands: 20
15Operationoperator: 37
operands: 21
16Operationoperator: 37
operands: 22
17Literal
18ExprTuple23
19Literal
20ExprTuple34, 24
21ExprTuple47, 25
22ExprTuple48, 26
23Lambdaparameter: 50
body: 27
24Literal
25Operationoperator: 29
operands: 28
26Operationoperator: 29
operands: 30
27Conditionalvalue: 31
condition: 32
28ExprTuple41, 33
29Literal
30ExprTuple41, 34
31Operationoperator: 35
operands: 36
32Operationoperator: 37
operands: 38
33Variable
34Variable
35Literal
36ExprTuple39, 40
37Literal
38ExprTuple50, 41
39Operationoperator: 43
operand: 45
40Operationoperator: 43
operand: 46
41Variable
42ExprTuple45
43Literal
44ExprTuple46
45Operationoperator: 47
operand: 50
46Operationoperator: 48
operand: 50
47Variable
48Variable
49ExprTuple50
50Variable