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 ExprTuple, k, t
from proveit.linear_algebra import ScalarMult, VecAdd, VecSum
from proveit.numbers import Exp, Interval, Mult, e, i, one, pi, subtract, two, zero
from proveit.physics.quantum import NumKet, ket0, ket1
from proveit.physics.quantum.QPE import _phase, two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(VecAdd(ket0, ScalarMult(Exp(e, Mult(two, pi, i, _phase, two_pow_t)), ket1)), VecSum(index_or_indices = [k], summand = ScalarMult(Exp(e, Mult(two, pi, i, _phase, k)), NumKet(k, t)), domain = 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(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot 2^{t}} \cdot \lvert 1 \rangle\right), \sum_{k=0}^{2^{t} - 1} \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \lvert k \rangle_{t}\right)\right)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
wrap_positionsposition(s) at which wrapping is to occur; 'n' is after the nth comma.()()('with_wrapping_at',)
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'leftleft('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1, 2
1Operationoperator: 3
operands: 4
2Operationoperator: 5
operand: 9
3Literal
4ExprTuple7, 8
5Literal
6ExprTuple9
7Operationoperator: 19
operand: 36
8Operationoperator: 20
operands: 11
9Lambdaparameter: 45
body: 13
10ExprTuple36
11ExprTuple14, 15
12ExprTuple45
13Conditionalvalue: 16
condition: 17
14Operationoperator: 48
operands: 18
15Operationoperator: 19
operand: 54
16Operationoperator: 20
operands: 21
17Operationoperator: 22
operands: 23
18ExprTuple34, 24
19Literal
20Literal
21ExprTuple25, 26
22Literal
23ExprTuple45, 27
24Operationoperator: 38
operands: 28
25Operationoperator: 48
operands: 29
26Operationoperator: 30
operands: 31
27Operationoperator: 32
operands: 33
28ExprTuple52, 42, 43, 44, 46
29ExprTuple34, 35
30Literal
31ExprTuple45, 53
32Literal
33ExprTuple36, 37
34Literal
35Operationoperator: 38
operands: 39
36Literal
37Operationoperator: 40
operands: 41
38Literal
39ExprTuple52, 42, 43, 44, 45
40Literal
41ExprTuple46, 47
42Literal
43Literal
44Literal
45Variable
46Operationoperator: 48
operands: 49
47Operationoperator: 50
operand: 54
48Literal
49ExprTuple52, 53
50Literal
51ExprTuple54
52Literal
53Variable
54Literal