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 = [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_{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]
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
3ExprTuple101, 104
4Conditionalvalue: 5
condition: 6
5Operationoperator: 38
operand: 9
6Operationoperator: 40
operands: 8
7ExprTuple9
8ExprTuple10, 11
9Lambdaparameters: 12
body: 13
10Operationoperator: 72
operands: 14
11Operationoperator: 72
operands: 15
12ExprTuple16, 76, 17
13Conditionalvalue: 18
condition: 19
14ExprTuple101, 20
15ExprTuple104, 20
16ExprRangelambda_map: 21
start_index: 103
end_index: 101
17ExprRangelambda_map: 22
start_index: 103
end_index: 104
18Operationoperator: 38
operand: 25
19Operationoperator: 40
operands: 24
20Literal
21Lambdaparameter: 114
body: 77
22Lambdaparameter: 114
body: 78
23ExprTuple25
24ExprTuple26, 27, 28
25Lambdaparameters: 29
body: 30
26ExprRangelambda_map: 31
start_index: 103
end_index: 101
27Operationoperator: 43
operands: 32
28ExprRangelambda_map: 33
start_index: 103
end_index: 104
29ExprTuple93, 94, 95, 97
30Conditionalvalue: 34
condition: 35
31Lambdaparameter: 114
body: 36
32ExprTuple76, 50
33Lambdaparameter: 114
body: 37
34Operationoperator: 38
operand: 45
35Operationoperator: 40
operands: 41
36Operationoperator: 43
operands: 42
37Operationoperator: 43
operands: 44
38Literal
39ExprTuple45
40Literal
41ExprTuple46, 47, 48, 49
42ExprTuple77, 50
43Literal
44ExprTuple78, 50
45Lambdaparameter: 96
body: 52
46ExprRangelambda_map: 53
start_index: 103
end_index: 101
47ExprRangelambda_map: 54
start_index: 103
end_index: 104
48ExprRangelambda_map: 55
start_index: 103
end_index: 101
49ExprRangelambda_map: 56
start_index: 103
end_index: 104
50Operationoperator: 57
operand: 65
51ExprTuple96
52Conditionalvalue: 59
condition: 60
53Lambdaparameter: 114
body: 61
54Lambdaparameter: 114
body: 62
55Lambdaparameter: 114
body: 63
56Lambdaparameter: 114
body: 64
57Literal
58ExprTuple65
59Operationoperator: 66
operands: 67
60Operationoperator: 72
operands: 68
61Operationoperator: 72
operands: 69
62Operationoperator: 72
operands: 70
63Operationoperator: 72
operands: 71
64Operationoperator: 72
operands: 73
65Variable
66Literal
67ExprTuple74, 75
68ExprTuple96, 76
69ExprTuple105, 77
70ExprTuple106, 78
71ExprTuple107, 77
72Literal
73ExprTuple108, 78
74Operationoperator: 80
operands: 79
75Operationoperator: 80
operands: 81
76Variable
77IndexedVarvariable: 82
index: 114
78IndexedVarvariable: 83
index: 114
79ExprTuple84, 85
80Literal
81ExprTuple86, 87
82Variable
83Variable
84Operationoperator: 91
operands: 88
85Operationoperator: 91
operands: 89
86Operationoperator: 91
operands: 90
87Operationoperator: 91
operands: 92
88ExprTuple93, 94
89ExprTuple95, 97
90ExprTuple93, 96, 94
91Literal
92ExprTuple95, 96, 97
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
96Variable
97ExprRangelambda_map: 102
start_index: 103
end_index: 104
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