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, i, j, k
from proveit.core_expr_types import U_1_to_i, V_1_to_j, W_1_to_k, a_1_to_i, b_1_to_j, c_1_to_k
from proveit.linear_algebra import TensorProd, VecSpaces
from proveit.logic import And, Equals, Forall, InSet
from proveit.numbers import Natural
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [U_1_to_i, V_1_to_j, W_1_to_k]
expr = Conditional(Forall(instance_param_or_params = sub_expr1, instance_expr = Forall(instance_param_or_params = [a_1_to_i, b_1_to_j, c_1_to_k], instance_expr = Equals(TensorProd(a_1_to_i, b_1_to_j, c_1_to_k), TensorProd(a_1_to_i, TensorProd(b_1_to_j), c_1_to_k)).with_wrapping_at(2), domains = sub_expr1).with_wrapping(), domain = VecSpaces(K)).with_wrapping(), And(InSet(i, Natural), InSet(j, 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_{1}, V_{2}, \ldots, V_{j}, 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(b_{1} \in V_{1}\right), \left(b_{2} \in V_{2}\right), \ldots, \left(b_{j} \in V_{j}\right),\left(c_{1} \in W_{1}\right), \left(c_{2} \in W_{2}\right), \ldots, \left(c_{k} \in W_{k}\right)}~\\
\left(\begin{array}{c} \begin{array}{l} \left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i}{\otimes} b_{1} {\otimes}  b_{2} {\otimes}  \ldots {\otimes}  b_{j}{\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) =  \\ \left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} \left(b_{1} {\otimes}  b_{2} {\otimes}  \ldots {\otimes}  b_{j}\right){\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) \end{array} \end{array}\right)\end{array}\right]\end{array} \textrm{ if } i \in \mathbb{N} ,  j \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: 23
operand: 5
2Operationoperator: 41
operands: 4
3ExprTuple5
4ExprTuple6, 7, 8
5Lambdaparameters: 9
body: 10
6Operationoperator: 75
operands: 11
7Operationoperator: 75
operands: 12
8Operationoperator: 75
operands: 13
9ExprTuple14, 15, 16
10Conditionalvalue: 17
condition: 18
11ExprTuple68, 19
12ExprTuple85, 19
13ExprTuple72, 19
14ExprRangelambda_map: 20
start_index: 84
end_index: 68
15ExprRangelambda_map: 21
start_index: 84
end_index: 85
16ExprRangelambda_map: 22
start_index: 84
end_index: 72
17Operationoperator: 23
operand: 26
18Operationoperator: 41
operands: 25
19Literal
20Lambdaparameter: 94
body: 79
21Lambdaparameter: 94
body: 80
22Lambdaparameter: 94
body: 82
23Literal
24ExprTuple26
25ExprTuple27, 28, 29
26Lambdaparameters: 53
body: 30
27ExprRangelambda_map: 31
start_index: 84
end_index: 68
28ExprRangelambda_map: 32
start_index: 84
end_index: 85
29ExprRangelambda_map: 33
start_index: 84
end_index: 72
30Conditionalvalue: 34
condition: 35
31Lambdaparameter: 94
body: 36
32Lambdaparameter: 94
body: 37
33Lambdaparameter: 94
body: 38
34Operationoperator: 39
operands: 40
35Operationoperator: 41
operands: 42
36Operationoperator: 45
operands: 43
37Operationoperator: 45
operands: 44
38Operationoperator: 45
operands: 46
39Literal
40ExprTuple47, 48
41Literal
42ExprTuple49, 50, 51
43ExprTuple79, 52
44ExprTuple80, 52
45Literal
46ExprTuple82, 52
47Operationoperator: 69
operands: 53
48Operationoperator: 69
operands: 54
49ExprRangelambda_map: 55
start_index: 84
end_index: 68
50ExprRangelambda_map: 56
start_index: 84
end_index: 85
51ExprRangelambda_map: 57
start_index: 84
end_index: 72
52Operationoperator: 58
operand: 66
53ExprTuple60, 77, 62
54ExprTuple60, 61, 62
55Lambdaparameter: 94
body: 63
56Lambdaparameter: 94
body: 64
57Lambdaparameter: 94
body: 65
58Literal
59ExprTuple66
60ExprRangelambda_map: 67
start_index: 84
end_index: 68
61Operationoperator: 69
operands: 70
62ExprRangelambda_map: 71
start_index: 84
end_index: 72
63Operationoperator: 75
operands: 73
64Operationoperator: 75
operands: 74
65Operationoperator: 75
operands: 76
66Variable
67Lambdaparameter: 94
body: 78
68Variable
69Literal
70ExprTuple77
71Lambdaparameter: 94
body: 81
72Variable
73ExprTuple78, 79
74ExprTuple91, 80
75Literal
76ExprTuple81, 82
77ExprRangelambda_map: 83
start_index: 84
end_index: 85
78IndexedVarvariable: 86
index: 94
79IndexedVarvariable: 87
index: 94
80IndexedVarvariable: 88
index: 94
81IndexedVarvariable: 89
index: 94
82IndexedVarvariable: 90
index: 94
83Lambdaparameter: 94
body: 91
84Literal
85Variable
86Variable
87Variable
88Variable
89Variable
90Variable
91IndexedVarvariable: 92
index: 94
92Variable
93ExprTuple94
94Variable