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, Lambda, V, b, e
from proveit.core_expr_types import a_1_to_i, c_1_to_k, d_1_to_i, f_1_to_k
from proveit.linear_algebra import TensorProd, VecZero
from proveit.logic import And, Equals, Implies, InSet, NotEquals
In [2]:
# build up the expression from sub-expressions
expr = Lambda([b, e], Conditional(Implies(Equals(TensorProd(a_1_to_i, b, c_1_to_k), TensorProd(d_1_to_i, e, f_1_to_k)).with_wrapping_at(2), Equals(TensorProd(a_1_to_i, c_1_to_k), TensorProd(d_1_to_i, f_1_to_k)).with_wrapping_at(2)).with_wrapping_at(2), And(InSet(b, V), InSet(e, V), Equals(b, e), NotEquals(b, VecZero(V)))))
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(b, e\right) \mapsto \left\{\begin{array}{c} \begin{array}{l} \left(\begin{array}{c} \begin{array}{l} \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) =  \\ \left(d_{1} {\otimes}  d_{2} {\otimes}  \ldots {\otimes}  d_{i} {\otimes} e{\otimes} f_{1} {\otimes}  f_{2} {\otimes}  \ldots {\otimes}  f_{k}\right) \end{array} \end{array}\right) \Rightarrow  \\ \left(\begin{array}{c} \begin{array}{l} \left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i}{\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) =  \\ \left(d_{1} {\otimes}  d_{2} {\otimes}  \ldots {\otimes}  d_{i}{\otimes} f_{1} {\otimes}  f_{2} {\otimes}  \ldots {\otimes}  f_{k}\right) \end{array} \end{array}\right) \end{array} \end{array} \textrm{ if } b \in V ,  e \in V ,  b = e ,  b \neq \vec{0}\left(V\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: 20
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 4
operands: 5
3Operationoperator: 6
operands: 7
4Literal
5ExprTuple8, 9
6Literal
7ExprTuple10, 11, 12, 13
8Operationoperator: 19
operands: 14
9Operationoperator: 19
operands: 15
10Operationoperator: 17
operands: 16
11Operationoperator: 17
operands: 18
12Operationoperator: 19
operands: 20
13Operationoperator: 21
operands: 22
14ExprTuple23, 24
15ExprTuple25, 26
16ExprTuple35, 41
17Literal
18ExprTuple36, 41
19Literal
20ExprTuple35, 36
21Literal
22ExprTuple35, 27
23Operationoperator: 31
operands: 28
24Operationoperator: 31
operands: 29
25Operationoperator: 31
operands: 30
26Operationoperator: 31
operands: 32
27Operationoperator: 33
operand: 41
28ExprTuple37, 35, 38
29ExprTuple39, 36, 40
30ExprTuple37, 38
31Literal
32ExprTuple39, 40
33Literal
34ExprTuple41
35Variable
36Variable
37ExprRangelambda_map: 42
start_index: 47
end_index: 45
38ExprRangelambda_map: 43
start_index: 47
end_index: 48
39ExprRangelambda_map: 44
start_index: 47
end_index: 45
40ExprRangelambda_map: 46
start_index: 47
end_index: 48
41Variable
42Lambdaparameter: 58
body: 49
43Lambdaparameter: 58
body: 50
44Lambdaparameter: 58
body: 51
45Variable
46Lambdaparameter: 58
body: 52
47Literal
48Variable
49IndexedVarvariable: 53
index: 58
50IndexedVarvariable: 54
index: 58
51IndexedVarvariable: 55
index: 58
52IndexedVarvariable: 56
index: 58
53Variable
54Variable
55Variable
56Variable
57ExprTuple58
58Variable