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, j
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 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 = [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()
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())
\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}
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneTrue('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: 7
operand: 2
1ExprTuple2
2Lambdaparameter: 26
body: 4
3ExprTuple26
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operand: 11
6Operationoperator: 9
operands: 10
7Literal
8ExprTuple11
9Literal
10ExprTuple26, 12
11Lambdaparameters: 13
body: 14
12Operationoperator: 15
operand: 19
13ExprTuple43, 36, 45
14Operationoperator: 17
operands: 18
15Literal
16ExprTuple19
17Literal
18ExprTuple20, 21
19Variable
20Operationoperator: 22
operands: 23
21Operationoperator: 24
operands: 25
22Literal
23ExprTuple27, 26
24Literal
25ExprTuple27, 28
26Variable
27Operationoperator: 40
operands: 29
28Operationoperator: 33
operands: 30
29ExprTuple43, 31, 45
30ExprTuple32
31Operationoperator: 33
operands: 34
32ExprRangelambda_map: 35
start_index: 51
end_index: 39
33Literal
34ExprTuple36
35Lambdaparameter: 54
body: 37
36ExprRangelambda_map: 38
start_index: 51
end_index: 39
37Operationoperator: 40
operands: 41
38Lambdaparameter: 59
body: 42
39Variable
40Literal
41ExprTuple43, 44, 45
42IndexedVarvariable: 48
index: 59
43ExprRangelambda_map: 46
start_index: 51
end_index: 47
44IndexedVarvariable: 48
index: 54
45ExprRangelambda_map: 50
start_index: 51
end_index: 52
46Lambdaparameter: 59
body: 53
47Variable
48Variable
49ExprTuple54
50Lambdaparameter: 59
body: 55
51Literal
52Variable
53IndexedVarvariable: 56
index: 59
54Variable
55IndexedVarvariable: 57
index: 59
56Variable
57Variable
58ExprTuple59
59Variable