# 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 Conditional, Lambda, a, alpha, b, c, k
from proveit.core_expr_types import alpha_k
from proveit.logic import And, Equals, Forall, InSet
from proveit.numbers import Add, Integer, Interval, LessEq, Sum, one

In [2]:
# build up the expression from sub-expressions
sub_expr1 = [k]
expr = Lambda([a, b, c], Conditional(Forall(instance_param_or_params = [alpha], instance_expr = 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))))), And(InSet(a, Integer), InSet(b, Integer), InSet(c, Integer), And(LessEq(a, b), LessEq(b, c)).with_total_ordering_style())))

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(a, b, c\right) \mapsto \left\{\forall_{\alpha}~\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) \textrm{ if } a \in \mathbb{Z} ,  b \in \mathbb{Z} ,  c \in \mathbb{Z} ,  a \leq b \leq c\right..

In [5]:
stored_expr.style_options()

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

core typesub-expressionsexpression
0Lambdaparameters: 1
body: 2
1ExprTuple60, 65, 62
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 18
operands: 7
5Literal
6ExprTuple8
7ExprTuple9, 10, 11, 12
8Lambdaparameter: 50
body: 14
9Operationoperator: 52
operands: 15
10Operationoperator: 52
operands: 16
11Operationoperator: 52
operands: 17
12Operationoperator: 18
operands: 19
13ExprTuple50
14Operationoperator: 20
operands: 21
15ExprTuple60, 22
16ExprTuple65, 22
17ExprTuple62, 22
18Literal
19ExprTuple23, 24
20Literal
21ExprTuple25, 26
22Literal
23Operationoperator: 27
operands: 57
24Operationoperator: 27
operands: 28
25Operationoperator: 36
operand: 31
26Operationoperator: 63
operands: 30
27Literal
28ExprTuple65, 62
29ExprTuple31
30ExprTuple32, 33
31Lambdaparameter: 55
body: 34
32Operationoperator: 36
operand: 39
33Operationoperator: 36
operand: 40
34Conditionalvalue: 46
condition: 38
35ExprTuple39
36Literal
37ExprTuple40
38Operationoperator: 52
operands: 41
39Lambdaparameter: 55
body: 42
40Lambdaparameter: 55
body: 43
41ExprTuple55, 44
42Conditionalvalue: 46
condition: 45
43Conditionalvalue: 46
condition: 47
44Operationoperator: 58
operands: 48
45Operationoperator: 52
operands: 49
46IndexedVarvariable: 50
index: 55
47Operationoperator: 52
operands: 53
48ExprTuple60, 62
49ExprTuple55, 54
50Variable
51ExprTuple55
52Literal
53ExprTuple55, 56
54Operationoperator: 58
operands: 57
55Variable
56Operationoperator: 58
operands: 59
57ExprTuple60, 65
58Literal
59ExprTuple61, 62
60Variable
61Operationoperator: 63
operands: 64
62Variable
63Literal
64ExprTuple65, 66
65Variable
66Literal