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, 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
from proveit.logic import And, Equals, Forall, InSet
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(A, sub_expr1)
expr = Conditional(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(sub_expr2, [IndexedVar(v, sub_expr1)]), one, n))), domains = [V_1_to_n]).with_wrapping(), And(ExprRange(sub_expr1, InSet(sub_expr2, LinMap(IndexedVar(V, sub_expr1), IndexedVar(W, sub_expr1))), 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(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} \textrm{ if } \left(A_{1} \in \mathcal{L}\left(V_{1}, W_{1}\right)\right) \land  \left(A_{2} \in \mathcal{L}\left(V_{2}, W_{2}\right)\right) \land  \ldots \land  \left(A_{n} \in \mathcal{L}\left(V_{n}, W_{n}\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: 15
operands: 5
3Literal
4ExprTuple6
5ExprTuple7
6Lambdaparameters: 35
body: 8
7ExprRangelambda_map: 9
start_index: 45
end_index: 46
8Conditionalvalue: 10
condition: 11
9Lambdaparameter: 54
body: 12
10Operationoperator: 13
operands: 14
11Operationoperator: 15
operands: 16
12Operationoperator: 37
operands: 17
13Literal
14ExprTuple18, 19
15Literal
16ExprTuple20
17ExprTuple47, 21
18Operationoperator: 22
operand: 29
19Operationoperator: 34
operands: 24
20ExprRangelambda_map: 25
start_index: 45
end_index: 46
21Operationoperator: 26
operands: 27
22Operationoperator: 34
operands: 28
23ExprTuple29
24ExprTuple30
25Lambdaparameter: 54
body: 31
26Literal
27ExprTuple43, 32
28ExprTuple33
29Operationoperator: 34
operands: 35
30ExprRangelambda_map: 36
start_index: 45
end_index: 46
31Operationoperator: 37
operands: 38
32IndexedVarvariable: 39
index: 54
33ExprRangelambda_map: 40
start_index: 45
end_index: 46
34Literal
35ExprTuple41
36Lambdaparameter: 54
body: 42
37Literal
38ExprTuple51, 43
39Variable
40Lambdaparameter: 54
body: 47
41ExprRangelambda_map: 44
start_index: 45
end_index: 46
42Operationoperator: 47
operand: 51
43IndexedVarvariable: 49
index: 54
44Lambdaparameter: 54
body: 51
45Literal
46Variable
47IndexedVarvariable: 50
index: 54
48ExprTuple51
49Variable
50Variable
51IndexedVarvariable: 52
index: 54
52Variable
53ExprTuple54
54Variable