logo

Expression of type ExprTuple

from the theory of proveit.linear_algebra.scalar_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 Conditional, ExprRange, ExprTuple, IndexedVar, Lambda, V, Variable, n, x
from proveit.core_expr_types import x_1_to_n
from proveit.linear_algebra import lin_comb_axn
from proveit.logic import And, InSet
from proveit.numbers import one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = ExprTuple(Lambda([x_1_to_n], Conditional(InSet(lin_comb_axn, V), And(ExprRange(sub_expr1, InSet(IndexedVar(x, sub_expr1), V), one, n)))))
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(x_{1}, x_{2}, \ldots, x_{n}\right) \mapsto \left\{\left(\left(a_{1} \cdot x_{1}\right) +  \left(a_{2} \cdot x_{2}\right) +  \ldots +  \left(a_{n} \cdot x_{n}\right)\right) \in V \textrm{ if } \left(x_{1} \in V\right) \land  \left(x_{2} \in V\right) \land  \ldots \land  \left(x_{n} \in V\right)\right..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameters: 2
body: 3
2ExprTuple4
3Conditionalvalue: 5
condition: 6
4ExprRangelambda_map: 7
start_index: 19
end_index: 20
5Operationoperator: 21
operands: 8
6Operationoperator: 9
operands: 10
7Lambdaparameter: 32
body: 28
8ExprTuple11, 24
9Literal
10ExprTuple12
11Operationoperator: 13
operands: 14
12ExprRangelambda_map: 15
start_index: 19
end_index: 20
13Literal
14ExprTuple16
15Lambdaparameter: 32
body: 17
16ExprRangelambda_map: 18
start_index: 19
end_index: 20
17Operationoperator: 21
operands: 22
18Lambdaparameter: 32
body: 23
19Literal
20Variable
21Literal
22ExprTuple28, 24
23Operationoperator: 25
operands: 26
24Variable
25Literal
26ExprTuple27, 28
27IndexedVarvariable: 29
index: 32
28IndexedVarvariable: 30
index: 32
29Variable
30Variable
31ExprTuple32
32Variable