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, Function, K, Lambda, V, c, 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(j, Conditional(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)), 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)}~\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] \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: 66
body: 2
1ExprTuple66
2Conditionalvalue: 3
condition: 4
3Operationoperator: 13
operand: 7
4Operationoperator: 31
operands: 6
5ExprTuple7
6ExprTuple66, 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: 58
body: 20
18Operationoperator: 21
operand: 30
19ExprTuple58
20Conditionalvalue: 23
condition: 24
21Literal
22ExprTuple30
23Operationoperator: 25
operands: 26
24Operationoperator: 31
operands: 27
25Literal
26ExprTuple28, 29
27ExprTuple58, 30
28Operationoperator: 31
operands: 32
29Operationoperator: 33
operands: 34
30Variable
31Literal
32ExprTuple40, 35
33Literal
34ExprTuple36, 37
35Variable
36Operationoperator: 52
operands: 38
37Operationoperator: 42
operand: 41
38ExprTuple58, 40
39ExprTuple41
40Operationoperator: 42
operand: 45
41Lambdaparameters: 62
body: 44
42Literal
43ExprTuple45
44Conditionalvalue: 46
condition: 50
45Lambdaparameters: 62
body: 47
46Operationoperator: 52
operands: 48
47Conditionalvalue: 49
condition: 50
48ExprTuple51, 57
49Operationoperator: 52
operands: 53
50Operationoperator: 54
operands: 62
51Operationoperator: 55
operands: 56
52Literal
53ExprTuple59, 57
54Variable
55Literal
56ExprTuple58, 59
57Operationoperator: 60
operands: 62
58Variable
59Operationoperator: 61
operands: 62
60Variable
61Variable
62ExprTuple63
63ExprRangelambda_map: 64
start_index: 65
end_index: 66
64Lambdaparameter: 70
body: 67
65Literal
66Variable
67IndexedVarvariable: 68
index: 70
68Variable
69ExprTuple70
70Variable