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, 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 = [U], instance_expr = 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(), domain = Unitary(n)), 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\{\forall_{U \in \textrm{U}\left(n\right)}~\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}\right] \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: 79
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 4
operand: 7
3Operationoperator: 56
operands: 6
4Literal
5ExprTuple7
6ExprTuple79, 8
7Lambdaparameter: 32
body: 10
8Literal
9ExprTuple32
10Conditionalvalue: 11
condition: 12
11Operationoperator: 13
operand: 16
12Operationoperator: 56
operands: 15
13Literal
14ExprTuple16
15ExprTuple32, 17
16Lambdaparameters: 18
body: 19
17Operationoperator: 20
operand: 79
18ExprTuple22, 23
19Conditionalvalue: 24
condition: 25
20Literal
21ExprTuple79
22ExprRangelambda_map: 26
start_index: 78
end_index: 79
23ExprRangelambda_map: 27
start_index: 78
end_index: 79
24Operationoperator: 28
operands: 29
25Operationoperator: 30
operands: 31
26Lambdaparameter: 92
body: 87
27Lambdaparameter: 92
body: 88
28Literal
29ExprTuple32, 33
30Literal
31ExprTuple34, 35
32Variable
33Operationoperator: 36
operand: 40
34Operationoperator: 56
operands: 38
35Operationoperator: 56
operands: 39
36Literal
37ExprTuple40
38ExprTuple41, 43
39ExprTuple42, 43
40Lambdaparameter: 86
body: 44
41Operationoperator: 59
operand: 51
42Operationoperator: 59
operand: 52
43Operationoperator: 47
operand: 53
44Conditionalvalue: 49
condition: 50
45ExprTuple51
46ExprTuple52
47Literal
48ExprTuple53
49Operationoperator: 54
operands: 55
50Operationoperator: 56
operands: 57
51Operationoperator: 59
operands: 58
52Operationoperator: 59
operands: 60
53Operationoperator: 61
operands: 62
54Literal
55ExprTuple63, 64
56Literal
57ExprTuple86, 65
58ExprTuple66
59Literal
60ExprTuple67
61Literal
62ExprTuple68, 79
63Operationoperator: 84
operand: 76
64Operationoperator: 70
operand: 77
65Operationoperator: 72
operands: 73
66ExprRangelambda_map: 74
start_index: 78
end_index: 79
67ExprRangelambda_map: 75
start_index: 78
end_index: 79
68Literal
69ExprTuple76
70Literal
71ExprTuple77
72Literal
73ExprTuple78, 79
74Lambdaparameter: 92
body: 80
75Lambdaparameter: 92
body: 81
76IndexedVarvariable: 89
index: 86
77IndexedVarvariable: 90
index: 86
78Literal
79Variable
80Operationoperator: 84
operand: 87
81Operationoperator: 84
operand: 88
82ExprTuple86
83ExprTuple87
84Literal
85ExprTuple88
86Variable
87IndexedVarvariable: 89
index: 92
88IndexedVarvariable: 90
index: 92
89Variable
90Variable
91ExprTuple92
92Variable