logo

Expression of type ExprTuple

from the theory of proveit.numbers.summation

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, c, l
from proveit.numbers import Add, Integer, Mult, Sum, one, zero
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = [l]
sub_expr3 = Add(l, one)
sub_expr4 = IndexedVar(c, one)
sub_expr5 = ExprRange(sub_expr1, IndexedVar(a, sub_expr1), one, zero)
expr = ExprTuple(Mult(sub_expr5, Sum(index_or_indices = sub_expr2, summand = sub_expr3, domain = Integer), sub_expr4), Sum(index_or_indices = sub_expr2, summand = Mult(sub_expr5, sub_expr3, sub_expr4), domain = Integer))
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(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{0} \cdot \left[\sum_{l \in \mathbb{Z}}~\left(l + 1\right)\right] \cdot c_{1}, \sum_{l \in \mathbb{Z}}~\left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{0} \cdot \left(l + 1\right) \cdot c_{1}\right)\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: 14
operands: 3
2Operationoperator: 7
operand: 6
3ExprTuple17, 5, 19
4ExprTuple6
5Operationoperator: 7
operand: 10
6Lambdaparameter: 30
body: 9
7Literal
8ExprTuple10
9Conditionalvalue: 11
condition: 16
10Lambdaparameter: 30
body: 13
11Operationoperator: 14
operands: 15
12ExprTuple30
13Conditionalvalue: 18
condition: 16
14Literal
15ExprTuple17, 18, 19
16Operationoperator: 20
operands: 21
17ExprRangelambda_map: 22
start_index: 31
end_index: 23
18Operationoperator: 24
operands: 25
19IndexedVarvariable: 26
index: 31
20Literal
21ExprTuple30, 28
22Lambdaparameter: 34
body: 29
23Literal
24Literal
25ExprTuple30, 31
26Variable
27ExprTuple31
28Literal
29IndexedVarvariable: 32
index: 34
30Variable
31Literal
32Variable
33ExprTuple34
34Variable