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
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
from proveit.logic import Equals, Forall, Implies
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, 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()
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(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}
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
3ExprTuple55, 56, 57, 59
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operand: 11
6Operationoperator: 9
operands: 10
7Literal
8ExprTuple11
9Literal
10ExprTuple12, 13, 14, 15
11Lambdaparameter: 58
body: 17
12ExprRangelambda_map: 18
start_index: 65
end_index: 63
13ExprRangelambda_map: 19
start_index: 65
end_index: 66
14ExprRangelambda_map: 20
start_index: 65
end_index: 63
15ExprRangelambda_map: 21
start_index: 65
end_index: 66
16ExprTuple58
17Conditionalvalue: 22
condition: 23
18Lambdaparameter: 76
body: 24
19Lambdaparameter: 76
body: 25
20Lambdaparameter: 76
body: 26
21Lambdaparameter: 76
body: 27
22Operationoperator: 28
operands: 29
23Operationoperator: 34
operands: 30
24Operationoperator: 34
operands: 31
25Operationoperator: 34
operands: 32
26Operationoperator: 34
operands: 33
27Operationoperator: 34
operands: 35
28Literal
29ExprTuple36, 37
30ExprTuple58, 38
31ExprTuple67, 39
32ExprTuple68, 40
33ExprTuple69, 39
34Literal
35ExprTuple70, 40
36Operationoperator: 42
operands: 41
37Operationoperator: 42
operands: 43
38Variable
39IndexedVarvariable: 44
index: 76
40IndexedVarvariable: 45
index: 76
41ExprTuple46, 47
42Literal
43ExprTuple48, 49
44Variable
45Variable
46Operationoperator: 53
operands: 50
47Operationoperator: 53
operands: 51
48Operationoperator: 53
operands: 52
49Operationoperator: 53
operands: 54
50ExprTuple55, 56
51ExprTuple57, 59
52ExprTuple55, 58, 56
53Literal
54ExprTuple57, 58, 59
55ExprRangelambda_map: 60
start_index: 65
end_index: 63
56ExprRangelambda_map: 61
start_index: 65
end_index: 66
57ExprRangelambda_map: 62
start_index: 65
end_index: 63
58Variable
59ExprRangelambda_map: 64
start_index: 65
end_index: 66
60Lambdaparameter: 76
body: 67
61Lambdaparameter: 76
body: 68
62Lambdaparameter: 76
body: 69
63Variable
64Lambdaparameter: 76
body: 70
65Literal
66Variable
67IndexedVarvariable: 71
index: 76
68IndexedVarvariable: 72
index: 76
69IndexedVarvariable: 73
index: 76
70IndexedVarvariable: 74
index: 76
71Variable
72Variable
73Variable
74Variable
75ExprTuple76
76Variable