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 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
from proveit.numbers import Natural
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 = [K], instance_expr = Forall(instance_param_or_params = [i, j, k], instance_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(), 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_{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}\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: 30
operand: 2
1ExprTuple2
2Lambdaparameter: 73
body: 3
3Operationoperator: 30
operand: 5
4ExprTuple5
5Lambdaparameters: 6
body: 7
6ExprTuple77, 92, 79
7Conditionalvalue: 8
condition: 9
8Operationoperator: 30
operand: 12
9Operationoperator: 48
operands: 11
10ExprTuple12
11ExprTuple13, 14, 15
12Lambdaparameters: 16
body: 17
13Operationoperator: 82
operands: 18
14Operationoperator: 82
operands: 19
15Operationoperator: 82
operands: 20
16ExprTuple21, 22, 23
17Conditionalvalue: 24
condition: 25
18ExprTuple77, 26
19ExprTuple92, 26
20ExprTuple79, 26
21ExprRangelambda_map: 27
start_index: 91
end_index: 77
22ExprRangelambda_map: 28
start_index: 91
end_index: 92
23ExprRangelambda_map: 29
start_index: 91
end_index: 79
24Operationoperator: 30
operand: 33
25Operationoperator: 48
operands: 32
26Literal
27Lambdaparameter: 101
body: 86
28Lambdaparameter: 101
body: 87
29Lambdaparameter: 101
body: 89
30Literal
31ExprTuple33
32ExprTuple34, 35, 36
33Lambdaparameters: 61
body: 37
34ExprRangelambda_map: 38
start_index: 91
end_index: 77
35ExprRangelambda_map: 39
start_index: 91
end_index: 92
36ExprRangelambda_map: 40
start_index: 91
end_index: 79
37Conditionalvalue: 41
condition: 42
38Lambdaparameter: 101
body: 43
39Lambdaparameter: 101
body: 44
40Lambdaparameter: 101
body: 45
41Operationoperator: 46
operands: 47
42Operationoperator: 48
operands: 49
43Operationoperator: 52
operands: 50
44Operationoperator: 52
operands: 51
45Operationoperator: 52
operands: 53
46Literal
47ExprTuple54, 55
48Literal
49ExprTuple56, 57, 58
50ExprTuple86, 59
51ExprTuple87, 59
52Literal
53ExprTuple89, 59
54Operationoperator: 74
operands: 60
55Operationoperator: 74
operands: 61
56ExprRangelambda_map: 62
start_index: 91
end_index: 77
57ExprRangelambda_map: 63
start_index: 91
end_index: 92
58ExprRangelambda_map: 64
start_index: 91
end_index: 79
59Operationoperator: 65
operand: 73
60ExprTuple68, 67, 69
61ExprTuple68, 84, 69
62Lambdaparameter: 101
body: 70
63Lambdaparameter: 101
body: 71
64Lambdaparameter: 101
body: 72
65Literal
66ExprTuple73
67Operationoperator: 74
operands: 75
68ExprRangelambda_map: 76
start_index: 91
end_index: 77
69ExprRangelambda_map: 78
start_index: 91
end_index: 79
70Operationoperator: 82
operands: 80
71Operationoperator: 82
operands: 81
72Operationoperator: 82
operands: 83
73Variable
74Literal
75ExprTuple84
76Lambdaparameter: 101
body: 85
77Variable
78Lambdaparameter: 101
body: 88
79Variable
80ExprTuple85, 86
81ExprTuple98, 87
82Literal
83ExprTuple88, 89
84ExprRangelambda_map: 90
start_index: 91
end_index: 92
85IndexedVarvariable: 93
index: 101
86IndexedVarvariable: 94
index: 101
87IndexedVarvariable: 95
index: 101
88IndexedVarvariable: 96
index: 101
89IndexedVarvariable: 97
index: 101
90Lambdaparameter: 101
body: 98
91Literal
92Variable
93Variable
94Variable
95Variable
96Variable
97Variable
98IndexedVarvariable: 99
index: 101
99Variable
100ExprTuple101
101Variable