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 A, Conditional, ExprRange, Function, IndexedVar, Lambda, V, Variable, W, n, v
from proveit.core_expr_types import A_1_to_n, V_1_to_n, v_1_to_n
from proveit.linear_algebra import LinMap, TensorProd
from proveit.logic import And, Equals, Forall, InSet
from proveit.numbers import one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = IndexedVar(A, sub_expr1)
expr = Lambda([A_1_to_n], Conditional(Forall(instance_param_or_params = [v_1_to_n], instance_expr = Equals(Function(TensorProd(A_1_to_n), [TensorProd(v_1_to_n)]), TensorProd(ExprRange(sub_expr1, Function(sub_expr2, [IndexedVar(v, sub_expr1)]), one, n))), domains = [V_1_to_n]).with_wrapping(), And(ExprRange(sub_expr1, InSet(sub_expr2, LinMap(IndexedVar(V, sub_expr1), IndexedVar(W, sub_expr1))), one, n))))
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_{n}\right) \mapsto \left\{\begin{array}{l}\forall_{\left(v_{1} \in V_{1}\right), \left(v_{2} \in V_{2}\right), \ldots, \left(v_{n} \in V_{n}\right)}~\\
\left(\left(A_{1} {\otimes}  A_{2} {\otimes}  \ldots {\otimes}  A_{n}\right)\left(v_{1} {\otimes}  v_{2} {\otimes}  \ldots {\otimes}  v_{n}\right) = \left(A_{1}\left(v_{1}\right) {\otimes}  A_{2}\left(v_{2}\right) {\otimes}  \ldots {\otimes}  A_{n}\left(v_{n}\right)\right)\right)\end{array} \textrm{ if } \left(A_{1} \in \mathcal{L}\left(V_{1}, W_{1}\right)\right) \land  \left(A_{2} \in \mathcal{L}\left(V_{2}, W_{2}\right)\right) \land  \ldots \land  \left(A_{n} \in \mathcal{L}\left(V_{n}, W_{n}\right)\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: 29
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 4
operand: 7
3Operationoperator: 16
operands: 6
4Literal
5ExprTuple7
6ExprTuple8
7Lambdaparameters: 36
body: 9
8ExprRangelambda_map: 10
start_index: 46
end_index: 47
9Conditionalvalue: 11
condition: 12
10Lambdaparameter: 55
body: 13
11Operationoperator: 14
operands: 15
12Operationoperator: 16
operands: 17
13Operationoperator: 38
operands: 18
14Literal
15ExprTuple19, 20
16Literal
17ExprTuple21
18ExprTuple48, 22
19Operationoperator: 23
operand: 30
20Operationoperator: 35
operands: 25
21ExprRangelambda_map: 26
start_index: 46
end_index: 47
22Operationoperator: 27
operands: 28
23Operationoperator: 35
operands: 29
24ExprTuple30
25ExprTuple31
26Lambdaparameter: 55
body: 32
27Literal
28ExprTuple44, 33
29ExprTuple34
30Operationoperator: 35
operands: 36
31ExprRangelambda_map: 37
start_index: 46
end_index: 47
32Operationoperator: 38
operands: 39
33IndexedVarvariable: 40
index: 55
34ExprRangelambda_map: 41
start_index: 46
end_index: 47
35Literal
36ExprTuple42
37Lambdaparameter: 55
body: 43
38Literal
39ExprTuple52, 44
40Variable
41Lambdaparameter: 55
body: 48
42ExprRangelambda_map: 45
start_index: 46
end_index: 47
43Operationoperator: 48
operand: 52
44IndexedVarvariable: 50
index: 55
45Lambdaparameter: 55
body: 52
46Literal
47Variable
48IndexedVarvariable: 51
index: 55
49ExprTuple52
50Variable
51Variable
52IndexedVarvariable: 53
index: 55
53Variable
54ExprTuple55
55Variable