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, Function, K, Lambda, V, c, k
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.logic import Equals, Implies, InSet
from proveit.numbers import Mult
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [b_1_to_j]
sub_expr2 = Function(c, sub_expr1)
sub_expr3 = VecSum(index_or_indices = sub_expr1, summand = ScalarMult(sub_expr2, f__b_1_to_j), condition = Q__b_1_to_j)
expr = Lambda(k, Conditional(Implies(InSet(sub_expr3, V), Equals(VecSum(index_or_indices = sub_expr1, summand = ScalarMult(Mult(k, sub_expr2), f__b_1_to_j), condition = Q__b_1_to_j), ScalarMult(k, sub_expr3)).with_wrapping_at(1)).with_wrapping_at(1), InSet(k, 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\{\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)}~\left(c\left(b_{1}, b_{2}, \ldots, b_{j}\right) \cdot f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\right)\right] \in V\right) \\  \Rightarrow \left(\begin{array}{c} \begin{array}{l} \left[\sum_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~\left(\left(k \cdot c\left(b_{1}, b_{2}, \ldots, b_{j}\right)\right) \cdot f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\right)\right] \\  = \left(k \cdot \left[\sum_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~\left(c\left(b_{1}, b_{2}, \ldots, b_{j}\right) \cdot f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\right)\right]\right) \end{array} \end{array}\right) \end{array} \end{array} \textrm{ if } k \in K\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 37
body: 2
1ExprTuple37
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 11
operands: 7
5Literal
6ExprTuple8, 9
7ExprTuple37, 10
8Operationoperator: 11
operands: 12
9Operationoperator: 13
operands: 14
10Variable
11Literal
12ExprTuple21, 15
13Literal
14ExprTuple16, 17
15Variable
16Operationoperator: 23
operand: 20
17Operationoperator: 34
operands: 19
18ExprTuple20
19ExprTuple37, 21
20Lambdaparameters: 42
body: 22
21Operationoperator: 23
operand: 26
22Conditionalvalue: 25
condition: 31
23Literal
24ExprTuple26
25Operationoperator: 34
operands: 27
26Lambdaparameters: 42
body: 28
27ExprTuple29, 39
28Conditionalvalue: 30
condition: 31
29Operationoperator: 32
operands: 33
30Operationoperator: 34
operands: 35
31Operationoperator: 36
operands: 42
32Literal
33ExprTuple37, 38
34Literal
35ExprTuple38, 39
36Variable
37Variable
38Operationoperator: 40
operands: 42
39Operationoperator: 41
operands: 42
40Variable
41Variable
42ExprTuple43
43ExprRangelambda_map: 44
start_index: 45
end_index: 46
44Lambdaparameter: 50
body: 47
45Literal
46Variable
47IndexedVarvariable: 48
index: 50
48Variable
49ExprTuple50
50Variable