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 ExprRange, IndexedVar, K, V, Variable, b, i, j, k
from proveit.core_expr_types import a_1_to_i, b_1_to_j, c_1_to_k
from proveit.linear_algebra import TensorProd, VecAdd, VecSpaces
from proveit.logic import Equals, Forall, Implies, InSet
from proveit.numbers import Natural, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_b", latex_format = r"{_{-}b}")
sub_expr2 = TensorProd(a_1_to_i, VecAdd(b_1_to_j), c_1_to_k)
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, b_1_to_j, c_1_to_k], instance_expr = Implies(InSet(sub_expr2, V), Equals(sub_expr2, VecAdd(ExprRange(sub_expr1, TensorProd(a_1_to_i, IndexedVar(b, sub_expr1), c_1_to_k), one, j))).with_wrapping_at(2)).with_wrapping_at(2)).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, j, 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}, b_{1}, b_{2}, \ldots, b_{j}, c_{1}, c_{2}, \ldots, c_{k}}~\\
\left(\begin{array}{c} \begin{array}{l} \left(\left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} \left(b_{1} +  b_{2} +  \ldots +  b_{j}\right){\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) \in V\right) \Rightarrow  \\ \left(\begin{array}{c} \begin{array}{l} \left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} \left(b_{1} +  b_{2} +  \ldots +  b_{j}\right){\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) =  \\ \left(\left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} b_{1}{\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) +  \left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} b_{2}{\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) +  \ldots +  \left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} b_{j}{\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]
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: 22
operand: 2
1ExprTuple2
2Lambdaparameters: 3
body: 4
3ExprTuple62, 54, 67
4Conditionalvalue: 5
condition: 6
5Operationoperator: 22
operand: 10
6Operationoperator: 8
operands: 9
7ExprTuple10
8Literal
9ExprTuple11, 12, 13
10Lambdaparameter: 41
body: 15
11Operationoperator: 37
operands: 16
12Operationoperator: 37
operands: 17
13Operationoperator: 37
operands: 18
14ExprTuple41
15Conditionalvalue: 19
condition: 20
16ExprTuple62, 21
17ExprTuple54, 21
18ExprTuple67, 21
19Operationoperator: 22
operand: 26
20Operationoperator: 24
operands: 25
21Literal
22Literal
23ExprTuple26
24Literal
25ExprTuple41, 27
26Lambdaparameters: 28
body: 29
27Operationoperator: 30
operand: 34
28ExprTuple58, 51, 60
29Operationoperator: 32
operands: 33
30Literal
31ExprTuple34
32Literal
33ExprTuple35, 36
34Variable
35Operationoperator: 37
operands: 38
36Operationoperator: 39
operands: 40
37Literal
38ExprTuple42, 41
39Literal
40ExprTuple42, 43
41Variable
42Operationoperator: 55
operands: 44
43Operationoperator: 48
operands: 45
44ExprTuple58, 46, 60
45ExprTuple47
46Operationoperator: 48
operands: 49
47ExprRangelambda_map: 50
start_index: 66
end_index: 54
48Literal
49ExprTuple51
50Lambdaparameter: 69
body: 52
51ExprRangelambda_map: 53
start_index: 66
end_index: 54
52Operationoperator: 55
operands: 56
53Lambdaparameter: 74
body: 57
54Variable
55Literal
56ExprTuple58, 59, 60
57IndexedVarvariable: 63
index: 74
58ExprRangelambda_map: 61
start_index: 66
end_index: 62
59IndexedVarvariable: 63
index: 69
60ExprRangelambda_map: 65
start_index: 66
end_index: 67
61Lambdaparameter: 74
body: 68
62Variable
63Variable
64ExprTuple69
65Lambdaparameter: 74
body: 70
66Literal
67Variable
68IndexedVarvariable: 71
index: 74
69Variable
70IndexedVarvariable: 72
index: 74
71Variable
72Variable
73ExprTuple74
74Variable