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 NaturalPos, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Forall(instance_param_or_params = [n], instance_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(), domain = NaturalPos)
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_{n \in \mathbb{N}^+}~\left[\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}\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: 31
operand: 2
1ExprTuple2
2Lambdaparameter: 81
body: 4
3ExprTuple81
4Conditionalvalue: 5
condition: 6
5Operationoperator: 31
operand: 9
6Operationoperator: 72
operands: 8
7ExprTuple9
8ExprTuple81, 10
9Lambdaparameters: 11
body: 12
10Literal
11ExprTuple13, 14
12Conditionalvalue: 15
condition: 16
13ExprRangelambda_map: 17
start_index: 80
end_index: 81
14ExprRangelambda_map: 18
start_index: 80
end_index: 81
15Operationoperator: 31
operand: 21
16Operationoperator: 50
operands: 20
17Lambdaparameter: 89
body: 78
18Lambdaparameter: 89
body: 67
19ExprTuple21
20ExprTuple22, 23
21Lambdaparameters: 63
body: 24
22ExprRangelambda_map: 25
start_index: 80
end_index: 81
23ExprRangelambda_map: 26
start_index: 80
end_index: 81
24Conditionalvalue: 27
condition: 28
25Lambdaparameter: 89
body: 29
26Lambdaparameter: 89
body: 30
27Operationoperator: 31
operand: 37
28Operationoperator: 50
operands: 33
29Operationoperator: 35
operands: 34
30Operationoperator: 35
operands: 36
31Literal
32ExprTuple37
33ExprTuple38
34ExprTuple78, 39
35Literal
36ExprTuple67, 39
37Lambdaparameters: 70
body: 40
38ExprRangelambda_map: 41
start_index: 80
end_index: 81
39Operationoperator: 42
operand: 47
40Conditionalvalue: 44
condition: 45
41Lambdaparameter: 89
body: 46
42Literal
43ExprTuple47
44Operationoperator: 48
operands: 49
45Operationoperator: 50
operands: 51
46Operationoperator: 72
operands: 52
47Variable
48Literal
49ExprTuple53, 54
50Literal
51ExprTuple55
52ExprTuple82, 56
53Operationoperator: 57
operand: 64
54Operationoperator: 69
operands: 59
55ExprRangelambda_map: 60
start_index: 80
end_index: 81
56Operationoperator: 61
operands: 62
57Operationoperator: 69
operands: 63
58ExprTuple64
59ExprTuple65
60Lambdaparameter: 89
body: 66
61Literal
62ExprTuple78, 67
63ExprTuple68
64Operationoperator: 69
operands: 70
65ExprRangelambda_map: 71
start_index: 80
end_index: 81
66Operationoperator: 72
operands: 73
67IndexedVarvariable: 74
index: 89
68ExprRangelambda_map: 75
start_index: 80
end_index: 81
69Literal
70ExprTuple76
71Lambdaparameter: 89
body: 77
72Literal
73ExprTuple86, 78
74Variable
75Lambdaparameter: 89
body: 82
76ExprRangelambda_map: 79
start_index: 80
end_index: 81
77Operationoperator: 82
operand: 86
78IndexedVarvariable: 84
index: 89
79Lambdaparameter: 89
body: 86
80Literal
81Variable
82IndexedVarvariable: 85
index: 89
83ExprTuple86
84Variable
85Variable
86IndexedVarvariable: 87
index: 89
87Variable
88ExprTuple89
89Variable