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, 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, ket1
from proveit.physics.quantum.QPE import _phase, two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = InSet(VecSum(index_or_indices = [k], summand = ScalarMult(Exp(e, Mult(two, pi, i, _phase, k)), TensorProd(ket1, 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(\sum_{k=0}^{2^{t} - 1} \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \left(\lvert 1 \rangle {\otimes} \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: 20
operands: 1
1ExprTuple2, 3
2Operationoperator: 4
operand: 7
3Operationoperator: 26
operands: 6
4Literal
5ExprTuple7
6ExprTuple8, 9
7Lambdaparameter: 46
body: 11
8Operationoperator: 13
operands: 12
9Operationoperator: 13
operands: 14
10ExprTuple46
11Conditionalvalue: 15
condition: 16
12ExprTuple17, 53
13Literal
14ExprTuple17, 47
15Operationoperator: 18
operands: 19
16Operationoperator: 20
operands: 21
17Literal
18Literal
19ExprTuple22, 23
20Literal
21ExprTuple46, 24
22Operationoperator: 49
operands: 25
23Operationoperator: 26
operands: 27
24Operationoperator: 28
operands: 29
25ExprTuple30, 31
26Literal
27ExprTuple32, 33
28Literal
29ExprTuple34, 35
30Literal
31Operationoperator: 36
operands: 37
32Operationoperator: 38
operand: 55
33Operationoperator: 39
operands: 40
34Literal
35Operationoperator: 41
operands: 42
36Literal
37ExprTuple53, 43, 44, 45, 46
38Literal
39Literal
40ExprTuple46, 54
41Literal
42ExprTuple47, 48
43Literal
44Literal
45Literal
46Variable
47Operationoperator: 49
operands: 50
48Operationoperator: 51
operand: 55
49Literal
50ExprTuple53, 54
51Literal
52ExprTuple55
53Literal
54Variable
55Literal