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
from proveit.core_expr_types import U_1_to_i, V_1_to_j, W_1_to_k, a_1_to_i, b_1_to_j, c_1_to_k
from proveit.linear_algebra import TensorProd, VecSpaces
from proveit.logic import Equals, Forall
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [U_1_to_i, V_1_to_j, W_1_to_k]
expr = Forall(instance_param_or_params = sub_expr1, instance_expr = Forall(instance_param_or_params = [a_1_to_i, b_1_to_j, c_1_to_k], instance_expr = Equals(TensorProd(a_1_to_i, TensorProd(b_1_to_j), c_1_to_k), TensorProd(a_1_to_i, b_1_to_j, c_1_to_k)).with_wrapping_at(1), domains = sub_expr1).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_{1}, V_{2}, \ldots, V_{j}, 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(b_{1} \in V_{1}\right), \left(b_{2} \in V_{2}\right), \ldots, \left(b_{j} \in V_{j}\right),\left(c_{1} \in W_{1}\right), \left(c_{2} \in W_{2}\right), \ldots, \left(c_{k} \in W_{k}\right)}~\\
\left(\begin{array}{c} \begin{array}{l} \left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} \left(b_{1} {\otimes}  b_{2} {\otimes}  \ldots {\otimes}  b_{j}\right){\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) \\  = \left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i}{\otimes} b_{1} {\otimes}  b_{2} {\otimes}  \ldots {\otimes}  b_{j}{\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) \end{array} \end{array}\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: 13
operand: 2
1ExprTuple2
2Lambdaparameters: 3
body: 4
3ExprTuple5, 6, 7
4Conditionalvalue: 8
condition: 9
5ExprRangelambda_map: 10
start_index: 74
end_index: 60
6ExprRangelambda_map: 11
start_index: 74
end_index: 75
7ExprRangelambda_map: 12
start_index: 74
end_index: 62
8Operationoperator: 13
operand: 16
9Operationoperator: 31
operands: 15
10Lambdaparameter: 84
body: 69
11Lambdaparameter: 84
body: 70
12Lambdaparameter: 84
body: 72
13Literal
14ExprTuple16
15ExprTuple17, 18, 19
16Lambdaparameters: 44
body: 20
17ExprRangelambda_map: 21
start_index: 74
end_index: 60
18ExprRangelambda_map: 22
start_index: 74
end_index: 75
19ExprRangelambda_map: 23
start_index: 74
end_index: 62
20Conditionalvalue: 24
condition: 25
21Lambdaparameter: 84
body: 26
22Lambdaparameter: 84
body: 27
23Lambdaparameter: 84
body: 28
24Operationoperator: 29
operands: 30
25Operationoperator: 31
operands: 32
26Operationoperator: 35
operands: 33
27Operationoperator: 35
operands: 34
28Operationoperator: 35
operands: 36
29Literal
30ExprTuple37, 38
31Literal
32ExprTuple39, 40, 41
33ExprTuple69, 42
34ExprTuple70, 42
35Literal
36ExprTuple72, 42
37Operationoperator: 57
operands: 43
38Operationoperator: 57
operands: 44
39ExprRangelambda_map: 45
start_index: 74
end_index: 60
40ExprRangelambda_map: 46
start_index: 74
end_index: 75
41ExprRangelambda_map: 47
start_index: 74
end_index: 62
42Operationoperator: 48
operand: 56
43ExprTuple51, 50, 52
44ExprTuple51, 67, 52
45Lambdaparameter: 84
body: 53
46Lambdaparameter: 84
body: 54
47Lambdaparameter: 84
body: 55
48Literal
49ExprTuple56
50Operationoperator: 57
operands: 58
51ExprRangelambda_map: 59
start_index: 74
end_index: 60
52ExprRangelambda_map: 61
start_index: 74
end_index: 62
53Operationoperator: 65
operands: 63
54Operationoperator: 65
operands: 64
55Operationoperator: 65
operands: 66
56Variable
57Literal
58ExprTuple67
59Lambdaparameter: 84
body: 68
60Variable
61Lambdaparameter: 84
body: 71
62Variable
63ExprTuple68, 69
64ExprTuple81, 70
65Literal
66ExprTuple71, 72
67ExprRangelambda_map: 73
start_index: 74
end_index: 75
68IndexedVarvariable: 76
index: 84
69IndexedVarvariable: 77
index: 84
70IndexedVarvariable: 78
index: 84
71IndexedVarvariable: 79
index: 84
72IndexedVarvariable: 80
index: 84
73Lambdaparameter: 84
body: 81
74Literal
75Variable
76Variable
77Variable
78Variable
79Variable
80Variable
81IndexedVarvariable: 82
index: 84
82Variable
83ExprTuple84
84Variable