logo

Expression of type ExprTuple

from the theory of proveit.physics.quantum.QPE

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, ExprRange, ExprTuple, Lambda, Variable, t
from proveit.linear_algebra import ScalarMult, TensorProd, VecAdd
from proveit.logic import Equals, InSet
from proveit.numbers import Add, Exp, Mult, NaturalPos, Neg, e, frac, i, one, pi, sqrt, two, zero
from proveit.physics.quantum import ket0, ket1
from proveit.physics.quantum.QPE import _phase, _psi_t_ket
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = ExprTuple(Lambda(t, Conditional(Equals(_psi_t_ket, TensorProd(ExprRange(sub_expr1, ScalarMult(frac(one, sqrt(two)), VecAdd(ket0, ScalarMult(Exp(e, Mult(two, pi, i, Exp(two, Neg(sub_expr1)), _phase)), ket1))), Add(Neg(t), one), zero).with_decreasing_order())), InSet(t, 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())
\left(t \mapsto \left\{\lvert \psi_{t} \rangle = \left(\left(\frac{1}{\sqrt{2}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot 2^{t - 1} \cdot \varphi} \cdot \lvert 1 \rangle\right)\right)\right) {\otimes}  \left(\frac{1}{\sqrt{2}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot 2^{t - 2} \cdot \varphi} \cdot \lvert 1 \rangle\right)\right)\right) {\otimes}  \ldots {\otimes}  \left(\frac{1}{\sqrt{2}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot 2^{0} \cdot \varphi} \cdot \lvert 1 \rangle\right)\right)\right)\right) \textrm{ if } t \in \mathbb{N}^+\right..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameter: 29
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9, 10
7Literal
8ExprTuple29, 11
9Operationoperator: 12
operand: 29
10Operationoperator: 13
operands: 14
11Literal
12Literal
13Literal
14ExprTuple15
15ExprRangelambda_map: 16
start_index: 17
end_index: 38
16Lambdaparameter: 61
body: 18
17Operationoperator: 19
operands: 20
18Operationoperator: 35
operands: 21
19Literal
20ExprTuple22, 48
21ExprTuple23, 24
22Operationoperator: 59
operand: 29
23Operationoperator: 41
operands: 26
24Operationoperator: 27
operands: 28
25ExprTuple29
26ExprTuple48, 30
27Literal
28ExprTuple31, 32
29Variable
30Operationoperator: 55
operands: 33
31Operationoperator: 44
operand: 38
32Operationoperator: 35
operands: 36
33ExprTuple57, 37
34ExprTuple38
35Literal
36ExprTuple39, 40
37Operationoperator: 41
operands: 42
38Literal
39Operationoperator: 55
operands: 43
40Operationoperator: 44
operand: 48
41Literal
42ExprTuple48, 57
43ExprTuple46, 47
44Literal
45ExprTuple48
46Literal
47Operationoperator: 49
operands: 50
48Literal
49Literal
50ExprTuple57, 51, 52, 53, 54
51Literal
52Literal
53Operationoperator: 55
operands: 56
54Literal
55Literal
56ExprTuple57, 58
57Literal
58Operationoperator: 59
operand: 61
59Literal
60ExprTuple61
61Variable