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.core_expr_types import U_1_to_i, V_1_to_j, W_1_to_k, a_1_to_i, b_1_to_j, c_1_to_k
from proveit.linear_algebra import TensorProd
from proveit.logic import Equals, Forall
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [a_1_to_i, b_1_to_j, c_1_to_k], instance_expr = Equals(TensorProd(a_1_to_i, TensorProd(b_1_to_j), c_1_to_k), TensorProd(a_1_to_i, b_1_to_j, c_1_to_k)).with_wrapping_at(1), domains = [U_1_to_i, V_1_to_j, W_1_to_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_{\left(a_{1} \in U_{1}\right), \left(a_{2} \in U_{2}\right), \ldots, \left(a_{i} \in U_{i}\right),\left(b_{1} \in V_{1}\right), \left(b_{2} \in V_{2}\right), \ldots, \left(b_{j} \in V_{j}\right),\left(c_{1} \in W_{1}\right), \left(c_{2} \in W_{2}\right), \ldots, \left(c_{k} \in W_{k}\right)}~\\
\left(\begin{array}{c} \begin{array}{l} \left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} \left(b_{1} {\otimes}  b_{2} {\otimes}  \ldots {\otimes}  b_{j}\right){\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_{1} {\otimes}  b_{2} {\otimes}  \ldots {\otimes}  b_{j}{\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) \end{array} \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: 1
operand: 3
1Literal
2ExprTuple3
3Lambdaparameters: 17
body: 4
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operands: 8
6Operationoperator: 9
operands: 10
7Literal
8ExprTuple11, 12
9Literal
10ExprTuple13, 14, 15
11Operationoperator: 27
operands: 16
12Operationoperator: 27
operands: 17
13ExprRangelambda_map: 18
start_index: 44
end_index: 30
14ExprRangelambda_map: 19
start_index: 44
end_index: 45
15ExprRangelambda_map: 20
start_index: 44
end_index: 32
16ExprTuple22, 21, 23
17ExprTuple22, 37, 23
18Lambdaparameter: 54
body: 24
19Lambdaparameter: 54
body: 25
20Lambdaparameter: 54
body: 26
21Operationoperator: 27
operands: 28
22ExprRangelambda_map: 29
start_index: 44
end_index: 30
23ExprRangelambda_map: 31
start_index: 44
end_index: 32
24Operationoperator: 35
operands: 33
25Operationoperator: 35
operands: 34
26Operationoperator: 35
operands: 36
27Literal
28ExprTuple37
29Lambdaparameter: 54
body: 38
30Variable
31Lambdaparameter: 54
body: 41
32Variable
33ExprTuple38, 39
34ExprTuple51, 40
35Literal
36ExprTuple41, 42
37ExprRangelambda_map: 43
start_index: 44
end_index: 45
38IndexedVarvariable: 46
index: 54
39IndexedVarvariable: 47
index: 54
40IndexedVarvariable: 48
index: 54
41IndexedVarvariable: 49
index: 54
42IndexedVarvariable: 50
index: 54
43Lambdaparameter: 54
body: 51
44Literal
45Variable
46Variable
47Variable
48Variable
49Variable
50Variable
51IndexedVarvariable: 52
index: 54
52Variable
53ExprTuple54
54Variable