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, b, e, i, k
from proveit.core_expr_types import U_1_to_i, W_1_to_k, a_1_to_i, c_1_to_k, d_1_to_i, f_1_to_k
from proveit.linear_algebra import TensorProd, VecSpaces, VecZero
from proveit.logic import And, Equals, Forall, Implies, InClass, 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 = VecSpaces(K)
expr = Conditional(Forall(instance_param_or_params = [a_1_to_i, c_1_to_k, d_1_to_i, f_1_to_k], instance_expr = 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))]), domains = [U_1_to_i, W_1_to_k, U_1_to_i, W_1_to_k]).with_wrapping(), And(ExprRange(sub_expr1, InClass(IndexedVar(U, sub_expr1), sub_expr2), one, i), InClass(V, sub_expr2), 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(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)}~\\
\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)\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) ,  V \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\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: 18
operand: 5
2Operationoperator: 46
operands: 4
3ExprTuple5
4ExprTuple6, 7, 8
5Lambdaparameters: 9
body: 10
6ExprRangelambda_map: 11
start_index: 95
end_index: 93
7Operationoperator: 22
operands: 12
8ExprRangelambda_map: 13
start_index: 95
end_index: 96
9ExprTuple85, 86, 87, 88
10Conditionalvalue: 14
condition: 15
11Lambdaparameter: 106
body: 16
12ExprTuple89, 29
13Lambdaparameter: 106
body: 17
14Operationoperator: 18
operand: 24
15Operationoperator: 46
operands: 20
16Operationoperator: 22
operands: 21
17Operationoperator: 22
operands: 23
18Literal
19ExprTuple24
20ExprTuple25, 26, 27, 28
21ExprTuple58, 29
22Literal
23ExprTuple59, 29
24Lambdaparameters: 66
body: 30
25ExprRangelambda_map: 31
start_index: 95
end_index: 93
26ExprRangelambda_map: 32
start_index: 95
end_index: 96
27ExprRangelambda_map: 33
start_index: 95
end_index: 93
28ExprRangelambda_map: 34
start_index: 95
end_index: 96
29Operationoperator: 35
operand: 43
30Conditionalvalue: 37
condition: 38
31Lambdaparameter: 106
body: 39
32Lambdaparameter: 106
body: 40
33Lambdaparameter: 106
body: 41
34Lambdaparameter: 106
body: 42
35Literal
36ExprTuple43
37Operationoperator: 44
operands: 45
38Operationoperator: 46
operands: 47
39Operationoperator: 63
operands: 48
40Operationoperator: 63
operands: 49
41Operationoperator: 63
operands: 50
42Operationoperator: 63
operands: 51
43Variable
44Literal
45ExprTuple52, 53
46Literal
47ExprTuple54, 55, 56, 57
48ExprTuple97, 58
49ExprTuple98, 59
50ExprTuple99, 58
51ExprTuple100, 59
52Operationoperator: 65
operands: 60
53Operationoperator: 65
operands: 61
54Operationoperator: 63
operands: 62
55Operationoperator: 63
operands: 64
56Operationoperator: 65
operands: 66
57Operationoperator: 67
operands: 68
58IndexedVarvariable: 69
index: 106
59IndexedVarvariable: 70
index: 106
60ExprTuple71, 72
61ExprTuple73, 74
62ExprTuple83, 89
63Literal
64ExprTuple84, 89
65Literal
66ExprTuple83, 84
67Literal
68ExprTuple83, 75
69Variable
70Variable
71Operationoperator: 79
operands: 76
72Operationoperator: 79
operands: 77
73Operationoperator: 79
operands: 78
74Operationoperator: 79
operands: 80
75Operationoperator: 81
operand: 89
76ExprTuple85, 83, 86
77ExprTuple87, 84, 88
78ExprTuple85, 86
79Literal
80ExprTuple87, 88
81Literal
82ExprTuple89
83Variable
84Variable
85ExprRangelambda_map: 90
start_index: 95
end_index: 93
86ExprRangelambda_map: 91
start_index: 95
end_index: 96
87ExprRangelambda_map: 92
start_index: 95
end_index: 93
88ExprRangelambda_map: 94
start_index: 95
end_index: 96
89Variable
90Lambdaparameter: 106
body: 97
91Lambdaparameter: 106
body: 98
92Lambdaparameter: 106
body: 99
93Variable
94Lambdaparameter: 106
body: 100
95Literal
96Variable
97IndexedVarvariable: 101
index: 106
98IndexedVarvariable: 102
index: 106
99IndexedVarvariable: 103
index: 106
100IndexedVarvariable: 104
index: 106
101Variable
102Variable
103Variable
104Variable
105ExprTuple106
106Variable