logo

Expression of type Conditional

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 Conditional, U, i, j, n
from proveit.core_expr_types import v_i, v_j
from proveit.linear_algebra import Adj
from proveit.logic import And, Equals, InSet
from proveit.numbers import Interval, KroneckerDelta, one
from proveit.physics.quantum import Bra, Ket, Qmult
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Interval(one, n)
expr = Conditional(Equals(Qmult(Bra(v_i), Adj(U), U, Ket(v_j)), KroneckerDelta(i, j)), And(InSet(i, sub_expr1), InSet(j, sub_expr1)))
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(\langle v_{i} \rvert \thinspace U^{\dagger} \thinspace U \thinspace \lvert v_{j} \rangle\right) = \delta_{i, j} \textrm{ if } i \in \{1~\ldotp \ldotp~n\} ,  j \in \{1~\ldotp \ldotp~n\}\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, 10
7Operationoperator: 11
operands: 12
8Operationoperator: 13
operands: 14
9Operationoperator: 16
operands: 15
10Operationoperator: 16
operands: 17
11Literal
12ExprTuple18, 19, 31, 20
13Literal
14ExprTuple38, 39
15ExprTuple38, 21
16Literal
17ExprTuple39, 21
18Operationoperator: 22
operand: 30
19Operationoperator: 24
operand: 31
20Operationoperator: 26
operand: 32
21Operationoperator: 28
operands: 29
22Literal
23ExprTuple30
24Literal
25ExprTuple31
26Literal
27ExprTuple32
28Literal
29ExprTuple33, 34
30IndexedVarvariable: 36
index: 38
31Variable
32IndexedVarvariable: 36
index: 39
33Literal
34Variable
35ExprTuple38
36Variable
37ExprTuple39
38Variable
39Variable