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, U, V, Variable, W, a, b, c, d, e, i, k
from proveit.core_expr_types import a_1_to_i, c_1_to_k, d_1_to_i, e_1_to_k
from proveit.linear_algebra import TensorProd
from proveit.logic import And, Equals, Forall, Implies, 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 = IndexedVar(U, sub_expr1)
sub_expr3 = IndexedVar(W, sub_expr1)
expr = Conditional(Forall(instance_param_or_params = [b], instance_expr = Implies(Equals(TensorProd(a_1_to_i, c_1_to_k), TensorProd(d_1_to_i, e_1_to_k)).with_wrapping_at(2), Equals(TensorProd(a_1_to_i, b, c_1_to_k), TensorProd(d_1_to_i, b, e_1_to_k)).with_wrapping_at(2)).with_wrapping_at(2), domain = V), And(ExprRange(sub_expr1, InSet(IndexedVar(a, sub_expr1), sub_expr2), one, i), ExprRange(sub_expr1, InSet(IndexedVar(c, sub_expr1), sub_expr3), one, k), ExprRange(sub_expr1, InSet(IndexedVar(d, sub_expr1), sub_expr2), one, i), ExprRange(sub_expr1, InSet(IndexedVar(e, sub_expr1), sub_expr3), 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\{\forall_{b \in V}~\left(\begin{array}{c} \begin{array}{l} \left(\begin{array}{c} \begin{array}{l} \left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i}{\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) =  \\ \left(d_{1} {\otimes}  d_{2} {\otimes}  \ldots {\otimes}  d_{i}{\otimes} e_{1} {\otimes}  e_{2} {\otimes}  \ldots {\otimes}  e_{k}\right) \end{array} \end{array}\right) \Rightarrow  \\ \left(\begin{array}{c} \begin{array}{l} \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) =  \\ \left(d_{1} {\otimes}  d_{2} {\otimes}  \ldots {\otimes}  d_{i} {\otimes} b{\otimes} e_{1} {\otimes}  e_{2} {\otimes}  \ldots {\otimes}  e_{k}\right) \end{array} \end{array}\right) \end{array} \end{array}\right) \textrm{ if } \left(a_{1} \in U_{1}\right) ,  \left(a_{2} \in U_{2}\right) ,  \ldots ,  \left(a_{i} \in U_{i}\right), \left(c_{1} \in W_{1}\right) ,  \left(c_{2} \in W_{2}\right) ,  \ldots ,  \left(c_{k} \in W_{k}\right), \left(d_{1} \in U_{1}\right) ,  \left(d_{2} \in U_{2}\right) ,  \ldots ,  \left(d_{i} \in U_{i}\right), \left(e_{1} \in W_{1}\right) ,  \left(e_{2} \in W_{2}\right) ,  \ldots ,  \left(e_{k} \in W_{k}\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: 7
2Operationoperator: 5
operands: 6
3Literal
4ExprTuple7
5Literal
6ExprTuple8, 9, 10, 11
7Lambdaparameter: 54
body: 13
8ExprRangelambda_map: 14
start_index: 61
end_index: 59
9ExprRangelambda_map: 15
start_index: 61
end_index: 62
10ExprRangelambda_map: 16
start_index: 61
end_index: 59
11ExprRangelambda_map: 17
start_index: 61
end_index: 62
12ExprTuple54
13Conditionalvalue: 18
condition: 19
14Lambdaparameter: 72
body: 20
15Lambdaparameter: 72
body: 21
16Lambdaparameter: 72
body: 22
17Lambdaparameter: 72
body: 23
18Operationoperator: 24
operands: 25
19Operationoperator: 30
operands: 26
20Operationoperator: 30
operands: 27
21Operationoperator: 30
operands: 28
22Operationoperator: 30
operands: 29
23Operationoperator: 30
operands: 31
24Literal
25ExprTuple32, 33
26ExprTuple54, 34
27ExprTuple63, 35
28ExprTuple64, 36
29ExprTuple65, 35
30Literal
31ExprTuple66, 36
32Operationoperator: 38
operands: 37
33Operationoperator: 38
operands: 39
34Variable
35IndexedVarvariable: 40
index: 72
36IndexedVarvariable: 41
index: 72
37ExprTuple42, 43
38Literal
39ExprTuple44, 45
40Variable
41Variable
42Operationoperator: 49
operands: 46
43Operationoperator: 49
operands: 47
44Operationoperator: 49
operands: 48
45Operationoperator: 49
operands: 50
46ExprTuple51, 52
47ExprTuple53, 55
48ExprTuple51, 54, 52
49Literal
50ExprTuple53, 54, 55
51ExprRangelambda_map: 56
start_index: 61
end_index: 59
52ExprRangelambda_map: 57
start_index: 61
end_index: 62
53ExprRangelambda_map: 58
start_index: 61
end_index: 59
54Variable
55ExprRangelambda_map: 60
start_index: 61
end_index: 62
56Lambdaparameter: 72
body: 63
57Lambdaparameter: 72
body: 64
58Lambdaparameter: 72
body: 65
59Variable
60Lambdaparameter: 72
body: 66
61Literal
62Variable
63IndexedVarvariable: 67
index: 72
64IndexedVarvariable: 68
index: 72
65IndexedVarvariable: 69
index: 72
66IndexedVarvariable: 70
index: 72
67Variable
68Variable
69Variable
70Variable
71ExprTuple72
72Variable