logo

Expression of type ExprArray

from the theory of proveit.core_expr_types.expr_arrays

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 A, B, C, ExprArray, ExprRange, IndexedVar, Variable, i, j
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = IndexedVar(B, sub_expr1)
expr = ExprArray([ExprRange(sub_expr1, IndexedVar(C, sub_expr1), i, j), ExprRange(sub_expr1, sub_expr2, j, i)], [ExprRange(sub_expr1, IndexedVar(A, sub_expr1), i, j), ExprRange(sub_expr1, sub_expr2, i, 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())
ExprArray\left(\begin{array}{c} \left(C_{i}, C_{i + 1}, \ldots, C_{j},B_{j}, B_{j + 1}, \ldots, B_{i}\right),  \\ \left(A_{i}, A_{i + 1}, \ldots, A_{j},B_{i}, B_{i + 1}, \ldots, B_{j}\right) \end{array}\right)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
justificationjustify to the 'left', 'center', or 'right' in the array cellscentercenterwith_justification
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1, 2
1ExprTuple3, 4
2ExprTuple5, 6
3ExprRangelambda_map: 7
start_index: 10
end_index: 11
4ExprRangelambda_map: 9
start_index: 11
end_index: 10
5ExprRangelambda_map: 8
start_index: 10
end_index: 11
6ExprRangelambda_map: 9
start_index: 10
end_index: 11
7Lambdaparameter: 19
body: 12
8Lambdaparameter: 19
body: 13
9Lambdaparameter: 19
body: 14
10Variable
11Variable
12IndexedVarvariable: 15
index: 19
13IndexedVarvariable: 16
index: 19
14IndexedVarvariable: 17
index: 19
15Variable
16Variable
17Variable
18ExprTuple19
19Variable