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, Function, Lambda, f, i, n
from proveit.core_expr_types import a_1_to_n, a_i, v_1_to_n, v_i
from proveit.linear_algebra import Dim, HilbertSpaces, Hspace, OrthoNormBases, ScalarMult, VecSum
from proveit.logic import Equals, Forall, Functions, 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
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [i]
sub_expr2 = Interval(one, n)
sub_expr3 = Qmult(Ket(v_i), Bra(v_i))
expr = Lambda(n, Conditional(Forall(instance_param_or_params = [Hspace], instance_expr = Forall(instance_param_or_params = [v_1_to_n], instance_expr = Forall(instance_param_or_params = [a_1_to_n], instance_expr = Forall(instance_param_or_params = [f], instance_expr = Equals(Function(f, [VecSum(index_or_indices = sub_expr1, summand = ScalarMult(a_i, sub_expr3), domain = sub_expr2)]), VecSum(index_or_indices = sub_expr1, summand = ScalarMult(Function(f, [a_i]), sub_expr3), domain = sub_expr2)), domain = Functions(Complex, Complex)), domain = Complex), condition = InSet(Set(v_1_to_n_kets), OrthoNormBases(Hspace))).with_wrapping(), domain = HilbertSpaces, condition = Equals(Dim(Hspace), n)).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_{\mathcal{H} \underset{{\scriptscriptstyle c}}{\in} \textrm{HilbertSpaces}~|~\textrm{Dim}\left(\mathcal{H}\right) = 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(\mathcal{H}\right)}~\\
\left[\forall_{a_{1}, a_{2}, \ldots, a_{n} \in \mathbb{C}}~\left[\forall_{f \in \left[\mathbb{C} \rightarrow \mathbb{C}\right]}~\left(f\left(\sum_{i=1}^{n} \left(a_{i} \cdot \left(\lvert v_{i} \rangle \thinspace \langle v_{i} \rvert\right)\right)\right) = \left(\sum_{i=1}^{n} \left(f\left(a_{i}\right) \cdot \left(\lvert v_{i} \rangle \thinspace \langle v_{i} \rvert\right)\right)\right)\right)\right]\right]\end{array}\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: 108
body: 2
1ExprTuple108
2Conditionalvalue: 3
condition: 4
3Operationoperator: 45
operand: 7
4Operationoperator: 93
operands: 6
5ExprTuple7
6ExprTuple108, 8
7Lambdaparameter: 43
body: 9
8Literal
9Conditionalvalue: 10
condition: 11
10Operationoperator: 45
operand: 14
11Operationoperator: 47
operands: 13
12ExprTuple14
13ExprTuple15, 16
14Lambdaparameters: 17
body: 18
15Operationoperator: 19
operands: 20
16Operationoperator: 62
operands: 21
17ExprTuple22
18Conditionalvalue: 23
condition: 24
19Literal
20ExprTuple43, 25
21ExprTuple26, 108
22ExprRangelambda_map: 27
start_index: 107
end_index: 108
23Operationoperator: 45
operand: 31
24Operationoperator: 93
operands: 29
25Literal
26Operationoperator: 30
operand: 43
27Lambdaparameter: 80
body: 71
28ExprTuple31
29ExprTuple32, 33
30Literal
31Lambdaparameters: 34
body: 35
32Operationoperator: 49
operand: 42
33Operationoperator: 37
operand: 43
34ExprTuple39
35Conditionalvalue: 40
condition: 41
36ExprTuple42
37Literal
38ExprTuple43
39ExprRangelambda_map: 44
start_index: 107
end_index: 108
40Operationoperator: 45
operand: 51
41Operationoperator: 47
operands: 48
42Operationoperator: 49
operands: 50
43Variable
44Lambdaparameter: 80
body: 70
45Literal
46ExprTuple51
47Literal
48ExprTuple52
49Literal
50ExprTuple53
51Lambdaparameter: 95
body: 55
52ExprRangelambda_map: 56
start_index: 107
end_index: 108
53ExprRangelambda_map: 57
start_index: 107
end_index: 108
54ExprTuple95
55Conditionalvalue: 58
condition: 59
56Lambdaparameter: 80
body: 60
57Lambdaparameter: 80
body: 61
58Operationoperator: 62
operands: 63
59Operationoperator: 93
operands: 64
60Operationoperator: 93
operands: 65
61Operationoperator: 109
operand: 71
62Literal
63ExprTuple67, 68
64ExprTuple95, 69
65ExprTuple70, 79
66ExprTuple71
67Operationoperator: 95
operand: 77
68Operationoperator: 81
operand: 78
69Operationoperator: 74
operands: 75
70IndexedVarvariable: 104
index: 80
71IndexedVarvariable: 113
index: 80
72ExprTuple77
73ExprTuple78
74Literal
75ExprTuple79, 79
76ExprTuple80
77Operationoperator: 81
operand: 84
78Lambdaparameter: 115
body: 83
79Literal
80Variable
81Literal
82ExprTuple84
83Conditionalvalue: 85
condition: 89
84Lambdaparameter: 115
body: 86
85Operationoperator: 91
operands: 87
86Conditionalvalue: 88
condition: 89
87ExprTuple90, 97
88Operationoperator: 91
operands: 92
89Operationoperator: 93
operands: 94
90Operationoperator: 95
operand: 99
91Literal
92ExprTuple99, 97
93Literal
94ExprTuple115, 98
95Variable
96ExprTuple99
97Operationoperator: 100
operands: 101
98Operationoperator: 102
operands: 103
99IndexedVarvariable: 104
index: 115
100Literal
101ExprTuple105, 106
102Literal
103ExprTuple107, 108
104Variable
105Operationoperator: 109
operand: 112
106Operationoperator: 110
operand: 112
107Literal
108Variable
109Literal
110Literal
111ExprTuple112
112IndexedVarvariable: 113
index: 115
113Variable
114ExprTuple115
115Variable