logo

Expression of type Implies

from the theory of proveit.core_expr_types.tuples

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 ExprRange, IndexedVar, Variable, a, b, m, n
from proveit.logic import And, Equals, Forall, Implies
from proveit.numbers import Add, NaturalPos, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = IndexedVar(a, one)
sub_expr3 = IndexedVar(b, one)
sub_expr4 = IndexedVar(a, sub_expr1)
sub_expr5 = Add(m, one)
sub_expr6 = IndexedVar(b, sub_expr1)
sub_expr7 = ExprRange(sub_expr1, sub_expr4, one, sub_expr5)
sub_expr8 = ExprRange(sub_expr1, sub_expr6, one, sub_expr5)
sub_expr9 = Equals(sub_expr4, sub_expr6)
sub_expr10 = ExprRange(sub_expr1, sub_expr4, one, m)
sub_expr11 = ExprRange(sub_expr1, sub_expr6, one, m)
sub_expr12 = ExprRange(sub_expr1, sub_expr4, one, n)
sub_expr13 = ExprRange(sub_expr1, sub_expr6, one, n)
expr = Implies(And(Forall(instance_param_or_params = [sub_expr2, sub_expr3], instance_expr = Equals([sub_expr2], [sub_expr3]), condition = Equals(sub_expr2, sub_expr3)), Forall(instance_param_or_params = [m], instance_expr = Forall(instance_param_or_params = [sub_expr7, sub_expr8], instance_expr = Equals([sub_expr7], [sub_expr8]), condition = ExprRange(sub_expr1, sub_expr9, one, sub_expr5)), domain = NaturalPos, condition = Forall(instance_param_or_params = [sub_expr10, sub_expr11], instance_expr = Equals([sub_expr10], [sub_expr11]), condition = ExprRange(sub_expr1, sub_expr9, one, m)))), Forall(instance_param_or_params = [n], instance_expr = Forall(instance_param_or_params = [sub_expr12, sub_expr13], instance_expr = Equals([sub_expr12], [sub_expr13]), condition = ExprRange(sub_expr1, sub_expr9, one, n)), domain = NaturalPos))
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(\left[\forall_{a_{1}, b_{1}~|~a_{1} = b_{1}}~\left(\left(a_{1}\right) = \left(b_{1}\right)\right)\right] \land \left[\forall_{m \in \mathbb{N}^+~|~\forall_{a_{1}, a_{2}, \ldots, a_{m}, b_{1}, b_{2}, \ldots, b_{m}~|~\left(a_{1} = b_{1}\right), \left(a_{2} = b_{2}\right), \ldots, \left(a_{m} = b_{m}\right)}~\left(\left(a_{1}, a_{2}, \ldots, a_{m}\right) = \left(b_{1}, b_{2}, \ldots, b_{m}\right)\right)}~\left[\forall_{a_{1}, a_{2}, \ldots, a_{m + 1}, b_{1}, b_{2}, \ldots, b_{m + 1}~|~\left(a_{1} = b_{1}\right), \left(a_{2} = b_{2}\right), \ldots, \left(a_{m + 1} = b_{m + 1}\right)}~\left(\left(a_{1}, a_{2}, \ldots, a_{m + 1}\right) = \left(b_{1}, b_{2}, \ldots, b_{m + 1}\right)\right)\right]\right]\right) \Rightarrow \left[\forall_{n \in \mathbb{N}^+}~\left[\forall_{a_{1}, a_{2}, \ldots, a_{n}, b_{1}, b_{2}, \ldots, b_{n}~|~\left(a_{1} = b_{1}\right), \left(a_{2} = b_{2}\right), \ldots, \left(a_{n} = b_{n}\right)}~\left(\left(a_{1}, a_{2}, \ldots, a_{n}\right) = \left(b_{1}, b_{2}, \ldots, b_{n}\right)\right)\right]\right]
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.()()('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: 74
operands: 5
4Operationoperator: 47
operand: 9
5ExprTuple7, 8
6ExprTuple9
7Operationoperator: 47
operand: 14
8Operationoperator: 47
operand: 15
9Lambdaparameter: 70
body: 13
10ExprTuple14
11ExprTuple15
12ExprTuple70
13Conditionalvalue: 16
condition: 17
14Lambdaparameters: 29
body: 18
15Lambdaparameter: 88
body: 20
16Operationoperator: 47
operand: 27
17Operationoperator: 45
operands: 22
18Conditionalvalue: 23
condition: 24
19ExprTuple88
20Conditionalvalue: 25
condition: 26
21ExprTuple27
22ExprTuple70, 54
23Operationoperator: 90
operands: 28
24Operationoperator: 90
operands: 29
25Operationoperator: 47
operand: 36
26Operationoperator: 74
operands: 31
27Lambdaparameters: 32
body: 33
28ExprTuple34, 35
29ExprTuple41, 42
30ExprTuple36
31ExprTuple37, 38
32ExprTuple63, 64
33Conditionalvalue: 39
condition: 40
34ExprTuple41
35ExprTuple42
36Lambdaparameters: 43
body: 44
37Operationoperator: 45
operands: 46
38Operationoperator: 47
operand: 55
39Operationoperator: 90
operands: 49
40Operationoperator: 74
operands: 50
41IndexedVarvariable: 94
index: 87
42IndexedVarvariable: 95
index: 87
43ExprTuple71, 72
44Conditionalvalue: 52
condition: 53
45Literal
46ExprTuple88, 54
47Literal
48ExprTuple55
49ExprTuple56, 57
50ExprTuple58
51ExprTuple87
52Operationoperator: 90
operands: 59
53Operationoperator: 74
operands: 60
54Literal
55Lambdaparameters: 61
body: 62
56ExprTuple63
57ExprTuple64
58ExprRangelambda_map: 84
start_index: 87
end_index: 70
59ExprTuple65, 66
60ExprTuple67
61ExprTuple82, 83
62Conditionalvalue: 68
condition: 69
63ExprRangelambda_map: 85
start_index: 87
end_index: 70
64ExprRangelambda_map: 86
start_index: 87
end_index: 70
65ExprTuple71
66ExprTuple72
67ExprRangelambda_map: 84
start_index: 87
end_index: 76
68Operationoperator: 90
operands: 73
69Operationoperator: 74
operands: 75
70Variable
71ExprRangelambda_map: 85
start_index: 87
end_index: 76
72ExprRangelambda_map: 86
start_index: 87
end_index: 76
73ExprTuple77, 78
74Literal
75ExprTuple79
76Operationoperator: 80
operands: 81
77ExprTuple82
78ExprTuple83
79ExprRangelambda_map: 84
start_index: 87
end_index: 88
80Literal
81ExprTuple88, 87
82ExprRangelambda_map: 85
start_index: 87
end_index: 88
83ExprRangelambda_map: 86
start_index: 87
end_index: 88
84Lambdaparameter: 97
body: 89
85Lambdaparameter: 97
body: 92
86Lambdaparameter: 97
body: 93
87Literal
88Variable
89Operationoperator: 90
operands: 91
90Literal
91ExprTuple92, 93
92IndexedVarvariable: 94
index: 97
93IndexedVarvariable: 95
index: 97
94Variable
95Variable
96ExprTuple97
97Variable