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, VecSum
from proveit.linear_algebra.addition import vec_summation_b1toj_fQ
from proveit.logic import Equals, Implies, 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(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), InSet(v, V)))
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\{\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} \textrm{ if } v \in V\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 34
body: 2
1ExprTuple34
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 11
operands: 7
5Literal
6ExprTuple8, 9
7ExprTuple34, 10
8Operationoperator: 11
operands: 12
9Operationoperator: 13
operands: 14
10Variable
11Literal
12ExprTuple15, 16
13Literal
14ExprTuple17, 18
15Operationoperator: 20
operand: 27
16Variable
17Operationoperator: 30
operands: 19
18Operationoperator: 20
operand: 23
19ExprTuple22, 34
20Literal
21ExprTuple23
22Operationoperator: 24
operand: 27
23Lambdaparameters: 37
body: 26
24Literal
25ExprTuple27
26Conditionalvalue: 28
condition: 32
27Lambdaparameters: 37
body: 29
28Operationoperator: 30
operands: 31
29Conditionalvalue: 33
condition: 32
30Literal
31ExprTuple33, 34
32Operationoperator: 35
operands: 37
33Operationoperator: 36
operands: 37
34Variable
35Variable
36Variable
37ExprTuple38
38ExprRangelambda_map: 39
start_index: 40
end_index: 41
39Lambdaparameter: 45
body: 42
40Literal
41Variable
42IndexedVarvariable: 43
index: 45
43Variable
44ExprTuple45
45Variable