logo

Expression of type ExprTuple

from the theory of proveit.linear_algebra.vector_sets

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, K, Lambda, V, Variable, a, n
from proveit.core_expr_types import a_1_to_n
from proveit.linear_algebra import VecZero, lin_comb_axn, some_nonzero_a
from proveit.logic import And, Equals, 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([a_1_to_n], Conditional(Equals(lin_comb_axn, VecZero(V)), And(ExprRange(sub_expr1, InSet(IndexedVar(a, sub_expr1), K), one, n), some_nonzero_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())
\left(\left(a_{1}, a_{2}, \ldots, a_{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) = \vec{0}\left(V\right) \textrm{ if } \left(a_{1} \in K\right) ,  \left(a_{2} \in K\right) ,  \ldots ,  \left(a_{n} \in K\right) ,  \left(a_{1} \neq 0\right) \lor  \left(a_{2} \neq 0\right) \lor  \ldots \lor  \left(a_{n} \neq 0\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: 31
end_index: 32
5Operationoperator: 8
operands: 9
6Operationoperator: 10
operands: 11
7Lambdaparameter: 46
body: 41
8Literal
9ExprTuple12, 13
10Literal
11ExprTuple14, 15
12Operationoperator: 16
operands: 17
13Operationoperator: 18
operand: 24
14ExprRangelambda_map: 20
start_index: 31
end_index: 32
15Operationoperator: 21
operands: 22
16Literal
17ExprTuple23
18Literal
19ExprTuple24
20Lambdaparameter: 46
body: 25
21Literal
22ExprTuple26
23ExprRangelambda_map: 27
start_index: 31
end_index: 32
24Variable
25Operationoperator: 28
operands: 29
26ExprRangelambda_map: 30
start_index: 31
end_index: 32
27Lambdaparameter: 46
body: 33
28Literal
29ExprTuple41, 34
30Lambdaparameter: 46
body: 35
31Literal
32Variable
33Operationoperator: 36
operands: 37
34Variable
35Operationoperator: 38
operands: 39
36Literal
37ExprTuple41, 40
38Literal
39ExprTuple41, 42
40IndexedVarvariable: 43
index: 46
41IndexedVarvariable: 44
index: 46
42Literal
43Variable
44Variable
45ExprTuple46
46Variable