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, alpha, b
from proveit.core_expr_types import U_1_to_i, W_1_to_k, a_1_to_i, c_1_to_k
from proveit.linear_algebra import ScalarMult, 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, c_1_to_k], instance_expr = Equals(TensorProd(a_1_to_i, ScalarMult(alpha, b), c_1_to_k), ScalarMult(alpha, TensorProd(a_1_to_i, b, c_1_to_k))).with_wrapping_at(1), domains = [U_1_to_i, V, 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), b \in V,\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(\alpha \cdot b\right){\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) \\  = \left(\alpha \cdot \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)\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: 29
body: 4
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operands: 8
6Operationoperator: 9
operands: 10
7Literal
8ExprTuple11, 12
9Literal
10ExprTuple13, 14, 15
11Operationoperator: 28
operands: 16
12Operationoperator: 26
operands: 17
13ExprRangelambda_map: 18
start_index: 42
end_index: 40
14Operationoperator: 31
operands: 19
15ExprRangelambda_map: 20
start_index: 42
end_index: 43
16ExprTuple34, 21, 36
17ExprTuple33, 22
18Lambdaparameter: 51
body: 23
19ExprTuple35, 24
20Lambdaparameter: 51
body: 25
21Operationoperator: 26
operands: 27
22Operationoperator: 28
operands: 29
23Operationoperator: 31
operands: 30
24Variable
25Operationoperator: 31
operands: 32
26Literal
27ExprTuple33, 35
28Literal
29ExprTuple34, 35, 36
30ExprTuple46, 37
31Literal
32ExprTuple47, 38
33Variable
34ExprRangelambda_map: 39
start_index: 42
end_index: 40
35Variable
36ExprRangelambda_map: 41
start_index: 42
end_index: 43
37IndexedVarvariable: 44
index: 51
38IndexedVarvariable: 45
index: 51
39Lambdaparameter: 51
body: 46
40Variable
41Lambdaparameter: 51
body: 47
42Literal
43Variable
44Variable
45Variable
46IndexedVarvariable: 48
index: 51
47IndexedVarvariable: 49
index: 51
48Variable
49Variable
50ExprTuple51
51Variable