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, ket0
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(ket0, 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 0 \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: 35
body: 3
2ExprTuple35
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operands: 7
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10, 11
8Literal
9ExprTuple35, 12
10Operationoperator: 38
operands: 13
11Operationoperator: 14
operands: 15
12Operationoperator: 16
operands: 17
13ExprTuple18, 19
14Literal
15ExprTuple20, 21
16Literal
17ExprTuple34, 22
18Literal
19Operationoperator: 23
operands: 24
20Operationoperator: 25
operand: 34
21Operationoperator: 27
operands: 28
22Operationoperator: 29
operands: 30
23Literal
24ExprTuple42, 31, 32, 33, 35
25Literal
26ExprTuple34
27Literal
28ExprTuple35, 43
29Literal
30ExprTuple36, 37
31Literal
32Literal
33Literal
34Literal
35Variable
36Operationoperator: 38
operands: 39
37Operationoperator: 40
operand: 44
38Literal
39ExprTuple42, 43
40Literal
41ExprTuple44
42Literal
43Variable
44Literal