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.logic import CartExp
from proveit.numbers import Complex, Exp, Interval, Mult, e, i, one, pi, subtract, two, zero
from proveit.physics.quantum import NumKet, QubitSpace, ket1
from proveit.physics.quantum.QPE import _phase, two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(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))), TensorProd(QubitSpace, CartExp(Complex, two_pow_t)))
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(\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), \mathbb{C}^{2} {\otimes} \mathbb{C}^{2^{t}}\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
operand: 6
2Operationoperator: 25
operands: 5
3Literal
4ExprTuple6
5ExprTuple7, 8
6Lambdaparameter: 45
body: 10
7Operationoperator: 12
operands: 11
8Operationoperator: 12
operands: 13
9ExprTuple45
10Conditionalvalue: 14
condition: 15
11ExprTuple16, 52
12Literal
13ExprTuple16, 46
14Operationoperator: 17
operands: 18
15Operationoperator: 19
operands: 20
16Literal
17Literal
18ExprTuple21, 22
19Literal
20ExprTuple45, 23
21Operationoperator: 48
operands: 24
22Operationoperator: 25
operands: 26
23Operationoperator: 27
operands: 28
24ExprTuple29, 30
25Literal
26ExprTuple31, 32
27Literal
28ExprTuple33, 34
29Literal
30Operationoperator: 35
operands: 36
31Operationoperator: 37
operand: 54
32Operationoperator: 38
operands: 39
33Literal
34Operationoperator: 40
operands: 41
35Literal
36ExprTuple52, 42, 43, 44, 45
37Literal
38Literal
39ExprTuple45, 53
40Literal
41ExprTuple46, 47
42Literal
43Literal
44Literal
45Variable
46Operationoperator: 48
operands: 49
47Operationoperator: 50
operand: 54
48Literal
49ExprTuple52, 53
50Literal
51ExprTuple54
52Literal
53Variable
54Literal