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(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), 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(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)\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, 64, 58, 65
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: 62
body: 24
22Operationoperator: 25
operand: 34
23ExprTuple62
24Conditionalvalue: 27
condition: 28
25Literal
26ExprTuple34
27Operationoperator: 29
operands: 30
28Operationoperator: 35
operands: 31
29Literal
30ExprTuple32, 33
31ExprTuple62, 34
32Operationoperator: 35
operands: 36
33Operationoperator: 37
operands: 38
34Variable
35Literal
36ExprTuple44, 39
37Literal
38ExprTuple40, 41
39Variable
40Operationoperator: 56
operands: 42
41Operationoperator: 46
operand: 45
42ExprTuple62, 44
43ExprTuple45
44Operationoperator: 46
operand: 49
45Lambdaparameters: 66
body: 48
46Literal
47ExprTuple49
48Conditionalvalue: 50
condition: 54
49Lambdaparameters: 66
body: 51
50Operationoperator: 56
operands: 52
51Conditionalvalue: 53
condition: 54
52ExprTuple55, 61
53Operationoperator: 56
operands: 57
54Operationoperator: 58
operands: 66
55Operationoperator: 59
operands: 60
56Literal
57ExprTuple63, 61
58Variable
59Literal
60ExprTuple62, 63
61Operationoperator: 64
operands: 66
62Variable
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