logo

Expression of type Implies

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 Qx, Rx, Ry, X, fx, fy, x, y
from proveit.logic import Equals, Forall, Implies, Not
from proveit.numbers import one, subtract
from proveit.statistics import ProbOfAll
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
expr = Implies(Forall(instance_param_or_params = sub_expr1, instance_expr = Equals(Qx, Not(Rx)), domain = X), Equals(ProbOfAll(instance_param_or_params = sub_expr1, instance_element = fx, domain = X, condition = Qx), subtract(one, ProbOfAll(instance_param_or_params = [y], instance_element = fy, domain = X, condition = Ry))).with_wrapping_at(2)).with_wrapping_at(2)
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())
\begin{array}{c} \begin{array}{l} \left[\forall_{x \in X}~\left(Q\left(x\right) = (\lnot R\left(x\right))\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] =  \\ \left(1 - \left[\textrm{Prob}_{y \in X~|~R\left(y\right)}~f\left(y\right)\right]\right) \end{array} \end{array}\right) \end{array} \end{array}
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
operation'infix' or 'function' style formattinginfixinfix
wrap_positionsposition(s) at which wrapping is to occur; '2 n - 1' is after the nth operand, '2 n' is after the nth operation.()(2)('with_wrapping_at', 'with_wrap_before_operator', 'with_wrap_after_operator', 'without_wrapping', 'wrap_positions')
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'centercenter('with_justification',)
directionDirection of the relation (normal or reversed)normalnormal('with_direction_reversed', 'is_reversed')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 1
operands: 2
1Literal
2ExprTuple3, 4
3Operationoperator: 5
operand: 8
4Operationoperator: 19
operands: 7
5Literal
6ExprTuple8
7ExprTuple9, 10
8Lambdaparameter: 41
body: 11
9Operationoperator: 31
operand: 16
10Operationoperator: 13
operands: 14
11Conditionalvalue: 15
condition: 34
12ExprTuple16
13Literal
14ExprTuple17, 18
15Operationoperator: 19
operands: 20
16Lambdaparameter: 41
body: 21
17Literal
18Operationoperator: 22
operand: 27
19Literal
20ExprTuple35, 24
21Conditionalvalue: 25
condition: 26
22Literal
23ExprTuple27
24Operationoperator: 28
operand: 33
25Operationoperator: 44
operand: 41
26Operationoperator: 45
operands: 30
27Operationoperator: 31
operand: 36
28Literal
29ExprTuple33
30ExprTuple34, 35
31Literal
32ExprTuple36
33Operationoperator: 51
operand: 41
34Operationoperator: 49
operands: 37
35Operationoperator: 38
operand: 41
36Lambdaparameter: 54
body: 40
37ExprTuple41, 53
38Variable
39ExprTuple41
40Conditionalvalue: 42
condition: 43
41Variable
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