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 V, b, e
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, VecZero
from proveit.logic import Equals, Forall, Implies, NotEquals
In [2]:
# build up the expression from sub-expressions
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()
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_{\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}
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: 7
operand: 2
1ExprTuple2
2Lambdaparameters: 3
body: 4
3ExprTuple67, 68, 69, 70
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operand: 10
6Operationoperator: 28
operands: 9
7Literal
8ExprTuple10
9ExprTuple11, 12, 13, 14
10Lambdaparameters: 48
body: 15
11ExprRangelambda_map: 16
start_index: 77
end_index: 75
12ExprRangelambda_map: 17
start_index: 77
end_index: 78
13ExprRangelambda_map: 18
start_index: 77
end_index: 75
14ExprRangelambda_map: 19
start_index: 77
end_index: 78
15Conditionalvalue: 20
condition: 21
16Lambdaparameter: 88
body: 22
17Lambdaparameter: 88
body: 23
18Lambdaparameter: 88
body: 24
19Lambdaparameter: 88
body: 25
20Operationoperator: 26
operands: 27
21Operationoperator: 28
operands: 29
22Operationoperator: 45
operands: 30
23Operationoperator: 45
operands: 31
24Operationoperator: 45
operands: 32
25Operationoperator: 45
operands: 33
26Literal
27ExprTuple34, 35
28Literal
29ExprTuple36, 37, 38, 39
30ExprTuple79, 40
31ExprTuple80, 41
32ExprTuple81, 40
33ExprTuple82, 41
34Operationoperator: 47
operands: 42
35Operationoperator: 47
operands: 43
36Operationoperator: 45
operands: 44
37Operationoperator: 45
operands: 46
38Operationoperator: 47
operands: 48
39Operationoperator: 49
operands: 50
40IndexedVarvariable: 51
index: 88
41IndexedVarvariable: 52
index: 88
42ExprTuple53, 54
43ExprTuple55, 56
44ExprTuple65, 71
45Literal
46ExprTuple66, 71
47Literal
48ExprTuple65, 66
49Literal
50ExprTuple65, 57
51Variable
52Variable
53Operationoperator: 61
operands: 58
54Operationoperator: 61
operands: 59
55Operationoperator: 61
operands: 60
56Operationoperator: 61
operands: 62
57Operationoperator: 63
operand: 71
58ExprTuple67, 65, 68
59ExprTuple69, 66, 70
60ExprTuple67, 68
61Literal
62ExprTuple69, 70
63Literal
64ExprTuple71
65Variable
66Variable
67ExprRangelambda_map: 72
start_index: 77
end_index: 75
68ExprRangelambda_map: 73
start_index: 77
end_index: 78
69ExprRangelambda_map: 74
start_index: 77
end_index: 75
70ExprRangelambda_map: 76
start_index: 77
end_index: 78
71Variable
72Lambdaparameter: 88
body: 79
73Lambdaparameter: 88
body: 80
74Lambdaparameter: 88
body: 81
75Variable
76Lambdaparameter: 88
body: 82
77Literal
78Variable
79IndexedVarvariable: 83
index: 88
80IndexedVarvariable: 84
index: 88
81IndexedVarvariable: 85
index: 88
82IndexedVarvariable: 86
index: 88
83Variable
84Variable
85Variable
86Variable
87ExprTuple88
88Variable