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, R, Rx, X, f, fx, x
from proveit.logic import Forall, Functions, Implies, InClass
from proveit.numbers import LessEq
from proveit.statistics import 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, R], instance_expr = Implies(Forall(instance_param_or_params = sub_expr1, instance_expr = Rx, domain = X, condition = Qx), LessEq(ProbOfAll(instance_param_or_params = sub_expr1, instance_element = fx, domain = X, condition = Qx), ProbOfAll(instance_param_or_params = sub_expr1, instance_element = fx, domain = X, condition = Rx)).with_wrapping_at(2)).with_wrapping_at(2)), domain = Functions(X, Omega)).with_wrapping()), 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[\begin{array}{l}\forall_{f \in \left[X \rightarrow \Omega\right]}~\\
\left[\forall_{Q, R}~\left(\begin{array}{c} \begin{array}{l} \left[\forall_{x \in X~|~Q\left(x\right)}~R\left(x\right)\right] \Rightarrow  \\ \left(\begin{array}{c} \begin{array}{l} \left[\textrm{Prob}_{x \in X~|~Q\left(x\right)}~f\left(x\right)\right] \leq  \\ \left[\textrm{Prob}_{x \in X~|~R\left(x\right)}~f\left(x\right)\right] \end{array} \end{array}\right) \end{array} \end{array}\right)\right]\end{array}\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: 29
operand: 6
2Operationoperator: 4
operands: 5
3ExprTuple6
4Literal
5ExprTuple26, 7
6Lambdaparameter: 59
body: 9
7Literal
8ExprTuple59
9Operationoperator: 29
operand: 11
10ExprTuple11
11Lambdaparameter: 48
body: 13
12ExprTuple48
13Conditionalvalue: 14
condition: 15
14Operationoperator: 29
operand: 18
15Operationoperator: 55
operands: 17
16ExprTuple18
17ExprTuple48, 19
18Lambdaparameters: 20
body: 21
19Operationoperator: 22
operands: 23
20ExprTuple54, 57
21Operationoperator: 24
operands: 25
22Literal
23ExprTuple59, 26
24Literal
25ExprTuple27, 28
26Variable
27Operationoperator: 29
operand: 33
28Operationoperator: 31
operands: 32
29Literal
30ExprTuple33
31Literal
32ExprTuple34, 35
33Lambdaparameter: 60
body: 36
34Operationoperator: 38
operand: 40
35Operationoperator: 38
operand: 41
36Conditionalvalue: 53
condition: 44
37ExprTuple40
38Literal
39ExprTuple41
40Lambdaparameter: 60
body: 42
41Lambdaparameter: 60
body: 43
42Conditionalvalue: 45
condition: 44
43Conditionalvalue: 45
condition: 46
44Operationoperator: 49
operands: 47
45Operationoperator: 48
operand: 60
46Operationoperator: 49
operands: 50
47ExprTuple52, 51
48Variable
49Literal
50ExprTuple52, 53
51Operationoperator: 54
operand: 60
52Operationoperator: 55
operands: 56
53Operationoperator: 57
operand: 60
54Variable
55Literal
56ExprTuple60, 59
57Variable
58ExprTuple60
59Variable
60Variable