logo

Expression of type ExprTuple

from the theory of proveit.physics.quantum.algebra

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, ExprTuple, i, j, m, n
from proveit.core_expr_types import v_i, w_j
from proveit.linear_algebra import VecSum
from proveit.numbers import Interval, one
from proveit.physics.quantum import Bra, Ket, Qmult
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(A, VecSum(index_or_indices = [i], summand = VecSum(index_or_indices = [j], summand = Qmult(Bra(w_j), A, Ket(v_i), Ket(w_j), Bra(v_i)), domain = Interval(one, n)), domain = Interval(one, m)))
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(A, \sum_{i=1}^{m} \left(\sum_{j=1}^{n} \left(\langle w_{j} \rvert \thinspace A \thinspace \lvert v_{i} \rangle \thinspace \lvert w_{j} \rangle \thinspace \langle v_{i} \rvert\right)\right)\right)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
wrap_positionsposition(s) at which wrapping is to occur; 'n' is after the nth comma.()()('with_wrapping_at',)
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'leftleft('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple22, 1
1Operationoperator: 7
operand: 3
2ExprTuple3
3Lambdaparameter: 42
body: 4
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operand: 10
6Operationoperator: 19
operands: 9
7Literal
8ExprTuple10
9ExprTuple42, 11
10Lambdaparameter: 41
body: 12
11Operationoperator: 31
operands: 13
12Conditionalvalue: 14
condition: 15
13ExprTuple35, 16
14Operationoperator: 17
operands: 18
15Operationoperator: 19
operands: 20
16Variable
17Literal
18ExprTuple21, 22, 23, 24, 25
19Literal
20ExprTuple41, 26
21Operationoperator: 29
operand: 33
22Variable
23Operationoperator: 27
operand: 34
24Operationoperator: 27
operand: 33
25Operationoperator: 29
operand: 34
26Operationoperator: 31
operands: 32
27Literal
28ExprTuple33
29Literal
30ExprTuple34
31Literal
32ExprTuple35, 36
33IndexedVarvariable: 37
index: 41
34IndexedVarvariable: 39
index: 42
35Literal
36Variable
37Variable
38ExprTuple41
39Variable
40ExprTuple42
41Variable
42Variable