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 Function, K, V, i, j, k, s
from proveit.core_expr_types import Q__b_1_to_j, a_1_to_i, b_1_to_j, c_1_to_k, f__b_1_to_j
from proveit.linear_algebra import ScalarMult, TensorProd, VecSpaces, VecSum
from proveit.logic import Equals, Forall, Implies, InSet
from proveit.numbers import Natural, NaturalPos
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [b_1_to_j]
sub_expr2 = Function(s, sub_expr1)
sub_expr3 = ScalarMult(sub_expr2, f__b_1_to_j)
expr = Forall(instance_param_or_params = [i, j, k], instance_expr = Forall(instance_param_or_params = [V], instance_expr = Forall(instance_param_or_params = [a_1_to_i, c_1_to_k], instance_expr = Implies(Forall(instance_param_or_params = sub_expr1, instance_expr = InSet(TensorProd(a_1_to_i, sub_expr3, c_1_to_k), V), condition = Q__b_1_to_j), Equals(VecSum(index_or_indices = sub_expr1, summand = ScalarMult(sub_expr2, TensorProd(a_1_to_i, f__b_1_to_j, c_1_to_k)), condition = Q__b_1_to_j), TensorProd(a_1_to_i, VecSum(index_or_indices = sub_expr1, summand = sub_expr3, condition = Q__b_1_to_j), c_1_to_k)).with_wrapping_at(1)).with_wrapping_at(2)).with_wrapping(), domain = VecSpaces(K)).with_wrapping(), domains = [Natural, NaturalPos, 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 \in \mathbb{N}, j \in \mathbb{N}^+, k \in \mathbb{N}}~\left[\begin{array}{l}\forall_{V \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)}~\\
\left[\begin{array}{l}\forall_{a_{1}, a_{2}, \ldots, a_{i}, c_{1}, c_{2}, \ldots, c_{k}}~\\
\left(\begin{array}{c} \begin{array}{l} \left[\forall_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~\left(\left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} \left(s\left(b_{1}, b_{2}, \ldots, b_{j}\right) \cdot f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\right){\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) \in V\right)\right] \Rightarrow  \\ \left(\begin{array}{c} \begin{array}{l} \left[\sum_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~\left(s\left(b_{1}, b_{2}, \ldots, b_{j}\right) \cdot \left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} f\left(b_{1}, b_{2}, \ldots, b_{j}\right){\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right)\right)\right] \\  = \left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} \left[\sum_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~\left(s\left(b_{1}, b_{2}, \ldots, b_{j}\right) \cdot f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\right)\right]{\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) \end{array} \end{array}\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: 37
operand: 2
1ExprTuple2
2Lambdaparameters: 3
body: 4
3ExprTuple75, 88, 77
4Conditionalvalue: 5
condition: 6
5Operationoperator: 37
operand: 10
6Operationoperator: 8
operands: 9
7ExprTuple10
8Literal
9ExprTuple11, 12, 13
10Lambdaparameter: 56
body: 15
11Operationoperator: 50
operands: 16
12Operationoperator: 50
operands: 17
13Operationoperator: 50
operands: 18
14ExprTuple56
15Conditionalvalue: 19
condition: 20
16ExprTuple75, 22
17ExprTuple88, 21
18ExprTuple77, 22
19Operationoperator: 37
operand: 26
20Operationoperator: 24
operands: 25
21Literal
22Literal
23ExprTuple26
24Literal
25ExprTuple56, 27
26Lambdaparameters: 28
body: 29
27Operationoperator: 30
operand: 34
28ExprTuple70, 71
29Operationoperator: 32
operands: 33
30Literal
31ExprTuple34
32Literal
33ExprTuple35, 36
34Variable
35Operationoperator: 37
operand: 41
36Operationoperator: 39
operands: 40
37Literal
38ExprTuple41
39Literal
40ExprTuple42, 43
41Lambdaparameters: 80
body: 44
42Operationoperator: 53
operand: 48
43Operationoperator: 65
operands: 46
44Conditionalvalue: 47
condition: 64
45ExprTuple48
46ExprTuple70, 49, 71
47Operationoperator: 50
operands: 51
48Lambdaparameters: 80
body: 52
49Operationoperator: 53
operand: 58
50Literal
51ExprTuple55, 56
52Conditionalvalue: 57
condition: 64
53Literal
54ExprTuple58
55Operationoperator: 65
operands: 59
56Variable
57Operationoperator: 67
operands: 60
58Lambdaparameters: 80
body: 61
59ExprTuple70, 63, 71
60ExprTuple72, 62
61Conditionalvalue: 63
condition: 64
62Operationoperator: 65
operands: 66
63Operationoperator: 67
operands: 68
64Operationoperator: 69
operands: 80
65Literal
66ExprTuple70, 73, 71
67Literal
68ExprTuple72, 73
69Variable
70ExprRangelambda_map: 74
start_index: 87
end_index: 75
71ExprRangelambda_map: 76
start_index: 87
end_index: 77
72Operationoperator: 78
operands: 80
73Operationoperator: 79
operands: 80
74Lambdaparameter: 92
body: 81
75Variable
76Lambdaparameter: 92
body: 82
77Variable
78Variable
79Variable
80ExprTuple83
81IndexedVarvariable: 84
index: 92
82IndexedVarvariable: 85
index: 92
83ExprRangelambda_map: 86
start_index: 87
end_index: 88
84Variable
85Variable
86Lambdaparameter: 92
body: 89
87Literal
88Variable
89IndexedVarvariable: 90
index: 92
90Variable
91ExprTuple92
92Variable