logo

Expression of type Implies

from the theory of proveit.numbers.summation

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 k, m, n
from proveit.logic import And, Equals, Forall, Implies, TRUE
from proveit.numbers import Add, Interval, Mult, NaturalPos, Sum, frac, one, two
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [k]
sub_expr2 = Add(m, one)
expr = Implies(And(TRUE, Forall(instance_param_or_params = [m], instance_expr = Equals(Sum(index_or_indices = sub_expr1, summand = k, domain = Interval(one, sub_expr2)), frac(Mult(sub_expr2, Add(m, two)), two)), domain = NaturalPos, condition = Equals(Sum(index_or_indices = sub_expr1, summand = k, domain = Interval(one, m)), frac(Mult(m, sub_expr2), two)))), Forall(instance_param_or_params = [n], instance_expr = Equals(Sum(index_or_indices = sub_expr1, summand = k, domain = Interval(one, n)), frac(Mult(n, Add(n, one)), two)), 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(\top \land \left[\forall_{m \in \mathbb{N}^+~|~\left(\sum_{k = 1}^{m} k\right) = \frac{m \cdot \left(m + 1\right)}{2}}~\left(\left(\sum_{k = 1}^{m + 1} k\right) = \frac{\left(m + 1\right) \cdot \left(m + 2\right)}{2}\right)\right]\right) \Rightarrow \left[\forall_{n \in \mathbb{N}^+}~\left(\left(\sum_{k = 1}^{n} k\right) = \frac{n \cdot \left(n + 1\right)}{2}\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: 26
operands: 5
4Operationoperator: 10
operand: 9
5ExprTuple7, 8
6ExprTuple9
7Literal
8Operationoperator: 10
operand: 14
9Lambdaparameter: 73
body: 13
10Literal
11ExprTuple14
12ExprTuple73
13Conditionalvalue: 15
condition: 16
14Lambdaparameter: 85
body: 18
15Operationoperator: 39
operands: 19
16Operationoperator: 75
operands: 20
17ExprTuple85
18Conditionalvalue: 21
condition: 22
19ExprTuple23, 24
20ExprTuple73, 45
21Operationoperator: 39
operands: 25
22Operationoperator: 26
operands: 27
23Operationoperator: 52
operand: 34
24Operationoperator: 54
operands: 29
25ExprTuple30, 31
26Literal
27ExprTuple32, 33
28ExprTuple34
29ExprTuple35, 71
30Operationoperator: 52
operand: 43
31Operationoperator: 54
operands: 37
32Operationoperator: 75
operands: 38
33Operationoperator: 39
operands: 40
34Lambdaparameter: 78
body: 41
35Operationoperator: 67
operands: 42
36ExprTuple43
37ExprTuple44, 71
38ExprTuple85, 45
39Literal
40ExprTuple46, 47
41Conditionalvalue: 78
condition: 48
42ExprTuple73, 49
43Lambdaparameter: 78
body: 50
44Operationoperator: 67
operands: 51
45Literal
46Operationoperator: 52
operand: 60
47Operationoperator: 54
operands: 55
48Operationoperator: 75
operands: 56
49Operationoperator: 80
operands: 57
50Conditionalvalue: 78
condition: 58
51ExprTuple77, 59
52Literal
53ExprTuple60
54Literal
55ExprTuple61, 71
56ExprTuple78, 62
57ExprTuple73, 84
58Operationoperator: 75
operands: 63
59Operationoperator: 80
operands: 64
60Lambdaparameter: 78
body: 66
61Operationoperator: 67
operands: 68
62Operationoperator: 82
operands: 69
63ExprTuple78, 70
64ExprTuple85, 71
65ExprTuple78
66Conditionalvalue: 78
condition: 72
67Literal
68ExprTuple85, 77
69ExprTuple84, 73
70Operationoperator: 82
operands: 74
71Literal
72Operationoperator: 75
operands: 76
73Variable
74ExprTuple84, 77
75Literal
76ExprTuple78, 79
77Operationoperator: 80
operands: 81
78Variable
79Operationoperator: 82
operands: 83
80Literal
81ExprTuple85, 84
82Literal
83ExprTuple84, 85
84Literal
85Variable