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
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
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, 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()
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(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}
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, 64, 6
4Conditionalvalue: 7
condition: 8
5ExprRangelambda_map: 9
start_index: 91
end_index: 89
6ExprRangelambda_map: 10
start_index: 91
end_index: 92
7Operationoperator: 26
operand: 13
8Operationoperator: 28
operands: 12
9Lambdaparameter: 102
body: 65
10Lambdaparameter: 102
body: 66
11ExprTuple13
12ExprTuple14, 15, 16
13Lambdaparameters: 17
body: 18
14ExprRangelambda_map: 19
start_index: 91
end_index: 89
15Operationoperator: 31
operands: 20
16ExprRangelambda_map: 21
start_index: 91
end_index: 92
17ExprTuple81, 82, 83, 85
18Conditionalvalue: 22
condition: 23
19Lambdaparameter: 102
body: 24
20ExprTuple64, 38
21Lambdaparameter: 102
body: 25
22Operationoperator: 26
operand: 33
23Operationoperator: 28
operands: 29
24Operationoperator: 31
operands: 30
25Operationoperator: 31
operands: 32
26Literal
27ExprTuple33
28Literal
29ExprTuple34, 35, 36, 37
30ExprTuple65, 38
31Literal
32ExprTuple66, 38
33Lambdaparameter: 84
body: 40
34ExprRangelambda_map: 41
start_index: 91
end_index: 89
35ExprRangelambda_map: 42
start_index: 91
end_index: 92
36ExprRangelambda_map: 43
start_index: 91
end_index: 89
37ExprRangelambda_map: 44
start_index: 91
end_index: 92
38Operationoperator: 45
operand: 53
39ExprTuple84
40Conditionalvalue: 47
condition: 48
41Lambdaparameter: 102
body: 49
42Lambdaparameter: 102
body: 50
43Lambdaparameter: 102
body: 51
44Lambdaparameter: 102
body: 52
45Literal
46ExprTuple53
47Operationoperator: 54
operands: 55
48Operationoperator: 60
operands: 56
49Operationoperator: 60
operands: 57
50Operationoperator: 60
operands: 58
51Operationoperator: 60
operands: 59
52Operationoperator: 60
operands: 61
53Variable
54Literal
55ExprTuple62, 63
56ExprTuple84, 64
57ExprTuple93, 65
58ExprTuple94, 66
59ExprTuple95, 65
60Literal
61ExprTuple96, 66
62Operationoperator: 68
operands: 67
63Operationoperator: 68
operands: 69
64Variable
65IndexedVarvariable: 70
index: 102
66IndexedVarvariable: 71
index: 102
67ExprTuple72, 73
68Literal
69ExprTuple74, 75
70Variable
71Variable
72Operationoperator: 79
operands: 76
73Operationoperator: 79
operands: 77
74Operationoperator: 79
operands: 78
75Operationoperator: 79
operands: 80
76ExprTuple81, 82
77ExprTuple83, 85
78ExprTuple81, 84, 82
79Literal
80ExprTuple83, 84, 85
81ExprRangelambda_map: 86
start_index: 91
end_index: 89
82ExprRangelambda_map: 87
start_index: 91
end_index: 92
83ExprRangelambda_map: 88
start_index: 91
end_index: 89
84Variable
85ExprRangelambda_map: 90
start_index: 91
end_index: 92
86Lambdaparameter: 102
body: 93
87Lambdaparameter: 102
body: 94
88Lambdaparameter: 102
body: 95
89Variable
90Lambdaparameter: 102
body: 96
91Literal
92Variable
93IndexedVarvariable: 97
index: 102
94IndexedVarvariable: 98
index: 102
95IndexedVarvariable: 99
index: 102
96IndexedVarvariable: 100
index: 102
97Variable
98Variable
99Variable
100Variable
101ExprTuple102
102Variable