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 A, B, C, Omega, Qx, X, f, fx, x
from proveit.logic import Equals, Forall, Injections
from proveit.numbers import Add
from proveit.statistics import ProbOfAll
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
expr = Forall(instance_param_or_params = [f], instance_expr = Equals(ProbOfAll(instance_param_or_params = sub_expr1, instance_element = fx, domain = C, condition = Qx), Add(ProbOfAll(instance_param_or_params = sub_expr1, instance_element = fx, domain = A, condition = Qx), ProbOfAll(instance_param_or_params = sub_expr1, instance_element = fx, domain = B, condition = Qx))), domain = Injections(X, Omega))
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_{f \in \left[X \xrightarrow[]{\text{1-to-1}} \Omega\right]}~\left(\left[\textrm{Prob}_{x \in C~|~Q\left(x\right)}~f\left(x\right)\right] = \left(\left[\textrm{Prob}_{x \in A~|~Q\left(x\right)}~f\left(x\right)\right] + \left[\textrm{Prob}_{x \in B~|~Q\left(x\right)}~f\left(x\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: 1
operand: 3
1Literal
2ExprTuple3
3Lambdaparameter: 40
body: 5
4ExprTuple40
5Conditionalvalue: 6
condition: 7
6Operationoperator: 8
operands: 9
7Operationoperator: 48
operands: 10
8Literal
9ExprTuple11, 12
10ExprTuple40, 13
11Operationoperator: 26
operand: 19
12Operationoperator: 15
operands: 16
13Operationoperator: 17
operands: 18
14ExprTuple19
15Literal
16ExprTuple20, 21
17Literal
18ExprTuple22, 23
19Lambdaparameter: 54
body: 24
20Operationoperator: 26
operand: 29
21Operationoperator: 26
operand: 30
22Variable
23Variable
24Conditionalvalue: 36
condition: 28
25ExprTuple29
26Literal
27ExprTuple30
28Operationoperator: 41
operands: 31
29Lambdaparameter: 54
body: 32
30Lambdaparameter: 54
body: 33
31ExprTuple34, 46
32Conditionalvalue: 36
condition: 35
33Conditionalvalue: 36
condition: 37
34Operationoperator: 48
operands: 38
35Operationoperator: 41
operands: 39
36Operationoperator: 40
operand: 54
37Operationoperator: 41
operands: 42
38ExprTuple54, 43
39ExprTuple44, 46
40Variable
41Literal
42ExprTuple45, 46
43Variable
44Operationoperator: 48
operands: 47
45Operationoperator: 48
operands: 49
46Operationoperator: 50
operand: 54
47ExprTuple54, 52
48Literal
49ExprTuple54, 53
50Variable
51ExprTuple54
52Variable
53Variable
54Variable