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, Lambda, V, n
from proveit.core_expr_types import x_1_to_n
from proveit.linear_algebra import Bases, LinDepSets, SpanningSets
from proveit.logic import And, Equals, Forall, InSet, NotInSet, Set
from proveit.numbers import NaturalPos
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Set(x_1_to_n)
expr = Lambda(n, Conditional(Forall(instance_param_or_params = [x_1_to_n], instance_expr = Equals(InSet(sub_expr1, Bases(V)), And(InSet(sub_expr1, SpanningSets(V)), NotInSet(sub_expr1, LinDepSets(V))).with_wrapping_at(2)).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} \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}\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: 45
body: 2
1ExprTuple45
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 31
operands: 7
5Literal
6ExprTuple8
7ExprTuple45, 9
8Lambdaparameters: 38
body: 10
9Literal
10Conditionalvalue: 11
condition: 12
11Operationoperator: 13
operands: 14
12Operationoperator: 20
operands: 15
13Literal
14ExprTuple16, 17
15ExprTuple18
16Operationoperator: 31
operands: 19
17Operationoperator: 20
operands: 21
18ExprRangelambda_map: 22
start_index: 44
end_index: 45
19ExprTuple34, 23
20Literal
21ExprTuple24, 25
22Lambdaparameter: 49
body: 26
23Operationoperator: 27
operand: 42
24Operationoperator: 31
operands: 28
25Operationoperator: 29
operands: 30
26Operationoperator: 31
operands: 32
27Literal
28ExprTuple34, 33
29Literal
30ExprTuple34, 35
31Literal
32ExprTuple46, 42
33Operationoperator: 36
operand: 42
34Operationoperator: 37
operands: 38
35Operationoperator: 39
operand: 42
36Literal
37Literal
38ExprTuple41
39Literal
40ExprTuple42
41ExprRangelambda_map: 43
start_index: 44
end_index: 45
42Variable
43Lambdaparameter: 49
body: 46
44Literal
45Variable
46IndexedVarvariable: 47
index: 49
47Variable
48ExprTuple49
49Variable