logo

Expression of type Implies

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, Equals, Implies, 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
sub_expr1 = ScalarMult(Exp(e, Mult(two, pi, i, _phase, two_pow_t)), ket1)
sub_expr2 = 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)))
sub_expr3 = TensorProd(VecAdd(ket0, sub_expr1), sub_expr2)
expr = Implies(InSet(sub_expr3, CartExp(Complex, Mult(two, two_pow_t))), Equals(VecAdd(TensorProd(ket0, sub_expr2), TensorProd(sub_expr1, sub_expr2)), sub_expr3).with_wrapping_at(2)).with_wrapping_at(2)
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())
\begin{array}{c} \begin{array}{l} \left(\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}}\right) \Rightarrow  \\ \left(\begin{array}{c} \begin{array}{l} \left(\left(\lvert 0 \rangle {\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) + \left(\left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot 2^{t}} \cdot \lvert 1 \rangle\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)\right) =  \\ \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) \end{array} \end{array}\right) \end{array} \end{array}
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.()(2)('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: 45
operands: 5
4Operationoperator: 6
operands: 7
5ExprTuple10, 8
6Literal
7ExprTuple9, 10
8Operationoperator: 11
operands: 12
9Operationoperator: 24
operands: 13
10Operationoperator: 22
operands: 14
11Literal
12ExprTuple15, 16
13ExprTuple17, 18
14ExprTuple19, 26
15Literal
16Operationoperator: 60
operands: 20
17Operationoperator: 22
operands: 21
18Operationoperator: 22
operands: 23
19Operationoperator: 24
operands: 25
20ExprTuple74, 68
21ExprTuple27, 26
22Literal
23ExprTuple28, 26
24Literal
25ExprTuple27, 28
26Operationoperator: 29
operand: 33
27Operationoperator: 39
operand: 58
28Operationoperator: 43
operands: 32
29Literal
30ExprTuple33
31ExprTuple58
32ExprTuple34, 35
33Lambdaparameter: 67
body: 37
34Operationoperator: 70
operands: 38
35Operationoperator: 39
operand: 76
36ExprTuple67
37Conditionalvalue: 40
condition: 41
38ExprTuple56, 42
39Literal
40Operationoperator: 43
operands: 44
41Operationoperator: 45
operands: 46
42Operationoperator: 60
operands: 47
43Literal
44ExprTuple48, 49
45Literal
46ExprTuple67, 50
47ExprTuple74, 64, 65, 66, 68
48Operationoperator: 70
operands: 51
49Operationoperator: 52
operands: 53
50Operationoperator: 54
operands: 55
51ExprTuple56, 57
52Literal
53ExprTuple67, 75
54Literal
55ExprTuple58, 59
56Literal
57Operationoperator: 60
operands: 61
58Literal
59Operationoperator: 62
operands: 63
60Literal
61ExprTuple74, 64, 65, 66, 67
62Literal
63ExprTuple68, 69
64Literal
65Literal
66Literal
67Variable
68Operationoperator: 70
operands: 71
69Operationoperator: 72
operand: 76
70Literal
71ExprTuple74, 75
72Literal
73ExprTuple76
74Literal
75Variable
76Literal