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 ExprTuple, 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 = ExprTuple(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())

\left(\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)\right)

In [5]:
stored_expr.style_options()

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

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