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, alpha, b, i, k
from proveit.core_expr_types import U_1_to_i, W_1_to_k, a_1_to_i, c_1_to_k
from proveit.linear_algebra import ScalarMult, TensorProd, VecSpaces
from proveit.logic import And, Equals, Forall, InSet
from proveit.numbers import Natural
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [U_1_to_i, V, W_1_to_k]
expr = Lambda([i, k], Conditional(Forall(instance_param_or_params = sub_expr1, instance_expr = Forall(instance_param_or_params = [a_1_to_i, b, c_1_to_k], instance_expr = Equals(TensorProd(a_1_to_i, ScalarMult(alpha, b), c_1_to_k), ScalarMult(alpha, TensorProd(a_1_to_i, b, c_1_to_k))).with_wrapping_at(1), domains = sub_expr1).with_wrapping(), domain = VecSpaces(K)).with_wrapping(), And(InSet(i, Natural), InSet(k, Natural))))
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(i, k\right) \mapsto \left\{\begin{array}{l}\forall_{U_{1}, U_{2}, \ldots, U_{i}, V, W_{1}, W_{2}, \ldots, W_{k} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)}~\\
\left[\begin{array}{l}\forall_{\left(a_{1} \in U_{1}\right), \left(a_{2} \in U_{2}\right), \ldots, \left(a_{i} \in U_{i}\right), b \in V,\left(c_{1} \in W_{1}\right), \left(c_{2} \in W_{2}\right), \ldots, \left(c_{k} \in W_{k}\right)}~\\
\left(\begin{array}{c} \begin{array}{l} \left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} \left(\alpha \cdot b\right){\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) \\  = \left(\alpha \cdot \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)\right) \end{array} \end{array}\right)\end{array}\right]\end{array} \textrm{ if } i \in \mathbb{N} ,  k \in \mathbb{N}\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
1ExprTuple76, 79
2Conditionalvalue: 3
condition: 4
3Operationoperator: 21
operand: 7
4Operationoperator: 38
operands: 6
5ExprTuple7
6ExprTuple8, 9
7Lambdaparameters: 10
body: 11
8Operationoperator: 67
operands: 12
9Operationoperator: 67
operands: 13
10ExprTuple14, 59, 15
11Conditionalvalue: 16
condition: 17
12ExprTuple76, 18
13ExprTuple79, 18
14ExprRangelambda_map: 19
start_index: 78
end_index: 76
15ExprRangelambda_map: 20
start_index: 78
end_index: 79
16Operationoperator: 21
operand: 24
17Operationoperator: 38
operands: 23
18Literal
19Lambdaparameter: 87
body: 73
20Lambdaparameter: 87
body: 74
21Literal
22ExprTuple24
23ExprTuple25, 26, 27
24Lambdaparameters: 65
body: 28
25ExprRangelambda_map: 29
start_index: 78
end_index: 76
26Operationoperator: 41
operands: 30
27ExprRangelambda_map: 31
start_index: 78
end_index: 79
28Conditionalvalue: 32
condition: 33
29Lambdaparameter: 87
body: 34
30ExprTuple59, 48
31Lambdaparameter: 87
body: 35
32Operationoperator: 36
operands: 37
33Operationoperator: 38
operands: 39
34Operationoperator: 41
operands: 40
35Operationoperator: 41
operands: 42
36Literal
37ExprTuple43, 44
38Literal
39ExprTuple45, 46, 47
40ExprTuple73, 48
41Literal
42ExprTuple74, 48
43Operationoperator: 64
operands: 49
44Operationoperator: 62
operands: 50
45ExprRangelambda_map: 51
start_index: 78
end_index: 76
46Operationoperator: 67
operands: 52
47ExprRangelambda_map: 53
start_index: 78
end_index: 79
48Operationoperator: 54
operand: 61
49ExprTuple70, 56, 72
50ExprTuple69, 57
51Lambdaparameter: 87
body: 58
52ExprTuple71, 59
53Lambdaparameter: 87
body: 60
54Literal
55ExprTuple61
56Operationoperator: 62
operands: 63
57Operationoperator: 64
operands: 65
58Operationoperator: 67
operands: 66
59Variable
60Operationoperator: 67
operands: 68
61Variable
62Literal
63ExprTuple69, 71
64Literal
65ExprTuple70, 71, 72
66ExprTuple82, 73
67Literal
68ExprTuple83, 74
69Variable
70ExprRangelambda_map: 75
start_index: 78
end_index: 76
71Variable
72ExprRangelambda_map: 77
start_index: 78
end_index: 79
73IndexedVarvariable: 80
index: 87
74IndexedVarvariable: 81
index: 87
75Lambdaparameter: 87
body: 82
76Variable
77Lambdaparameter: 87
body: 83
78Literal
79Variable
80Variable
81Variable
82IndexedVarvariable: 84
index: 87
83IndexedVarvariable: 85
index: 87
84Variable
85Variable
86ExprTuple87
87Variable