logo

Expression of type Conditional

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, IndexedVar, K, U, V, Variable, W, i, j, k
from proveit.core_expr_types import U_1_to_i, V_1_to_j, W_1_to_k, a_1_to_i, b_1_to_j, c_1_to_k
from proveit.linear_algebra import TensorProd, VecSpaces
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 = VecSpaces(K)
expr = Conditional(Forall(instance_param_or_params = [a_1_to_i, b_1_to_j, c_1_to_k], instance_expr = Equals(TensorProd(a_1_to_i, TensorProd(b_1_to_j), c_1_to_k), TensorProd(a_1_to_i, b_1_to_j, c_1_to_k)).with_wrapping_at(1), domains = [U_1_to_i, V_1_to_j, W_1_to_k]).with_wrapping(), And(ExprRange(sub_expr1, InClass(IndexedVar(U, sub_expr1), sub_expr2), one, i), ExprRange(sub_expr1, InClass(IndexedVar(V, sub_expr1), sub_expr2), one, j), ExprRange(sub_expr1, InClass(IndexedVar(W, sub_expr1), sub_expr2), one, k)))
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\{\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),\left(b_{1} \in V_{1}\right), \left(b_{2} \in V_{2}\right), \ldots, \left(b_{j} \in V_{j}\right),\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(b_{1} {\otimes}  b_{2} {\otimes}  \ldots {\otimes}  b_{j}\right){\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) \\  = \left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i}{\otimes} b_{1} {\otimes}  b_{2} {\otimes}  \ldots {\otimes}  b_{j}{\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) \end{array} \end{array}\right)\end{array} \textrm{ if } \left(U_{1} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\right) ,  \left(U_{2} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\right) ,  \ldots ,  \left(U_{i} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\right), \left(V_{1} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\right) ,  \left(V_{2} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\right) ,  \ldots ,  \left(V_{j} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\right), \left(W_{1} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\right) ,  \left(W_{2} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\right) ,  \ldots ,  \left(W_{k} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\right)\right..
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
condition_delimiter'comma' or 'and'commacomma('with_comma_delimiter', 'with_conjunction_delimiter')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Conditionalvalue: 1
condition: 2
1Operationoperator: 3
operand: 6
2Operationoperator: 21
operands: 5
3Literal
4ExprTuple6
5ExprTuple7, 8, 9
6Lambdaparameters: 34
body: 10
7ExprRangelambda_map: 11
start_index: 64
end_index: 50
8ExprRangelambda_map: 12
start_index: 64
end_index: 65
9ExprRangelambda_map: 13
start_index: 64
end_index: 52
10Conditionalvalue: 14
condition: 15
11Lambdaparameter: 74
body: 16
12Lambdaparameter: 74
body: 17
13Lambdaparameter: 74
body: 18
14Operationoperator: 19
operands: 20
15Operationoperator: 21
operands: 22
16Operationoperator: 25
operands: 23
17Operationoperator: 25
operands: 24
18Operationoperator: 25
operands: 26
19Literal
20ExprTuple27, 28
21Literal
22ExprTuple29, 30, 31
23ExprTuple59, 32
24ExprTuple60, 32
25Literal
26ExprTuple62, 32
27Operationoperator: 47
operands: 33
28Operationoperator: 47
operands: 34
29ExprRangelambda_map: 35
start_index: 64
end_index: 50
30ExprRangelambda_map: 36
start_index: 64
end_index: 65
31ExprRangelambda_map: 37
start_index: 64
end_index: 52
32Operationoperator: 38
operand: 46
33ExprTuple41, 40, 42
34ExprTuple41, 57, 42
35Lambdaparameter: 74
body: 43
36Lambdaparameter: 74
body: 44
37Lambdaparameter: 74
body: 45
38Literal
39ExprTuple46
40Operationoperator: 47
operands: 48
41ExprRangelambda_map: 49
start_index: 64
end_index: 50
42ExprRangelambda_map: 51
start_index: 64
end_index: 52
43Operationoperator: 55
operands: 53
44Operationoperator: 55
operands: 54
45Operationoperator: 55
operands: 56
46Variable
47Literal
48ExprTuple57
49Lambdaparameter: 74
body: 58
50Variable
51Lambdaparameter: 74
body: 61
52Variable
53ExprTuple58, 59
54ExprTuple71, 60
55Literal
56ExprTuple61, 62
57ExprRangelambda_map: 63
start_index: 64
end_index: 65
58IndexedVarvariable: 66
index: 74
59IndexedVarvariable: 67
index: 74
60IndexedVarvariable: 68
index: 74
61IndexedVarvariable: 69
index: 74
62IndexedVarvariable: 70
index: 74
63Lambdaparameter: 74
body: 71
64Literal
65Variable
66Variable
67Variable
68Variable
69Variable
70Variable
71IndexedVarvariable: 72
index: 74
72Variable
73ExprTuple74
74Variable