logo

Expression of type Equals

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.
%load_expr # Load the stored expression as 'stored_expr'
# import Expression classes needed to build the expression
from proveit import ExprRange, IndexedVar, Variable, a, b, c, n
from proveit.logic import Equals
from proveit.numbers import Add, Neg, one, subtract, three, two
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = IndexedVar(a, sub_expr1)
sub_expr3 = Neg(c)
expr = Equals(Add(Add(ExprRange(sub_expr1, sub_expr2, three, n), b), subtract(sub_expr3, Add(ExprRange(sub_expr1, sub_expr2, one, subtract(n, two))))), Add(IndexedVar(a, subtract(n, one)), IndexedVar(a, n), b, sub_expr3, Neg(IndexedVar(a, one)), Neg(IndexedVar(a, two))))
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(\left(a_{3} +  a_{4} +  \ldots +  a_{n} + b\right) + \left(-c - \left(a_{1} +  a_{2} +  \ldots +  a_{n - 2}\right)\right)\right) = \left(a_{n - 1} + a_{n} + b - c - a_{1} - a_{2}\right)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
operation'infix' or 'function' style formattinginfixinfix
wrap_positionsposition(s) at which wrapping is to occur; '2 n - 1' is after the nth operand, '2 n' is after the nth operation.()()('with_wrapping_at', 'with_wrap_before_operator', 'with_wrap_after_operator', 'without_wrapping', 'wrap_positions')
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'centercenter('with_justification',)
directionDirection of the relation (normal or reversed)normalnormal('with_direction_reversed', 'is_reversed')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 1
operands: 2
1Literal
2ExprTuple3, 4
3Operationoperator: 40
operands: 5
4Operationoperator: 40
operands: 6
5ExprTuple7, 8
6ExprTuple9, 10, 20, 21, 11, 12
7Operationoperator: 40
operands: 13
8Operationoperator: 40
operands: 14
9IndexedVarvariable: 42
index: 23
10IndexedVarvariable: 42
index: 44
11Operationoperator: 47
operand: 24
12Operationoperator: 47
operand: 25
13ExprTuple19, 20
14ExprTuple21, 22
15ExprTuple23
16ExprTuple44
17ExprTuple24
18ExprTuple25
19ExprRangelambda_map: 36
start_index: 26
end_index: 44
20Variable
21Operationoperator: 47
operand: 30
22Operationoperator: 47
operand: 31
23Operationoperator: 40
operands: 29
24IndexedVarvariable: 42
index: 37
25IndexedVarvariable: 42
index: 49
26Literal
27ExprTuple30
28ExprTuple31
29ExprTuple44, 32
30Variable
31Operationoperator: 40
operands: 33
32Operationoperator: 47
operand: 37
33ExprTuple35
34ExprTuple37
35ExprRangelambda_map: 36
start_index: 37
end_index: 38
36Lambdaparameter: 46
body: 39
37Literal
38Operationoperator: 40
operands: 41
39IndexedVarvariable: 42
index: 46
40Literal
41ExprTuple44, 45
42Variable
43ExprTuple46
44Variable
45Operationoperator: 47
operand: 49
46Variable
47Literal
48ExprTuple49
49Literal