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, Unitary
from proveit.logic import Equals, InSet
from proveit.numbers import Exp, IntervalCO, Mult, Real, e, i, one, pi, 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
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(InSet(U, Unitary(two_pow_s)), InSet(var_ket_u, s_ket_domain), InSet(phase, Real), InSet(phase, IntervalCO(zero, one)), normalized_var_ket_u, 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(U \in \textrm{U}\left(2^{s}\right), \lvert u \rangle \in \mathbb{C}^{2^{s}}, \varphi \in \mathbb{R}, \varphi \in \left[0,1\right), \left \|\lvert u \rangle\right \| = 1, \left(U \thinspace \lvert u \rangle\right) = \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi} \cdot \lvert u \rangle\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: 10
operands: 7
2Operationoperator: 10
operands: 8
3Operationoperator: 10
operands: 9
4Operationoperator: 10
operands: 11
5Operationoperator: 13
operands: 12
6Operationoperator: 13
operands: 14
7ExprTuple38, 15
8ExprTuple40, 16
9ExprTuple52, 17
10Literal
11ExprTuple52, 18
12ExprTuple19, 37
13Literal
14ExprTuple20, 21
15Operationoperator: 22
operand: 35
16Operationoperator: 24
operands: 25
17Literal
18Operationoperator: 26
operands: 27
19Operationoperator: 28
operand: 40
20Operationoperator: 30
operands: 31
21Operationoperator: 32
operands: 33
22Literal
23ExprTuple35
24Literal
25ExprTuple34, 35
26Literal
27ExprTuple36, 37
28Literal
29ExprTuple40
30Literal
31ExprTuple38, 40
32Literal
33ExprTuple39, 40
34Literal
35Operationoperator: 42
operands: 41
36Literal
37Literal
38Variable
39Operationoperator: 42
operands: 43
40Variable
41ExprTuple49, 44
42Literal
43ExprTuple45, 46
44Variable
45Literal
46Operationoperator: 47
operands: 48
47Literal
48ExprTuple49, 50, 51, 52
49Literal
50Literal
51Literal
52Variable