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, 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(j, Conditional(Forall(instance_param_or_params = [V], instance_expr = 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), domain = VecSpaces(K)), InSet(j, 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())
j \mapsto \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[\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)\right] \textrm{ if } j \in \mathbb{N}^+\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 59
body: 2
1ExprTuple59
2Conditionalvalue: 3
condition: 4
3Operationoperator: 13
operand: 7
4Operationoperator: 31
operands: 6
5ExprTuple7
6ExprTuple59, 8
7Lambdaparameter: 35
body: 10
8Literal
9ExprTuple35
10Conditionalvalue: 11
condition: 12
11Operationoperator: 13
operand: 17
12Operationoperator: 15
operands: 16
13Literal
14ExprTuple17
15Literal
16ExprTuple35, 18
17Lambdaparameter: 50
body: 20
18Operationoperator: 21
operand: 30
19ExprTuple50
20Conditionalvalue: 23
condition: 24
21Literal
22ExprTuple30
23Operationoperator: 25
operands: 26
24Operationoperator: 31
operands: 27
25Literal
26ExprTuple28, 29
27ExprTuple50, 30
28Operationoperator: 31
operands: 32
29Operationoperator: 33
operands: 34
30Variable
31Literal
32ExprTuple41, 35
33Literal
34ExprTuple36, 37
35Variable
36Operationoperator: 43
operand: 40
37Operationoperator: 47
operands: 39
38ExprTuple40
39ExprTuple50, 41
40Lambdaparameters: 55
body: 42
41Operationoperator: 43
operand: 46
42Conditionalvalue: 45
condition: 52
43Literal
44ExprTuple46
45Operationoperator: 47
operands: 48
46Lambdaparameters: 55
body: 49
47Literal
48ExprTuple50, 51
49Conditionalvalue: 51
condition: 52
50Variable
51Operationoperator: 53
operands: 55
52Operationoperator: 54
operands: 55
53Variable
54Variable
55ExprTuple56
56ExprRangelambda_map: 57
start_index: 58
end_index: 59
57Lambdaparameter: 63
body: 60
58Literal
59Variable
60IndexedVarvariable: 61
index: 63
61Variable
62ExprTuple63
63Variable