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, Variable, t
from proveit.linear_algebra import ScalarMult, VecAdd
from proveit.numbers import Add, Exp, Mult, e, frac, i, one, pi, subtract, two
from proveit.physics.quantum import ket0, ket1
from proveit.physics.quantum.QPE import _phase, two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(ScalarMult(frac(one, Exp(two, subtract(frac(Add(t, one), two), frac(t, two)))), VecAdd(ket0, ScalarMult(Exp(e, Mult(two, pi, i, _phase, two_pow_t)), ket1))), Variable("_a", latex_format = r"{_{-}a}"))
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(\frac{1}{2^{\frac{t + 1}{2} - \frac{t}{2}}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot 2^{t}} \cdot \lvert 1 \rangle\right)\right), {_{-}a}\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: 14
operands: 3
2Variable
3ExprTuple4, 5
4Operationoperator: 41
operands: 6
5Operationoperator: 7
operands: 8
6ExprTuple45, 9
7Literal
8ExprTuple10, 11
9Operationoperator: 43
operands: 12
10Operationoperator: 22
operand: 17
11Operationoperator: 14
operands: 15
12ExprTuple46, 16
13ExprTuple17
14Literal
15ExprTuple18, 19
16Operationoperator: 39
operands: 20
17Literal
18Operationoperator: 43
operands: 21
19Operationoperator: 22
operand: 45
20ExprTuple24, 25
21ExprTuple26, 27
22Literal
23ExprTuple45
24Operationoperator: 41
operands: 28
25Operationoperator: 29
operand: 34
26Literal
27Operationoperator: 31
operands: 32
28ExprTuple33, 46
29Literal
30ExprTuple34
31Literal
32ExprTuple46, 35, 36, 37, 38
33Operationoperator: 39
operands: 40
34Operationoperator: 41
operands: 42
35Literal
36Literal
37Literal
38Operationoperator: 43
operands: 44
39Literal
40ExprTuple47, 45
41Literal
42ExprTuple47, 46
43Literal
44ExprTuple46, 47
45Literal
46Literal
47Variable