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, V, alpha, b
from proveit.core_expr_types import U_1_to_i, W_1_to_k, a_1_to_i, c_1_to_k
from proveit.linear_algebra import ScalarMult, TensorProd, VecSpaces
from proveit.logic import Equals, Forall
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [U_1_to_i, V, W_1_to_k]
expr = Forall(instance_param_or_params = sub_expr1, instance_expr = Forall(instance_param_or_params = [a_1_to_i, b, c_1_to_k], instance_expr = Equals(TensorProd(a_1_to_i, ScalarMult(alpha, b), c_1_to_k), ScalarMult(alpha, TensorProd(a_1_to_i, b, c_1_to_k))).with_wrapping_at(1), domains = sub_expr1).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_{U_{1}, U_{2}, \ldots, U_{i}, V, 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), b \in V,\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(\alpha \cdot b\right){\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) \\  = \left(\alpha \cdot \left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} b{\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right)\right) \end{array} \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: 11
operand: 2
1ExprTuple2
2Lambdaparameters: 3
body: 4
3ExprTuple5, 49, 6
4Conditionalvalue: 7
condition: 8
5ExprRangelambda_map: 9
start_index: 68
end_index: 66
6ExprRangelambda_map: 10
start_index: 68
end_index: 69
7Operationoperator: 11
operand: 14
8Operationoperator: 28
operands: 13
9Lambdaparameter: 77
body: 63
10Lambdaparameter: 77
body: 64
11Literal
12ExprTuple14
13ExprTuple15, 16, 17
14Lambdaparameters: 55
body: 18
15ExprRangelambda_map: 19
start_index: 68
end_index: 66
16Operationoperator: 31
operands: 20
17ExprRangelambda_map: 21
start_index: 68
end_index: 69
18Conditionalvalue: 22
condition: 23
19Lambdaparameter: 77
body: 24
20ExprTuple49, 38
21Lambdaparameter: 77
body: 25
22Operationoperator: 26
operands: 27
23Operationoperator: 28
operands: 29
24Operationoperator: 31
operands: 30
25Operationoperator: 31
operands: 32
26Literal
27ExprTuple33, 34
28Literal
29ExprTuple35, 36, 37
30ExprTuple63, 38
31Literal
32ExprTuple64, 38
33Operationoperator: 54
operands: 39
34Operationoperator: 52
operands: 40
35ExprRangelambda_map: 41
start_index: 68
end_index: 66
36Operationoperator: 57
operands: 42
37ExprRangelambda_map: 43
start_index: 68
end_index: 69
38Operationoperator: 44
operand: 51
39ExprTuple60, 46, 62
40ExprTuple59, 47
41Lambdaparameter: 77
body: 48
42ExprTuple61, 49
43Lambdaparameter: 77
body: 50
44Literal
45ExprTuple51
46Operationoperator: 52
operands: 53
47Operationoperator: 54
operands: 55
48Operationoperator: 57
operands: 56
49Variable
50Operationoperator: 57
operands: 58
51Variable
52Literal
53ExprTuple59, 61
54Literal
55ExprTuple60, 61, 62
56ExprTuple72, 63
57Literal
58ExprTuple73, 64
59Variable
60ExprRangelambda_map: 65
start_index: 68
end_index: 66
61Variable
62ExprRangelambda_map: 67
start_index: 68
end_index: 69
63IndexedVarvariable: 70
index: 77
64IndexedVarvariable: 71
index: 77
65Lambdaparameter: 77
body: 72
66Variable
67Lambdaparameter: 77
body: 73
68Literal
69Variable
70Variable
71Variable
72IndexedVarvariable: 74
index: 77
73IndexedVarvariable: 75
index: 77
74Variable
75Variable
76ExprTuple77
77Variable