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, ExprRange, ExprTuple, IndexedVar, K, Lambda, V, Variable, a, i
from proveit.core_expr_types import V_1_to_i, a_1_to_i
from proveit.linear_algebra import InnerProdSpaces, Norm, TensorProd
from proveit.logic import And, Equals, Forall, InClass
from proveit.numbers import one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = [V_1_to_i]
expr = ExprTuple(Lambda(sub_expr2, Conditional(Forall(instance_param_or_params = [a_1_to_i], instance_expr = Equals(Norm(TensorProd(a_1_to_i)), one), domains = sub_expr2, condition = And(ExprRange(sub_expr1, Equals(Norm(IndexedVar(a, sub_expr1)), one), one, i))).with_wrapping(), And(ExprRange(sub_expr1, InClass(IndexedVar(V, sub_expr1), InnerProdSpaces(K)), one, i)))))
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(V_{1}, V_{2}, \ldots, V_{i}\right) \mapsto \left\{\begin{array}{l}\forall_{\left(a_{1} \in V_{1}\right), \left(a_{2} \in V_{2}\right), \ldots, \left(a_{i} \in V_{i}\right)~|~\left(\left \|a_{1}\right \| = 1\right) \land  \left(\left \|a_{2}\right \| = 1\right) \land  \ldots \land  \left(\left \|a_{i}\right \| = 1\right)}~\\
\left(\left \|a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i}\right \| = 1\right)\end{array} \textrm{ if } \left(V_{1} \underset{{\scriptscriptstyle c}}{\in} \textrm{InnerProdSpaces}\left(K\right)\right) \land  \left(V_{2} \underset{{\scriptscriptstyle c}}{\in} \textrm{InnerProdSpaces}\left(K\right)\right) \land  \ldots \land  \left(V_{i} \underset{{\scriptscriptstyle c}}{\in} \textrm{InnerProdSpaces}\left(K\right)\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
0ExprTuple1
1Lambdaparameters: 2
body: 3
2ExprTuple4
3Conditionalvalue: 5
condition: 6
4ExprRangelambda_map: 7
start_index: 50
end_index: 45
5Operationoperator: 8
operand: 11
6Operationoperator: 28
operands: 10
7Lambdaparameter: 56
body: 42
8Literal
9ExprTuple11
10ExprTuple12
11Lambdaparameters: 37
body: 13
12ExprRangelambda_map: 14
start_index: 50
end_index: 45
13Conditionalvalue: 15
condition: 16
14Lambdaparameter: 56
body: 17
15Operationoperator: 47
operands: 18
16Operationoperator: 28
operands: 19
17Operationoperator: 20
operands: 21
18ExprTuple22, 50
19ExprTuple23, 24
20Literal
21ExprTuple42, 25
22Operationoperator: 51
operand: 32
23ExprRangelambda_map: 27
start_index: 50
end_index: 45
24Operationoperator: 28
operands: 29
25Operationoperator: 30
operand: 35
26ExprTuple32
27Lambdaparameter: 56
body: 33
28Literal
29ExprTuple34
30Literal
31ExprTuple35
32Operationoperator: 36
operands: 37
33Operationoperator: 38
operands: 39
34ExprRangelambda_map: 40
start_index: 50
end_index: 45
35Variable
36Literal
37ExprTuple41
38Literal
39ExprTuple53, 42
40Lambdaparameter: 56
body: 43
41ExprRangelambda_map: 44
start_index: 50
end_index: 45
42IndexedVarvariable: 46
index: 56
43Operationoperator: 47
operands: 48
44Lambdaparameter: 56
body: 53
45Variable
46Variable
47Literal
48ExprTuple49, 50
49Operationoperator: 51
operand: 53
50Literal
51Literal
52ExprTuple53
53IndexedVarvariable: 54
index: 56
54Variable
55ExprTuple56
56Variable