logo

Expression of type ExprTuple

from the theory of proveit.core_expr_types.tuples

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, Function, Variable, f, i, j
from proveit.numbers import Add, one, subtract, two
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = ExprTuple([ExprRange(sub_expr1, Function(f, [Add(sub_expr1, one)]), subtract(i, one), subtract(j, one))], [ExprRange(sub_expr1, Function(f, [Add(sub_expr1, two)]), subtract(i, two), subtract(j, 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(f\left(\left(i - 1\right) + 1\right), f\left(i + 1\right), \ldots, f\left(\left(j - 1\right) + 1\right)\right), \left(f\left(\left(i - 2\right) + 2\right), f\left(\left(i - 1\right) + 2\right), \ldots, f\left(\left(j - 2\right) + 2\right)\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
1ExprTuple3
2ExprTuple4
3ExprRangelambda_map: 5
start_index: 6
end_index: 7
4ExprRangelambda_map: 8
start_index: 9
end_index: 10
5Lambdaparameter: 34
body: 11
6Operationoperator: 31
operands: 12
7Operationoperator: 31
operands: 13
8Lambdaparameter: 34
body: 15
9Operationoperator: 31
operands: 16
10Operationoperator: 31
operands: 17
11Operationoperator: 20
operand: 25
12ExprTuple22, 19
13ExprTuple23, 19
14ExprTuple34
15Operationoperator: 20
operand: 27
16ExprTuple22, 24
17ExprTuple23, 24
18ExprTuple25
19Operationoperator: 28
operand: 33
20Variable
21ExprTuple27
22Variable
23Variable
24Operationoperator: 28
operand: 35
25Operationoperator: 31
operands: 30
26ExprTuple33
27Operationoperator: 31
operands: 32
28Literal
29ExprTuple35
30ExprTuple34, 33
31Literal
32ExprTuple34, 35
33Literal
34Variable
35Literal