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 ExprRange, IndexedVar, K, Lambda, V, Variable, a, i, v
from proveit.core_expr_types import a_1_to_i
from proveit.linear_algebra import ScalarMult, VecAdd, VecSpaces
from proveit.logic import Equals, Forall
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(K, Forall(instance_param_or_params = [V], instance_expr = Forall(instance_param_or_params = [i], instance_expr = 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]), domain = Natural), domain = VecSpaces(K)))
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())
K \mapsto \left[\forall_{V \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)}~\left[\forall_{i \in \mathbb{N}}~\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)\right]\right]\right]
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 19
body: 1
1Operationoperator: 20
operand: 3
2ExprTuple3
3Lambdaparameter: 44
body: 5
4ExprTuple44
5Conditionalvalue: 6
condition: 7
6Operationoperator: 20
operand: 11
7Operationoperator: 9
operands: 10
8ExprTuple11
9Literal
10ExprTuple44, 12
11Lambdaparameter: 57
body: 14
12Operationoperator: 15
operand: 19
13ExprTuple57
14Conditionalvalue: 17
condition: 18
15Literal
16ExprTuple19
17Operationoperator: 20
operand: 23
18Operationoperator: 48
operands: 22
19Variable
20Literal
21ExprTuple23
22ExprTuple57, 24
23Lambdaparameters: 25
body: 26
24Literal
25ExprTuple51, 58
26Conditionalvalue: 27
condition: 28
27Operationoperator: 29
operands: 30
28Operationoperator: 31
operands: 32
29Literal
30ExprTuple33, 34
31Literal
32ExprTuple35, 36
33Operationoperator: 46
operands: 37
34Operationoperator: 53
operands: 38
35ExprRangelambda_map: 39
start_index: 56
end_index: 57
36Operationoperator: 48
operands: 40
37ExprTuple41
38ExprTuple42, 58
39Lambdaparameter: 62
body: 43
40ExprTuple58, 44
41ExprRangelambda_map: 45
start_index: 56
end_index: 57
42Operationoperator: 46
operands: 47
43Operationoperator: 48
operands: 49
44Variable
45Lambdaparameter: 62
body: 50
46Literal
47ExprTuple51
48Literal
49ExprTuple59, 52
50Operationoperator: 53
operands: 54
51ExprRangelambda_map: 55
start_index: 56
end_index: 57
52Literal
53Literal
54ExprTuple59, 58
55Lambdaparameter: 62
body: 59
56Literal
57Variable
58Variable
59IndexedVarvariable: 60
index: 62
60Variable
61ExprTuple62
62Variable