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, K, Lambda, V, v
from proveit.core_expr_types import Q__b_1_to_j, b_1_to_j, f__b_1_to_j
from proveit.linear_algebra import ScalarMult, VecSpaces, VecSum
from proveit.linear_algebra.addition import vec_summation_b1toj_fQ
from proveit.logic import Equals, Forall, Implies, InClass, InSet
from proveit.numbers import Sum
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [b_1_to_j]
expr = Lambda(V, Conditional(Forall(instance_param_or_params = [v], instance_expr = Implies(InSet(vec_summation_b1toj_fQ, K), Equals(ScalarMult(Sum(index_or_indices = sub_expr1, summand = f__b_1_to_j, condition = Q__b_1_to_j), v), VecSum(index_or_indices = sub_expr1, summand = ScalarMult(f__b_1_to_j, v), condition = Q__b_1_to_j)).with_wrapping_at(1)).with_wrapping_at(2), domain = V), 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_{v \in V}~\left(\begin{array}{c} \begin{array}{l} \left(\left[\sum_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\right] \in K\right) \Rightarrow  \\ \left(\begin{array}{c} \begin{array}{l} \left(\left[\sum_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\right] \cdot v\right) \\  = \left[\sum_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~\left(f\left(b_{1}, b_{2}, \ldots, b_{j}\right) \cdot v\right)\right] \end{array} \end{array}\right) \end{array} \end{array}\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: 22
body: 2
1ExprTuple22
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 9
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9
7Literal
8ExprTuple22, 10
9Lambdaparameter: 46
body: 12
10Operationoperator: 13
operand: 28
11ExprTuple46
12Conditionalvalue: 15
condition: 16
13Literal
14ExprTuple28
15Operationoperator: 17
operands: 18
16Operationoperator: 23
operands: 19
17Literal
18ExprTuple20, 21
19ExprTuple46, 22
20Operationoperator: 23
operands: 24
21Operationoperator: 25
operands: 26
22Variable
23Literal
24ExprTuple27, 28
25Literal
26ExprTuple29, 30
27Operationoperator: 32
operand: 39
28Variable
29Operationoperator: 42
operands: 31
30Operationoperator: 32
operand: 35
31ExprTuple34, 46
32Literal
33ExprTuple35
34Operationoperator: 36
operand: 39
35Lambdaparameters: 49
body: 38
36Literal
37ExprTuple39
38Conditionalvalue: 40
condition: 44
39Lambdaparameters: 49
body: 41
40Operationoperator: 42
operands: 43
41Conditionalvalue: 45
condition: 44
42Literal
43ExprTuple45, 46
44Operationoperator: 47
operands: 49
45Operationoperator: 48
operands: 49
46Variable
47Variable
48Variable
49ExprTuple50
50ExprRangelambda_map: 51
start_index: 52
end_index: 53
51Lambdaparameter: 57
body: 54
52Literal
53Variable
54IndexedVarvariable: 55
index: 57
55Variable
56ExprTuple57
57Variable