logo

Expression of type ExprTuple

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, ExprTuple, 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 = ExprTuple(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(\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..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameters: 2
body: 3
2ExprTuple77, 80
3Conditionalvalue: 4
condition: 5
4Operationoperator: 22
operand: 8
5Operationoperator: 39
operands: 7
6ExprTuple8
7ExprTuple9, 10
8Lambdaparameters: 11
body: 12
9Operationoperator: 68
operands: 13
10Operationoperator: 68
operands: 14
11ExprTuple15, 60, 16
12Conditionalvalue: 17
condition: 18
13ExprTuple77, 19
14ExprTuple80, 19
15ExprRangelambda_map: 20
start_index: 79
end_index: 77
16ExprRangelambda_map: 21
start_index: 79
end_index: 80
17Operationoperator: 22
operand: 25
18Operationoperator: 39
operands: 24
19Literal
20Lambdaparameter: 88
body: 74
21Lambdaparameter: 88
body: 75
22Literal
23ExprTuple25
24ExprTuple26, 27, 28
25Lambdaparameters: 66
body: 29
26ExprRangelambda_map: 30
start_index: 79
end_index: 77
27Operationoperator: 42
operands: 31
28ExprRangelambda_map: 32
start_index: 79
end_index: 80
29Conditionalvalue: 33
condition: 34
30Lambdaparameter: 88
body: 35
31ExprTuple60, 49
32Lambdaparameter: 88
body: 36
33Operationoperator: 37
operands: 38
34Operationoperator: 39
operands: 40
35Operationoperator: 42
operands: 41
36Operationoperator: 42
operands: 43
37Literal
38ExprTuple44, 45
39Literal
40ExprTuple46, 47, 48
41ExprTuple74, 49
42Literal
43ExprTuple75, 49
44Operationoperator: 65
operands: 50
45Operationoperator: 63
operands: 51
46ExprRangelambda_map: 52
start_index: 79
end_index: 77
47Operationoperator: 68
operands: 53
48ExprRangelambda_map: 54
start_index: 79
end_index: 80
49Operationoperator: 55
operand: 62
50ExprTuple71, 57, 73
51ExprTuple70, 58
52Lambdaparameter: 88
body: 59
53ExprTuple72, 60
54Lambdaparameter: 88
body: 61
55Literal
56ExprTuple62
57Operationoperator: 63
operands: 64
58Operationoperator: 65
operands: 66
59Operationoperator: 68
operands: 67
60Variable
61Operationoperator: 68
operands: 69
62Variable
63Literal
64ExprTuple70, 72
65Literal
66ExprTuple71, 72, 73
67ExprTuple83, 74
68Literal
69ExprTuple84, 75
70Variable
71ExprRangelambda_map: 76
start_index: 79
end_index: 77
72Variable
73ExprRangelambda_map: 78
start_index: 79
end_index: 80
74IndexedVarvariable: 81
index: 88
75IndexedVarvariable: 82
index: 88
76Lambdaparameter: 88
body: 83
77Variable
78Lambdaparameter: 88
body: 84
79Literal
80Variable
81Variable
82Variable
83IndexedVarvariable: 85
index: 88
84IndexedVarvariable: 86
index: 88
85Variable
86Variable
87ExprTuple88
88Variable