logo

Expression of type And

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
from proveit.logic import And, Equals, Forall, 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 = 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))))
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())
\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]
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',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 12
operands: 1
1ExprTuple2, 3
2Literal
3Operationoperator: 4
operand: 6
4Literal
5ExprTuple6
6Lambdaparameter: 58
body: 8
7ExprTuple58
8Conditionalvalue: 9
condition: 10
9Operationoperator: 21
operands: 11
10Operationoperator: 12
operands: 13
11ExprTuple14, 15
12Literal
13ExprTuple16, 17
14Operationoperator: 30
operand: 23
15Operationoperator: 32
operands: 19
16Operationoperator: 48
operands: 20
17Operationoperator: 21
operands: 22
18ExprTuple23
19ExprTuple24, 45
20ExprTuple58, 25
21Literal
22ExprTuple26, 27
23Lambdaparameter: 51
body: 28
24Operationoperator: 42
operands: 29
25Literal
26Operationoperator: 30
operand: 36
27Operationoperator: 32
operands: 33
28Conditionalvalue: 51
condition: 34
29ExprTuple50, 35
30Literal
31ExprTuple36
32Literal
33ExprTuple37, 45
34Operationoperator: 48
operands: 38
35Operationoperator: 53
operands: 39
36Lambdaparameter: 51
body: 41
37Operationoperator: 42
operands: 43
38ExprTuple51, 44
39ExprTuple58, 45
40ExprTuple51
41Conditionalvalue: 51
condition: 46
42Literal
43ExprTuple58, 50
44Operationoperator: 55
operands: 47
45Literal
46Operationoperator: 48
operands: 49
47ExprTuple57, 50
48Literal
49ExprTuple51, 52
50Operationoperator: 53
operands: 54
51Variable
52Operationoperator: 55
operands: 56
53Literal
54ExprTuple58, 57
55Literal
56ExprTuple57, 58
57Literal
58Variable