logo

Expression of type Lambda

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, 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 = 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(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..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameters: 1
body: 2
1ExprTuple3
2Conditionalvalue: 4
condition: 5
3ExprRangelambda_map: 6
start_index: 30
end_index: 31
4Operationoperator: 7
operands: 8
5Operationoperator: 9
operands: 10
6Lambdaparameter: 45
body: 40
7Literal
8ExprTuple11, 12
9Literal
10ExprTuple13, 14
11Operationoperator: 15
operands: 16
12Operationoperator: 17
operand: 23
13ExprRangelambda_map: 19
start_index: 30
end_index: 31
14Operationoperator: 20
operands: 21
15Literal
16ExprTuple22
17Literal
18ExprTuple23
19Lambdaparameter: 45
body: 24
20Literal
21ExprTuple25
22ExprRangelambda_map: 26
start_index: 30
end_index: 31
23Variable
24Operationoperator: 27
operands: 28
25ExprRangelambda_map: 29
start_index: 30
end_index: 31
26Lambdaparameter: 45
body: 32
27Literal
28ExprTuple40, 33
29Lambdaparameter: 45
body: 34
30Literal
31Variable
32Operationoperator: 35
operands: 36
33Variable
34Operationoperator: 37
operands: 38
35Literal
36ExprTuple40, 39
37Literal
38ExprTuple40, 41
39IndexedVarvariable: 42
index: 45
40IndexedVarvariable: 43
index: 45
41Literal
42Variable
43Variable
44ExprTuple45
45Variable