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, 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, InClass
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(V, Conditional(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), InClass(V, 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())
V \mapsto \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] \textrm{ if } V \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(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
0Lambdaparameter: 41
body: 2
1ExprTuple41
2Conditionalvalue: 3
condition: 4
3Operationoperator: 17
operand: 8
4Operationoperator: 6
operands: 7
5ExprTuple8
6Literal
7ExprTuple41, 9
8Lambdaparameter: 54
body: 11
9Operationoperator: 12
operand: 16
10ExprTuple54
11Conditionalvalue: 14
condition: 15
12Literal
13ExprTuple16
14Operationoperator: 17
operand: 20
15Operationoperator: 45
operands: 19
16Variable
17Literal
18ExprTuple20
19ExprTuple54, 21
20Lambdaparameters: 22
body: 23
21Literal
22ExprTuple48, 55
23Conditionalvalue: 24
condition: 25
24Operationoperator: 26
operands: 27
25Operationoperator: 28
operands: 29
26Literal
27ExprTuple30, 31
28Literal
29ExprTuple32, 33
30Operationoperator: 43
operands: 34
31Operationoperator: 50
operands: 35
32ExprRangelambda_map: 36
start_index: 53
end_index: 54
33Operationoperator: 45
operands: 37
34ExprTuple38
35ExprTuple39, 55
36Lambdaparameter: 59
body: 40
37ExprTuple55, 41
38ExprRangelambda_map: 42
start_index: 53
end_index: 54
39Operationoperator: 43
operands: 44
40Operationoperator: 45
operands: 46
41Variable
42Lambdaparameter: 59
body: 47
43Literal
44ExprTuple48
45Literal
46ExprTuple56, 49
47Operationoperator: 50
operands: 51
48ExprRangelambda_map: 52
start_index: 53
end_index: 54
49Literal
50Literal
51ExprTuple56, 55
52Lambdaparameter: 59
body: 56
53Literal
54Variable
55Variable
56IndexedVarvariable: 57
index: 59
57Variable
58ExprTuple59
59Variable