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, 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, InSet
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, 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(), 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(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}\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: 36
operands: 4
3ExprTuple5
4ExprTuple6, 7
5Lambdaparameters: 8
body: 9
6Operationoperator: 68
operands: 10
7Operationoperator: 68
operands: 11
8ExprTuple12, 72, 13
9Conditionalvalue: 14
condition: 15
10ExprTuple97, 16
11ExprTuple100, 16
12ExprRangelambda_map: 17
start_index: 99
end_index: 97
13ExprRangelambda_map: 18
start_index: 99
end_index: 100
14Operationoperator: 34
operand: 21
15Operationoperator: 36
operands: 20
16Literal
17Lambdaparameter: 110
body: 73
18Lambdaparameter: 110
body: 74
19ExprTuple21
20ExprTuple22, 23, 24
21Lambdaparameters: 25
body: 26
22ExprRangelambda_map: 27
start_index: 99
end_index: 97
23Operationoperator: 39
operands: 28
24ExprRangelambda_map: 29
start_index: 99
end_index: 100
25ExprTuple89, 90, 91, 93
26Conditionalvalue: 30
condition: 31
27Lambdaparameter: 110
body: 32
28ExprTuple72, 46
29Lambdaparameter: 110
body: 33
30Operationoperator: 34
operand: 41
31Operationoperator: 36
operands: 37
32Operationoperator: 39
operands: 38
33Operationoperator: 39
operands: 40
34Literal
35ExprTuple41
36Literal
37ExprTuple42, 43, 44, 45
38ExprTuple73, 46
39Literal
40ExprTuple74, 46
41Lambdaparameter: 92
body: 48
42ExprRangelambda_map: 49
start_index: 99
end_index: 97
43ExprRangelambda_map: 50
start_index: 99
end_index: 100
44ExprRangelambda_map: 51
start_index: 99
end_index: 97
45ExprRangelambda_map: 52
start_index: 99
end_index: 100
46Operationoperator: 53
operand: 61
47ExprTuple92
48Conditionalvalue: 55
condition: 56
49Lambdaparameter: 110
body: 57
50Lambdaparameter: 110
body: 58
51Lambdaparameter: 110
body: 59
52Lambdaparameter: 110
body: 60
53Literal
54ExprTuple61
55Operationoperator: 62
operands: 63
56Operationoperator: 68
operands: 64
57Operationoperator: 68
operands: 65
58Operationoperator: 68
operands: 66
59Operationoperator: 68
operands: 67
60Operationoperator: 68
operands: 69
61Variable
62Literal
63ExprTuple70, 71
64ExprTuple92, 72
65ExprTuple101, 73
66ExprTuple102, 74
67ExprTuple103, 73
68Literal
69ExprTuple104, 74
70Operationoperator: 76
operands: 75
71Operationoperator: 76
operands: 77
72Variable
73IndexedVarvariable: 78
index: 110
74IndexedVarvariable: 79
index: 110
75ExprTuple80, 81
76Literal
77ExprTuple82, 83
78Variable
79Variable
80Operationoperator: 87
operands: 84
81Operationoperator: 87
operands: 85
82Operationoperator: 87
operands: 86
83Operationoperator: 87
operands: 88
84ExprTuple89, 90
85ExprTuple91, 93
86ExprTuple89, 92, 90
87Literal
88ExprTuple91, 92, 93
89ExprRangelambda_map: 94
start_index: 99
end_index: 97
90ExprRangelambda_map: 95
start_index: 99
end_index: 100
91ExprRangelambda_map: 96
start_index: 99
end_index: 97
92Variable
93ExprRangelambda_map: 98
start_index: 99
end_index: 100
94Lambdaparameter: 110
body: 101
95Lambdaparameter: 110
body: 102
96Lambdaparameter: 110
body: 103
97Variable
98Lambdaparameter: 110
body: 104
99Literal
100Variable
101IndexedVarvariable: 105
index: 110
102IndexedVarvariable: 106
index: 110
103IndexedVarvariable: 107
index: 110
104IndexedVarvariable: 108
index: 110
105Variable
106Variable
107Variable
108Variable
109ExprTuple110
110Variable