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 = [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_{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]
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: 38
operand: 2
1ExprTuple2
2Lambdaparameters: 3
body: 4
3ExprTuple113, 116
4Conditionalvalue: 5
condition: 6
5Operationoperator: 38
operand: 9
6Operationoperator: 66
operands: 8
7ExprTuple9
8ExprTuple10, 11
9Lambdaparameters: 12
body: 13
10Operationoperator: 83
operands: 14
11Operationoperator: 83
operands: 15
12ExprTuple16, 109, 17
13Conditionalvalue: 18
condition: 19
14ExprTuple113, 20
15ExprTuple116, 20
16ExprRangelambda_map: 21
start_index: 115
end_index: 113
17ExprRangelambda_map: 22
start_index: 115
end_index: 116
18Operationoperator: 38
operand: 25
19Operationoperator: 66
operands: 24
20Literal
21Lambdaparameter: 126
body: 78
22Lambdaparameter: 126
body: 79
23ExprTuple25
24ExprTuple26, 27, 28
25Lambdaparameters: 29
body: 30
26ExprRangelambda_map: 31
start_index: 115
end_index: 113
27Operationoperator: 42
operands: 32
28ExprRangelambda_map: 33
start_index: 115
end_index: 116
29ExprTuple105, 106, 107, 108
30Conditionalvalue: 34
condition: 35
31Lambdaparameter: 126
body: 36
32ExprTuple109, 49
33Lambdaparameter: 126
body: 37
34Operationoperator: 38
operand: 44
35Operationoperator: 66
operands: 40
36Operationoperator: 42
operands: 41
37Operationoperator: 42
operands: 43
38Literal
39ExprTuple44
40ExprTuple45, 46, 47, 48
41ExprTuple78, 49
42Literal
43ExprTuple79, 49
44Lambdaparameters: 86
body: 50
45ExprRangelambda_map: 51
start_index: 115
end_index: 113
46ExprRangelambda_map: 52
start_index: 115
end_index: 116
47ExprRangelambda_map: 53
start_index: 115
end_index: 113
48ExprRangelambda_map: 54
start_index: 115
end_index: 116
49Operationoperator: 55
operand: 63
50Conditionalvalue: 57
condition: 58
51Lambdaparameter: 126
body: 59
52Lambdaparameter: 126
body: 60
53Lambdaparameter: 126
body: 61
54Lambdaparameter: 126
body: 62
55Literal
56ExprTuple63
57Operationoperator: 64
operands: 65
58Operationoperator: 66
operands: 67
59Operationoperator: 83
operands: 68
60Operationoperator: 83
operands: 69
61Operationoperator: 83
operands: 70
62Operationoperator: 83
operands: 71
63Variable
64Literal
65ExprTuple72, 73
66Literal
67ExprTuple74, 75, 76, 77
68ExprTuple117, 78
69ExprTuple118, 79
70ExprTuple119, 78
71ExprTuple120, 79
72Operationoperator: 85
operands: 80
73Operationoperator: 85
operands: 81
74Operationoperator: 83
operands: 82
75Operationoperator: 83
operands: 84
76Operationoperator: 85
operands: 86
77Operationoperator: 87
operands: 88
78IndexedVarvariable: 89
index: 126
79IndexedVarvariable: 90
index: 126
80ExprTuple91, 92
81ExprTuple93, 94
82ExprTuple103, 109
83Literal
84ExprTuple104, 109
85Literal
86ExprTuple103, 104
87Literal
88ExprTuple103, 95
89Variable
90Variable
91Operationoperator: 99
operands: 96
92Operationoperator: 99
operands: 97
93Operationoperator: 99
operands: 98
94Operationoperator: 99
operands: 100
95Operationoperator: 101
operand: 109
96ExprTuple105, 103, 106
97ExprTuple107, 104, 108
98ExprTuple105, 106
99Literal
100ExprTuple107, 108
101Literal
102ExprTuple109
103Variable
104Variable
105ExprRangelambda_map: 110
start_index: 115
end_index: 113
106ExprRangelambda_map: 111
start_index: 115
end_index: 116
107ExprRangelambda_map: 112
start_index: 115
end_index: 113
108ExprRangelambda_map: 114
start_index: 115
end_index: 116
109Variable
110Lambdaparameter: 126
body: 117
111Lambdaparameter: 126
body: 118
112Lambdaparameter: 126
body: 119
113Variable
114Lambdaparameter: 126
body: 120
115Literal
116Variable
117IndexedVarvariable: 121
index: 126
118IndexedVarvariable: 122
index: 126
119IndexedVarvariable: 123
index: 126
120IndexedVarvariable: 124
index: 126
121Variable
122Variable
123Variable
124Variable
125ExprTuple126
126Variable