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, V, Variable, W, n, v
from proveit.core_expr_types import A_1_to_n, V_1_to_n, v_1_to_n
from proveit.linear_algebra import LinMap, TensorProd
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 = [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()
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_{\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}
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: 6
operand: 2
1ExprTuple2
2Lambdaparameters: 31
body: 3
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 18
operands: 8
6Literal
7ExprTuple9
8ExprTuple10
9Lambdaparameters: 38
body: 11
10ExprRangelambda_map: 12
start_index: 48
end_index: 49
11Conditionalvalue: 13
condition: 14
12Lambdaparameter: 57
body: 15
13Operationoperator: 16
operands: 17
14Operationoperator: 18
operands: 19
15Operationoperator: 40
operands: 20
16Literal
17ExprTuple21, 22
18Literal
19ExprTuple23
20ExprTuple50, 24
21Operationoperator: 25
operand: 32
22Operationoperator: 37
operands: 27
23ExprRangelambda_map: 28
start_index: 48
end_index: 49
24Operationoperator: 29
operands: 30
25Operationoperator: 37
operands: 31
26ExprTuple32
27ExprTuple33
28Lambdaparameter: 57
body: 34
29Literal
30ExprTuple46, 35
31ExprTuple36
32Operationoperator: 37
operands: 38
33ExprRangelambda_map: 39
start_index: 48
end_index: 49
34Operationoperator: 40
operands: 41
35IndexedVarvariable: 42
index: 57
36ExprRangelambda_map: 43
start_index: 48
end_index: 49
37Literal
38ExprTuple44
39Lambdaparameter: 57
body: 45
40Literal
41ExprTuple54, 46
42Variable
43Lambdaparameter: 57
body: 50
44ExprRangelambda_map: 47
start_index: 48
end_index: 49
45Operationoperator: 50
operand: 54
46IndexedVarvariable: 52
index: 57
47Lambdaparameter: 57
body: 54
48Literal
49Variable
50IndexedVarvariable: 53
index: 57
51ExprTuple54
52Variable
53Variable
54IndexedVarvariable: 55
index: 57
55Variable
56ExprTuple57
57Variable