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, K, Lambda, V
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 TensorProd, VecSpaces, VecSum
from proveit.linear_algebra.addition import vec_summation_b1toj_fQ
from proveit.logic import Equals, Forall, Implies, InClass, InSet
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [b_1_to_j]
sub_expr2 = TensorProd(a_1_to_i, f__b_1_to_j, c_1_to_k)
expr = Lambda(V, Conditional(Forall(instance_param_or_params = [a_1_to_i, c_1_to_k], instance_expr = Implies(Forall(instance_param_or_params = sub_expr1, instance_expr = InSet(sub_expr2, V), condition = Q__b_1_to_j), Equals(VecSum(index_or_indices = sub_expr1, summand = sub_expr2, condition = Q__b_1_to_j), TensorProd(a_1_to_i, vec_summation_b1toj_fQ, c_1_to_k)).with_wrapping_at(1)).with_wrapping_at(2)), 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\{\forall_{a_{1}, a_{2}, \ldots, a_{i}, c_{1}, c_{2}, \ldots, c_{k}}~\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} f\left(b_{1}, b_{2}, \ldots, b_{j}\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[\sum_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~\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] \\  = \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)}~f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\right]{\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) \end{array} \end{array}\right) \end{array} \end{array}\right) \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: 37
body: 2
1ExprTuple37
2Conditionalvalue: 3
condition: 4
3Operationoperator: 19
operand: 8
4Operationoperator: 6
operands: 7
5ExprTuple8
6Literal
7ExprTuple37, 9
8Lambdaparameters: 10
body: 11
9Operationoperator: 12
operand: 16
10ExprTuple43, 44
11Operationoperator: 14
operands: 15
12Literal
13ExprTuple16
14Literal
15ExprTuple17, 18
16Variable
17Operationoperator: 19
operand: 23
18Operationoperator: 21
operands: 22
19Literal
20ExprTuple23
21Literal
22ExprTuple24, 25
23Lambdaparameters: 53
body: 26
24Operationoperator: 35
operand: 30
25Operationoperator: 40
operands: 28
26Conditionalvalue: 29
condition: 46
27ExprTuple30
28ExprTuple43, 31, 44
29Operationoperator: 32
operands: 33
30Lambdaparameters: 53
body: 34
31Operationoperator: 35
operand: 39
32Literal
33ExprTuple38, 37
34Conditionalvalue: 38
condition: 46
35Literal
36ExprTuple39
37Variable
38Operationoperator: 40
operands: 41
39Lambdaparameters: 53
body: 42
40Literal
41ExprTuple43, 45, 44
42Conditionalvalue: 45
condition: 46
43ExprRangelambda_map: 47
start_index: 60
end_index: 48
44ExprRangelambda_map: 49
start_index: 60
end_index: 50
45Operationoperator: 51
operands: 53
46Operationoperator: 52
operands: 53
47Lambdaparameter: 65
body: 54
48Variable
49Lambdaparameter: 65
body: 55
50Variable
51Variable
52Variable
53ExprTuple56
54IndexedVarvariable: 57
index: 65
55IndexedVarvariable: 58
index: 65
56ExprRangelambda_map: 59
start_index: 60
end_index: 61
57Variable
58Variable
59Lambdaparameter: 65
body: 62
60Literal
61Variable
62IndexedVarvariable: 63
index: 65
63Variable
64ExprTuple65
65Variable