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, K, Lambda, V, Variable, b, j
from proveit.core_expr_types import a_1_to_i, b_1_to_j, c_1_to_k
from proveit.linear_algebra import TensorProd, VecAdd, VecSpaces
from proveit.logic import Equals, Forall, Implies, InClass, InSet
from proveit.numbers import one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_b", latex_format = r"{_{-}b}")
sub_expr2 = TensorProd(a_1_to_i, VecAdd(b_1_to_j), c_1_to_k)
expr = Lambda(V, Conditional(Forall(instance_param_or_params = [a_1_to_i, b_1_to_j, c_1_to_k], instance_expr = Implies(InSet(sub_expr2, V), Equals(VecAdd(ExprRange(sub_expr1, TensorProd(a_1_to_i, IndexedVar(b, sub_expr1), c_1_to_k), one, j)), sub_expr2).with_wrapping_at(2)).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}, b_{1}, b_{2}, \ldots, b_{j}, c_{1}, c_{2}, \ldots, c_{k}}~\\
\left(\begin{array}{c} \begin{array}{l} \left(\left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} \left(b_{1} +  b_{2} +  \ldots +  b_{j}\right){\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) \in V\right) \Rightarrow  \\ \left(\begin{array}{c} \begin{array}{l} \left(\left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} b_{1}{\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) +  \left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} b_{2}{\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) +  \ldots +  \left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} b_{j}{\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(b_{1} +  b_{2} +  \ldots +  b_{j}\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: 24
body: 2
1ExprTuple24
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 9
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9
7Literal
8ExprTuple24, 10
9Lambdaparameters: 11
body: 12
10Operationoperator: 13
operand: 17
11ExprTuple40, 35, 42
12Operationoperator: 15
operands: 16
13Literal
14ExprTuple17
15Literal
16ExprTuple18, 19
17Variable
18Operationoperator: 20
operands: 21
19Operationoperator: 22
operands: 23
20Literal
21ExprTuple26, 24
22Literal
23ExprTuple25, 26
24Variable
25Operationoperator: 32
operands: 27
26Operationoperator: 36
operands: 28
27ExprTuple29
28ExprTuple40, 30, 42
29ExprRangelambda_map: 31
start_index: 48
end_index: 39
30Operationoperator: 32
operands: 33
31Lambdaparameter: 52
body: 34
32Literal
33ExprTuple35
34Operationoperator: 36
operands: 37
35ExprRangelambda_map: 38
start_index: 48
end_index: 39
36Literal
37ExprTuple40, 41, 42
38Lambdaparameter: 57
body: 43
39Variable
40ExprRangelambda_map: 44
start_index: 48
end_index: 45
41IndexedVarvariable: 50
index: 52
42ExprRangelambda_map: 47
start_index: 48
end_index: 49
43IndexedVarvariable: 50
index: 57
44Lambdaparameter: 57
body: 51
45Variable
46ExprTuple52
47Lambdaparameter: 57
body: 53
48Literal
49Variable
50Variable
51IndexedVarvariable: 54
index: 57
52Variable
53IndexedVarvariable: 55
index: 57
54Variable
55Variable
56ExprTuple57
57Variable