# from the theory of proveit.numbers.addition.subtraction¶

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 Conditional, b, d, i, j, k
from proveit.core_expr_types import a_1_to_i, c_1_to_j, e_1_to_k
from proveit.logic import And, Equals, Forall, InSet
from proveit.numbers import Add, Complex, Natural, Neg

In [2]:
# build up the expression from sub-expressions
expr = Conditional(Forall(instance_param_or_params = [a_1_to_i, b, c_1_to_j, d, e_1_to_k], instance_expr = Equals(Add(a_1_to_i, b, c_1_to_j, Neg(d), e_1_to_k), Add(a_1_to_i, c_1_to_j, e_1_to_k)), domain = Complex, condition = Equals(b, d)), 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\{\forall_{a_{1}, a_{2}, \ldots, a_{i}, b, c_{1}, c_{2}, \ldots, c_{j}, d, e_{1}, e_{2}, \ldots, e_{k} \in \mathbb{C}~|~b = d}~\left(\left(a_{1} +  a_{2} +  \ldots +  a_{i} + b+ c_{1} +  c_{2} +  \ldots +  c_{j} - d+ e_{1} +  e_{2} +  \ldots +  e_{k}\right) = \left(a_{1} +  a_{2} +  \ldots +  a_{i}+ c_{1} +  c_{2} +  \ldots +  c_{j}+ e_{1} +  e_{2} +  \ldots +  e_{k}\right)\right) \textrm{ if } i \in \mathbb{N} ,  j \in \mathbb{N} ,  k \in \mathbb{N}\right..

In [5]:
stored_expr.style_options()

namedescriptiondefaultcurrent valuerelated methods
condition_delimiter'comma' or 'and'commacomma('with_comma_delimiter', 'with_conjunction_delimiter')
In [6]:
# display the expression information
stored_expr.expr_info()

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