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, f, i, k
from proveit.core_expr_types import a_1_to_i, c_1_to_k, d_1_to_i, f_1_to_k
from proveit.linear_algebra import TensorProd, VecZero
from proveit.logic import And, Equals, Forall, Implies, InSet, NotEquals
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, e], instance_expr = Implies(Equals(TensorProd(a_1_to_i, b, c_1_to_k), TensorProd(d_1_to_i, e, f_1_to_k)).with_wrapping_at(2), Equals(TensorProd(a_1_to_i, c_1_to_k), TensorProd(d_1_to_i, f_1_to_k)).with_wrapping_at(2)).with_wrapping_at(2), domain = V, conditions = [Equals(b, e), NotEquals(b, VecZero(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(f, 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, e \in V~|~b = e, b \neq \vec{0}\left(V\right)}~\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} 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} e{\otimes} f_{1} {\otimes}  f_{2} {\otimes}  \ldots {\otimes}  f_{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} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) =  \\ \left(d_{1} {\otimes}  d_{2} {\otimes}  \ldots {\otimes}  d_{i}{\otimes} f_{1} {\otimes}  f_{2} {\otimes}  \ldots {\otimes}  f_{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(f_{1} \in W_{1}\right) ,  \left(f_{2} \in W_{2}\right) ,  \ldots ,  \left(f_{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: 6
2Operationoperator: 24
operands: 5
3Literal
4ExprTuple6
5ExprTuple7, 8, 9, 10
6Lambdaparameters: 44
body: 11
7ExprRangelambda_map: 12
start_index: 73
end_index: 71
8ExprRangelambda_map: 13
start_index: 73
end_index: 74
9ExprRangelambda_map: 14
start_index: 73
end_index: 71
10ExprRangelambda_map: 15
start_index: 73
end_index: 74
11Conditionalvalue: 16
condition: 17
12Lambdaparameter: 84
body: 18
13Lambdaparameter: 84
body: 19
14Lambdaparameter: 84
body: 20
15Lambdaparameter: 84
body: 21
16Operationoperator: 22
operands: 23
17Operationoperator: 24
operands: 25
18Operationoperator: 41
operands: 26
19Operationoperator: 41
operands: 27
20Operationoperator: 41
operands: 28
21Operationoperator: 41
operands: 29
22Literal
23ExprTuple30, 31
24Literal
25ExprTuple32, 33, 34, 35
26ExprTuple75, 36
27ExprTuple76, 37
28ExprTuple77, 36
29ExprTuple78, 37
30Operationoperator: 43
operands: 38
31Operationoperator: 43
operands: 39
32Operationoperator: 41
operands: 40
33Operationoperator: 41
operands: 42
34Operationoperator: 43
operands: 44
35Operationoperator: 45
operands: 46
36IndexedVarvariable: 47
index: 84
37IndexedVarvariable: 48
index: 84
38ExprTuple49, 50
39ExprTuple51, 52
40ExprTuple61, 67
41Literal
42ExprTuple62, 67
43Literal
44ExprTuple61, 62
45Literal
46ExprTuple61, 53
47Variable
48Variable
49Operationoperator: 57
operands: 54
50Operationoperator: 57
operands: 55
51Operationoperator: 57
operands: 56
52Operationoperator: 57
operands: 58
53Operationoperator: 59
operand: 67
54ExprTuple63, 61, 64
55ExprTuple65, 62, 66
56ExprTuple63, 64
57Literal
58ExprTuple65, 66
59Literal
60ExprTuple67
61Variable
62Variable
63ExprRangelambda_map: 68
start_index: 73
end_index: 71
64ExprRangelambda_map: 69
start_index: 73
end_index: 74
65ExprRangelambda_map: 70
start_index: 73
end_index: 71
66ExprRangelambda_map: 72
start_index: 73
end_index: 74
67Variable
68Lambdaparameter: 84
body: 75
69Lambdaparameter: 84
body: 76
70Lambdaparameter: 84
body: 77
71Variable
72Lambdaparameter: 84
body: 78
73Literal
74Variable
75IndexedVarvariable: 79
index: 84
76IndexedVarvariable: 80
index: 84
77IndexedVarvariable: 81
index: 84
78IndexedVarvariable: 82
index: 84
79Variable
80Variable
81Variable
82Variable
83ExprTuple84
84Variable