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, j, n
from proveit.core_expr_types import v_1_to_n, v_i, v_j
from proveit.linear_algebra import Adj, MatrixSpace, OrthoNormBases, Unitary
from proveit.logic import CartExp, Equals, Forall, Implies, InSet, Set
from proveit.numbers import Complex, Interval, KroneckerDelta, one
from proveit.physics.quantum import Bra, Ket, Qmult
from proveit.physics.quantum.algebra import v_1_to_n_kets
In [2]:
# build up the expression from sub-expressions
expr = Lambda(U, Conditional(Forall(instance_param_or_params = [v_1_to_n], instance_expr = Implies(Forall(instance_param_or_params = [i, j], instance_expr = Equals(Qmult(Bra(v_i), Adj(U), U, Ket(v_j)), KroneckerDelta(i, j)), domain = Interval(one, n)), InSet(U, Unitary(n))), condition = InSet(Set(v_1_to_n_kets), OrthoNormBases(CartExp(Complex, n)))).with_wrapping(), InSet(U, MatrixSpace(field = Complex, rows = n, columns = 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}\forall_{v_{1}, v_{2}, \ldots, v_{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[\forall_{i, j \in \{1~\ldotp \ldotp~n\}}~\left(\left(\langle v_{i} \rvert \thinspace U^{\dagger} \thinspace U \thinspace \lvert v_{j} \rangle\right) = \delta_{i, j}\right)\right] \Rightarrow \left(U \in \textrm{U}\left(n\right)\right)\right)\end{array} \textrm{ if } U \in \mathbb{C}^{n \times 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: 77
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 23
operand: 6
3Operationoperator: 59
operands: 5
4ExprTuple6
5ExprTuple77, 7
6Lambdaparameters: 8
body: 9
7Operationoperator: 10
operands: 11
8ExprTuple12
9Conditionalvalue: 13
condition: 14
10Literal
11NamedExprsfield: 43
rows: 80
columns: 80
12ExprRangelambda_map: 15
start_index: 79
end_index: 80
13Operationoperator: 16
operands: 17
14Operationoperator: 59
operands: 18
15Lambdaparameter: 81
body: 66
16Literal
17ExprTuple19, 20
18ExprTuple21, 22
19Operationoperator: 23
operand: 29
20Operationoperator: 59
operands: 25
21Operationoperator: 36
operand: 31
22Operationoperator: 27
operand: 32
23Literal
24ExprTuple29
25ExprTuple77, 30
26ExprTuple31
27Literal
28ExprTuple32
29Lambdaparameters: 57
body: 33
30Operationoperator: 34
operand: 80
31Operationoperator: 36
operands: 37
32Operationoperator: 38
operands: 39
33Conditionalvalue: 40
condition: 41
34Literal
35ExprTuple80
36Literal
37ExprTuple42
38Literal
39ExprTuple43, 80
40Operationoperator: 44
operands: 45
41Operationoperator: 46
operands: 47
42ExprRangelambda_map: 48
start_index: 79
end_index: 80
43Literal
44Literal
45ExprTuple49, 50
46Literal
47ExprTuple51, 52
48Lambdaparameter: 81
body: 53
49Operationoperator: 54
operands: 55
50Operationoperator: 56
operands: 57
51Operationoperator: 59
operands: 58
52Operationoperator: 59
operands: 60
53Operationoperator: 71
operand: 66
54Literal
55ExprTuple62, 63, 77, 64
56Literal
57ExprTuple85, 86
58ExprTuple85, 65
59Literal
60ExprTuple86, 65
61ExprTuple66
62Operationoperator: 67
operand: 76
63Operationoperator: 69
operand: 77
64Operationoperator: 71
operand: 78
65Operationoperator: 73
operands: 74
66IndexedVarvariable: 83
index: 81
67Literal
68ExprTuple76
69Literal
70ExprTuple77
71Literal
72ExprTuple78
73Literal
74ExprTuple79, 80
75ExprTuple81
76IndexedVarvariable: 83
index: 85
77Variable
78IndexedVarvariable: 83
index: 86
79Literal
80Variable
81Variable
82ExprTuple85
83Variable
84ExprTuple86
85Variable
86Variable