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 K, Lambda, Q, V, 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.linear_algebra.addition import vec_summation_b1toj_fQ
from proveit.logic import Equals, Forall, Implies, InSet
from proveit.numbers import NaturalPos
In [2]:
# build up the expression from sub-expressions
expr = Lambda([K, f, Q], 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(vec_summation_b1toj_fQ, V), Equals(ScalarMult(k, vec_summation_b1toj_fQ), VecSum(index_or_indices = [b_1_to_j], summand = ScalarMult(k, f__b_1_to_j), condition = Q__b_1_to_j)).with_wrapping_at(1)).with_wrapping_at(2), 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\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)}~f\left(b_{1}, b_{2}, \ldots, b_{j}\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)}~f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\right]\right) \\  = \left[\sum_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~\left(k \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, 58, 57
2Operationoperator: 17
operand: 4
3ExprTuple4
4Lambdaparameter: 63
body: 6
5ExprTuple63
6Conditionalvalue: 7
condition: 8
7Operationoperator: 17
operand: 11
8Operationoperator: 35
operands: 10
9ExprTuple11
10ExprTuple63, 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: 55
body: 24
22Operationoperator: 25
operand: 34
23ExprTuple55
24Conditionalvalue: 27
condition: 28
25Literal
26ExprTuple34
27Operationoperator: 29
operands: 30
28Operationoperator: 35
operands: 31
29Literal
30ExprTuple32, 33
31ExprTuple55, 34
32Operationoperator: 35
operands: 36
33Operationoperator: 37
operands: 38
34Variable
35Literal
36ExprTuple44, 39
37Literal
38ExprTuple40, 41
39Variable
40Operationoperator: 52
operands: 42
41Operationoperator: 46
operand: 45
42ExprTuple55, 44
43ExprTuple45
44Operationoperator: 46
operand: 49
45Lambdaparameters: 59
body: 48
46Literal
47ExprTuple49
48Conditionalvalue: 50
condition: 54
49Lambdaparameters: 59
body: 51
50Operationoperator: 52
operands: 53
51Conditionalvalue: 56
condition: 54
52Literal
53ExprTuple55, 56
54Operationoperator: 57
operands: 59
55Variable
56Operationoperator: 58
operands: 59
57Variable
58Variable
59ExprTuple60
60ExprRangelambda_map: 61
start_index: 62
end_index: 63
61Lambdaparameter: 67
body: 64
62Literal
63Variable
64IndexedVarvariable: 65
index: 67
65Variable
66ExprTuple67
67Variable