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 Lambda, V
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 TensorProd, VecSum
from proveit.linear_algebra.addition import vec_summation_b1toj_fQ
from proveit.logic import Equals, Forall, Implies, InSet
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [b_1_to_j]
sub_expr2 = TensorProd(a_1_to_i, f__b_1_to_j, c_1_to_k)
expr = Lambda([a_1_to_i, c_1_to_k], Implies(Forall(instance_param_or_params = sub_expr1, instance_expr = InSet(sub_expr2, V), condition = Q__b_1_to_j), Equals(VecSum(index_or_indices = sub_expr1, summand = sub_expr2, condition = Q__b_1_to_j), TensorProd(a_1_to_i, vec_summation_b1toj_fQ, c_1_to_k)).with_wrapping_at(1)).with_wrapping_at(2))
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(a_{1}, a_{2}, \ldots, a_{i}, c_{1}, c_{2}, \ldots, c_{k}\right) \mapsto \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} f\left(b_{1}, b_{2}, \ldots, b_{j}\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(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] \\  = \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)}~f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\right]{\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) \end{array} \end{array}\right) \end{array} \end{array}\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
1ExprTuple31, 32
2Operationoperator: 3
operands: 4
3Literal
4ExprTuple5, 6
5Operationoperator: 7
operand: 11
6Operationoperator: 9
operands: 10
7Literal
8ExprTuple11
9Literal
10ExprTuple12, 13
11Lambdaparameters: 41
body: 14
12Operationoperator: 23
operand: 18
13Operationoperator: 28
operands: 16
14Conditionalvalue: 17
condition: 34
15ExprTuple18
16ExprTuple31, 19, 32
17Operationoperator: 20
operands: 21
18Lambdaparameters: 41
body: 22
19Operationoperator: 23
operand: 27
20Literal
21ExprTuple26, 25
22Conditionalvalue: 26
condition: 34
23Literal
24ExprTuple27
25Variable
26Operationoperator: 28
operands: 29
27Lambdaparameters: 41
body: 30
28Literal
29ExprTuple31, 33, 32
30Conditionalvalue: 33
condition: 34
31ExprRangelambda_map: 35
start_index: 48
end_index: 36
32ExprRangelambda_map: 37
start_index: 48
end_index: 38
33Operationoperator: 39
operands: 41
34Operationoperator: 40
operands: 41
35Lambdaparameter: 53
body: 42
36Variable
37Lambdaparameter: 53
body: 43
38Variable
39Variable
40Variable
41ExprTuple44
42IndexedVarvariable: 45
index: 53
43IndexedVarvariable: 46
index: 53
44ExprRangelambda_map: 47
start_index: 48
end_index: 49
45Variable
46Variable
47Lambdaparameter: 53
body: 50
48Literal
49Variable
50IndexedVarvariable: 51
index: 53
51Variable
52ExprTuple53
53Variable