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, Lambda, Variable, t
from proveit.linear_algebra import ScalarMult, VecAdd
from proveit.numbers import Add, Exp, Mult, Neg, e, frac, i, one, pi, sqrt, two
from proveit.physics.quantum import ket0, ket1
from proveit.physics.quantum.QPE import _phase
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = frac(one, sqrt(two))
expr = ExprTuple(Lambda(Variable("_b", latex_format = r"{_{-}b}"), ScalarMult(sub_expr2, VecAdd(ket0, ScalarMult(Exp(e, Mult(two, pi, i, Exp(two, Neg(Add(Neg(t), one))), _phase)), ket1)))), Lambda(sub_expr1, ScalarMult(sub_expr2, VecAdd(ket0, ScalarMult(Exp(e, Mult(two, pi, i, Exp(two, Neg(sub_expr1)), _phase)), ket1)))))
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({_{-}b} \mapsto \left(\frac{1}{\sqrt{2}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot 2^{-\left(-t + 1\right)} \cdot \varphi} \cdot \lvert 1 \rangle\right)\right)\right), {_{-}a} \mapsto \left(\frac{1}{\sqrt{2}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot 2^{-{_{-}a}} \cdot \varphi} \cdot \lvert 1 \rangle\right)\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
1Lambdaparameter: 6
body: 4
2Lambdaparameter: 56
body: 5
3ExprTuple6
4Operationoperator: 23
operands: 7
5Operationoperator: 23
operands: 8
6Variable
7ExprTuple10, 9
8ExprTuple10, 11
9Operationoperator: 14
operands: 12
10Operationoperator: 31
operands: 13
11Operationoperator: 14
operands: 15
12ExprTuple18, 16
13ExprTuple60, 17
14Literal
15ExprTuple18, 19
16Operationoperator: 23
operands: 20
17Operationoperator: 48
operands: 21
18Operationoperator: 34
operand: 27
19Operationoperator: 23
operands: 24
20ExprTuple25, 29
21ExprTuple51, 26
22ExprTuple27
23Literal
24ExprTuple28, 29
25Operationoperator: 48
operands: 30
26Operationoperator: 31
operands: 32
27Literal
28Operationoperator: 48
operands: 33
29Operationoperator: 34
operand: 60
30ExprTuple37, 36
31Literal
32ExprTuple60, 51
33ExprTuple37, 38
34Literal
35ExprTuple60
36Operationoperator: 40
operands: 39
37Literal
38Operationoperator: 40
operands: 41
39ExprTuple51, 43, 44, 42, 46
40Literal
41ExprTuple51, 43, 44, 45, 46
42Operationoperator: 48
operands: 47
43Literal
44Literal
45Operationoperator: 48
operands: 49
46Literal
47ExprTuple51, 50
48Literal
49ExprTuple51, 52
50Operationoperator: 61
operand: 55
51Literal
52Operationoperator: 61
operand: 56
53ExprTuple55
54ExprTuple56
55Operationoperator: 57
operands: 58
56Variable
57Literal
58ExprTuple59, 60
59Operationoperator: 61
operand: 63
60Literal
61Literal
62ExprTuple63
63Variable