logo

Expression of type Equals

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, i, j, m, n
from proveit.core_expr_types import v_i, w_j
from proveit.linear_algebra import VecSum
from proveit.logic import Equals
from proveit.numbers import Interval, one
from proveit.physics.quantum import Bra, Ket, Qmult
In [2]:
# build up the expression from sub-expressions
expr = Equals(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())
A = \left(\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
operation'infix' or 'function' style formattinginfixinfix
wrap_positionsposition(s) at which wrapping is to occur; '2 n - 1' is after the nth operand, '2 n' is after the nth operation.()()('with_wrapping_at', 'with_wrap_before_operator', 'with_wrap_after_operator', 'without_wrapping', 'wrap_positions')
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'centercenter('with_justification',)
directionDirection of the relation (normal or reversed)normalnormal('with_direction_reversed', 'is_reversed')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 1
operands: 2
1Literal
2ExprTuple24, 3
3Operationoperator: 9
operand: 5
4ExprTuple5
5Lambdaparameter: 44
body: 6
6Conditionalvalue: 7
condition: 8
7Operationoperator: 9
operand: 12
8Operationoperator: 21
operands: 11
9Literal
10ExprTuple12
11ExprTuple44, 13
12Lambdaparameter: 43
body: 14
13Operationoperator: 33
operands: 15
14Conditionalvalue: 16
condition: 17
15ExprTuple37, 18
16Operationoperator: 19
operands: 20
17Operationoperator: 21
operands: 22
18Variable
19Literal
20ExprTuple23, 24, 25, 26, 27
21Literal
22ExprTuple43, 28
23Operationoperator: 31
operand: 35
24Variable
25Operationoperator: 29
operand: 36
26Operationoperator: 29
operand: 35
27Operationoperator: 31
operand: 36
28Operationoperator: 33
operands: 34
29Literal
30ExprTuple35
31Literal
32ExprTuple36
33Literal
34ExprTuple37, 38
35IndexedVarvariable: 39
index: 43
36IndexedVarvariable: 41
index: 44
37Literal
38Variable
39Variable
40ExprTuple43
41Variable
42ExprTuple44
43Variable
44Variable