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 Function, K, Lambda, Q, V, c, f, j, 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, InSet
from proveit.numbers import Mult, NaturalPos
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, f, Q, c], Forall(instance_param_or_params = [j], instance_expr = Forall(instance_param_or_params = [V], instance_expr = Forall(instance_param_or_params = [k], instance_expr = 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), domain = K), domain = VecSpaces(K)), domain = NaturalPos))
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())
\left(K, f, Q, c\right) \mapsto \left[\forall_{j \in \mathbb{N}^+}~\left[\forall_{V \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)}~\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[\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}\right)\right]\right]\right]
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameters: 1
body: 2
1ExprTuple34, 65, 60, 64
2Operationoperator: 17
operand: 4
3ExprTuple4
4Lambdaparameter: 70
body: 6
5ExprTuple70
6Conditionalvalue: 7
condition: 8
7Operationoperator: 17
operand: 11
8Operationoperator: 35
operands: 10
9ExprTuple11
10ExprTuple70, 12
11Lambdaparameter: 39
body: 14
12Literal
13ExprTuple39
14Conditionalvalue: 15
condition: 16
15Operationoperator: 17
operand: 21
16Operationoperator: 19
operands: 20
17Literal
18ExprTuple21
19Literal
20ExprTuple39, 22
21Lambdaparameter: 61
body: 24
22Operationoperator: 25
operand: 34
23ExprTuple61
24Conditionalvalue: 27
condition: 28
25Literal
26ExprTuple34
27Operationoperator: 29
operands: 30
28Operationoperator: 35
operands: 31
29Literal
30ExprTuple32, 33
31ExprTuple61, 34
32Operationoperator: 35
operands: 36
33Operationoperator: 37
operands: 38
34Variable
35Literal
36ExprTuple45, 39
37Literal
38ExprTuple40, 41
39Variable
40Operationoperator: 47
operand: 44
41Operationoperator: 58
operands: 43
42ExprTuple44
43ExprTuple61, 45
44Lambdaparameters: 66
body: 46
45Operationoperator: 47
operand: 50
46Conditionalvalue: 49
condition: 55
47Literal
48ExprTuple50
49Operationoperator: 58
operands: 51
50Lambdaparameters: 66
body: 52
51ExprTuple53, 63
52Conditionalvalue: 54
condition: 55
53Operationoperator: 56
operands: 57
54Operationoperator: 58
operands: 59
55Operationoperator: 60
operands: 66
56Literal
57ExprTuple61, 62
58Literal
59ExprTuple62, 63
60Variable
61Variable
62Operationoperator: 64
operands: 66
63Operationoperator: 65
operands: 66
64Variable
65Variable
66ExprTuple67
67ExprRangelambda_map: 68
start_index: 69
end_index: 70
68Lambdaparameter: 74
body: 71
69Literal
70Variable
71IndexedVarvariable: 72
index: 74
72Variable
73ExprTuple74
74Variable