logo

Expression of type Lambda

from the theory of proveit.linear_algebra.scalar_multiplication

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, a, n
from proveit.core_expr_types import a_1_to_n, x_1_to_n
from proveit.linear_algebra import lin_comb_axn
from proveit.logic import And, Forall, 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(Forall(instance_param_or_params = [x_1_to_n], instance_expr = InSet(lin_comb_axn, V), domain = V), 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\{\forall_{x_{1}, x_{2}, \ldots, x_{n} \in V}~\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) \in V\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: 33
end_index: 34
4Operationoperator: 7
operand: 10
5Operationoperator: 21
operands: 9
6Lambdaparameter: 46
body: 41
7Literal
8ExprTuple10
9ExprTuple11
10Lambdaparameters: 12
body: 13
11ExprRangelambda_map: 14
start_index: 33
end_index: 34
12ExprTuple15
13Conditionalvalue: 16
condition: 17
14Lambdaparameter: 46
body: 18
15ExprRangelambda_map: 19
start_index: 33
end_index: 34
16Operationoperator: 35
operands: 20
17Operationoperator: 21
operands: 22
18Operationoperator: 35
operands: 23
19Lambdaparameter: 46
body: 42
20ExprTuple24, 38
21Literal
22ExprTuple25
23ExprTuple41, 26
24Operationoperator: 27
operands: 28
25ExprRangelambda_map: 29
start_index: 33
end_index: 34
26Variable
27Literal
28ExprTuple30
29Lambdaparameter: 46
body: 31
30ExprRangelambda_map: 32
start_index: 33
end_index: 34
31Operationoperator: 35
operands: 36
32Lambdaparameter: 46
body: 37
33Literal
34Variable
35Literal
36ExprTuple42, 38
37Operationoperator: 39
operands: 40
38Variable
39Literal
40ExprTuple41, 42
41IndexedVarvariable: 43
index: 46
42IndexedVarvariable: 44
index: 46
43Variable
44Variable
45ExprTuple46
46Variable