logo

Expression of type ExprTuple

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, ExprTuple, IndexedVar, Variable, a, b, c, n
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 = ExprTuple(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), a_{n - 1} + a_{n} + b - c - a_{1} - a_{2}\right)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
wrap_positionsposition(s) at which wrapping is to occur; 'n' is after the nth comma.()()('with_wrapping_at',)
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'leftleft('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1, 2
1Operationoperator: 38
operands: 3
2Operationoperator: 38
operands: 4
3ExprTuple5, 6
4ExprTuple7, 8, 18, 19, 9, 10
5Operationoperator: 38
operands: 11
6Operationoperator: 38
operands: 12
7IndexedVarvariable: 40
index: 21
8IndexedVarvariable: 40
index: 42
9Operationoperator: 45
operand: 22
10Operationoperator: 45
operand: 23
11ExprTuple17, 18
12ExprTuple19, 20
13ExprTuple21
14ExprTuple42
15ExprTuple22
16ExprTuple23
17ExprRangelambda_map: 34
start_index: 24
end_index: 42
18Variable
19Operationoperator: 45
operand: 28
20Operationoperator: 45
operand: 29
21Operationoperator: 38
operands: 27
22IndexedVarvariable: 40
index: 35
23IndexedVarvariable: 40
index: 47
24Literal
25ExprTuple28
26ExprTuple29
27ExprTuple42, 30
28Variable
29Operationoperator: 38
operands: 31
30Operationoperator: 45
operand: 35
31ExprTuple33
32ExprTuple35
33ExprRangelambda_map: 34
start_index: 35
end_index: 36
34Lambdaparameter: 44
body: 37
35Literal
36Operationoperator: 38
operands: 39
37IndexedVarvariable: 40
index: 44
38Literal
39ExprTuple42, 43
40Variable
41ExprTuple44
42Variable
43Operationoperator: 45
operand: 47
44Variable
45Literal
46ExprTuple47
47Literal