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 = [K], 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, b_1_to_j, c_1_to_k], instance_expr = Implies(InSet(sub_expr2, V), Equals(VecAdd(ExprRange(sub_expr1, TensorProd(a_1_to_i, IndexedVar(b, sub_expr1), c_1_to_k), one, j)), sub_expr2).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_{K}~\left[\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(\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) =  \\ \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) \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: 25
operand: 2
1ExprTuple2
2Lambdaparameter: 37
body: 3
3Operationoperator: 25
operand: 5
4ExprTuple5
5Lambdaparameters: 6
body: 7
6ExprTuple65, 59, 69
7Conditionalvalue: 8
condition: 9
8Operationoperator: 25
operand: 13
9Operationoperator: 11
operands: 12
10ExprTuple13
11Literal
12ExprTuple14, 15, 16
13Lambdaparameter: 44
body: 18
14Operationoperator: 40
operands: 19
15Operationoperator: 40
operands: 20
16Operationoperator: 40
operands: 21
17ExprTuple44
18Conditionalvalue: 22
condition: 23
19ExprTuple65, 24
20ExprTuple59, 24
21ExprTuple69, 24
22Operationoperator: 25
operand: 29
23Operationoperator: 27
operands: 28
24Literal
25Literal
26ExprTuple29
27Literal
28ExprTuple44, 30
29Lambdaparameters: 31
body: 32
30Operationoperator: 33
operand: 37
31ExprTuple60, 55, 62
32Operationoperator: 35
operands: 36
33Literal
34ExprTuple37
35Literal
36ExprTuple38, 39
37Variable
38Operationoperator: 40
operands: 41
39Operationoperator: 42
operands: 43
40Literal
41ExprTuple46, 44
42Literal
43ExprTuple45, 46
44Variable
45Operationoperator: 52
operands: 47
46Operationoperator: 56
operands: 48
47ExprTuple49
48ExprTuple60, 50, 62
49ExprRangelambda_map: 51
start_index: 68
end_index: 59
50Operationoperator: 52
operands: 53
51Lambdaparameter: 72
body: 54
52Literal
53ExprTuple55
54Operationoperator: 56
operands: 57
55ExprRangelambda_map: 58
start_index: 68
end_index: 59
56Literal
57ExprTuple60, 61, 62
58Lambdaparameter: 77
body: 63
59Variable
60ExprRangelambda_map: 64
start_index: 68
end_index: 65
61IndexedVarvariable: 70
index: 72
62ExprRangelambda_map: 67
start_index: 68
end_index: 69
63IndexedVarvariable: 70
index: 77
64Lambdaparameter: 77
body: 71
65Variable
66ExprTuple72
67Lambdaparameter: 77
body: 73
68Literal
69Variable
70Variable
71IndexedVarvariable: 74
index: 77
72Variable
73IndexedVarvariable: 75
index: 77
74Variable
75Variable
76ExprTuple77
77Variable