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, i, j, k
from proveit.core_expr_types import 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
from proveit.numbers import Natural
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [K], instance_expr = Forall(instance_param_or_params = [i, j, k], 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, B_1_to_j, C_1_to_k), TensorProd(A_1_to_i, TensorProd(B_1_to_j), C_1_to_k)).with_wrapping_at(1), 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_{K}~\left[\forall_{i, j, k \in \mathbb{N}}~\left[\begin{array}{l}\forall_{A_{1}, A_{2}, \ldots, A_{i}, B_{1}, B_{2}, \ldots, B_{j}, C_{1}, C_{2}, \ldots, C_{k} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)}~\\
\left(\begin{array}{c} \begin{array}{l} \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) \\  = \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) \end{array} \end{array}\right)\end{array}\right]\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: 10
operand: 2
1ExprTuple2
2Lambdaparameter: 67
body: 3
3Operationoperator: 10
operand: 5
4ExprTuple5
5Lambdaparameters: 6
body: 7
6ExprTuple46, 61, 50
7Conditionalvalue: 8
condition: 9
8Operationoperator: 10
operand: 13
9Operationoperator: 27
operands: 12
10Literal
11ExprTuple13
12ExprTuple14, 15, 16
13Lambdaparameters: 34
body: 17
14Operationoperator: 20
operands: 18
15Operationoperator: 20
operands: 19
16Operationoperator: 20
operands: 21
17Conditionalvalue: 22
condition: 23
18ExprTuple46, 24
19ExprTuple61, 24
20Literal
21ExprTuple50, 24
22Operationoperator: 25
operands: 26
23Operationoperator: 27
operands: 28
24Literal
25Literal
26ExprTuple29, 30
27Literal
28ExprTuple31, 32, 33
29Operationoperator: 47
operands: 34
30Operationoperator: 47
operands: 35
31ExprRangelambda_map: 36
start_index: 60
end_index: 46
32ExprRangelambda_map: 37
start_index: 60
end_index: 61
33ExprRangelambda_map: 38
start_index: 60
end_index: 50
34ExprTuple39, 55, 41
35ExprTuple39, 40, 41
36Lambdaparameter: 70
body: 42
37Lambdaparameter: 70
body: 43
38Lambdaparameter: 70
body: 44
39ExprRangelambda_map: 45
start_index: 60
end_index: 46
40Operationoperator: 47
operands: 48
41ExprRangelambda_map: 49
start_index: 60
end_index: 50
42Operationoperator: 53
operands: 51
43Operationoperator: 53
operands: 52
44Operationoperator: 53
operands: 54
45Lambdaparameter: 70
body: 56
46Variable
47Literal
48ExprTuple55
49Lambdaparameter: 70
body: 57
50Variable
51ExprTuple56, 58
52ExprTuple66, 58
53Literal
54ExprTuple57, 58
55ExprRangelambda_map: 59
start_index: 60
end_index: 61
56IndexedVarvariable: 62
index: 70
57IndexedVarvariable: 63
index: 70
58Operationoperator: 64
operand: 67
59Lambdaparameter: 70
body: 66
60Literal
61Variable
62Variable
63Variable
64Literal
65ExprTuple67
66IndexedVarvariable: 68
index: 70
67Variable
68Variable
69ExprTuple70
70Variable