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(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), TensorProd(a_1_to_i, VecSum(index_or_indices = sub_expr1, summand = sub_expr3, condition = Q__b_1_to_j), c_1_to_k)).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[\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] \\  = \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) \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
10ExprTuple52, 53
11Operationoperator: 14
operands: 15
12Literal
13ExprTuple16
14Literal
15ExprTuple17, 18
16Variable
17Operationoperator: 19
operand: 23
18Operationoperator: 21
operands: 22
19Literal
20ExprTuple23
21Literal
22ExprTuple24, 25
23Lambdaparameters: 62
body: 26
24Operationoperator: 35
operand: 30
25Operationoperator: 47
operands: 28
26Conditionalvalue: 29
condition: 46
27ExprTuple30
28ExprTuple52, 31, 53
29Operationoperator: 32
operands: 33
30Lambdaparameters: 62
body: 34
31Operationoperator: 35
operand: 40
32Literal
33ExprTuple37, 38
34Conditionalvalue: 39
condition: 46
35Literal
36ExprTuple40
37Operationoperator: 47
operands: 41
38Variable
39Operationoperator: 49
operands: 42
40Lambdaparameters: 62
body: 43
41ExprTuple52, 45, 53
42ExprTuple54, 44
43Conditionalvalue: 45
condition: 46
44Operationoperator: 47
operands: 48
45Operationoperator: 49
operands: 50
46Operationoperator: 51
operands: 62
47Literal
48ExprTuple52, 55, 53
49Literal
50ExprTuple54, 55
51Variable
52ExprRangelambda_map: 56
start_index: 69
end_index: 57
53ExprRangelambda_map: 58
start_index: 69
end_index: 59
54Operationoperator: 60
operands: 62
55Operationoperator: 61
operands: 62
56Lambdaparameter: 74
body: 63
57Variable
58Lambdaparameter: 74
body: 64
59Variable
60Variable
61Variable
62ExprTuple65
63IndexedVarvariable: 66
index: 74
64IndexedVarvariable: 67
index: 74
65ExprRangelambda_map: 68
start_index: 69
end_index: 70
66Variable
67Variable
68Lambdaparameter: 74
body: 71
69Literal
70Variable
71IndexedVarvariable: 72
index: 74
72Variable
73ExprTuple74
74Variable