logo

Expression of type InSet

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 ExprRange, Variable, t
from proveit.linear_algebra import ScalarMult, TensorProd, VecAdd
from proveit.logic import InSet
from proveit.numbers import Add, Exp, Mult, Neg, e, frac, i, one, pi, sqrt, two, zero
from proveit.physics.quantum import QubitSpace, 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 = Add(Neg(t), one)
expr = InSet(TensorProd(ExprRange(sub_expr1, ScalarMult(frac(one, sqrt(two)), VecAdd(ket0, ScalarMult(Exp(e, Mult(two, pi, i, Exp(two, Neg(sub_expr1)), _phase)), ket1))), sub_expr2, zero).with_decreasing_order()), TensorProd(ExprRange(sub_expr1, QubitSpace, sub_expr2, 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(\left(\frac{1}{\sqrt{2}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot 2^{t - 1} \cdot \varphi} \cdot \lvert 1 \rangle\right)\right)\right) {\otimes}  \left(\frac{1}{\sqrt{2}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot 2^{t - 2} \cdot \varphi} \cdot \lvert 1 \rangle\right)\right)\right) {\otimes}  \ldots {\otimes}  \left(\frac{1}{\sqrt{2}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot 2^{0} \cdot \varphi} \cdot \lvert 1 \rangle\right)\right)\right)\right) \in \left(\mathbb{C}^{2} {\otimes}  \mathbb{C}^{2} {\otimes}  ..\left(t - 3\right) \times.. {\otimes}  \mathbb{C}^{2}\right)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
operation'infix' or 'function' style formattinginfixinfix
wrap_positionsposition(s) at which wrapping is to occur; '2 n - 1' is after the nth operand, '2 n' is after the nth operation.()()('with_wrapping_at', 'with_wrap_before_operator', 'with_wrap_after_operator', 'without_wrapping', 'wrap_positions')
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'centercenter('with_justification',)
directionDirection of the relation (normal or reversed)normalnormal('with_direction_reversed', 'is_reversed')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 1
operands: 2
1Literal
2ExprTuple3, 4
3Operationoperator: 6
operands: 5
4Operationoperator: 6
operands: 7
5ExprTuple8
6Literal
7ExprTuple9
8ExprRangelambda_map: 10
start_index: 12
end_index: 37
9ExprRangelambda_map: 11
start_index: 12
end_index: 37
10Lambdaparameter: 60
body: 13
11Lambdaparameter: 60
body: 14
12Operationoperator: 15
operands: 16
13Operationoperator: 34
operands: 17
14Operationoperator: 18
operands: 19
15Literal
16ExprTuple20, 47
17ExprTuple21, 22
18Literal
19ExprTuple23, 56
20Operationoperator: 58
operand: 28
21Operationoperator: 40
operands: 25
22Operationoperator: 26
operands: 27
23Literal
24ExprTuple28
25ExprTuple47, 29
26Literal
27ExprTuple30, 31
28Variable
29Operationoperator: 54
operands: 32
30Operationoperator: 43
operand: 37
31Operationoperator: 34
operands: 35
32ExprTuple56, 36
33ExprTuple37
34Literal
35ExprTuple38, 39
36Operationoperator: 40
operands: 41
37Literal
38Operationoperator: 54
operands: 42
39Operationoperator: 43
operand: 47
40Literal
41ExprTuple47, 56
42ExprTuple45, 46
43Literal
44ExprTuple47
45Literal
46Operationoperator: 48
operands: 49
47Literal
48Literal
49ExprTuple56, 50, 51, 52, 53
50Literal
51Literal
52Operationoperator: 54
operands: 55
53Literal
54Literal
55ExprTuple56, 57
56Literal
57Operationoperator: 58
operand: 60
58Literal
59ExprTuple60
60Variable