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, i, k
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
from proveit.numbers import Natural
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 = [alpha], instance_expr = Forall(instance_param_or_params = [i, k], instance_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(), domain = Natural), domain = K)
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_{\alpha \in K}~\left[\forall_{i, k \in \mathbb{N}}~\left[\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}\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: 78
body: 4
3ExprTuple78
4Conditionalvalue: 5
condition: 6
5Operationoperator: 30
operand: 9
6Operationoperator: 76
operands: 8
7ExprTuple9
8ExprTuple78, 70
9Lambdaparameters: 10
body: 11
10ExprTuple85, 88
11Conditionalvalue: 12
condition: 13
12Operationoperator: 30
operand: 16
13Operationoperator: 47
operands: 15
14ExprTuple16
15ExprTuple17, 18
16Lambdaparameters: 19
body: 20
17Operationoperator: 76
operands: 21
18Operationoperator: 76
operands: 22
19ExprTuple23, 68, 24
20Conditionalvalue: 25
condition: 26
21ExprTuple85, 27
22ExprTuple88, 27
23ExprRangelambda_map: 28
start_index: 87
end_index: 85
24ExprRangelambda_map: 29
start_index: 87
end_index: 88
25Operationoperator: 30
operand: 33
26Operationoperator: 47
operands: 32
27Literal
28Lambdaparameter: 96
body: 82
29Lambdaparameter: 96
body: 83
30Literal
31ExprTuple33
32ExprTuple34, 35, 36
33Lambdaparameters: 74
body: 37
34ExprRangelambda_map: 38
start_index: 87
end_index: 85
35Operationoperator: 50
operands: 39
36ExprRangelambda_map: 40
start_index: 87
end_index: 88
37Conditionalvalue: 41
condition: 42
38Lambdaparameter: 96
body: 43
39ExprTuple68, 57
40Lambdaparameter: 96
body: 44
41Operationoperator: 45
operands: 46
42Operationoperator: 47
operands: 48
43Operationoperator: 50
operands: 49
44Operationoperator: 50
operands: 51
45Literal
46ExprTuple52, 53
47Literal
48ExprTuple54, 55, 56
49ExprTuple82, 57
50Literal
51ExprTuple83, 57
52Operationoperator: 73
operands: 58
53Operationoperator: 71
operands: 59
54ExprRangelambda_map: 60
start_index: 87
end_index: 85
55Operationoperator: 76
operands: 61
56ExprRangelambda_map: 62
start_index: 87
end_index: 88
57Operationoperator: 63
operand: 70
58ExprTuple79, 65, 81
59ExprTuple78, 66
60Lambdaparameter: 96
body: 67
61ExprTuple80, 68
62Lambdaparameter: 96
body: 69
63Literal
64ExprTuple70
65Operationoperator: 71
operands: 72
66Operationoperator: 73
operands: 74
67Operationoperator: 76
operands: 75
68Variable
69Operationoperator: 76
operands: 77
70Variable
71Literal
72ExprTuple78, 80
73Literal
74ExprTuple79, 80, 81
75ExprTuple91, 82
76Literal
77ExprTuple92, 83
78Variable
79ExprRangelambda_map: 84
start_index: 87
end_index: 85
80Variable
81ExprRangelambda_map: 86
start_index: 87
end_index: 88
82IndexedVarvariable: 89
index: 96
83IndexedVarvariable: 90
index: 96
84Lambdaparameter: 96
body: 91
85Variable
86Lambdaparameter: 96
body: 92
87Literal
88Variable
89Variable
90Variable
91IndexedVarvariable: 93
index: 96
92IndexedVarvariable: 94
index: 96
93Variable
94Variable
95ExprTuple96
96Variable