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, 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 Equals, Forall, Implies, NotEquals
from proveit.numbers import Natural
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [K], instance_expr = Forall(instance_param_or_params = [i, k], instance_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(), domain = 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())
\forall_{K}~\left[\forall_{i, k \in \mathbb{N}}~\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}\right]\right]
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneNone/False('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: 41
operand: 2
1ExprTuple2
2Lambdaparameter: 66
body: 3
3Operationoperator: 41
operand: 5
4ExprTuple5
5Lambdaparameters: 6
body: 7
6ExprTuple116, 119
7Conditionalvalue: 8
condition: 9
8Operationoperator: 41
operand: 12
9Operationoperator: 69
operands: 11
10ExprTuple12
11ExprTuple13, 14
12Lambdaparameters: 15
body: 16
13Operationoperator: 86
operands: 17
14Operationoperator: 86
operands: 18
15ExprTuple19, 112, 20
16Conditionalvalue: 21
condition: 22
17ExprTuple116, 23
18ExprTuple119, 23
19ExprRangelambda_map: 24
start_index: 118
end_index: 116
20ExprRangelambda_map: 25
start_index: 118
end_index: 119
21Operationoperator: 41
operand: 28
22Operationoperator: 69
operands: 27
23Literal
24Lambdaparameter: 129
body: 81
25Lambdaparameter: 129
body: 82
26ExprTuple28
27ExprTuple29, 30, 31
28Lambdaparameters: 32
body: 33
29ExprRangelambda_map: 34
start_index: 118
end_index: 116
30Operationoperator: 45
operands: 35
31ExprRangelambda_map: 36
start_index: 118
end_index: 119
32ExprTuple108, 109, 110, 111
33Conditionalvalue: 37
condition: 38
34Lambdaparameter: 129
body: 39
35ExprTuple112, 52
36Lambdaparameter: 129
body: 40
37Operationoperator: 41
operand: 47
38Operationoperator: 69
operands: 43
39Operationoperator: 45
operands: 44
40Operationoperator: 45
operands: 46
41Literal
42ExprTuple47
43ExprTuple48, 49, 50, 51
44ExprTuple81, 52
45Literal
46ExprTuple82, 52
47Lambdaparameters: 89
body: 53
48ExprRangelambda_map: 54
start_index: 118
end_index: 116
49ExprRangelambda_map: 55
start_index: 118
end_index: 119
50ExprRangelambda_map: 56
start_index: 118
end_index: 116
51ExprRangelambda_map: 57
start_index: 118
end_index: 119
52Operationoperator: 58
operand: 66
53Conditionalvalue: 60
condition: 61
54Lambdaparameter: 129
body: 62
55Lambdaparameter: 129
body: 63
56Lambdaparameter: 129
body: 64
57Lambdaparameter: 129
body: 65
58Literal
59ExprTuple66
60Operationoperator: 67
operands: 68
61Operationoperator: 69
operands: 70
62Operationoperator: 86
operands: 71
63Operationoperator: 86
operands: 72
64Operationoperator: 86
operands: 73
65Operationoperator: 86
operands: 74
66Variable
67Literal
68ExprTuple75, 76
69Literal
70ExprTuple77, 78, 79, 80
71ExprTuple120, 81
72ExprTuple121, 82
73ExprTuple122, 81
74ExprTuple123, 82
75Operationoperator: 88
operands: 83
76Operationoperator: 88
operands: 84
77Operationoperator: 86
operands: 85
78Operationoperator: 86
operands: 87
79Operationoperator: 88
operands: 89
80Operationoperator: 90
operands: 91
81IndexedVarvariable: 92
index: 129
82IndexedVarvariable: 93
index: 129
83ExprTuple94, 95
84ExprTuple96, 97
85ExprTuple106, 112
86Literal
87ExprTuple107, 112
88Literal
89ExprTuple106, 107
90Literal
91ExprTuple106, 98
92Variable
93Variable
94Operationoperator: 102
operands: 99
95Operationoperator: 102
operands: 100
96Operationoperator: 102
operands: 101
97Operationoperator: 102
operands: 103
98Operationoperator: 104
operand: 112
99ExprTuple108, 106, 109
100ExprTuple110, 107, 111
101ExprTuple108, 109
102Literal
103ExprTuple110, 111
104Literal
105ExprTuple112
106Variable
107Variable
108ExprRangelambda_map: 113
start_index: 118
end_index: 116
109ExprRangelambda_map: 114
start_index: 118
end_index: 119
110ExprRangelambda_map: 115
start_index: 118
end_index: 116
111ExprRangelambda_map: 117
start_index: 118
end_index: 119
112Variable
113Lambdaparameter: 129
body: 120
114Lambdaparameter: 129
body: 121
115Lambdaparameter: 129
body: 122
116Variable
117Lambdaparameter: 129
body: 123
118Literal
119Variable
120IndexedVarvariable: 124
index: 129
121IndexedVarvariable: 125
index: 129
122IndexedVarvariable: 126
index: 129
123IndexedVarvariable: 127
index: 129
124Variable
125Variable
126Variable
127Variable
128ExprTuple129
129Variable