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, i
from proveit.core_expr_types import V_1_to_i, a_1_to_i
from proveit.linear_algebra import TensorProd, VecSpaces
from proveit.logic import And, Forall, InClass, InSet
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 = InSet(TensorProd(a_1_to_i), TensorProd(V_1_to_i)), domains = sub_expr2), And(ExprRange(sub_expr1, InClass(IndexedVar(V, sub_expr1), VecSpaces(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\{\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) \in \left(V_{1} {\otimes}  V_{2} {\otimes}  \ldots {\otimes}  V_{i}\right)\right) \textrm{ if } \left(V_{1} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\right) \land  \left(V_{2} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\right) \land  \ldots \land  \left(V_{i} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\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: 26
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 16
operands: 7
5Literal
6ExprTuple8
7ExprTuple9
8Lambdaparameters: 24
body: 10
9ExprRangelambda_map: 11
start_index: 36
end_index: 37
10Conditionalvalue: 12
condition: 13
11Lambdaparameter: 45
body: 14
12Operationoperator: 38
operands: 15
13Operationoperator: 16
operands: 17
14Operationoperator: 18
operands: 19
15ExprTuple20, 21
16Literal
17ExprTuple22
18Literal
19ExprTuple41, 23
20Operationoperator: 25
operands: 24
21Operationoperator: 25
operands: 26
22ExprRangelambda_map: 27
start_index: 36
end_index: 37
23Operationoperator: 28
operand: 33
24ExprTuple30
25Literal
26ExprTuple31
27Lambdaparameter: 45
body: 32
28Literal
29ExprTuple33
30ExprRangelambda_map: 34
start_index: 36
end_index: 37
31ExprRangelambda_map: 35
start_index: 36
end_index: 37
32Operationoperator: 38
operands: 39
33Variable
34Lambdaparameter: 45
body: 40
35Lambdaparameter: 45
body: 41
36Literal
37Variable
38Literal
39ExprTuple40, 41
40IndexedVarvariable: 42
index: 45
41IndexedVarvariable: 43
index: 45
42Variable
43Variable
44ExprTuple45
45Variable