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
expr = ExprTuple(Exp(e, Mult(two, pi, i, _phase, two_pow_t)), VecSum(index_or_indices = [k], summand = ScalarMult(Exp(e, Mult(two, pi, i, _phase, k)), TensorProd(ket1, 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(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot 2^{t}}, \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)
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: 44
operands: 3
2Operationoperator: 4
operand: 7
3ExprTuple25, 6
4Literal
5ExprTuple7
6Operationoperator: 31
operands: 8
7Lambdaparameter: 41
body: 10
8ExprTuple48, 38, 39, 40, 42
9ExprTuple41
10Conditionalvalue: 11
condition: 12
11Operationoperator: 13
operands: 14
12Operationoperator: 15
operands: 16
13Literal
14ExprTuple17, 18
15Literal
16ExprTuple41, 19
17Operationoperator: 44
operands: 20
18Operationoperator: 21
operands: 22
19Operationoperator: 23
operands: 24
20ExprTuple25, 26
21Literal
22ExprTuple27, 28
23Literal
24ExprTuple29, 30
25Literal
26Operationoperator: 31
operands: 32
27Operationoperator: 33
operand: 50
28Operationoperator: 34
operands: 35
29Literal
30Operationoperator: 36
operands: 37
31Literal
32ExprTuple48, 38, 39, 40, 41
33Literal
34Literal
35ExprTuple41, 49
36Literal
37ExprTuple42, 43
38Literal
39Literal
40Literal
41Variable
42Operationoperator: 44
operands: 45
43Operationoperator: 46
operand: 50
44Literal
45ExprTuple48, 49
46Literal
47ExprTuple50
48Literal
49Variable
50Literal