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 k, t
from proveit.linear_algebra import ScalarMult, TensorProd, VecAdd, VecSum
from proveit.logic import CartExp, InSet
from proveit.numbers import Complex, Exp, Interval, Mult, e, i, one, pi, subtract, two, zero
from proveit.physics.quantum import NumKet, QubitSpace, ket0, ket1
from proveit.physics.quantum.QPE import _phase, two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = InSet(TensorProd(VecAdd(ket0, ScalarMult(Exp(e, Mult(two, pi, i, _phase, two_pow_t)), ket1)), VecSum(index_or_indices = [k], summand = ScalarMult(Exp(e, Mult(two, pi, i, _phase, k)), NumKet(k, t)), domain = Interval(zero, subtract(two_pow_t, one)))), TensorProd(QubitSpace, CartExp(Complex, two_pow_t)))
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(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot 2^{t}} \cdot \lvert 1 \rangle\right)\right) {\otimes} \left(\sum_{k=0}^{2^{t} - 1} \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \lvert k \rangle_{t}\right)\right)\right) \in \left(\mathbb{C}^{2} {\otimes} \mathbb{C}^{2^{t}}\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: 34
operands: 1
1ExprTuple2, 3
2Operationoperator: 5
operands: 4
3Operationoperator: 5
operands: 6
4ExprTuple7, 8
5Literal
6ExprTuple9, 10
7Operationoperator: 11
operands: 12
8Operationoperator: 13
operand: 20
9Operationoperator: 16
operands: 15
10Operationoperator: 16
operands: 17
11Literal
12ExprTuple18, 19
13Literal
14ExprTuple20
15ExprTuple21, 64
16Literal
17ExprTuple21, 58
18Operationoperator: 31
operand: 48
19Operationoperator: 32
operands: 23
20Lambdaparameter: 57
body: 25
21Literal
22ExprTuple48
23ExprTuple26, 27
24ExprTuple57
25Conditionalvalue: 28
condition: 29
26Operationoperator: 60
operands: 30
27Operationoperator: 31
operand: 66
28Operationoperator: 32
operands: 33
29Operationoperator: 34
operands: 35
30ExprTuple46, 36
31Literal
32Literal
33ExprTuple37, 38
34Literal
35ExprTuple57, 39
36Operationoperator: 50
operands: 40
37Operationoperator: 60
operands: 41
38Operationoperator: 42
operands: 43
39Operationoperator: 44
operands: 45
40ExprTuple64, 54, 55, 56, 58
41ExprTuple46, 47
42Literal
43ExprTuple57, 65
44Literal
45ExprTuple48, 49
46Literal
47Operationoperator: 50
operands: 51
48Literal
49Operationoperator: 52
operands: 53
50Literal
51ExprTuple64, 54, 55, 56, 57
52Literal
53ExprTuple58, 59
54Literal
55Literal
56Literal
57Variable
58Operationoperator: 60
operands: 61
59Operationoperator: 62
operand: 66
60Literal
61ExprTuple64, 65
62Literal
63ExprTuple66
64Literal
65Variable
66Literal