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, n, x
from proveit.core_expr_types import a_1_to_n, x_1_to_n
from proveit.linear_algebra import Span, lin_comb_axn
from proveit.logic import And, Equals, InSet, Set, SetOfAll
from proveit.numbers import one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Lambda([x_1_to_n], Conditional(Equals(Span(Set(x_1_to_n)), SetOfAll(instance_param_or_params = [a_1_to_n], instance_element = lin_comb_axn, domain = K)).with_wrapping_at(2), 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(x_{1}, x_{2}, \ldots, x_{n}\right) \mapsto \left\{\begin{array}{c} \begin{array}{l} \textrm{Span}\left(\left\{x_{1}, x_{2}, \ldots, x_{n}\right\}\right) =  \\ \left\{\left(a_{1} \cdot x_{1}\right) +  \left(a_{2} \cdot x_{2}\right) +  \ldots +  \left(a_{n} \cdot x_{n}\right)\right\}_{a_{1}, a_{2}, \ldots, a_{n} \in K} \end{array} \end{array} \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..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameters: 19
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 4
operands: 5
3Operationoperator: 32
operands: 6
4Literal
5ExprTuple7, 8
6ExprTuple9
7Operationoperator: 10
operand: 15
8Operationoperator: 12
operand: 16
9ExprRangelambda_map: 14
start_index: 38
end_index: 39
10Literal
11ExprTuple15
12Literal
13ExprTuple16
14Lambdaparameter: 52
body: 17
15Operationoperator: 18
operands: 19
16Lambdaparameters: 20
body: 21
17Operationoperator: 44
operands: 22
18Literal
19ExprTuple23
20ExprTuple24
21Conditionalvalue: 25
condition: 26
22ExprTuple46, 27
23ExprRangelambda_map: 28
start_index: 38
end_index: 39
24ExprRangelambda_map: 29
start_index: 38
end_index: 39
25Operationoperator: 30
operands: 31
26Operationoperator: 32
operands: 33
27Variable
28Lambdaparameter: 52
body: 46
29Lambdaparameter: 52
body: 47
30Literal
31ExprTuple34
32Literal
33ExprTuple35
34ExprRangelambda_map: 36
start_index: 38
end_index: 39
35ExprRangelambda_map: 37
start_index: 38
end_index: 39
36Lambdaparameter: 52
body: 40
37Lambdaparameter: 52
body: 41
38Literal
39Variable
40Operationoperator: 42
operands: 43
41Operationoperator: 44
operands: 45
42Literal
43ExprTuple47, 46
44Literal
45ExprTuple47, 48
46IndexedVarvariable: 49
index: 52
47IndexedVarvariable: 50
index: 52
48Variable
49Variable
50Variable
51ExprTuple52
52Variable