logo

Expression of type Conditional

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 Conditional, ExprRange, IndexedVar, U, V, Variable, W, a, alpha, b, c, i, k
from proveit.core_expr_types import a_1_to_i, c_1_to_k
from proveit.linear_algebra import ScalarMult, TensorProd
from proveit.logic import And, Equals, InSet
from proveit.numbers import one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Conditional(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), And(ExprRange(sub_expr1, InSet(IndexedVar(a, sub_expr1), IndexedVar(U, sub_expr1)), one, i), InSet(b, V), ExprRange(sub_expr1, InSet(IndexedVar(c, sub_expr1), IndexedVar(W, sub_expr1)), one, k)))
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())
\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} \textrm{ if } \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)\right..
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
condition_delimiter'comma' or 'and'commacomma('with_comma_delimiter', 'with_conjunction_delimiter')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Conditionalvalue: 1
condition: 2
1Operationoperator: 3
operands: 4
2Operationoperator: 5
operands: 6
3Literal
4ExprTuple7, 8
5Literal
6ExprTuple9, 10, 11
7Operationoperator: 24
operands: 12
8Operationoperator: 22
operands: 13
9ExprRangelambda_map: 14
start_index: 38
end_index: 36
10Operationoperator: 27
operands: 15
11ExprRangelambda_map: 16
start_index: 38
end_index: 39
12ExprTuple30, 17, 32
13ExprTuple29, 18
14Lambdaparameter: 47
body: 19
15ExprTuple31, 20
16Lambdaparameter: 47
body: 21
17Operationoperator: 22
operands: 23
18Operationoperator: 24
operands: 25
19Operationoperator: 27
operands: 26
20Variable
21Operationoperator: 27
operands: 28
22Literal
23ExprTuple29, 31
24Literal
25ExprTuple30, 31, 32
26ExprTuple42, 33
27Literal
28ExprTuple43, 34
29Variable
30ExprRangelambda_map: 35
start_index: 38
end_index: 36
31Variable
32ExprRangelambda_map: 37
start_index: 38
end_index: 39
33IndexedVarvariable: 40
index: 47
34IndexedVarvariable: 41
index: 47
35Lambdaparameter: 47
body: 42
36Variable
37Lambdaparameter: 47
body: 43
38Literal
39Variable
40Variable
41Variable
42IndexedVarvariable: 44
index: 47
43IndexedVarvariable: 45
index: 47
44Variable
45Variable
46ExprTuple47
47Variable