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, K, Lambda, V, n
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 Equals, Forall, InSet, Set, SetOfAll
from proveit.numbers import NaturalPos
In [2]:
# build up the expression from sub-expressions
expr = Lambda(n, Conditional(Forall(instance_param_or_params = [x_1_to_n], instance_expr = 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), domain = V).with_wrapping(), InSet(n, NaturalPos)))
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())
n \mapsto \left\{\begin{array}{l}\forall_{x_{1}, x_{2}, \ldots, x_{n} \in V}~\\
\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}\right)\end{array} \textrm{ if } n \in \mathbb{N}^+\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 48
body: 2
1ExprTuple48
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 53
operands: 7
5Literal
6ExprTuple8
7ExprTuple48, 9
8Lambdaparameters: 28
body: 10
9Literal
10Conditionalvalue: 11
condition: 12
11Operationoperator: 13
operands: 14
12Operationoperator: 41
operands: 15
13Literal
14ExprTuple16, 17
15ExprTuple18
16Operationoperator: 19
operand: 24
17Operationoperator: 21
operand: 25
18ExprRangelambda_map: 23
start_index: 47
end_index: 48
19Literal
20ExprTuple24
21Literal
22ExprTuple25
23Lambdaparameter: 61
body: 26
24Operationoperator: 27
operands: 28
25Lambdaparameters: 29
body: 30
26Operationoperator: 53
operands: 31
27Literal
28ExprTuple32
29ExprTuple33
30Conditionalvalue: 34
condition: 35
31ExprTuple55, 36
32ExprRangelambda_map: 37
start_index: 47
end_index: 48
33ExprRangelambda_map: 38
start_index: 47
end_index: 48
34Operationoperator: 39
operands: 40
35Operationoperator: 41
operands: 42
36Variable
37Lambdaparameter: 61
body: 55
38Lambdaparameter: 61
body: 56
39Literal
40ExprTuple43
41Literal
42ExprTuple44
43ExprRangelambda_map: 45
start_index: 47
end_index: 48
44ExprRangelambda_map: 46
start_index: 47
end_index: 48
45Lambdaparameter: 61
body: 49
46Lambdaparameter: 61
body: 50
47Literal
48Variable
49Operationoperator: 51
operands: 52
50Operationoperator: 53
operands: 54
51Literal
52ExprTuple56, 55
53Literal
54ExprTuple56, 57
55IndexedVarvariable: 58
index: 61
56IndexedVarvariable: 59
index: 61
57Variable
58Variable
59Variable
60ExprTuple61
61Variable