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 Function, Lambda, V, s
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 ScalarMult, TensorProd, VecSum
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 = Function(s, sub_expr1)
sub_expr3 = ScalarMult(sub_expr2, f__b_1_to_j)
expr = Lambda([a_1_to_i, c_1_to_k], Implies(Forall(instance_param_or_params = sub_expr1, instance_expr = InSet(TensorProd(a_1_to_i, sub_expr3, c_1_to_k), V), condition = Q__b_1_to_j), Equals(TensorProd(a_1_to_i, VecSum(index_or_indices = sub_expr1, summand = sub_expr3, condition = Q__b_1_to_j), c_1_to_k), VecSum(index_or_indices = sub_expr1, summand = ScalarMult(sub_expr2, TensorProd(a_1_to_i, f__b_1_to_j, c_1_to_k)), condition = Q__b_1_to_j)).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} \left(s\left(b_{1}, b_{2}, \ldots, b_{j}\right) \cdot f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\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(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)}~\left(s\left(b_{1}, b_{2}, \ldots, b_{j}\right) \cdot f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\right)\right]{\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) \\  = \left[\sum_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~\left(s\left(b_{1}, b_{2}, \ldots, b_{j}\right) \cdot \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)\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
1ExprTuple41, 43
2Operationoperator: 3
operands: 4
3Literal
4ExprTuple5, 6
5Operationoperator: 7
operand: 11
6Operationoperator: 9
operands: 10
7Literal
8ExprTuple11
9Literal
10ExprTuple12, 13
11Lambdaparameters: 48
body: 14
12Operationoperator: 38
operands: 15
13Operationoperator: 22
operand: 19
14Conditionalvalue: 17
condition: 33
15ExprTuple41, 18, 43
16ExprTuple19
17Operationoperator: 20
operands: 21
18Operationoperator: 22
operand: 27
19Lambdaparameters: 48
body: 24
20Literal
21ExprTuple25, 26
22Literal
23ExprTuple27
24Conditionalvalue: 28
condition: 33
25Operationoperator: 38
operands: 29
26Variable
27Lambdaparameters: 48
body: 30
28Operationoperator: 35
operands: 31
29ExprTuple41, 32, 43
30Conditionalvalue: 32
condition: 33
31ExprTuple40, 34
32Operationoperator: 35
operands: 36
33Operationoperator: 37
operands: 48
34Operationoperator: 38
operands: 39
35Literal
36ExprTuple40, 42
37Variable
38Literal
39ExprTuple41, 42, 43
40Operationoperator: 44
operands: 48
41ExprRangelambda_map: 45
start_index: 56
end_index: 46
42Operationoperator: 47
operands: 48
43ExprRangelambda_map: 49
start_index: 56
end_index: 50
44Variable
45Lambdaparameter: 62
body: 51
46Variable
47Variable
48ExprTuple52
49Lambdaparameter: 62
body: 53
50Variable
51IndexedVarvariable: 54
index: 62
52ExprRangelambda_map: 55
start_index: 56
end_index: 57
53IndexedVarvariable: 58
index: 62
54Variable
55Lambdaparameter: 62
body: 59
56Literal
57Variable
58Variable
59IndexedVarvariable: 60
index: 62
60Variable
61ExprTuple62
62Variable