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, TensorProd, VecSum
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
sub_expr1 = [k]
sub_expr2 = Exp(e, Mult(two, pi, i, _phase, k))
sub_expr3 = TensorProd(ket1, NumKet(k, t))
sub_expr4 = Exp(e, Mult(two, pi, i, _phase, two_pow_t))
sub_expr5 = Interval(zero, subtract(two_pow_t, one))
expr = ExprTuple(ScalarMult(sub_expr4, VecSum(index_or_indices = sub_expr1, summand = ScalarMult(sub_expr2, sub_expr3), domain = sub_expr5)), VecSum(index_or_indices = sub_expr1, summand = ScalarMult(Mult(sub_expr4, sub_expr2), sub_expr3), domain = sub_expr5))
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(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot 2^{t}} \cdot \left(\sum_{k=0}^{2^{t} - 1} \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \left(\lvert 1 \rangle {\otimes} \lvert k \rangle_{t}\right)\right)\right), \sum_{k=0}^{2^{t} - 1} \left(\left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot 2^{t}} \cdot \mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k}\right) \cdot \left(\lvert 1 \rangle {\otimes} \lvert k \rangle_{t}\right)\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: 18
operands: 3
2Operationoperator: 7
operand: 6
3ExprTuple25, 5
4ExprTuple6
5Operationoperator: 7
operand: 10
6Lambdaparameter: 53
body: 9
7Literal
8ExprTuple10
9Conditionalvalue: 11
condition: 16
10Lambdaparameter: 53
body: 13
11Operationoperator: 18
operands: 14
12ExprTuple53
13Conditionalvalue: 15
condition: 16
14ExprTuple17, 23
15Operationoperator: 18
operands: 19
16Operationoperator: 20
operands: 21
17Operationoperator: 46
operands: 22
18Literal
19ExprTuple26, 23
20Literal
21ExprTuple53, 24
22ExprTuple25, 26
23Operationoperator: 27
operands: 28
24Operationoperator: 29
operands: 30
25Operationoperator: 56
operands: 31
26Operationoperator: 56
operands: 32
27Literal
28ExprTuple33, 34
29Literal
30ExprTuple35, 36
31ExprTuple38, 37
32ExprTuple38, 39
33Operationoperator: 40
operand: 58
34Operationoperator: 41
operands: 42
35Literal
36Operationoperator: 43
operands: 44
37Operationoperator: 46
operands: 45
38Literal
39Operationoperator: 46
operands: 47
40Literal
41Literal
42ExprTuple53, 60
43Literal
44ExprTuple49, 48
45ExprTuple59, 50, 51, 52, 49
46Literal
47ExprTuple59, 50, 51, 52, 53
48Operationoperator: 54
operand: 58
49Operationoperator: 56
operands: 57
50Literal
51Literal
52Literal
53Variable
54Literal
55ExprTuple58
56Literal
57ExprTuple59, 60
58Literal
59Literal
60Variable