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, n, v
from proveit.core_expr_types import A_1_to_n, v_1_to_n
from proveit.linear_algebra import 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}")
sub_expr2 = IndexedVar(v, sub_expr1)
expr = Conditional(Equals(Function(TensorProd(A_1_to_n), [TensorProd(v_1_to_n)]), TensorProd(ExprRange(sub_expr1, Function(IndexedVar(A, sub_expr1), [sub_expr2]), one, n))), And(ExprRange(sub_expr1, InSet(sub_expr2, IndexedVar(V, 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\{\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) \textrm{ if } \left(v_{1} \in V_{1}\right) \land  \left(v_{2} \in V_{2}\right) \land  \ldots \land  \left(v_{n} \in V_{n}\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
7Operationoperator: 10
operand: 15
8Operationoperator: 19
operands: 12
9ExprRangelambda_map: 13
start_index: 29
end_index: 30
10Operationoperator: 19
operands: 14
11ExprTuple15
12ExprTuple16
13Lambdaparameter: 38
body: 17
14ExprTuple18
15Operationoperator: 19
operands: 20
16ExprRangelambda_map: 21
start_index: 29
end_index: 30
17Operationoperator: 22
operands: 23
18ExprRangelambda_map: 24
start_index: 29
end_index: 30
19Literal
20ExprTuple25
21Lambdaparameter: 38
body: 26
22Literal
23ExprTuple35, 27
24Lambdaparameter: 38
body: 31
25ExprRangelambda_map: 28
start_index: 29
end_index: 30
26Operationoperator: 31
operand: 35
27IndexedVarvariable: 33
index: 38
28Lambdaparameter: 38
body: 35
29Literal
30Variable
31IndexedVarvariable: 34
index: 38
32ExprTuple35
33Variable
34Variable
35IndexedVarvariable: 36
index: 38
36Variable
37ExprTuple38
38Variable