logo

Expression of type Lambda

from the theory of proveit.linear_algebra.tensors

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, s
from proveit.core_expr_types import Q__b_1_to_j, a_1_to_i, b_1_to_j, c_1_to_k, f__b_1_to_j
from proveit.linear_algebra import ScalarMult, TensorProd, VecSpaces, VecSum
from proveit.logic import Equals, Forall, Implies, InClass, InSet
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [b_1_to_j]
sub_expr2 = Function(s, sub_expr1)
sub_expr3 = ScalarMult(sub_expr2, f__b_1_to_j)
expr = Lambda(V, Conditional(Forall(instance_param_or_params = [a_1_to_i, c_1_to_k], instance_expr = Implies(Forall(instance_param_or_params = sub_expr1, instance_expr = InSet(TensorProd(a_1_to_i, sub_expr3, c_1_to_k), V), condition = Q__b_1_to_j), Equals(TensorProd(a_1_to_i, VecSum(index_or_indices = sub_expr1, summand = sub_expr3, condition = Q__b_1_to_j), c_1_to_k), VecSum(index_or_indices = sub_expr1, summand = ScalarMult(sub_expr2, TensorProd(a_1_to_i, f__b_1_to_j, c_1_to_k)), condition = Q__b_1_to_j)).with_wrapping_at(1)).with_wrapping_at(2)).with_wrapping(), 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\{\begin{array}{l}\forall_{a_{1}, a_{2}, \ldots, a_{i}, c_{1}, c_{2}, \ldots, c_{k}}~\\
\left(\begin{array}{c} \begin{array}{l} \left[\forall_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~\left(\left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} \left(s\left(b_{1}, b_{2}, \ldots, b_{j}\right) \cdot f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\right){\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) \in V\right)\right] \Rightarrow  \\ \left(\begin{array}{c} \begin{array}{l} \left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} \left[\sum_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~\left(s\left(b_{1}, b_{2}, \ldots, b_{j}\right) \cdot f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\right)\right]{\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) \\  = \left[\sum_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~\left(s\left(b_{1}, b_{2}, \ldots, b_{j}\right) \cdot \left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} f\left(b_{1}, b_{2}, \ldots, b_{j}\right){\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right)\right)\right] \end{array} \end{array}\right) \end{array} \end{array}\right)\end{array} \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: 38
body: 2
1ExprTuple38
2Conditionalvalue: 3
condition: 4
3Operationoperator: 19
operand: 8
4Operationoperator: 6
operands: 7
5ExprTuple8
6Literal
7ExprTuple38, 9
8Lambdaparameters: 10
body: 11
9Operationoperator: 12
operand: 16
10ExprTuple53, 55
11Operationoperator: 14
operands: 15
12Literal
13ExprTuple16
14Literal
15ExprTuple17, 18
16Variable
17Operationoperator: 19
operand: 23
18Operationoperator: 21
operands: 22
19Literal
20ExprTuple23
21Literal
22ExprTuple24, 25
23Lambdaparameters: 60
body: 26
24Operationoperator: 50
operands: 27
25Operationoperator: 34
operand: 31
26Conditionalvalue: 29
condition: 45
27ExprTuple53, 30, 55
28ExprTuple31
29Operationoperator: 32
operands: 33
30Operationoperator: 34
operand: 39
31Lambdaparameters: 60
body: 36
32Literal
33ExprTuple37, 38
34Literal
35ExprTuple39
36Conditionalvalue: 40
condition: 45
37Operationoperator: 50
operands: 41
38Variable
39Lambdaparameters: 60
body: 42
40Operationoperator: 47
operands: 43
41ExprTuple53, 44, 55
42Conditionalvalue: 44
condition: 45
43ExprTuple52, 46
44Operationoperator: 47
operands: 48
45Operationoperator: 49
operands: 60
46Operationoperator: 50
operands: 51
47Literal
48ExprTuple52, 54
49Variable
50Literal
51ExprTuple53, 54, 55
52Operationoperator: 56
operands: 60
53ExprRangelambda_map: 57
start_index: 68
end_index: 58
54Operationoperator: 59
operands: 60
55ExprRangelambda_map: 61
start_index: 68
end_index: 62
56Variable
57Lambdaparameter: 74
body: 63
58Variable
59Variable
60ExprTuple64
61Lambdaparameter: 74
body: 65
62Variable
63IndexedVarvariable: 66
index: 74
64ExprRangelambda_map: 67
start_index: 68
end_index: 69
65IndexedVarvariable: 70
index: 74
66Variable
67Lambdaparameter: 74
body: 71
68Literal
69Variable
70Variable
71IndexedVarvariable: 72
index: 74
72Variable
73ExprTuple74
74Variable