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, 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, e_1_to_k
from proveit.linear_algebra import TensorProd, VecSpaces
from proveit.logic import And, Equals, Forall, Implies, 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, c_1_to_k, d_1_to_i, e_1_to_k], instance_expr = 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), 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(e_{1} \in W_{1}\right), \left(e_{2} \in W_{2}\right), \ldots, \left(e_{k} \in W_{k}\right)}~\\
\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)\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: 20
operands: 4
3ExprTuple5
4ExprTuple6, 7, 8
5Lambdaparameters: 9
body: 10
6ExprRangelambda_map: 11
start_index: 83
end_index: 81
7Operationoperator: 23
operands: 12
8ExprRangelambda_map: 13
start_index: 83
end_index: 84
9ExprTuple73, 74, 75, 77
10Conditionalvalue: 14
condition: 15
11Lambdaparameter: 94
body: 16
12ExprTuple56, 30
13Lambdaparameter: 94
body: 17
14Operationoperator: 18
operand: 25
15Operationoperator: 20
operands: 21
16Operationoperator: 23
operands: 22
17Operationoperator: 23
operands: 24
18Literal
19ExprTuple25
20Literal
21ExprTuple26, 27, 28, 29
22ExprTuple57, 30
23Literal
24ExprTuple58, 30
25Lambdaparameter: 76
body: 32
26ExprRangelambda_map: 33
start_index: 83
end_index: 81
27ExprRangelambda_map: 34
start_index: 83
end_index: 84
28ExprRangelambda_map: 35
start_index: 83
end_index: 81
29ExprRangelambda_map: 36
start_index: 83
end_index: 84
30Operationoperator: 37
operand: 45
31ExprTuple76
32Conditionalvalue: 39
condition: 40
33Lambdaparameter: 94
body: 41
34Lambdaparameter: 94
body: 42
35Lambdaparameter: 94
body: 43
36Lambdaparameter: 94
body: 44
37Literal
38ExprTuple45
39Operationoperator: 46
operands: 47
40Operationoperator: 52
operands: 48
41Operationoperator: 52
operands: 49
42Operationoperator: 52
operands: 50
43Operationoperator: 52
operands: 51
44Operationoperator: 52
operands: 53
45Variable
46Literal
47ExprTuple54, 55
48ExprTuple76, 56
49ExprTuple85, 57
50ExprTuple86, 58
51ExprTuple87, 57
52Literal
53ExprTuple88, 58
54Operationoperator: 60
operands: 59
55Operationoperator: 60
operands: 61
56Variable
57IndexedVarvariable: 62
index: 94
58IndexedVarvariable: 63
index: 94
59ExprTuple64, 65
60Literal
61ExprTuple66, 67
62Variable
63Variable
64Operationoperator: 71
operands: 68
65Operationoperator: 71
operands: 69
66Operationoperator: 71
operands: 70
67Operationoperator: 71
operands: 72
68ExprTuple73, 74
69ExprTuple75, 77
70ExprTuple73, 76, 74
71Literal
72ExprTuple75, 76, 77
73ExprRangelambda_map: 78
start_index: 83
end_index: 81
74ExprRangelambda_map: 79
start_index: 83
end_index: 84
75ExprRangelambda_map: 80
start_index: 83
end_index: 81
76Variable
77ExprRangelambda_map: 82
start_index: 83
end_index: 84
78Lambdaparameter: 94
body: 85
79Lambdaparameter: 94
body: 86
80Lambdaparameter: 94
body: 87
81Variable
82Lambdaparameter: 94
body: 88
83Literal
84Variable
85IndexedVarvariable: 89
index: 94
86IndexedVarvariable: 90
index: 94
87IndexedVarvariable: 91
index: 94
88IndexedVarvariable: 92
index: 94
89Variable
90Variable
91Variable
92Variable
93ExprTuple94
94Variable