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 A, ExprRange, Function, IndexedVar, K, V, Variable, W, n, v
from proveit.core_expr_types import A_1_to_n, V_1_to_n, W_1_to_n, v_1_to_n
from proveit.linear_algebra import LinMap, TensorProd, VecSpaces
from proveit.logic import Equals, Forall
from proveit.numbers import one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Forall(instance_param_or_params = [V_1_to_n, W_1_to_n], instance_expr = Forall(instance_param_or_params = [A_1_to_n], instance_expr = Forall(instance_param_or_params = [v_1_to_n], instance_expr = Equals(Function(TensorProd(A_1_to_n), [TensorProd(v_1_to_n)]), TensorProd(ExprRange(sub_expr1, Function(IndexedVar(A, sub_expr1), [IndexedVar(v, sub_expr1)]), one, n))), domains = [V_1_to_n]).with_wrapping(), domains = [ExprRange(sub_expr1, LinMap(IndexedVar(V, sub_expr1), IndexedVar(W, sub_expr1)), one, n)]).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_{V_{1}, V_{2}, \ldots, V_{n}, W_{1}, W_{2}, \ldots, W_{n} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)}~\\
\left[\begin{array}{l}\forall_{\left(A_{1} \in \mathcal{L}\left(V_{1}, W_{1}\right)\right), \left(A_{2} \in \mathcal{L}\left(V_{2}, W_{2}\right)\right), \ldots, \left(A_{n} \in \mathcal{L}\left(V_{n}, W_{n}\right)\right)}~\\
\left[\begin{array}{l}\forall_{\left(v_{1} \in V_{1}\right), \left(v_{2} \in V_{2}\right), \ldots, \left(v_{n} \in V_{n}\right)}~\\
\left(\left(A_{1} {\otimes}  A_{2} {\otimes}  \ldots {\otimes}  A_{n}\right)\left(v_{1} {\otimes}  v_{2} {\otimes}  \ldots {\otimes}  v_{n}\right) = \left(A_{1}\left(v_{1}\right) {\otimes}  A_{2}\left(v_{2}\right) {\otimes}  \ldots {\otimes}  A_{n}\left(v_{n}\right)\right)\right)\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: 23
operand: 2
1ExprTuple2
2Lambdaparameters: 3
body: 4
3ExprTuple5, 6
4Conditionalvalue: 7
condition: 8
5ExprRangelambda_map: 9
start_index: 72
end_index: 73
6ExprRangelambda_map: 10
start_index: 72
end_index: 73
7Operationoperator: 23
operand: 13
8Operationoperator: 42
operands: 12
9Lambdaparameter: 81
body: 70
10Lambdaparameter: 81
body: 59
11ExprTuple13
12ExprTuple14, 15
13Lambdaparameters: 55
body: 16
14ExprRangelambda_map: 17
start_index: 72
end_index: 73
15ExprRangelambda_map: 18
start_index: 72
end_index: 73
16Conditionalvalue: 19
condition: 20
17Lambdaparameter: 81
body: 21
18Lambdaparameter: 81
body: 22
19Operationoperator: 23
operand: 29
20Operationoperator: 42
operands: 25
21Operationoperator: 27
operands: 26
22Operationoperator: 27
operands: 28
23Literal
24ExprTuple29
25ExprTuple30
26ExprTuple70, 31
27Literal
28ExprTuple59, 31
29Lambdaparameters: 62
body: 32
30ExprRangelambda_map: 33
start_index: 72
end_index: 73
31Operationoperator: 34
operand: 39
32Conditionalvalue: 36
condition: 37
33Lambdaparameter: 81
body: 38
34Literal
35ExprTuple39
36Operationoperator: 40
operands: 41
37Operationoperator: 42
operands: 43
38Operationoperator: 64
operands: 44
39Variable
40Literal
41ExprTuple45, 46
42Literal
43ExprTuple47
44ExprTuple74, 48
45Operationoperator: 49
operand: 56
46Operationoperator: 61
operands: 51
47ExprRangelambda_map: 52
start_index: 72
end_index: 73
48Operationoperator: 53
operands: 54
49Operationoperator: 61
operands: 55
50ExprTuple56
51ExprTuple57
52Lambdaparameter: 81
body: 58
53Literal
54ExprTuple70, 59
55ExprTuple60
56Operationoperator: 61
operands: 62
57ExprRangelambda_map: 63
start_index: 72
end_index: 73
58Operationoperator: 64
operands: 65
59IndexedVarvariable: 66
index: 81
60ExprRangelambda_map: 67
start_index: 72
end_index: 73
61Literal
62ExprTuple68
63Lambdaparameter: 81
body: 69
64Literal
65ExprTuple78, 70
66Variable
67Lambdaparameter: 81
body: 74
68ExprRangelambda_map: 71
start_index: 72
end_index: 73
69Operationoperator: 74
operand: 78
70IndexedVarvariable: 76
index: 81
71Lambdaparameter: 81
body: 78
72Literal
73Variable
74IndexedVarvariable: 77
index: 81
75ExprTuple78
76Variable
77Variable
78IndexedVarvariable: 79
index: 81
79Variable
80ExprTuple81
81Variable