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, 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, Forall, InSet, Set
from proveit.numbers import Complex, Interval, NaturalPos, 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(n, Conditional(Forall(instance_param_or_params = [v_1_to_n, w_1_to_n], instance_expr = InSet(VecSum(index_or_indices = [i], summand = Qmult(Ket(v_i), Bra(w_i)), domain = Interval(one, n)), Unitary(n)), conditions = [InSet(Set(v_1_to_n_kets), sub_expr1), InSet(Set(w_1_to_n_kets), sub_expr1)]).with_wrapping(), InSet(n, NaturalPos)))
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())
n \mapsto \left\{\begin{array}{l}\forall_{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(\left(\sum_{i=1}^{n} \left(\lvert v_{i} \rangle \thinspace \langle w_{i} \rvert\right)\right) \in \textrm{U}\left(n\right)\right)\end{array} \textrm{ if } n \in \mathbb{N}^+\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 69
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 4
operand: 7
3Operationoperator: 46
operands: 6
4Literal
5ExprTuple7
6ExprTuple69, 8
7Lambdaparameters: 9
body: 10
8Literal
9ExprTuple11, 12
10Conditionalvalue: 13
condition: 14
11ExprRangelambda_map: 15
start_index: 68
end_index: 69
12ExprRangelambda_map: 16
start_index: 68
end_index: 69
13Operationoperator: 46
operands: 17
14Operationoperator: 18
operands: 19
15Lambdaparameter: 82
body: 77
16Lambdaparameter: 82
body: 78
17ExprTuple20, 21
18Literal
19ExprTuple22, 23
20Operationoperator: 24
operand: 30
21Operationoperator: 26
operand: 69
22Operationoperator: 46
operands: 28
23Operationoperator: 46
operands: 29
24Literal
25ExprTuple30
26Literal
27ExprTuple69
28ExprTuple31, 33
29ExprTuple32, 33
30Lambdaparameter: 76
body: 34
31Operationoperator: 49
operand: 41
32Operationoperator: 49
operand: 42
33Operationoperator: 37
operand: 43
34Conditionalvalue: 39
condition: 40
35ExprTuple41
36ExprTuple42
37Literal
38ExprTuple43
39Operationoperator: 44
operands: 45
40Operationoperator: 46
operands: 47
41Operationoperator: 49
operands: 48
42Operationoperator: 49
operands: 50
43Operationoperator: 51
operands: 52
44Literal
45ExprTuple53, 54
46Literal
47ExprTuple76, 55
48ExprTuple56
49Literal
50ExprTuple57
51Literal
52ExprTuple58, 69
53Operationoperator: 74
operand: 66
54Operationoperator: 60
operand: 67
55Operationoperator: 62
operands: 63
56ExprRangelambda_map: 64
start_index: 68
end_index: 69
57ExprRangelambda_map: 65
start_index: 68
end_index: 69
58Literal
59ExprTuple66
60Literal
61ExprTuple67
62Literal
63ExprTuple68, 69
64Lambdaparameter: 82
body: 70
65Lambdaparameter: 82
body: 71
66IndexedVarvariable: 79
index: 76
67IndexedVarvariable: 80
index: 76
68Literal
69Variable
70Operationoperator: 74
operand: 77
71Operationoperator: 74
operand: 78
72ExprTuple76
73ExprTuple77
74Literal
75ExprTuple78
76Variable
77IndexedVarvariable: 79
index: 82
78IndexedVarvariable: 80
index: 82
79Variable
80Variable
81ExprTuple82
82Variable