logo

Expression of type Abs

from the theory of proveit.numbers.multiplication

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, b, j
from proveit.core_expr_types import a_1_to_i, c_1_to_k
from proveit.numbers import Abs, Add, Mult, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_b", latex_format = r"{_{-}b}")
expr = Abs(Add(ExprRange(sub_expr1, Mult(a_1_to_i, IndexedVar(b, sub_expr1), c_1_to_k), one, j)))
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_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{i} \cdot b_{1}\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{k}\right) +  \left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{i} \cdot b_{2}\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{k}\right) +  \ldots +  \left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{i} \cdot b_{j}\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{k}\right)\right|
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
operation'infix' or 'function' style formattinginfixinfix
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 1
operand: 3
1Literal
2ExprTuple3
3Operationoperator: 4
operands: 5
4Literal
5ExprTuple6
6ExprRangelambda_map: 7
start_index: 20
end_index: 8
7Lambdaparameter: 23
body: 9
8Variable
9Operationoperator: 10
operands: 11
10Literal
11ExprTuple12, 13, 14
12ExprRangelambda_map: 15
start_index: 20
end_index: 16
13IndexedVarvariable: 17
index: 23
14ExprRangelambda_map: 19
start_index: 20
end_index: 21
15Lambdaparameter: 28
body: 22
16Variable
17Variable
18ExprTuple23
19Lambdaparameter: 28
body: 24
20Literal
21Variable
22IndexedVarvariable: 25
index: 28
23Variable
24IndexedVarvariable: 26
index: 28
25Variable
26Variable
27ExprTuple28
28Variable