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, s, t
from proveit.linear_algebra import MatrixMult, ScalarMult, Unitary
from proveit.logic import And, Equals, InSet
from proveit.numbers import Exp, Interval, Mult, NaturalPos, Real, e, i, one, pi, subtract, two, zero
from proveit.physics.quantum import normalized_var_ket_u, var_ket_u
from proveit.physics.quantum.QPE import phase, s_ket_domain, two_pow_s, two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(InSet(s, NaturalPos), InSet(t, NaturalPos), InSet(U, Unitary(two_pow_s)), InSet(var_ket_u, s_ket_domain), normalized_var_ket_u, And(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))))
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(s \in \mathbb{N}^+, t \in \mathbb{N}^+, U \in \textrm{U}\left(2^{s}\right), \lvert u \rangle \in \mathbb{C}^{2^{s}}, \left \|\lvert u \rangle\right \| = 1, \left(\varphi \in \mathbb{R}\right) \land \left(\left(2^{t} \cdot \varphi\right) \in \{0~\ldotp \ldotp~2^{t} - 1\}\right) \land \left(\left(U \thinspace \lvert u \rangle\right) = \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi} \cdot \lvert u \rangle\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, 3, 4, 5, 6
1Operationoperator: 28
operands: 7
2Operationoperator: 28
operands: 8
3Operationoperator: 28
operands: 9
4Operationoperator: 28
operands: 10
5Operationoperator: 30
operands: 11
6Operationoperator: 12
operands: 13
7ExprTuple47, 14
8ExprTuple66, 14
9ExprTuple50, 15
10ExprTuple52, 16
11ExprTuple17, 67
12Literal
13ExprTuple18, 19, 20
14Literal
15Operationoperator: 21
operand: 33
16Operationoperator: 23
operands: 24
17Operationoperator: 25
operand: 52
18Operationoperator: 28
operands: 27
19Operationoperator: 28
operands: 29
20Operationoperator: 30
operands: 31
21Literal
22ExprTuple33
23Literal
24ExprTuple32, 33
25Literal
26ExprTuple52
27ExprTuple71, 34
28Literal
29ExprTuple35, 36
30Literal
31ExprTuple37, 38
32Literal
33Operationoperator: 60
operands: 39
34Literal
35Operationoperator: 64
operands: 40
36Operationoperator: 41
operands: 42
37Operationoperator: 43
operands: 44
38Operationoperator: 45
operands: 46
39ExprTuple68, 47
40ExprTuple56, 71
41Literal
42ExprTuple48, 49
43Literal
44ExprTuple50, 52
45Literal
46ExprTuple51, 52
47Variable
48Literal
49Operationoperator: 53
operands: 54
50Variable
51Operationoperator: 60
operands: 55
52Variable
53Literal
54ExprTuple56, 57
55ExprTuple58, 59
56Operationoperator: 60
operands: 61
57Operationoperator: 62
operand: 67
58Literal
59Operationoperator: 64
operands: 65
60Literal
61ExprTuple68, 66
62Literal
63ExprTuple67
64Literal
65ExprTuple68, 69, 70, 71
66Variable
67Literal
68Literal
69Literal
70Literal
71Variable