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, ExprRange, IndexedVar, Lambda, U, V, Variable, W, a, alpha, b, c, i, k
from proveit.core_expr_types import a_1_to_i, c_1_to_k
from proveit.linear_algebra import ScalarMult, TensorProd
from proveit.logic import And, Equals, InSet
from proveit.numbers import one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Lambda([a_1_to_i, b, c_1_to_k], Conditional(Equals(TensorProd(a_1_to_i, ScalarMult(alpha, b), c_1_to_k), ScalarMult(alpha, TensorProd(a_1_to_i, b, c_1_to_k))).with_wrapping_at(1), And(ExprRange(sub_expr1, InSet(IndexedVar(a, sub_expr1), IndexedVar(U, sub_expr1)), one, i), InSet(b, V), ExprRange(sub_expr1, InSet(IndexedVar(c, sub_expr1), IndexedVar(W, sub_expr1)), one, 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())
\left(a_{1}, a_{2}, \ldots, a_{i}, b, c_{1}, c_{2}, \ldots, c_{k}\right) \mapsto \left\{\begin{array}{c} \begin{array}{l} \left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} \left(\alpha \cdot b\right){\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) \\  = \left(\alpha \cdot \left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} b{\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right)\right) \end{array} \end{array} \textrm{ if } \left(a_{1} \in U_{1}\right) ,  \left(a_{2} \in U_{2}\right) ,  \ldots ,  \left(a_{i} \in U_{i}\right) ,  b \in V, \left(c_{1} \in W_{1}\right) ,  \left(c_{2} \in W_{2}\right) ,  \ldots ,  \left(c_{k} \in W_{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
0Lambdaparameters: 26
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 4
operands: 5
3Operationoperator: 6
operands: 7
4Literal
5ExprTuple8, 9
6Literal
7ExprTuple10, 11, 12
8Operationoperator: 25
operands: 13
9Operationoperator: 23
operands: 14
10ExprRangelambda_map: 15
start_index: 39
end_index: 37
11Operationoperator: 28
operands: 16
12ExprRangelambda_map: 17
start_index: 39
end_index: 40
13ExprTuple31, 18, 33
14ExprTuple30, 19
15Lambdaparameter: 48
body: 20
16ExprTuple32, 21
17Lambdaparameter: 48
body: 22
18Operationoperator: 23
operands: 24
19Operationoperator: 25
operands: 26
20Operationoperator: 28
operands: 27
21Variable
22Operationoperator: 28
operands: 29
23Literal
24ExprTuple30, 32
25Literal
26ExprTuple31, 32, 33
27ExprTuple43, 34
28Literal
29ExprTuple44, 35
30Variable
31ExprRangelambda_map: 36
start_index: 39
end_index: 37
32Variable
33ExprRangelambda_map: 38
start_index: 39
end_index: 40
34IndexedVarvariable: 41
index: 48
35IndexedVarvariable: 42
index: 48
36Lambdaparameter: 48
body: 43
37Variable
38Lambdaparameter: 48
body: 44
39Literal
40Variable
41Variable
42Variable
43IndexedVarvariable: 45
index: 48
44IndexedVarvariable: 46
index: 48
45Variable
46Variable
47ExprTuple48
48Variable