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 A, Conditional, ExprRange, Function, IndexedVar, K, V, Variable, W, n, v
from proveit.core_expr_types import A_1_to_n, V_1_to_n, v_1_to_n
from proveit.linear_algebra import LinMap, 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 = IndexedVar(V, sub_expr1)
sub_expr3 = IndexedVar(W, sub_expr1)
sub_expr4 = VecSpaces(K)
expr = Conditional(Forall(instance_param_or_params = [A_1_to_n], instance_expr = Forall(instance_param_or_params = [v_1_to_n], instance_expr = Equals(Function(TensorProd(A_1_to_n), [TensorProd(v_1_to_n)]), TensorProd(ExprRange(sub_expr1, Function(IndexedVar(A, sub_expr1), [IndexedVar(v, sub_expr1)]), one, n))), domains = [V_1_to_n]).with_wrapping(), domains = [ExprRange(sub_expr1, LinMap(sub_expr2, sub_expr3), one, n)]).with_wrapping(), And(ExprRange(sub_expr1, InClass(sub_expr2, sub_expr4), one, n), ExprRange(sub_expr1, InClass(sub_expr3, sub_expr4), one, n)))
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 \mathcal{L}\left(V_{1}, W_{1}\right)\right), \left(A_{2} \in \mathcal{L}\left(V_{2}, W_{2}\right)\right), \ldots, \left(A_{n} \in \mathcal{L}\left(V_{n}, W_{n}\right)\right)}~\\
\left[\begin{array}{l}\forall_{\left(v_{1} \in V_{1}\right), \left(v_{2} \in V_{2}\right), \ldots, \left(v_{n} \in V_{n}\right)}~\\
\left(\left(A_{1} {\otimes}  A_{2} {\otimes}  \ldots {\otimes}  A_{n}\right)\left(v_{1} {\otimes}  v_{2} {\otimes}  \ldots {\otimes}  v_{n}\right) = \left(A_{1}\left(v_{1}\right) {\otimes}  A_{2}\left(v_{2}\right) {\otimes}  \ldots {\otimes}  A_{n}\left(v_{n}\right)\right)\right)\end{array}\right]\end{array} \textrm{ if } \left(V_{1} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\right) ,  \left(V_{2} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\right) ,  \ldots ,  \left(V_{n} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\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_{n} \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: 15
operand: 5
2Operationoperator: 34
operands: 4
3ExprTuple5
4ExprTuple6, 7
5Lambdaparameters: 47
body: 8
6ExprRangelambda_map: 9
start_index: 64
end_index: 65
7ExprRangelambda_map: 10
start_index: 64
end_index: 65
8Conditionalvalue: 11
condition: 12
9Lambdaparameter: 73
body: 13
10Lambdaparameter: 73
body: 14
11Operationoperator: 15
operand: 21
12Operationoperator: 34
operands: 17
13Operationoperator: 19
operands: 18
14Operationoperator: 19
operands: 20
15Literal
16ExprTuple21
17ExprTuple22
18ExprTuple62, 23
19Literal
20ExprTuple51, 23
21Lambdaparameters: 54
body: 24
22ExprRangelambda_map: 25
start_index: 64
end_index: 65
23Operationoperator: 26
operand: 31
24Conditionalvalue: 28
condition: 29
25Lambdaparameter: 73
body: 30
26Literal
27ExprTuple31
28Operationoperator: 32
operands: 33
29Operationoperator: 34
operands: 35
30Operationoperator: 56
operands: 36
31Variable
32Literal
33ExprTuple37, 38
34Literal
35ExprTuple39
36ExprTuple66, 40
37Operationoperator: 41
operand: 48
38Operationoperator: 53
operands: 43
39ExprRangelambda_map: 44
start_index: 64
end_index: 65
40Operationoperator: 45
operands: 46
41Operationoperator: 53
operands: 47
42ExprTuple48
43ExprTuple49
44Lambdaparameter: 73
body: 50
45Literal
46ExprTuple62, 51
47ExprTuple52
48Operationoperator: 53
operands: 54
49ExprRangelambda_map: 55
start_index: 64
end_index: 65
50Operationoperator: 56
operands: 57
51IndexedVarvariable: 58
index: 73
52ExprRangelambda_map: 59
start_index: 64
end_index: 65
53Literal
54ExprTuple60
55Lambdaparameter: 73
body: 61
56Literal
57ExprTuple70, 62
58Variable
59Lambdaparameter: 73
body: 66
60ExprRangelambda_map: 63
start_index: 64
end_index: 65
61Operationoperator: 66
operand: 70
62IndexedVarvariable: 68
index: 73
63Lambdaparameter: 73
body: 70
64Literal
65Variable
66IndexedVarvariable: 69
index: 73
67ExprTuple70
68Variable
69Variable
70IndexedVarvariable: 71
index: 73
71Variable
72ExprTuple73
73Variable