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, Q, V, f, 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 = [K, f, Q, s], 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(TensorProd(a_1_to_i, sub_expr3, c_1_to_k), V), condition = Q__b_1_to_j), Equals(TensorProd(a_1_to_i, VecSum(index_or_indices = sub_expr1, summand = sub_expr3, condition = Q__b_1_to_j), c_1_to_k), 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)).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, s}~\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} \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(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) \\  = \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] \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, 81, 71, 78
4Operationoperator: 41
operand: 6
5ExprTuple6
6Lambdaparameters: 7
body: 8
7ExprTuple80, 91, 84
8Conditionalvalue: 9
condition: 10
9Operationoperator: 41
operand: 14
10Operationoperator: 12
operands: 13
11ExprTuple14
12Literal
13ExprTuple15, 16, 17
14Lambdaparameter: 60
body: 19
15Operationoperator: 54
operands: 20
16Operationoperator: 54
operands: 21
17Operationoperator: 54
operands: 22
18ExprTuple60
19Conditionalvalue: 23
condition: 24
20ExprTuple80, 26
21ExprTuple91, 25
22ExprTuple84, 26
23Operationoperator: 41
operand: 30
24Operationoperator: 28
operands: 29
25Literal
26Literal
27ExprTuple30
28Literal
29ExprTuple60, 31
30Lambdaparameters: 32
body: 33
31Operationoperator: 34
operand: 38
32ExprTuple75, 77
33Operationoperator: 36
operands: 37
34Literal
35ExprTuple38
36Literal
37ExprTuple39, 40
38Variable
39Operationoperator: 41
operand: 45
40Operationoperator: 43
operands: 44
41Literal
42ExprTuple45
43Literal
44ExprTuple46, 47
45Lambdaparameters: 82
body: 48
46Operationoperator: 72
operands: 49
47Operationoperator: 56
operand: 53
48Conditionalvalue: 51
condition: 67
49ExprTuple75, 52, 77
50ExprTuple53
51Operationoperator: 54
operands: 55
52Operationoperator: 56
operand: 61
53Lambdaparameters: 82
body: 58
54Literal
55ExprTuple59, 60
56Literal
57ExprTuple61
58Conditionalvalue: 62
condition: 67
59Operationoperator: 72
operands: 63
60Variable
61Lambdaparameters: 82
body: 64
62Operationoperator: 69
operands: 65
63ExprTuple75, 66, 77
64Conditionalvalue: 66
condition: 67
65ExprTuple74, 68
66Operationoperator: 69
operands: 70
67Operationoperator: 71
operands: 82
68Operationoperator: 72
operands: 73
69Literal
70ExprTuple74, 76
71Variable
72Literal
73ExprTuple75, 76, 77
74Operationoperator: 78
operands: 82
75ExprRangelambda_map: 79
start_index: 90
end_index: 80
76Operationoperator: 81
operands: 82
77ExprRangelambda_map: 83
start_index: 90
end_index: 84
78Variable
79Lambdaparameter: 96
body: 85
80Variable
81Variable
82ExprTuple86
83Lambdaparameter: 96
body: 87
84Variable
85IndexedVarvariable: 88
index: 96
86ExprRangelambda_map: 89
start_index: 90
end_index: 91
87IndexedVarvariable: 92
index: 96
88Variable
89Lambdaparameter: 96
body: 93
90Literal
91Variable
92Variable
93IndexedVarvariable: 94
index: 96
94Variable
95ExprTuple96
96Variable