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 = [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)
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_{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]
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: 23
operand: 2
1ExprTuple2
2Lambdaparameters: 3
body: 4
3ExprTuple78, 81
4Conditionalvalue: 5
condition: 6
5Operationoperator: 23
operand: 9
6Operationoperator: 40
operands: 8
7ExprTuple9
8ExprTuple10, 11
9Lambdaparameters: 12
body: 13
10Operationoperator: 69
operands: 14
11Operationoperator: 69
operands: 15
12ExprTuple16, 61, 17
13Conditionalvalue: 18
condition: 19
14ExprTuple78, 20
15ExprTuple81, 20
16ExprRangelambda_map: 21
start_index: 80
end_index: 78
17ExprRangelambda_map: 22
start_index: 80
end_index: 81
18Operationoperator: 23
operand: 26
19Operationoperator: 40
operands: 25
20Literal
21Lambdaparameter: 89
body: 75
22Lambdaparameter: 89
body: 76
23Literal
24ExprTuple26
25ExprTuple27, 28, 29
26Lambdaparameters: 67
body: 30
27ExprRangelambda_map: 31
start_index: 80
end_index: 78
28Operationoperator: 43
operands: 32
29ExprRangelambda_map: 33
start_index: 80
end_index: 81
30Conditionalvalue: 34
condition: 35
31Lambdaparameter: 89
body: 36
32ExprTuple61, 50
33Lambdaparameter: 89
body: 37
34Operationoperator: 38
operands: 39
35Operationoperator: 40
operands: 41
36Operationoperator: 43
operands: 42
37Operationoperator: 43
operands: 44
38Literal
39ExprTuple45, 46
40Literal
41ExprTuple47, 48, 49
42ExprTuple75, 50
43Literal
44ExprTuple76, 50
45Operationoperator: 66
operands: 51
46Operationoperator: 64
operands: 52
47ExprRangelambda_map: 53
start_index: 80
end_index: 78
48Operationoperator: 69
operands: 54
49ExprRangelambda_map: 55
start_index: 80
end_index: 81
50Operationoperator: 56
operand: 63
51ExprTuple72, 58, 74
52ExprTuple71, 59
53Lambdaparameter: 89
body: 60
54ExprTuple73, 61
55Lambdaparameter: 89
body: 62
56Literal
57ExprTuple63
58Operationoperator: 64
operands: 65
59Operationoperator: 66
operands: 67
60Operationoperator: 69
operands: 68
61Variable
62Operationoperator: 69
operands: 70
63Variable
64Literal
65ExprTuple71, 73
66Literal
67ExprTuple72, 73, 74
68ExprTuple84, 75
69Literal
70ExprTuple85, 76
71Variable
72ExprRangelambda_map: 77
start_index: 80
end_index: 78
73Variable
74ExprRangelambda_map: 79
start_index: 80
end_index: 81
75IndexedVarvariable: 82
index: 89
76IndexedVarvariable: 83
index: 89
77Lambdaparameter: 89
body: 84
78Variable
79Lambdaparameter: 89
body: 85
80Literal
81Variable
82Variable
83Variable
84IndexedVarvariable: 86
index: 89
85IndexedVarvariable: 87
index: 89
86Variable
87Variable
88ExprTuple89
89Variable