logo

Expression of type Forall

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 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 = Forall(instance_param_or_params = [X, Y], instance_expr = 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())
\forall_{X, Y}~\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]
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneNone/False('with_wrapping',)
condition_wrappingWrap 'before' or 'after' the condition (or None).NoneNone/False('with_wrap_after_condition', 'with_wrap_before_condition')
wrap_paramsIf 'True', wraps every two parameters AND wraps the Expression after the parametersNoneNone/False('with_params',)
justificationjustify to the 'left', 'center', or 'right' in the array cellscentercenter('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 18
operand: 2
1ExprTuple2
2Lambdaparameters: 31
body: 3
3Operationoperator: 18
operand: 5
4ExprTuple5
5Lambdaparameters: 6
body: 7
6ExprTuple48, 49
7Conditionalvalue: 8
condition: 9
8Operationoperator: 10
operands: 11
9Operationoperator: 12
operands: 13
10Literal
11ExprTuple14, 15
12Literal
13ExprTuple16, 17
14Operationoperator: 18
operand: 24
15Operationoperator: 20
operands: 21
16Operationoperator: 38
operands: 22
17Operationoperator: 38
operands: 23
18Literal
19ExprTuple24
20Literal
21ExprTuple35, 25
22ExprTuple48, 26
23ExprTuple49, 27
24Lambdaparameter: 51
body: 28
25Literal
26Operationoperator: 30
operands: 29
27Operationoperator: 30
operands: 31
28Conditionalvalue: 32
condition: 33
29ExprTuple42, 34
30Literal
31ExprTuple42, 35
32Operationoperator: 36
operands: 37
33Operationoperator: 38
operands: 39
34Variable
35Variable
36Literal
37ExprTuple40, 41
38Literal
39ExprTuple51, 42
40Operationoperator: 44
operand: 46
41Operationoperator: 44
operand: 47
42Variable
43ExprTuple46
44Literal
45ExprTuple47
46Operationoperator: 48
operand: 51
47Operationoperator: 49
operand: 51
48Variable
49Variable
50ExprTuple51
51Variable