logo

Expression of type Lambda

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, Lambda, U, i, n
from proveit.core_expr_types import v_1_to_n, v_i, w_1_to_n, w_i
from proveit.linear_algebra import OrthoNormBases, Unitary, VecSum
from proveit.logic import CartExp, Equals, Exists, 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 = Lambda(U, Conditional(Exists(instance_param_or_params = [v_1_to_n, w_1_to_n], instance_expr = Equals(U, VecSum(index_or_indices = [i], summand = Qmult(Ket(v_i), Bra(w_i)), domain = Interval(one, n))), conditions = [InSet(Set(v_1_to_n_kets), sub_expr1), InSet(Set(w_1_to_n_kets), sub_expr1)]).with_wrapping(), InSet(U, Unitary(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())
U \mapsto \left\{\begin{array}{l}\exists_{v_{1}, v_{2}, \ldots, v_{n}, w_{1}, w_{2}, \ldots, w_{n}~|~\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)}~\\
\left(U = \left(\sum_{i=1}^{n} \left(\lvert v_{i} \rangle \thinspace \langle w_{i} \rvert\right)\right)\right)\end{array} \textrm{ if } U \in \textrm{U}\left(n\right)\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 24
body: 2
1ExprTuple24
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 48
operands: 7
5Literal
6ExprTuple8
7ExprTuple24, 9
8Lambdaparameters: 10
body: 11
9Operationoperator: 12
operand: 71
10ExprTuple14, 15
11Conditionalvalue: 16
condition: 17
12Literal
13ExprTuple71
14ExprRangelambda_map: 18
start_index: 70
end_index: 71
15ExprRangelambda_map: 19
start_index: 70
end_index: 71
16Operationoperator: 20
operands: 21
17Operationoperator: 22
operands: 23
18Lambdaparameter: 84
body: 79
19Lambdaparameter: 84
body: 80
20Literal
21ExprTuple24, 25
22Literal
23ExprTuple26, 27
24Variable
25Operationoperator: 28
operand: 32
26Operationoperator: 48
operands: 30
27Operationoperator: 48
operands: 31
28Literal
29ExprTuple32
30ExprTuple33, 35
31ExprTuple34, 35
32Lambdaparameter: 78
body: 36
33Operationoperator: 51
operand: 43
34Operationoperator: 51
operand: 44
35Operationoperator: 39
operand: 45
36Conditionalvalue: 41
condition: 42
37ExprTuple43
38ExprTuple44
39Literal
40ExprTuple45
41Operationoperator: 46
operands: 47
42Operationoperator: 48
operands: 49
43Operationoperator: 51
operands: 50
44Operationoperator: 51
operands: 52
45Operationoperator: 53
operands: 54
46Literal
47ExprTuple55, 56
48Literal
49ExprTuple78, 57
50ExprTuple58
51Literal
52ExprTuple59
53Literal
54ExprTuple60, 71
55Operationoperator: 76
operand: 68
56Operationoperator: 62
operand: 69
57Operationoperator: 64
operands: 65
58ExprRangelambda_map: 66
start_index: 70
end_index: 71
59ExprRangelambda_map: 67
start_index: 70
end_index: 71
60Literal
61ExprTuple68
62Literal
63ExprTuple69
64Literal
65ExprTuple70, 71
66Lambdaparameter: 84
body: 72
67Lambdaparameter: 84
body: 73
68IndexedVarvariable: 81
index: 78
69IndexedVarvariable: 82
index: 78
70Literal
71Variable
72Operationoperator: 76
operand: 79
73Operationoperator: 76
operand: 80
74ExprTuple78
75ExprTuple79
76Literal
77ExprTuple80
78Variable
79IndexedVarvariable: 81
index: 84
80IndexedVarvariable: 82
index: 84
81Variable
82Variable
83ExprTuple84
84Variable