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, VecSpaces, VecSum
from proveit.logic import Equals, Forall, Implies, InClass, 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(V, Conditional(Forall(instance_param_or_params = [k], instance_expr = Implies(InSet(sub_expr3, V), Equals(ScalarMult(k, sub_expr3), VecSum(index_or_indices = sub_expr1, summand = ScalarMult(Mult(k, sub_expr2), f__b_1_to_j), condition = Q__b_1_to_j)).with_wrapping_at(1)).with_wrapping_at(1), domain = K), 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_{k \in K}~\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(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) \\  = \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] \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: 27
body: 2
1ExprTuple27
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 9
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9
7Literal
8ExprTuple27, 10
9Lambdaparameter: 50
body: 12
10Operationoperator: 13
operand: 22
11ExprTuple50
12Conditionalvalue: 15
condition: 16
13Literal
14ExprTuple22
15Operationoperator: 17
operands: 18
16Operationoperator: 23
operands: 19
17Literal
18ExprTuple20, 21
19ExprTuple50, 22
20Operationoperator: 23
operands: 24
21Operationoperator: 25
operands: 26
22Variable
23Literal
24ExprTuple32, 27
25Literal
26ExprTuple28, 29
27Variable
28Operationoperator: 44
operands: 30
29Operationoperator: 34
operand: 33
30ExprTuple50, 32
31ExprTuple33
32Operationoperator: 34
operand: 37
33Lambdaparameters: 54
body: 36
34Literal
35ExprTuple37
36Conditionalvalue: 38
condition: 42
37Lambdaparameters: 54
body: 39
38Operationoperator: 44
operands: 40
39Conditionalvalue: 41
condition: 42
40ExprTuple43, 49
41Operationoperator: 44
operands: 45
42Operationoperator: 46
operands: 54
43Operationoperator: 47
operands: 48
44Literal
45ExprTuple51, 49
46Variable
47Literal
48ExprTuple50, 51
49Operationoperator: 52
operands: 54
50Variable
51Operationoperator: 53
operands: 54
52Variable
53Variable
54ExprTuple55
55ExprRangelambda_map: 56
start_index: 57
end_index: 58
56Lambdaparameter: 62
body: 59
57Literal
58Variable
59IndexedVarvariable: 60
index: 62
60Variable
61ExprTuple62
62Variable