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, K, U, V, Variable, W, alpha, b, i, k
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, VecSpaces
from proveit.logic import And, Equals, Forall, InClass
from proveit.numbers import one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = VecSpaces(K)
expr = Conditional(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(), And(ExprRange(sub_expr1, InClass(IndexedVar(U, sub_expr1), sub_expr2), one, i), InClass(V, sub_expr2), ExprRange(sub_expr1, InClass(IndexedVar(W, sub_expr1), sub_expr2), 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}{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} \textrm{ if } \left(U_{1} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\right) ,  \left(U_{2} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\right) ,  \ldots ,  \left(U_{i} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\right) ,  V \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right), \left(W_{1} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\right) ,  \left(W_{2} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\right) ,  \ldots ,  \left(W_{k} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\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
operand: 6
2Operationoperator: 20
operands: 5
3Literal
4ExprTuple6
5ExprTuple7, 8, 9
6Lambdaparameters: 47
body: 10
7ExprRangelambda_map: 11
start_index: 60
end_index: 58
8Operationoperator: 23
operands: 12
9ExprRangelambda_map: 13
start_index: 60
end_index: 61
10Conditionalvalue: 14
condition: 15
11Lambdaparameter: 69
body: 16
12ExprTuple41, 30
13Lambdaparameter: 69
body: 17
14Operationoperator: 18
operands: 19
15Operationoperator: 20
operands: 21
16Operationoperator: 23
operands: 22
17Operationoperator: 23
operands: 24
18Literal
19ExprTuple25, 26
20Literal
21ExprTuple27, 28, 29
22ExprTuple55, 30
23Literal
24ExprTuple56, 30
25Operationoperator: 46
operands: 31
26Operationoperator: 44
operands: 32
27ExprRangelambda_map: 33
start_index: 60
end_index: 58
28Operationoperator: 49
operands: 34
29ExprRangelambda_map: 35
start_index: 60
end_index: 61
30Operationoperator: 36
operand: 43
31ExprTuple52, 38, 54
32ExprTuple51, 39
33Lambdaparameter: 69
body: 40
34ExprTuple53, 41
35Lambdaparameter: 69
body: 42
36Literal
37ExprTuple43
38Operationoperator: 44
operands: 45
39Operationoperator: 46
operands: 47
40Operationoperator: 49
operands: 48
41Variable
42Operationoperator: 49
operands: 50
43Variable
44Literal
45ExprTuple51, 53
46Literal
47ExprTuple52, 53, 54
48ExprTuple64, 55
49Literal
50ExprTuple65, 56
51Variable
52ExprRangelambda_map: 57
start_index: 60
end_index: 58
53Variable
54ExprRangelambda_map: 59
start_index: 60
end_index: 61
55IndexedVarvariable: 62
index: 69
56IndexedVarvariable: 63
index: 69
57Lambdaparameter: 69
body: 64
58Variable
59Lambdaparameter: 69
body: 65
60Literal
61Variable
62Variable
63Variable
64IndexedVarvariable: 66
index: 69
65IndexedVarvariable: 67
index: 69
66Variable
67Variable
68ExprTuple69
69Variable