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, 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)))), CartExp(Complex, Mult(two, 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 \mathbb{C}^{2 \cdot 2^{t}}
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: 32
operands: 1
1ExprTuple2, 3
2Operationoperator: 4
operands: 5
3Operationoperator: 6
operands: 7
4Literal
5ExprTuple8, 9
6Literal
7ExprTuple10, 11
8Operationoperator: 12
operands: 13
9Operationoperator: 14
operand: 19
10Literal
11Operationoperator: 48
operands: 16
12Literal
13ExprTuple17, 18
14Literal
15ExprTuple19
16ExprTuple62, 56
17Operationoperator: 29
operand: 46
18Operationoperator: 30
operands: 21
19Lambdaparameter: 55
body: 23
20ExprTuple46
21ExprTuple24, 25
22ExprTuple55
23Conditionalvalue: 26
condition: 27
24Operationoperator: 58
operands: 28
25Operationoperator: 29
operand: 64
26Operationoperator: 30
operands: 31
27Operationoperator: 32
operands: 33
28ExprTuple44, 34
29Literal
30Literal
31ExprTuple35, 36
32Literal
33ExprTuple55, 37
34Operationoperator: 48
operands: 38
35Operationoperator: 58
operands: 39
36Operationoperator: 40
operands: 41
37Operationoperator: 42
operands: 43
38ExprTuple62, 52, 53, 54, 56
39ExprTuple44, 45
40Literal
41ExprTuple55, 63
42Literal
43ExprTuple46, 47
44Literal
45Operationoperator: 48
operands: 49
46Literal
47Operationoperator: 50
operands: 51
48Literal
49ExprTuple62, 52, 53, 54, 55
50Literal
51ExprTuple56, 57
52Literal
53Literal
54Literal
55Variable
56Operationoperator: 58
operands: 59
57Operationoperator: 60
operand: 64
58Literal
59ExprTuple62, 63
60Literal
61ExprTuple64
62Literal
63Variable
64Literal