# from the theory of proveit.numbers.addition¶

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, i, j, k
from proveit.core_expr_types import a_1_to_i, b_1_to_j, c_1_to_k
from proveit.logic import And, Equals, Forall, InSet
from proveit.numbers import Add, Complex, Natural

In [2]:
# build up the expression from sub-expressions
expr = Lambda([i, j, k], Conditional(Forall(instance_param_or_params = [a_1_to_i, b_1_to_j, c_1_to_k], instance_expr = Equals(Add(a_1_to_i, Add(b_1_to_j), c_1_to_k), Add(a_1_to_i, b_1_to_j, c_1_to_k)).with_wrapping_at(2), domain = Complex), And(InSet(i, Natural), InSet(j, Natural), InSet(k, Natural))))

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(i, j, k\right) \mapsto \left\{\forall_{a_{1}, a_{2}, \ldots, a_{i}, b_{1}, b_{2}, \ldots, b_{j}, c_{1}, c_{2}, \ldots, c_{k} \in \mathbb{C}}~\left(\begin{array}{c} \begin{array}{l} \left(a_{1} +  a_{2} +  \ldots +  a_{i} + \left(b_{1} +  b_{2} +  \ldots +  b_{j}\right)+ c_{1} +  c_{2} +  \ldots +  c_{k}\right) =  \\ \left(a_{1} +  a_{2} +  \ldots +  a_{i}+ b_{1} +  b_{2} +  \ldots +  b_{j}+ c_{1} +  c_{2} +  \ldots +  c_{k}\right) \end{array} \end{array}\right) \textrm{ if } i \in \mathbb{N} ,  j \in \mathbb{N} ,  k \in \mathbb{N}\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
1ExprTuple42, 55, 44
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 21
operands: 7
5Literal
6ExprTuple8
7ExprTuple9, 10, 11
8Lambdaparameters: 29
body: 12
9Operationoperator: 47
operands: 13
10Operationoperator: 47
operands: 14
11Operationoperator: 47
operands: 15
12Conditionalvalue: 16
condition: 17
13ExprTuple42, 18
14ExprTuple55, 18
15ExprTuple44, 18
16Operationoperator: 19
operands: 20
17Operationoperator: 21
operands: 22
18Literal
19Literal
20ExprTuple23, 24
21Literal
22ExprTuple25, 26, 27
23Operationoperator: 39
operands: 28
24Operationoperator: 39
operands: 29
25ExprRangelambda_map: 30
start_index: 54
end_index: 42
26ExprRangelambda_map: 31
start_index: 54
end_index: 55
27ExprRangelambda_map: 32
start_index: 54
end_index: 44
28ExprTuple34, 33, 35
29ExprTuple34, 49, 35
30Lambdaparameter: 61
body: 36
31Lambdaparameter: 61
body: 37
32Lambdaparameter: 61
body: 38
33Operationoperator: 39
operands: 40
34ExprRangelambda_map: 41
start_index: 54
end_index: 42
35ExprRangelambda_map: 43
start_index: 54
end_index: 44
36Operationoperator: 47
operands: 45
37Operationoperator: 47
operands: 46
38Operationoperator: 47
operands: 48
39Literal
40ExprTuple49
41Lambdaparameter: 61
body: 50
42Variable
43Lambdaparameter: 61
body: 51
44Variable
45ExprTuple50, 52
46ExprTuple58, 52
47Literal
48ExprTuple51, 52
49ExprRangelambda_map: 53
start_index: 54
end_index: 55
50IndexedVarvariable: 56
index: 61
51IndexedVarvariable: 57
index: 61
52Literal
53Lambdaparameter: 61
body: 58
54Literal
55Variable
56Variable
57Variable
58IndexedVarvariable: 59
index: 61
59Variable
60ExprTuple61
61Variable