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 V, b
from proveit.core_expr_types import a_1_to_i, c_1_to_k, d_1_to_i, e_1_to_k
from proveit.linear_algebra import TensorProd
from proveit.logic import Equals, Forall, Implies
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [b], instance_expr = Implies(Equals(TensorProd(a_1_to_i, c_1_to_k), TensorProd(d_1_to_i, e_1_to_k)).with_wrapping_at(2), Equals(TensorProd(a_1_to_i, b, c_1_to_k), TensorProd(d_1_to_i, b, e_1_to_k)).with_wrapping_at(2)).with_wrapping_at(2), domain = V)
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_{b \in V}~\left(\begin{array}{c} \begin{array}{l} \left(\begin{array}{c} \begin{array}{l} \left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i}{\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) =  \\ \left(d_{1} {\otimes}  d_{2} {\otimes}  \ldots {\otimes}  d_{i}{\otimes} e_{1} {\otimes}  e_{2} {\otimes}  \ldots {\otimes}  e_{k}\right) \end{array} \end{array}\right) \Rightarrow  \\ \left(\begin{array}{c} \begin{array}{l} \left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} b{\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) =  \\ \left(d_{1} {\otimes}  d_{2} {\otimes}  \ldots {\otimes}  d_{i} {\otimes} b{\otimes} e_{1} {\otimes}  e_{2} {\otimes}  \ldots {\otimes}  e_{k}\right) \end{array} \end{array}\right) \end{array} \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: 1
operand: 3
1Literal
2ExprTuple3
3Lambdaparameter: 30
body: 5
4ExprTuple30
5Conditionalvalue: 6
condition: 7
6Operationoperator: 8
operands: 9
7Operationoperator: 10
operands: 11
8Literal
9ExprTuple12, 13
10Literal
11ExprTuple30, 14
12Operationoperator: 16
operands: 15
13Operationoperator: 16
operands: 17
14Variable
15ExprTuple18, 19
16Literal
17ExprTuple20, 21
18Operationoperator: 25
operands: 22
19Operationoperator: 25
operands: 23
20Operationoperator: 25
operands: 24
21Operationoperator: 25
operands: 26
22ExprTuple27, 28
23ExprTuple29, 31
24ExprTuple27, 30, 28
25Literal
26ExprTuple29, 30, 31
27ExprRangelambda_map: 32
start_index: 37
end_index: 35
28ExprRangelambda_map: 33
start_index: 37
end_index: 38
29ExprRangelambda_map: 34
start_index: 37
end_index: 35
30Variable
31ExprRangelambda_map: 36
start_index: 37
end_index: 38
32Lambdaparameter: 48
body: 39
33Lambdaparameter: 48
body: 40
34Lambdaparameter: 48
body: 41
35Variable
36Lambdaparameter: 48
body: 42
37Literal
38Variable
39IndexedVarvariable: 43
index: 48
40IndexedVarvariable: 44
index: 48
41IndexedVarvariable: 45
index: 48
42IndexedVarvariable: 46
index: 48
43Variable
44Variable
45Variable
46Variable
47ExprTuple48
48Variable