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, K, V, 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, InSet, NotEquals
from proveit.numbers import Natural
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Forall(instance_param_or_params = [U_1_to_i, V, W_1_to_k], instance_expr = 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(), domain = VecSpaces(K)).with_wrapping(), And(InSet(i, Natural), InSet(k, Natural)))
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_{U_{1}, U_{2}, \ldots, U_{i}, V, W_{1}, W_{2}, \ldots, W_{k} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)}~\\
\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}\right]\end{array} \textrm{ if } i \in \mathbb{N} ,  k \in \mathbb{N}\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: 34
operand: 5
2Operationoperator: 62
operands: 4
3ExprTuple5
4ExprTuple6, 7
5Lambdaparameters: 8
body: 9
6Operationoperator: 79
operands: 10
7Operationoperator: 79
operands: 11
8ExprTuple12, 105, 13
9Conditionalvalue: 14
condition: 15
10ExprTuple109, 16
11ExprTuple112, 16
12ExprRangelambda_map: 17
start_index: 111
end_index: 109
13ExprRangelambda_map: 18
start_index: 111
end_index: 112
14Operationoperator: 34
operand: 21
15Operationoperator: 62
operands: 20
16Literal
17Lambdaparameter: 122
body: 74
18Lambdaparameter: 122
body: 75
19ExprTuple21
20ExprTuple22, 23, 24
21Lambdaparameters: 25
body: 26
22ExprRangelambda_map: 27
start_index: 111
end_index: 109
23Operationoperator: 38
operands: 28
24ExprRangelambda_map: 29
start_index: 111
end_index: 112
25ExprTuple101, 102, 103, 104
26Conditionalvalue: 30
condition: 31
27Lambdaparameter: 122
body: 32
28ExprTuple105, 45
29Lambdaparameter: 122
body: 33
30Operationoperator: 34
operand: 40
31Operationoperator: 62
operands: 36
32Operationoperator: 38
operands: 37
33Operationoperator: 38
operands: 39
34Literal
35ExprTuple40
36ExprTuple41, 42, 43, 44
37ExprTuple74, 45
38Literal
39ExprTuple75, 45
40Lambdaparameters: 82
body: 46
41ExprRangelambda_map: 47
start_index: 111
end_index: 109
42ExprRangelambda_map: 48
start_index: 111
end_index: 112
43ExprRangelambda_map: 49
start_index: 111
end_index: 109
44ExprRangelambda_map: 50
start_index: 111
end_index: 112
45Operationoperator: 51
operand: 59
46Conditionalvalue: 53
condition: 54
47Lambdaparameter: 122
body: 55
48Lambdaparameter: 122
body: 56
49Lambdaparameter: 122
body: 57
50Lambdaparameter: 122
body: 58
51Literal
52ExprTuple59
53Operationoperator: 60
operands: 61
54Operationoperator: 62
operands: 63
55Operationoperator: 79
operands: 64
56Operationoperator: 79
operands: 65
57Operationoperator: 79
operands: 66
58Operationoperator: 79
operands: 67
59Variable
60Literal
61ExprTuple68, 69
62Literal
63ExprTuple70, 71, 72, 73
64ExprTuple113, 74
65ExprTuple114, 75
66ExprTuple115, 74
67ExprTuple116, 75
68Operationoperator: 81
operands: 76
69Operationoperator: 81
operands: 77
70Operationoperator: 79
operands: 78
71Operationoperator: 79
operands: 80
72Operationoperator: 81
operands: 82
73Operationoperator: 83
operands: 84
74IndexedVarvariable: 85
index: 122
75IndexedVarvariable: 86
index: 122
76ExprTuple87, 88
77ExprTuple89, 90
78ExprTuple99, 105
79Literal
80ExprTuple100, 105
81Literal
82ExprTuple99, 100
83Literal
84ExprTuple99, 91
85Variable
86Variable
87Operationoperator: 95
operands: 92
88Operationoperator: 95
operands: 93
89Operationoperator: 95
operands: 94
90Operationoperator: 95
operands: 96
91Operationoperator: 97
operand: 105
92ExprTuple101, 99, 102
93ExprTuple103, 100, 104
94ExprTuple101, 102
95Literal
96ExprTuple103, 104
97Literal
98ExprTuple105
99Variable
100Variable
101ExprRangelambda_map: 106
start_index: 111
end_index: 109
102ExprRangelambda_map: 107
start_index: 111
end_index: 112
103ExprRangelambda_map: 108
start_index: 111
end_index: 109
104ExprRangelambda_map: 110
start_index: 111
end_index: 112
105Variable
106Lambdaparameter: 122
body: 113
107Lambdaparameter: 122
body: 114
108Lambdaparameter: 122
body: 115
109Variable
110Lambdaparameter: 122
body: 116
111Literal
112Variable
113IndexedVarvariable: 117
index: 122
114IndexedVarvariable: 118
index: 122
115IndexedVarvariable: 119
index: 122
116IndexedVarvariable: 120
index: 122
117Variable
118Variable
119Variable
120Variable
121ExprTuple122
122Variable