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, InSet
from proveit.numbers import LessEq
from proveit.statistics import ProbOfAll
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
expr = Conditional(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)), InSet(f, Functions(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())
\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) \textrm{ if } f \in \left[X \rightarrow \Omega\right]\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: 5
2Operationoperator: 42
operands: 4
3ExprTuple5
4ExprTuple35, 6
5Lambdaparameters: 7
body: 8
6Operationoperator: 9
operands: 10
7ExprTuple41, 44
8Operationoperator: 11
operands: 12
9Literal
10ExprTuple46, 13
11Literal
12ExprTuple14, 15
13Variable
14Operationoperator: 16
operand: 20
15Operationoperator: 18
operands: 19
16Literal
17ExprTuple20
18Literal
19ExprTuple21, 22
20Lambdaparameter: 47
body: 23
21Operationoperator: 25
operand: 27
22Operationoperator: 25
operand: 28
23Conditionalvalue: 40
condition: 31
24ExprTuple27
25Literal
26ExprTuple28
27Lambdaparameter: 47
body: 29
28Lambdaparameter: 47
body: 30
29Conditionalvalue: 32
condition: 31
30Conditionalvalue: 32
condition: 33
31Operationoperator: 36
operands: 34
32Operationoperator: 35
operand: 47
33Operationoperator: 36
operands: 37
34ExprTuple39, 38
35Variable
36Literal
37ExprTuple39, 40
38Operationoperator: 41
operand: 47
39Operationoperator: 42
operands: 43
40Operationoperator: 44
operand: 47
41Variable
42Literal
43ExprTuple47, 46
44Variable
45ExprTuple47
46Variable
47Variable