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, VecSum
from proveit.numbers import Add, Exp, Interval, Mult, e, frac, i, one, pi, subtract, two, zero
from proveit.physics.quantum import NumKet
from proveit.physics.quantum.QPE import _phase, two_pow_t
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Add(t, one)
expr = ExprTuple(frac(one, Exp(two, frac(sub_expr1, two))), VecSum(index_or_indices = [k], summand = ScalarMult(Exp(e, Mult(two, pi, i, _phase, k)), NumKet(k, sub_expr1)), domain = Interval(zero, subtract(Mult(two, 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(\frac{1}{2^{\frac{t + 1}{2}}}, \sum_{k=0}^{\left(2 \cdot 2^{t}\right) - 1} \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \lvert k \rangle_{t + 1}\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: 14
operands: 3
2Operationoperator: 4
operand: 7
3ExprTuple48, 6
4Literal
5ExprTuple7
6Operationoperator: 49
operands: 8
7Lambdaparameter: 40
body: 10
8ExprTuple51, 11
9ExprTuple40
10Conditionalvalue: 12
condition: 13
11Operationoperator: 14
operands: 15
12Operationoperator: 16
operands: 17
13Operationoperator: 18
operands: 19
14Literal
15ExprTuple30, 51
16Literal
17ExprTuple20, 21
18Literal
19ExprTuple40, 22
20Operationoperator: 49
operands: 23
21Operationoperator: 24
operands: 25
22Operationoperator: 26
operands: 27
23ExprTuple28, 29
24Literal
25ExprTuple40, 30
26Literal
27ExprTuple31, 32
28Literal
29Operationoperator: 43
operands: 33
30Operationoperator: 35
operands: 34
31Literal
32Operationoperator: 35
operands: 36
33ExprTuple51, 37, 38, 39, 40
34ExprTuple52, 48
35Literal
36ExprTuple41, 42
37Literal
38Literal
39Literal
40Variable
41Operationoperator: 43
operands: 44
42Operationoperator: 45
operand: 48
43Literal
44ExprTuple51, 47
45Literal
46ExprTuple48
47Operationoperator: 49
operands: 50
48Literal
49Literal
50ExprTuple51, 52
51Literal
52Variable