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, Q, V, f, i, j, k
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 TensorProd, VecSpaces, VecSum
from proveit.linear_algebra.addition import vec_summation_b1toj_fQ
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 = TensorProd(a_1_to_i, f__b_1_to_j, c_1_to_k)
expr = Forall(instance_param_or_params = [K, f, Q], instance_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(sub_expr2, V), condition = Q__b_1_to_j), Equals(TensorProd(a_1_to_i, vec_summation_b1toj_fQ, c_1_to_k), VecSum(index_or_indices = sub_expr1, summand = sub_expr2, condition = Q__b_1_to_j)).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_{K, f, Q}~\left[\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} f\left(b_{1}, b_{2}, \ldots, b_{j}\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(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)}~f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\right]{\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) \\  = \left[\sum_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~\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] \end{array} \end{array}\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: 41
operand: 2
1ExprTuple2
2Lambdaparameters: 3
body: 4
3ExprTuple38, 72, 69
4Operationoperator: 41
operand: 6
5ExprTuple6
6Lambdaparameters: 7
body: 8
7ExprTuple71, 82, 75
8Conditionalvalue: 9
condition: 10
9Operationoperator: 41
operand: 14
10Operationoperator: 12
operands: 13
11ExprTuple14
12Literal
13ExprTuple15, 16, 17
14Lambdaparameter: 59
body: 19
15Operationoperator: 54
operands: 20
16Operationoperator: 54
operands: 21
17Operationoperator: 54
operands: 22
18ExprTuple59
19Conditionalvalue: 23
condition: 24
20ExprTuple71, 26
21ExprTuple82, 25
22ExprTuple75, 26
23Operationoperator: 41
operand: 30
24Operationoperator: 28
operands: 29
25Literal
26Literal
27ExprTuple30
28Literal
29ExprTuple59, 31
30Lambdaparameters: 32
body: 33
31Operationoperator: 34
operand: 38
32ExprTuple66, 68
33Operationoperator: 36
operands: 37
34Literal
35ExprTuple38
36Literal
37ExprTuple39, 40
38Variable
39Operationoperator: 41
operand: 45
40Operationoperator: 43
operands: 44
41Literal
42ExprTuple45
43Literal
44ExprTuple46, 47
45Lambdaparameters: 73
body: 48
46Operationoperator: 63
operands: 49
47Operationoperator: 56
operand: 53
48Conditionalvalue: 51
condition: 65
49ExprTuple66, 52, 68
50ExprTuple53
51Operationoperator: 54
operands: 55
52Operationoperator: 56
operand: 60
53Lambdaparameters: 73
body: 58
54Literal
55ExprTuple61, 59
56Literal
57ExprTuple60
58Conditionalvalue: 61
condition: 65
59Variable
60Lambdaparameters: 73
body: 62
61Operationoperator: 63
operands: 64
62Conditionalvalue: 67
condition: 65
63Literal
64ExprTuple66, 67, 68
65Operationoperator: 69
operands: 73
66ExprRangelambda_map: 70
start_index: 81
end_index: 71
67Operationoperator: 72
operands: 73
68ExprRangelambda_map: 74
start_index: 81
end_index: 75
69Variable
70Lambdaparameter: 87
body: 76
71Variable
72Variable
73ExprTuple77
74Lambdaparameter: 87
body: 78
75Variable
76IndexedVarvariable: 79
index: 87
77ExprRangelambda_map: 80
start_index: 81
end_index: 82
78IndexedVarvariable: 83
index: 87
79Variable
80Lambdaparameter: 87
body: 84
81Literal
82Variable
83Variable
84IndexedVarvariable: 85
index: 87
85Variable
86ExprTuple87
87Variable