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, K, Lambda, V, 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, InClass, InSet
In [2]:
# build up the expression from sub-expressions
expr = Lambda(V, Conditional(Forall(instance_param_or_params = [k], instance_expr = Implies(InSet(vec_summation_b1toj_fQ, V), Equals(VecSum(index_or_indices = [b_1_to_j], summand = ScalarMult(k, f__b_1_to_j), condition = Q__b_1_to_j), ScalarMult(k, vec_summation_b1toj_fQ)).with_wrapping_at(1)).with_wrapping_at(2), 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)}~f\left(b_{1}, b_{2}, \ldots, b_{j}\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(k \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)}~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: 42
body: 12
10Operationoperator: 13
operand: 22
11ExprTuple42
12Conditionalvalue: 15
condition: 16
13Literal
14ExprTuple22
15Operationoperator: 17
operands: 18
16Operationoperator: 23
operands: 19
17Literal
18ExprTuple20, 21
19ExprTuple42, 22
20Operationoperator: 23
operands: 24
21Operationoperator: 25
operands: 26
22Variable
23Literal
24ExprTuple33, 27
25Literal
26ExprTuple28, 29
27Variable
28Operationoperator: 35
operand: 32
29Operationoperator: 39
operands: 31
30ExprTuple32
31ExprTuple42, 33
32Lambdaparameters: 47
body: 34
33Operationoperator: 35
operand: 38
34Conditionalvalue: 37
condition: 44
35Literal
36ExprTuple38
37Operationoperator: 39
operands: 40
38Lambdaparameters: 47
body: 41
39Literal
40ExprTuple42, 43
41Conditionalvalue: 43
condition: 44
42Variable
43Operationoperator: 45
operands: 47
44Operationoperator: 46
operands: 47
45Variable
46Variable
47ExprTuple48
48ExprRangelambda_map: 49
start_index: 50
end_index: 51
49Lambdaparameter: 55
body: 52
50Literal
51Variable
52IndexedVarvariable: 53
index: 55
53Variable
54ExprTuple55
55Variable