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 Conditional, ExprTuple, Lambda, Variable, t
from proveit.linear_algebra import ScalarMult, VecAdd
from proveit.logic import CartExp, InSet
from proveit.numbers import Add, Complex, Exp, Interval, Mult, Neg, e, frac, i, one, pi, sqrt, two, zero
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}")
expr = ExprTuple(Lambda(sub_expr1, Conditional(InSet(ScalarMult(frac(one, sqrt(two)), VecAdd(ket0, ScalarMult(Exp(e, Mult(two, pi, i, Exp(two, Neg(sub_expr1)), _phase)), ket1))), CartExp(Complex, Exp(two, one))), InSet(sub_expr1, Interval(Add(Neg(t), two), zero)))))
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({_{-}a} \mapsto \left\{\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) \in \mathbb{C}^{2^{1}} \textrm{ if } {_{-}a} \in \{-t + 2~\ldotp \ldotp~0\}\right..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameter: 61
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 6
operands: 5
4Operationoperator: 6
operands: 7
5ExprTuple8, 9
6Literal
7ExprTuple61, 10
8Operationoperator: 33
operands: 11
9Operationoperator: 12
operands: 13
10Operationoperator: 14
operands: 15
11ExprTuple16, 17
12Literal
13ExprTuple18, 19
14Literal
15ExprTuple20, 37
16Operationoperator: 41
operands: 21
17Operationoperator: 22
operands: 23
18Literal
19Operationoperator: 55
operands: 24
20Operationoperator: 25
operands: 26
21ExprTuple48, 27
22Literal
23ExprTuple28, 29
24ExprTuple57, 48
25Literal
26ExprTuple30, 57
27Operationoperator: 55
operands: 31
28Operationoperator: 44
operand: 37
29Operationoperator: 33
operands: 34
30Operationoperator: 59
operand: 40
31ExprTuple57, 36
32ExprTuple37
33Literal
34ExprTuple38, 39
35ExprTuple40
36Operationoperator: 41
operands: 42
37Literal
38Operationoperator: 55
operands: 43
39Operationoperator: 44
operand: 48
40Variable
41Literal
42ExprTuple48, 57
43ExprTuple46, 47
44Literal
45ExprTuple48
46Literal
47Operationoperator: 49
operands: 50
48Literal
49Literal
50ExprTuple57, 51, 52, 53, 54
51Literal
52Literal
53Operationoperator: 55
operands: 56
54Literal
55Literal
56ExprTuple57, 58
57Literal
58Operationoperator: 59
operand: 61
59Literal
60ExprTuple61
61Variable