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 Mult, 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)), Mult(ExprRange(sub_expr1, Norm(IndexedVar(a, sub_expr1)), one, i))), domains = sub_expr2).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} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i}\right \| = \left(\left \|a_{1}\right \| \cdot  \left \|a_{2}\right \| \cdot  \ldots \cdot  \left \|a_{i}\right \|\right)\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: 47
end_index: 48
5Operationoperator: 8
operand: 11
6Operationoperator: 20
operands: 10
7Lambdaparameter: 55
body: 45
8Literal
9ExprTuple11
10ExprTuple12
11Lambdaparameters: 39
body: 13
12ExprRangelambda_map: 14
start_index: 47
end_index: 48
13Conditionalvalue: 15
condition: 16
14Lambdaparameter: 55
body: 17
15Operationoperator: 18
operands: 19
16Operationoperator: 20
operands: 21
17Operationoperator: 22
operands: 23
18Literal
19ExprTuple24, 25
20Literal
21ExprTuple26
22Literal
23ExprTuple45, 27
24Operationoperator: 49
operand: 34
25Operationoperator: 29
operands: 30
26ExprRangelambda_map: 31
start_index: 47
end_index: 48
27Operationoperator: 32
operand: 37
28ExprTuple34
29Literal
30ExprTuple35
31Lambdaparameter: 55
body: 36
32Literal
33ExprTuple37
34Operationoperator: 38
operands: 39
35ExprRangelambda_map: 40
start_index: 47
end_index: 48
36Operationoperator: 41
operands: 42
37Variable
38Literal
39ExprTuple43
40Lambdaparameter: 55
body: 44
41Literal
42ExprTuple52, 45
43ExprRangelambda_map: 46
start_index: 47
end_index: 48
44Operationoperator: 49
operand: 52
45IndexedVarvariable: 51
index: 55
46Lambdaparameter: 55
body: 52
47Literal
48Variable
49Literal
50ExprTuple52
51Variable
52IndexedVarvariable: 53
index: 55
53Variable
54ExprTuple55
55Variable