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, U
from proveit.linear_algebra import MatrixMult, ScalarMult
from proveit.logic import Equals, InSet
from proveit.numbers import Exp, Interval, IntervalCO, Mult, Real, e, i, one, pi, subtract, two, zero
from proveit.physics.quantum import var_ket_u
from proveit.physics.quantum.QPE import phase, two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(InSet(phase, Real), InSet(Mult(two_pow_t, phase), Interval(zero, subtract(two_pow_t, one))), Equals(MatrixMult(U, var_ket_u), ScalarMult(Exp(e, Mult(two, pi, i, phase)), var_ket_u)), InSet(phase, IntervalCO(zero, 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(\varphi \in \mathbb{R}, \left(2^{t} \cdot \varphi\right) \in \{0~\ldotp \ldotp~2^{t} - 1\}, \left(U \thinspace \lvert u \rangle\right) = \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi} \cdot \lvert u \rangle\right), \varphi \in \left[0,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, 3, 4
1Operationoperator: 9
operands: 5
2Operationoperator: 9
operands: 6
3Operationoperator: 7
operands: 8
4Operationoperator: 9
operands: 10
5ExprTuple49, 11
6ExprTuple12, 13
7Literal
8ExprTuple14, 15
9Literal
10ExprTuple49, 16
11Literal
12Operationoperator: 42
operands: 17
13Operationoperator: 18
operands: 19
14Operationoperator: 20
operands: 21
15Operationoperator: 22
operands: 23
16Operationoperator: 24
operands: 25
17ExprTuple34, 49
18Literal
19ExprTuple30, 26
20Literal
21ExprTuple27, 29
22Literal
23ExprTuple28, 29
24Literal
25ExprTuple30, 45
26Operationoperator: 31
operands: 32
27Variable
28Operationoperator: 38
operands: 33
29Variable
30Literal
31Literal
32ExprTuple34, 35
33ExprTuple36, 37
34Operationoperator: 38
operands: 39
35Operationoperator: 40
operand: 45
36Literal
37Operationoperator: 42
operands: 43
38Literal
39ExprTuple46, 44
40Literal
41ExprTuple45
42Literal
43ExprTuple46, 47, 48, 49
44Variable
45Literal
46Literal
47Literal
48Literal
49Variable