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, ExprTuple, Lambda, k, t
from proveit.linear_algebra import ScalarMult, TensorProd
from proveit.logic import InSet
from proveit.numbers import Exp, Interval, Mult, e, i, one, pi, subtract, two, zero
from proveit.physics.quantum import NumKet, ket1
from proveit.physics.quantum.QPE import _phase, two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda(k, Conditional(ScalarMult(Exp(e, Mult(two, pi, i, _phase, k)), TensorProd(ket1, NumKet(k, t))), InSet(k, Interval(zero, subtract(two_pow_t, one))))))
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(k \mapsto \left\{\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \left(\lvert 1 \rangle {\otimes} \lvert k \rangle_{t}\right) \textrm{ if } k \in \{0~\ldotp \ldotp~2^{t} - 1\}\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: 34
body: 3
2ExprTuple34
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operands: 7
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10, 11
8Literal
9ExprTuple34, 12
10Operationoperator: 37
operands: 13
11Operationoperator: 14
operands: 15
12Operationoperator: 16
operands: 17
13ExprTuple18, 19
14Literal
15ExprTuple20, 21
16Literal
17ExprTuple22, 23
18Literal
19Operationoperator: 24
operands: 25
20Operationoperator: 26
operand: 43
21Operationoperator: 27
operands: 28
22Literal
23Operationoperator: 29
operands: 30
24Literal
25ExprTuple41, 31, 32, 33, 34
26Literal
27Literal
28ExprTuple34, 42
29Literal
30ExprTuple35, 36
31Literal
32Literal
33Literal
34Variable
35Operationoperator: 37
operands: 38
36Operationoperator: 39
operand: 43
37Literal
38ExprTuple41, 42
39Literal
40ExprTuple43
41Literal
42Variable
43Literal