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 LinDepSets, VecZero, lin_comb_axn, some_nonzero_a
from proveit.logic import And, Equals, Exists, InSet, Set
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(InSet(Set(x_1_to_n), LinDepSets(V)), Exists(instance_param_or_params = [a_1_to_n], instance_expr = Equals(lin_comb_axn, VecZero(V)), domain = K, condition = some_nonzero_a).with_wrapping()).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} \left(\left\{x_{1}, x_{2}, \ldots, x_{n}\right\} \in \textrm{LinDepSets}\left(V\right)\right) =  \\ \left[\begin{array}{l}\exists_{a_{1}, a_{2}, \ldots, a_{n} \in K~|~\left(a_{1} \neq 0\right) \lor  \left(a_{2} \neq 0\right) \lor  \ldots \lor  \left(a_{n} \neq 0\right)}~\\
\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)\right)\end{array}\right] \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: 18
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 29
operands: 4
3Operationoperator: 31
operands: 5
4ExprTuple6, 7
5ExprTuple8
6Operationoperator: 49
operands: 9
7Operationoperator: 10
operand: 15
8ExprRangelambda_map: 12
start_index: 52
end_index: 53
9ExprTuple13, 14
10Literal
11ExprTuple15
12Lambdaparameter: 67
body: 16
13Operationoperator: 17
operands: 18
14Operationoperator: 19
operand: 45
15Lambdaparameters: 20
body: 21
16Operationoperator: 49
operands: 22
17Literal
18ExprTuple23
19Literal
20ExprTuple24
21Conditionalvalue: 25
condition: 26
22ExprTuple61, 45
23ExprRangelambda_map: 27
start_index: 52
end_index: 53
24ExprRangelambda_map: 28
start_index: 52
end_index: 53
25Operationoperator: 29
operands: 30
26Operationoperator: 31
operands: 32
27Lambdaparameter: 67
body: 61
28Lambdaparameter: 67
body: 62
29Literal
30ExprTuple33, 34
31Literal
32ExprTuple35, 36
33Operationoperator: 37
operands: 38
34Operationoperator: 39
operand: 45
35ExprRangelambda_map: 41
start_index: 52
end_index: 53
36Operationoperator: 42
operands: 43
37Literal
38ExprTuple44
39Literal
40ExprTuple45
41Lambdaparameter: 67
body: 46
42Literal
43ExprTuple47
44ExprRangelambda_map: 48
start_index: 52
end_index: 53
45Variable
46Operationoperator: 49
operands: 50
47ExprRangelambda_map: 51
start_index: 52
end_index: 53
48Lambdaparameter: 67
body: 54
49Literal
50ExprTuple62, 55
51Lambdaparameter: 67
body: 56
52Literal
53Variable
54Operationoperator: 57
operands: 58
55Variable
56Operationoperator: 59
operands: 60
57Literal
58ExprTuple62, 61
59Literal
60ExprTuple62, 63
61IndexedVarvariable: 64
index: 67
62IndexedVarvariable: 65
index: 67
63Literal
64Variable
65Variable
66ExprTuple67
67Variable