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, D, ExprArray, ExprRange, IndexedVar, Variable, j, m
from proveit.numbers import one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = [sub_expr1, j]
expr = ExprArray(ExprRange(sub_expr1, [IndexedVar(A, sub_expr2), IndexedVar(B, sub_expr2), IndexedVar(C, sub_expr2), IndexedVar(D, sub_expr2)], one, m).with_explicit_parameterization(), [D, C, B, A])
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())
\begin{array}{cccc} 
 A_{1, j} & B_{1, j} & C_{1, j} & D_{1, j} \\
A_{2, j} & B_{2, j} & C_{2, j} & D_{2, j} \\
\begin{array}{c}:\\ A_{{_{-}a}, j} \\:\end{array} & \begin{array}{c}:\\ B_{{_{-}a}, j} \\:\end{array} & \begin{array}{c}:\\ C_{{_{-}a}, j} \\:\end{array} & \begin{array}{c}:\\ D_{{_{-}a}, j} \\:\end{array} \\
A_{m, j} & B_{m, j} & C_{m, j} & D_{m, j} \\
D & C & B & A \\
\end{array}

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
1ExprRangelambda_map: 3
start_index: 4
end_index: 5
2ExprTuple15, 14, 13, 12
3Lambdaparameter: 17
body: 7
4Literal
5Variable
6ExprTuple17
7ExprTuple8, 9, 10, 11
8IndexedVarvariable: 12
indices: 16
9IndexedVarvariable: 13
indices: 16
10IndexedVarvariable: 14
indices: 16
11IndexedVarvariable: 15
indices: 16
12Variable
13Variable
14Variable
15Variable
16ExprTuple17, 18
17Variable
18Variable