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, Q, Qx, X, f, fx, x
from proveit.logic import Equals, Forall, Functions, SetOfAll
from proveit.statistics import Prob, ProbOfAll, SampleSpaces
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
expr = Forall(instance_param_or_params = [Omega], instance_expr = Forall(instance_param_or_params = [X], instance_expr = Forall(instance_param_or_params = [f], instance_expr = Forall(instance_param_or_params = [Q], instance_expr = Equals(ProbOfAll(instance_param_or_params = sub_expr1, instance_element = fx, domain = X, condition = Qx), Prob(SetOfAll(instance_param_or_params = sub_expr1, instance_element = fx, domain = X, condition = Qx))).with_wrapping_at(2)), domain = Functions(X, Omega))), 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}~\left[\forall_{f \in \left[X \rightarrow \Omega\right]}~\left[\forall_{Q}~\left(\begin{array}{c} \begin{array}{l} \left[\textrm{Prob}_{x \in X~|~Q\left(x\right)}~f\left(x\right)\right] =  \\ \textrm{Pr}\left(\left\{f\left(x\right)~|~Q\left(x\right)\right\}_{x \in X}\right) \end{array} \end{array}\right)\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: 20
operand: 2
1ExprTuple2
2Lambdaparameter: 31
body: 4
3ExprTuple31
4Conditionalvalue: 5
condition: 6
5Operationoperator: 20
operand: 10
6Operationoperator: 8
operands: 9
7ExprTuple10
8Literal
9ExprTuple31, 11
10Lambdaparameter: 53
body: 13
11Literal
12ExprTuple53
13Operationoperator: 20
operand: 15
14ExprTuple15
15Lambdaparameter: 44
body: 17
16ExprTuple44
17Conditionalvalue: 18
condition: 19
18Operationoperator: 20
operand: 23
19Operationoperator: 49
operands: 22
20Literal
21ExprTuple23
22ExprTuple44, 24
23Lambdaparameter: 51
body: 26
24Operationoperator: 27
operands: 28
25ExprTuple51
26Operationoperator: 29
operands: 30
27Literal
28ExprTuple53, 31
29Literal
30ExprTuple32, 33
31Variable
32Operationoperator: 34
operand: 40
33Operationoperator: 35
operand: 37
34Literal
35Literal
36ExprTuple37
37Operationoperator: 38
operand: 40
38Literal
39ExprTuple40
40Lambdaparameter: 54
body: 41
41Conditionalvalue: 42
condition: 43
42Operationoperator: 44
operand: 54
43Operationoperator: 45
operands: 46
44Variable
45Literal
46ExprTuple47, 48
47Operationoperator: 49
operands: 50
48Operationoperator: 51
operand: 54
49Literal
50ExprTuple54, 53
51Variable
52ExprTuple54
53Variable
54Variable