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, Variable, a, n
from proveit.core_expr_types import a_1_to_n
from proveit.linear_algebra import lin_comb_axn
from proveit.logic import And, InSet
from proveit.numbers import one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Lambda([a_1_to_n], Conditional(lin_comb_axn, And(ExprRange(sub_expr1, InSet(IndexedVar(a, sub_expr1), K), 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(a_{1}, a_{2}, \ldots, a_{n}\right) \mapsto \left\{\left(a_{1} \cdot x_{1}\right) +  \left(a_{2} \cdot x_{2}\right) +  \ldots +  \left(a_{n} \cdot x_{n}\right) \textrm{ if } \left(a_{1} \in K\right) \land  \left(a_{2} \in K\right) \land  \ldots \land  \left(a_{n} \in K\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: 1
body: 2
1ExprTuple3
2Conditionalvalue: 4
condition: 5
3ExprRangelambda_map: 6
start_index: 15
end_index: 16
4Operationoperator: 7
operands: 8
5Operationoperator: 9
operands: 10
6Lambdaparameter: 29
body: 24
7Literal
8ExprTuple11
9Literal
10ExprTuple12
11ExprRangelambda_map: 13
start_index: 15
end_index: 16
12ExprRangelambda_map: 14
start_index: 15
end_index: 16
13Lambdaparameter: 29
body: 17
14Lambdaparameter: 29
body: 18
15Literal
16Variable
17Operationoperator: 19
operands: 20
18Operationoperator: 21
operands: 22
19Literal
20ExprTuple24, 23
21Literal
22ExprTuple24, 25
23IndexedVarvariable: 26
index: 29
24IndexedVarvariable: 27
index: 29
25Variable
26Variable
27Variable
28ExprTuple29
29Variable