logo

Expression of type Forall

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 K, V, b, e
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 Equals, Forall, Implies, NotEquals
In [2]:
# build up the expression from sub-expressions
expr = 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()
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())
\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}
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneTrue('with_wrapping',)
condition_wrappingWrap 'before' or 'after' the condition (or None).NoneNone/False('with_wrap_after_condition', 'with_wrap_before_condition')
wrap_paramsIf 'True', wraps every two parameters AND wraps the Expression after the parametersNoneNone/False('with_params',)
justificationjustify to the 'left', 'center', or 'right' in the array cellscentercenter('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 26
operand: 2
1ExprTuple2
2Lambdaparameters: 3
body: 4
3ExprTuple5, 97, 6
4Conditionalvalue: 7
condition: 8
5ExprRangelambda_map: 9
start_index: 103
end_index: 101
6ExprRangelambda_map: 10
start_index: 103
end_index: 104
7Operationoperator: 26
operand: 13
8Operationoperator: 54
operands: 12
9Lambdaparameter: 114
body: 66
10Lambdaparameter: 114
body: 67
11ExprTuple13
12ExprTuple14, 15, 16
13Lambdaparameters: 17
body: 18
14ExprRangelambda_map: 19
start_index: 103
end_index: 101
15Operationoperator: 30
operands: 20
16ExprRangelambda_map: 21
start_index: 103
end_index: 104
17ExprTuple93, 94, 95, 96
18Conditionalvalue: 22
condition: 23
19Lambdaparameter: 114
body: 24
20ExprTuple97, 37
21Lambdaparameter: 114
body: 25
22Operationoperator: 26
operand: 32
23Operationoperator: 54
operands: 28
24Operationoperator: 30
operands: 29
25Operationoperator: 30
operands: 31
26Literal
27ExprTuple32
28ExprTuple33, 34, 35, 36
29ExprTuple66, 37
30Literal
31ExprTuple67, 37
32Lambdaparameters: 74
body: 38
33ExprRangelambda_map: 39
start_index: 103
end_index: 101
34ExprRangelambda_map: 40
start_index: 103
end_index: 104
35ExprRangelambda_map: 41
start_index: 103
end_index: 101
36ExprRangelambda_map: 42
start_index: 103
end_index: 104
37Operationoperator: 43
operand: 51
38Conditionalvalue: 45
condition: 46
39Lambdaparameter: 114
body: 47
40Lambdaparameter: 114
body: 48
41Lambdaparameter: 114
body: 49
42Lambdaparameter: 114
body: 50
43Literal
44ExprTuple51
45Operationoperator: 52
operands: 53
46Operationoperator: 54
operands: 55
47Operationoperator: 71
operands: 56
48Operationoperator: 71
operands: 57
49Operationoperator: 71
operands: 58
50Operationoperator: 71
operands: 59
51Variable
52Literal
53ExprTuple60, 61
54Literal
55ExprTuple62, 63, 64, 65
56ExprTuple105, 66
57ExprTuple106, 67
58ExprTuple107, 66
59ExprTuple108, 67
60Operationoperator: 73
operands: 68
61Operationoperator: 73
operands: 69
62Operationoperator: 71
operands: 70
63Operationoperator: 71
operands: 72
64Operationoperator: 73
operands: 74
65Operationoperator: 75
operands: 76
66IndexedVarvariable: 77
index: 114
67IndexedVarvariable: 78
index: 114
68ExprTuple79, 80
69ExprTuple81, 82
70ExprTuple91, 97
71Literal
72ExprTuple92, 97
73Literal
74ExprTuple91, 92
75Literal
76ExprTuple91, 83
77Variable
78Variable
79Operationoperator: 87
operands: 84
80Operationoperator: 87
operands: 85
81Operationoperator: 87
operands: 86
82Operationoperator: 87
operands: 88
83Operationoperator: 89
operand: 97
84ExprTuple93, 91, 94
85ExprTuple95, 92, 96
86ExprTuple93, 94
87Literal
88ExprTuple95, 96
89Literal
90ExprTuple97
91Variable
92Variable
93ExprRangelambda_map: 98
start_index: 103
end_index: 101
94ExprRangelambda_map: 99
start_index: 103
end_index: 104
95ExprRangelambda_map: 100
start_index: 103
end_index: 101
96ExprRangelambda_map: 102
start_index: 103
end_index: 104
97Variable
98Lambdaparameter: 114
body: 105
99Lambdaparameter: 114
body: 106
100Lambdaparameter: 114
body: 107
101Variable
102Lambdaparameter: 114
body: 108
103Literal
104Variable
105IndexedVarvariable: 109
index: 114
106IndexedVarvariable: 110
index: 114
107IndexedVarvariable: 111
index: 114
108IndexedVarvariable: 112
index: 114
109Variable
110Variable
111Variable
112Variable
113ExprTuple114
114Variable