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, NaturalPos, 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(n, Conditional(Forall(instance_param_or_params = [U], instance_expr = 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(), domain = MatrixSpace(field = Complex, rows = n, columns = 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 \mathbb{C}^{n \times n}}~\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}\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: 87
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 30
operand: 6
3Operationoperator: 66
operands: 5
4ExprTuple6
5ExprTuple87, 7
6Lambdaparameter: 84
body: 8
7Literal
8Conditionalvalue: 9
condition: 10
9Operationoperator: 30
operand: 13
10Operationoperator: 66
operands: 12
11ExprTuple13
12ExprTuple84, 14
13Lambdaparameters: 15
body: 16
14Operationoperator: 17
operands: 18
15ExprTuple19
16Conditionalvalue: 20
condition: 21
17Literal
18NamedExprsfield: 50
rows: 87
columns: 87
19ExprRangelambda_map: 22
start_index: 86
end_index: 87
20Operationoperator: 23
operands: 24
21Operationoperator: 66
operands: 25
22Lambdaparameter: 88
body: 73
23Literal
24ExprTuple26, 27
25ExprTuple28, 29
26Operationoperator: 30
operand: 36
27Operationoperator: 66
operands: 32
28Operationoperator: 43
operand: 38
29Operationoperator: 34
operand: 39
30Literal
31ExprTuple36
32ExprTuple84, 37
33ExprTuple38
34Literal
35ExprTuple39
36Lambdaparameters: 64
body: 40
37Operationoperator: 41
operand: 87
38Operationoperator: 43
operands: 44
39Operationoperator: 45
operands: 46
40Conditionalvalue: 47
condition: 48
41Literal
42ExprTuple87
43Literal
44ExprTuple49
45Literal
46ExprTuple50, 87
47Operationoperator: 51
operands: 52
48Operationoperator: 53
operands: 54
49ExprRangelambda_map: 55
start_index: 86
end_index: 87
50Literal
51Literal
52ExprTuple56, 57
53Literal
54ExprTuple58, 59
55Lambdaparameter: 88
body: 60
56Operationoperator: 61
operands: 62
57Operationoperator: 63
operands: 64
58Operationoperator: 66
operands: 65
59Operationoperator: 66
operands: 67
60Operationoperator: 78
operand: 73
61Literal
62ExprTuple69, 70, 84, 71
63Literal
64ExprTuple92, 93
65ExprTuple92, 72
66Literal
67ExprTuple93, 72
68ExprTuple73
69Operationoperator: 74
operand: 83
70Operationoperator: 76
operand: 84
71Operationoperator: 78
operand: 85
72Operationoperator: 80
operands: 81
73IndexedVarvariable: 90
index: 88
74Literal
75ExprTuple83
76Literal
77ExprTuple84
78Literal
79ExprTuple85
80Literal
81ExprTuple86, 87
82ExprTuple88
83IndexedVarvariable: 90
index: 92
84Variable
85IndexedVarvariable: 90
index: 93
86Literal
87Variable
88Variable
89ExprTuple92
90Variable
91ExprTuple93
92Variable
93Variable