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 = [Omega], instance_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)])), domain = SampleSpaces)
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_{\Omega \underset{{\scriptscriptstyle c}}{\in} \textrm{SampleSpaces}}~\left[\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]\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: 25
operand: 2
1ExprTuple2
2Lambdaparameter: 41
body: 4
3ExprTuple41
4Conditionalvalue: 5
condition: 6
5Operationoperator: 25
operand: 9
6Operationoperator: 27
operands: 8
7ExprTuple9
8ExprTuple41, 32
9Lambdaparameters: 38
body: 10
10Operationoperator: 25
operand: 12
11ExprTuple12
12Lambdaparameters: 13
body: 14
13ExprTuple55, 56
14Conditionalvalue: 15
condition: 16
15Operationoperator: 17
operands: 18
16Operationoperator: 19
operands: 20
17Literal
18ExprTuple21, 22
19Literal
20ExprTuple23, 24
21Operationoperator: 25
operand: 31
22Operationoperator: 27
operands: 28
23Operationoperator: 45
operands: 29
24Operationoperator: 45
operands: 30
25Literal
26ExprTuple31
27Literal
28ExprTuple42, 32
29ExprTuple55, 33
30ExprTuple56, 34
31Lambdaparameter: 58
body: 35
32Literal
33Operationoperator: 37
operands: 36
34Operationoperator: 37
operands: 38
35Conditionalvalue: 39
condition: 40
36ExprTuple49, 41
37Literal
38ExprTuple49, 42
39Operationoperator: 43
operands: 44
40Operationoperator: 45
operands: 46
41Variable
42Variable
43Literal
44ExprTuple47, 48
45Literal
46ExprTuple58, 49
47Operationoperator: 51
operand: 53
48Operationoperator: 51
operand: 54
49Variable
50ExprTuple53
51Literal
52ExprTuple54
53Operationoperator: 55
operand: 58
54Operationoperator: 56
operand: 58
55Variable
56Variable
57ExprTuple58
58Variable