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, Lambda, V, Variable, a, i, v
from proveit.core_expr_types import a_1_to_i
from proveit.linear_algebra import ScalarMult, VecAdd
from proveit.logic import Equals, Forall, InSet
from proveit.numbers import Complex, Natural, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Lambda(i, Conditional(Forall(instance_param_or_params = [a_1_to_i, v], instance_expr = Equals(VecAdd(ExprRange(sub_expr1, ScalarMult(IndexedVar(a, sub_expr1), v), one, i)), ScalarMult(VecAdd(a_1_to_i), v)).with_wrapping_at(2), domains = [Complex, V]), InSet(i, Natural)))
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())
i \mapsto \left\{\forall_{\left(a_{1} \in \mathbb{C}\right), \left(a_{2} \in \mathbb{C}\right), \ldots, \left(a_{i} \in \mathbb{C}\right), v \in V}~\left(\begin{array}{c} \begin{array}{l} \left(\left(a_{1} \cdot v\right) +  \left(a_{2} \cdot v\right) +  \ldots +  \left(a_{i} \cdot v\right)\right) =  \\ \left(\left(a_{1} +  a_{2} +  \ldots +  a_{i}\right) \cdot v\right) \end{array} \end{array}\right) \textrm{ if } i \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: 42
body: 2
1ExprTuple42
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 33
operands: 7
5Literal
6ExprTuple8
7ExprTuple42, 9
8Lambdaparameters: 10
body: 11
9Literal
10ExprTuple36, 43
11Conditionalvalue: 12
condition: 13
12Operationoperator: 14
operands: 15
13Operationoperator: 16
operands: 17
14Literal
15ExprTuple18, 19
16Literal
17ExprTuple20, 21
18Operationoperator: 31
operands: 22
19Operationoperator: 38
operands: 23
20ExprRangelambda_map: 24
start_index: 41
end_index: 42
21Operationoperator: 33
operands: 25
22ExprTuple26
23ExprTuple27, 43
24Lambdaparameter: 47
body: 28
25ExprTuple43, 29
26ExprRangelambda_map: 30
start_index: 41
end_index: 42
27Operationoperator: 31
operands: 32
28Operationoperator: 33
operands: 34
29Variable
30Lambdaparameter: 47
body: 35
31Literal
32ExprTuple36
33Literal
34ExprTuple44, 37
35Operationoperator: 38
operands: 39
36ExprRangelambda_map: 40
start_index: 41
end_index: 42
37Literal
38Literal
39ExprTuple44, 43
40Lambdaparameter: 47
body: 44
41Literal
42Variable
43Variable
44IndexedVarvariable: 45
index: 47
45Variable
46ExprTuple47
47Variable