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, eps, n, s, t
from proveit.linear_algebra import MatrixMult, ScalarMult, Unitary
from proveit.logic import Equals, InSet
from proveit.numbers import Add, Ceil, Exp, IntervalCO, IntervalOC, Log, Mult, NaturalPos, Real, e, frac, greater_eq, 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(eps, IntervalOC(zero, one)), InSet(s, NaturalPos), InSet(n, NaturalPos), greater_eq(n, two), 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)), InSet(t, NaturalPos), greater_eq(t, Add(n, Ceil(Log(two, Add(two, frac(one, Mult(two, eps))))))))
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(\epsilon \in \left(0,1\right], s \in \mathbb{N}^+, n \in \mathbb{N}^+, n \geq 2, 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), t \in \mathbb{N}^+, t \geq \left(n + \left\lceil \textrm{log}_2\left(2 + \frac{1}{2 \cdot \epsilon}\right)\right\rceil\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, 7, 8, 9, 10, 11, 12
1Operationoperator: 24
operands: 13
2Operationoperator: 24
operands: 14
3Operationoperator: 24
operands: 15
4Operationoperator: 26
operands: 16
5Operationoperator: 24
operands: 17
6Operationoperator: 24
operands: 18
7Operationoperator: 24
operands: 19
8Operationoperator: 24
operands: 20
9Operationoperator: 22
operands: 21
10Operationoperator: 22
operands: 23
11Operationoperator: 24
operands: 25
12Operationoperator: 26
operands: 27
13ExprTuple87, 28
14ExprTuple66, 36
15ExprTuple59, 36
16ExprTuple86, 59
17ExprTuple56, 29
18ExprTuple58, 30
19ExprTuple75, 31
20ExprTuple75, 32
21ExprTuple33, 82
22Literal
23ExprTuple34, 35
24Literal
25ExprTuple38, 36
26Literal
27ExprTuple37, 38
28Operationoperator: 39
operands: 45
29Operationoperator: 40
operand: 54
30Operationoperator: 42
operands: 43
31Literal
32Operationoperator: 44
operands: 45
33Operationoperator: 46
operand: 58
34Operationoperator: 48
operands: 49
35Operationoperator: 50
operands: 51
36Literal
37Operationoperator: 77
operands: 52
38Variable
39Literal
40Literal
41ExprTuple54
42Literal
43ExprTuple53, 54
44Literal
45ExprTuple55, 82
46Literal
47ExprTuple58
48Literal
49ExprTuple56, 58
50Literal
51ExprTuple57, 58
52ExprTuple59, 60
53Literal
54Operationoperator: 62
operands: 61
55Literal
56Variable
57Operationoperator: 62
operands: 63
58Variable
59Variable
60Operationoperator: 64
operand: 69
61ExprTuple86, 66
62Literal
63ExprTuple67, 68
64Literal
65ExprTuple69
66Variable
67Literal
68Operationoperator: 84
operands: 70
69Operationoperator: 71
operands: 72
70ExprTuple86, 73, 74, 75
71Literal
72ExprTuple86, 76
73Literal
74Literal
75Variable
76Operationoperator: 77
operands: 78
77Literal
78ExprTuple86, 79
79Operationoperator: 80
operands: 81
80Literal
81ExprTuple82, 83
82Literal
83Operationoperator: 84
operands: 85
84Literal
85ExprTuple86, 87
86Literal
87Variable