# 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.
# import Expression classes needed to build the expression
from proveit import Lambda, a, alpha, b, c, k
from proveit.core_expr_types import alpha_k
from proveit.logic import Equals
from proveit.numbers import Add, Interval, Sum, one

In [2]:
# build up the expression from sub-expressions
sub_expr1 = [k]
expr = Lambda(alpha, Equals(Sum(index_or_indices = sub_expr1, summand = alpha_k, domain = Interval(a, c)), Add(Sum(index_or_indices = sub_expr1, summand = alpha_k, domain = Interval(a, b)), Sum(index_or_indices = sub_expr1, summand = alpha_k, domain = Interval(Add(b, one), c)))))

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())

\alpha \mapsto \left(\left(\sum_{k = a}^{c} \alpha_{k}\right) = \left(\left(\sum_{k = a}^{b} \alpha_{k}\right) + \left(\sum_{k = b + 1}^{c} \alpha_{k}\right)\right)\right)

In [5]:
stored_expr.style_options()

no style options
In [6]:
# display the expression information
stored_expr.expr_info()

core typesub-expressionsexpression
0Lambdaparameter: 28
body: 2
1ExprTuple28
2Operationoperator: 3
operands: 4
3Literal
4ExprTuple5, 6
5Operationoperator: 14
operand: 9
6Operationoperator: 41
operands: 8
7ExprTuple9
8ExprTuple10, 11
9Lambdaparameter: 33
body: 12
10Operationoperator: 14
operand: 17
11Operationoperator: 14
operand: 18
12Conditionalvalue: 24
condition: 16
13ExprTuple17
14Literal
15ExprTuple18
16Operationoperator: 30
operands: 19
17Lambdaparameter: 33
body: 20
18Lambdaparameter: 33
body: 21
19ExprTuple33, 22
20Conditionalvalue: 24
condition: 23
21Conditionalvalue: 24
condition: 25
22Operationoperator: 36
operands: 26
23Operationoperator: 30
operands: 27
24IndexedVarvariable: 28
index: 33
25Operationoperator: 30
operands: 31
26ExprTuple38, 40
27ExprTuple33, 32
28Variable
29ExprTuple33
30Literal
31ExprTuple33, 34
32Operationoperator: 36
operands: 35
33Variable
34Operationoperator: 36
operands: 37
35ExprTuple38, 43
36Literal
37ExprTuple39, 40
38Variable
39Operationoperator: 41
operands: 42
40Variable
41Literal
42ExprTuple43, 44
43Variable
44Literal