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, k
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 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 = [k, a_1_to_i], instance_expr = Equals(VecAdd(ExprRange(sub_expr1, ScalarMult(k, IndexedVar(a, sub_expr1)), one, i)), ScalarMult(k, VecAdd(a_1_to_i))).with_wrapping_at(2), domains = [K, 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_{k \in K,\left(a_{1} \in V\right), \left(a_{2} \in V\right), \ldots, \left(a_{i} \in V\right)}~\left(\begin{array}{c} \begin{array}{l} \left(\left(k \cdot a_{1}\right) +  \left(k \cdot a_{2}\right) +  \ldots +  \left(k \cdot a_{i}\right)\right) =  \\ \left(k \cdot \left(a_{1} +  a_{2} +  \ldots +  a_{i}\right)\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: 48
body: 2
1ExprTuple48
2Conditionalvalue: 3
condition: 4
3Operationoperator: 16
operand: 8
4Operationoperator: 6
operands: 7
5ExprTuple8
6Literal
7ExprTuple48, 9
8Lambdaparameter: 53
body: 11
9Operationoperator: 12
operand: 39
10ExprTuple53
11Conditionalvalue: 14
condition: 15
12Literal
13ExprTuple39
14Operationoperator: 16
operand: 19
15Operationoperator: 44
operands: 18
16Literal
17ExprTuple19
18ExprTuple53, 20
19Lambdaparameters: 21
body: 22
20Literal
21ExprTuple54, 47
22Conditionalvalue: 23
condition: 24
23Operationoperator: 25
operands: 26
24Operationoperator: 27
operands: 28
25Literal
26ExprTuple29, 30
27Literal
28ExprTuple31, 32
29Operationoperator: 42
operands: 33
30Operationoperator: 49
operands: 34
31Operationoperator: 44
operands: 35
32ExprRangelambda_map: 36
start_index: 52
end_index: 53
33ExprTuple37
34ExprTuple54, 38
35ExprTuple54, 39
36Lambdaparameter: 58
body: 40
37ExprRangelambda_map: 41
start_index: 52
end_index: 53
38Operationoperator: 42
operands: 43
39Variable
40Operationoperator: 44
operands: 45
41Lambdaparameter: 58
body: 46
42Literal
43ExprTuple47
44Literal
45ExprTuple55, 48
46Operationoperator: 49
operands: 50
47ExprRangelambda_map: 51
start_index: 52
end_index: 53
48Variable
49Literal
50ExprTuple54, 55
51Lambdaparameter: 58
body: 55
52Literal
53Variable
54Variable
55IndexedVarvariable: 56
index: 58
56Variable
57ExprTuple58
58Variable