logo

Expression of type Conditional

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 Conditional, Omega, Q, Qx, X, f, fx, x
from proveit.logic import Equals, Forall, Functions, InClass, SetOfAll
from proveit.statistics import Prob, ProbOfAll, SampleSpaces
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
expr = Conditional(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))), InClass(Omega, 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())
\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] \textrm{ if } \Omega \underset{{\scriptscriptstyle c}}{\in} \textrm{SampleSpaces}\right..
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
condition_delimiter'comma' or 'and'commacomma('with_comma_delimiter', 'with_conjunction_delimiter')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Conditionalvalue: 1
condition: 2
1Operationoperator: 16
operand: 6
2Operationoperator: 4
operands: 5
3ExprTuple6
4Literal
5ExprTuple27, 7
6Lambdaparameter: 49
body: 9
7Literal
8ExprTuple49
9Operationoperator: 16
operand: 11
10ExprTuple11
11Lambdaparameter: 40
body: 13
12ExprTuple40
13Conditionalvalue: 14
condition: 15
14Operationoperator: 16
operand: 19
15Operationoperator: 45
operands: 18
16Literal
17ExprTuple19
18ExprTuple40, 20
19Lambdaparameter: 47
body: 22
20Operationoperator: 23
operands: 24
21ExprTuple47
22Operationoperator: 25
operands: 26
23Literal
24ExprTuple49, 27
25Literal
26ExprTuple28, 29
27Variable
28Operationoperator: 30
operand: 36
29Operationoperator: 31
operand: 33
30Literal
31Literal
32ExprTuple33
33Operationoperator: 34
operand: 36
34Literal
35ExprTuple36
36Lambdaparameter: 50
body: 37
37Conditionalvalue: 38
condition: 39
38Operationoperator: 40
operand: 50
39Operationoperator: 41
operands: 42
40Variable
41Literal
42ExprTuple43, 44
43Operationoperator: 45
operands: 46
44Operationoperator: 47
operand: 50
45Literal
46ExprTuple50, 49
47Variable
48ExprTuple50
49Variable
50Variable