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, v
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, Sum
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [b_1_to_j]
expr = Lambda(j, Conditional(Forall(instance_param_or_params = [V], instance_expr = Forall(instance_param_or_params = [v], instance_expr = Implies(InSet(vec_summation_b1toj_fQ, K), Equals(ScalarMult(Sum(index_or_indices = sub_expr1, summand = f__b_1_to_j, condition = Q__b_1_to_j), v), VecSum(index_or_indices = sub_expr1, summand = ScalarMult(f__b_1_to_j, v), condition = Q__b_1_to_j)).with_wrapping_at(1)).with_wrapping_at(2), domain = V), 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_{v \in V}~\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 K\right) \Rightarrow  \\ \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] \cdot v\right) \\  = \left[\sum_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~\left(f\left(b_{1}, b_{2}, \ldots, b_{j}\right) \cdot v\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: 61
body: 2
1ExprTuple61
2Conditionalvalue: 3
condition: 4
3Operationoperator: 13
operand: 7
4Operationoperator: 31
operands: 6
5ExprTuple7
6ExprTuple61, 8
7Lambdaparameter: 30
body: 10
8Literal
9ExprTuple30
10Conditionalvalue: 11
condition: 12
11Operationoperator: 13
operand: 17
12Operationoperator: 15
operands: 16
13Literal
14ExprTuple17
15Literal
16ExprTuple30, 18
17Lambdaparameter: 54
body: 20
18Operationoperator: 21
operand: 36
19ExprTuple54
20Conditionalvalue: 23
condition: 24
21Literal
22ExprTuple36
23Operationoperator: 25
operands: 26
24Operationoperator: 31
operands: 27
25Literal
26ExprTuple28, 29
27ExprTuple54, 30
28Operationoperator: 31
operands: 32
29Operationoperator: 33
operands: 34
30Variable
31Literal
32ExprTuple35, 36
33Literal
34ExprTuple37, 38
35Operationoperator: 40
operand: 47
36Variable
37Operationoperator: 50
operands: 39
38Operationoperator: 40
operand: 43
39ExprTuple42, 54
40Literal
41ExprTuple43
42Operationoperator: 44
operand: 47
43Lambdaparameters: 57
body: 46
44Literal
45ExprTuple47
46Conditionalvalue: 48
condition: 52
47Lambdaparameters: 57
body: 49
48Operationoperator: 50
operands: 51
49Conditionalvalue: 53
condition: 52
50Literal
51ExprTuple53, 54
52Operationoperator: 55
operands: 57
53Operationoperator: 56
operands: 57
54Variable
55Variable
56Variable
57ExprTuple58
58ExprRangelambda_map: 59
start_index: 60
end_index: 61
59Lambdaparameter: 65
body: 62
60Literal
61Variable
62IndexedVarvariable: 63
index: 65
63Variable
64ExprTuple65
65Variable