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, 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([K, f, Q], Forall(instance_param_or_params = [j], instance_expr = Forall(instance_param_or_params = [V], instance_expr = Forall(instance_param_or_params = [v], instance_expr = Implies(InSet(vec_summation_b1toj_fQ, K), Equals(VecSum(index_or_indices = sub_expr1, summand = ScalarMult(f__b_1_to_j, v), condition = Q__b_1_to_j), ScalarMult(Sum(index_or_indices = sub_expr1, summand = f__b_1_to_j, condition = Q__b_1_to_j), v)).with_wrapping_at(1)).with_wrapping_at(2), domain = V), 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_{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[\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] \\  = \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) \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
1ExprTuple40, 59, 60
2Operationoperator: 17
operand: 4
3ExprTuple4
4Lambdaparameter: 65
body: 6
5ExprTuple65
6Conditionalvalue: 7
condition: 8
7Operationoperator: 17
operand: 11
8Operationoperator: 35
operands: 10
9ExprTuple11
10ExprTuple65, 12
11Lambdaparameter: 34
body: 14
12Literal
13ExprTuple34
14Conditionalvalue: 15
condition: 16
15Operationoperator: 17
operand: 21
16Operationoperator: 19
operands: 20
17Literal
18ExprTuple21
19Literal
20ExprTuple34, 22
21Lambdaparameter: 56
body: 24
22Operationoperator: 25
operand: 40
23ExprTuple56
24Conditionalvalue: 27
condition: 28
25Literal
26ExprTuple40
27Operationoperator: 29
operands: 30
28Operationoperator: 35
operands: 31
29Literal
30ExprTuple32, 33
31ExprTuple56, 34
32Operationoperator: 35
operands: 36
33Operationoperator: 37
operands: 38
34Variable
35Literal
36ExprTuple39, 40
37Literal
38ExprTuple41, 42
39Operationoperator: 43
operand: 52
40Variable
41Operationoperator: 43
operand: 46
42Operationoperator: 53
operands: 45
43Literal
44ExprTuple46
45ExprTuple47, 56
46Lambdaparameters: 61
body: 48
47Operationoperator: 49
operand: 52
48Conditionalvalue: 51
condition: 58
49Literal
50ExprTuple52
51Operationoperator: 53
operands: 54
52Lambdaparameters: 61
body: 55
53Literal
54ExprTuple57, 56
55Conditionalvalue: 57
condition: 58
56Variable
57Operationoperator: 59
operands: 61
58Operationoperator: 60
operands: 61
59Variable
60Variable
61ExprTuple62
62ExprRangelambda_map: 63
start_index: 64
end_index: 65
63Lambdaparameter: 69
body: 66
64Literal
65Variable
66IndexedVarvariable: 67
index: 69
67Variable
68ExprTuple69
69Variable