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, 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 Equals, Forall, Implies
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, 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(), 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(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}\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: 68
body: 3
3Operationoperator: 41
operand: 5
4ExprTuple5
5Lambdaparameters: 6
body: 7
6ExprTuple104, 107
7Conditionalvalue: 8
condition: 9
8Operationoperator: 41
operand: 12
9Operationoperator: 43
operands: 11
10ExprTuple12
11ExprTuple13, 14
12Lambdaparameters: 15
body: 16
13Operationoperator: 75
operands: 17
14Operationoperator: 75
operands: 18
15ExprTuple19, 79, 20
16Conditionalvalue: 21
condition: 22
17ExprTuple104, 23
18ExprTuple107, 23
19ExprRangelambda_map: 24
start_index: 106
end_index: 104
20ExprRangelambda_map: 25
start_index: 106
end_index: 107
21Operationoperator: 41
operand: 28
22Operationoperator: 43
operands: 27
23Literal
24Lambdaparameter: 117
body: 80
25Lambdaparameter: 117
body: 81
26ExprTuple28
27ExprTuple29, 30, 31
28Lambdaparameters: 32
body: 33
29ExprRangelambda_map: 34
start_index: 106
end_index: 104
30Operationoperator: 46
operands: 35
31ExprRangelambda_map: 36
start_index: 106
end_index: 107
32ExprTuple96, 97, 98, 100
33Conditionalvalue: 37
condition: 38
34Lambdaparameter: 117
body: 39
35ExprTuple79, 53
36Lambdaparameter: 117
body: 40
37Operationoperator: 41
operand: 48
38Operationoperator: 43
operands: 44
39Operationoperator: 46
operands: 45
40Operationoperator: 46
operands: 47
41Literal
42ExprTuple48
43Literal
44ExprTuple49, 50, 51, 52
45ExprTuple80, 53
46Literal
47ExprTuple81, 53
48Lambdaparameter: 99
body: 55
49ExprRangelambda_map: 56
start_index: 106
end_index: 104
50ExprRangelambda_map: 57
start_index: 106
end_index: 107
51ExprRangelambda_map: 58
start_index: 106
end_index: 104
52ExprRangelambda_map: 59
start_index: 106
end_index: 107
53Operationoperator: 60
operand: 68
54ExprTuple99
55Conditionalvalue: 62
condition: 63
56Lambdaparameter: 117
body: 64
57Lambdaparameter: 117
body: 65
58Lambdaparameter: 117
body: 66
59Lambdaparameter: 117
body: 67
60Literal
61ExprTuple68
62Operationoperator: 69
operands: 70
63Operationoperator: 75
operands: 71
64Operationoperator: 75
operands: 72
65Operationoperator: 75
operands: 73
66Operationoperator: 75
operands: 74
67Operationoperator: 75
operands: 76
68Variable
69Literal
70ExprTuple77, 78
71ExprTuple99, 79
72ExprTuple108, 80
73ExprTuple109, 81
74ExprTuple110, 80
75Literal
76ExprTuple111, 81
77Operationoperator: 83
operands: 82
78Operationoperator: 83
operands: 84
79Variable
80IndexedVarvariable: 85
index: 117
81IndexedVarvariable: 86
index: 117
82ExprTuple87, 88
83Literal
84ExprTuple89, 90
85Variable
86Variable
87Operationoperator: 94
operands: 91
88Operationoperator: 94
operands: 92
89Operationoperator: 94
operands: 93
90Operationoperator: 94
operands: 95
91ExprTuple96, 97
92ExprTuple98, 100
93ExprTuple96, 99, 97
94Literal
95ExprTuple98, 99, 100
96ExprRangelambda_map: 101
start_index: 106
end_index: 104
97ExprRangelambda_map: 102
start_index: 106
end_index: 107
98ExprRangelambda_map: 103
start_index: 106
end_index: 104
99Variable
100ExprRangelambda_map: 105
start_index: 106
end_index: 107
101Lambdaparameter: 117
body: 108
102Lambdaparameter: 117
body: 109
103Lambdaparameter: 117
body: 110
104Variable
105Lambdaparameter: 117
body: 111
106Literal
107Variable
108IndexedVarvariable: 112
index: 117
109IndexedVarvariable: 113
index: 117
110IndexedVarvariable: 114
index: 117
111IndexedVarvariable: 115
index: 117
112Variable
113Variable
114Variable
115Variable
116ExprTuple117
117Variable