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, Lambda, V, Variable, n, x
from proveit.core_expr_types import x_1_to_n
from proveit.linear_algebra import Bases, LinDepSets, SpanningSets
from proveit.logic import And, Equals, InSet, NotInSet, Set
from proveit.numbers import one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = Set(x_1_to_n)
expr = Lambda([x_1_to_n], Conditional(Equals(InSet(sub_expr2, Bases(V)), And(InSet(sub_expr2, SpanningSets(V)), NotInSet(sub_expr2, LinDepSets(V))).with_wrapping_at(2)).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{Bases}\left(V\right)\right) =  \\ \left(\begin{array}{c} \left(\left\{x_{1}, x_{2}, \ldots, x_{n}\right\} \in \textrm{SpanningSets}\left(V\right)\right) \land  \\ \left(\left\{x_{1}, x_{2}, \ldots, x_{n}\right\} \notin \textrm{LinDepSets}\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: 29
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 4
operands: 5
3Operationoperator: 11
operands: 6
4Literal
5ExprTuple7, 8
6ExprTuple9
7Operationoperator: 22
operands: 10
8Operationoperator: 11
operands: 12
9ExprRangelambda_map: 13
start_index: 35
end_index: 36
10ExprTuple25, 14
11Literal
12ExprTuple15, 16
13Lambdaparameter: 40
body: 17
14Operationoperator: 18
operand: 33
15Operationoperator: 22
operands: 19
16Operationoperator: 20
operands: 21
17Operationoperator: 22
operands: 23
18Literal
19ExprTuple25, 24
20Literal
21ExprTuple25, 26
22Literal
23ExprTuple37, 33
24Operationoperator: 27
operand: 33
25Operationoperator: 28
operands: 29
26Operationoperator: 30
operand: 33
27Literal
28Literal
29ExprTuple32
30Literal
31ExprTuple33
32ExprRangelambda_map: 34
start_index: 35
end_index: 36
33Variable
34Lambdaparameter: 40
body: 37
35Literal
36Variable
37IndexedVarvariable: 38
index: 40
38Variable
39ExprTuple40
40Variable