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, i, n
from proveit.core_expr_types import v_i, w_i
from proveit.linear_algebra import OrthoNormBases, Unitary, VecSum
from proveit.logic import And, CartExp, InSet, Set
from proveit.numbers import Complex, Interval, one
from proveit.physics.quantum import Bra, Ket, Qmult
from proveit.physics.quantum.algebra import v_1_to_n_kets, w_1_to_n_kets
In [2]:
# build up the expression from sub-expressions
sub_expr1 = OrthoNormBases(CartExp(Complex, n))
expr = Conditional(InSet(VecSum(index_or_indices = [i], summand = Qmult(Ket(v_i), Bra(w_i)), domain = Interval(one, n)), Unitary(n)), And(InSet(Set(v_1_to_n_kets), sub_expr1), InSet(Set(w_1_to_n_kets), 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(\sum_{i=1}^{n} \left(\lvert v_{i} \rangle \thinspace \langle w_{i} \rvert\right)\right) \in \textrm{U}\left(n\right) \textrm{ if } \left\{\left\{\lvert v_{1} \rangle, \lvert v_{2} \rangle, \ldots, \lvert v_{n} \rangle\right\}\right\} \in \textrm{O.N.Bases}\left(\mathbb{C}^{n}\right) ,  \left\{\left\{\lvert w_{1} \rangle, \lvert w_{2} \rangle, \ldots, \lvert w_{n} \rangle\right\}\right\} \in \textrm{O.N.Bases}\left(\mathbb{C}^{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: 32
operands: 3
2Operationoperator: 4
operands: 5
3ExprTuple6, 7
4Literal
5ExprTuple8, 9
6Operationoperator: 10
operand: 16
7Operationoperator: 12
operand: 55
8Operationoperator: 32
operands: 14
9Operationoperator: 32
operands: 15
10Literal
11ExprTuple16
12Literal
13ExprTuple55
14ExprTuple17, 19
15ExprTuple18, 19
16Lambdaparameter: 62
body: 20
17Operationoperator: 35
operand: 27
18Operationoperator: 35
operand: 28
19Operationoperator: 23
operand: 29
20Conditionalvalue: 25
condition: 26
21ExprTuple27
22ExprTuple28
23Literal
24ExprTuple29
25Operationoperator: 30
operands: 31
26Operationoperator: 32
operands: 33
27Operationoperator: 35
operands: 34
28Operationoperator: 35
operands: 36
29Operationoperator: 37
operands: 38
30Literal
31ExprTuple39, 40
32Literal
33ExprTuple62, 41
34ExprTuple42
35Literal
36ExprTuple43
37Literal
38ExprTuple44, 55
39Operationoperator: 60
operand: 52
40Operationoperator: 46
operand: 53
41Operationoperator: 48
operands: 49
42ExprRangelambda_map: 50
start_index: 54
end_index: 55
43ExprRangelambda_map: 51
start_index: 54
end_index: 55
44Literal
45ExprTuple52
46Literal
47ExprTuple53
48Literal
49ExprTuple54, 55
50Lambdaparameter: 68
body: 56
51Lambdaparameter: 68
body: 57
52IndexedVarvariable: 65
index: 62
53IndexedVarvariable: 66
index: 62
54Literal
55Variable
56Operationoperator: 60
operand: 63
57Operationoperator: 60
operand: 64
58ExprTuple62
59ExprTuple63
60Literal
61ExprTuple64
62Variable
63IndexedVarvariable: 65
index: 68
64IndexedVarvariable: 66
index: 68
65Variable
66Variable
67ExprTuple68
68Variable