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, 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, QubitSpace, ket1
from proveit.physics.quantum.QPE import _phase, two_pow_t
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [k]
sub_expr2 = Exp(e, Mult(two, pi, i, _phase, k))
sub_expr3 = TensorProd(ket1, NumKet(k, t))
sub_expr4 = Interval(zero, subtract(two_pow_t, one))
sub_expr5 = Exp(e, Mult(two, pi, i, _phase, two_pow_t))
sub_expr6 = VecSum(index_or_indices = sub_expr1, summand = ScalarMult(sub_expr2, sub_expr3), domain = sub_expr4)
expr = Implies(InSet(sub_expr6, TensorProd(QubitSpace, CartExp(Complex, two_pow_t))), Equals(ScalarMult(sub_expr5, sub_expr6), VecSum(index_or_indices = sub_expr1, summand = ScalarMult(Mult(sub_expr5, sub_expr2), sub_expr3), domain = sub_expr4)).with_wrapping_at(1)).with_wrapping_at(1)
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(\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)\right) \\  \Rightarrow \left(\begin{array}{c} \begin{array}{l} \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot 2^{t}} \cdot \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)\right) \\  = \left(\sum_{k=0}^{2^{t} - 1} \left(\left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot 2^{t}} \cdot \mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k}\right) \cdot \left(\lvert 1 \rangle {\otimes} \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.()(1)('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: 35
operands: 5
4Operationoperator: 6
operands: 7
5ExprTuple16, 8
6Literal
7ExprTuple9, 10
8Operationoperator: 42
operands: 11
9Operationoperator: 33
operands: 12
10Operationoperator: 21
operand: 17
11ExprTuple14, 15
12ExprTuple40, 16
13ExprTuple17
14Operationoperator: 19
operands: 18
15Operationoperator: 19
operands: 20
16Operationoperator: 21
operand: 25
17Lambdaparameter: 68
body: 23
18ExprTuple24, 74
19Literal
20ExprTuple24, 64
21Literal
22ExprTuple25
23Conditionalvalue: 26
condition: 31
24Literal
25Lambdaparameter: 68
body: 28
26Operationoperator: 33
operands: 29
27ExprTuple68
28Conditionalvalue: 30
condition: 31
29ExprTuple32, 38
30Operationoperator: 33
operands: 34
31Operationoperator: 35
operands: 36
32Operationoperator: 61
operands: 37
33Literal
34ExprTuple41, 38
35Literal
36ExprTuple68, 39
37ExprTuple40, 41
38Operationoperator: 42
operands: 43
39Operationoperator: 44
operands: 45
40Operationoperator: 71
operands: 46
41Operationoperator: 71
operands: 47
42Literal
43ExprTuple48, 49
44Literal
45ExprTuple50, 51
46ExprTuple53, 52
47ExprTuple53, 54
48Operationoperator: 55
operand: 73
49Operationoperator: 56
operands: 57
50Literal
51Operationoperator: 58
operands: 59
52Operationoperator: 61
operands: 60
53Literal
54Operationoperator: 61
operands: 62
55Literal
56Literal
57ExprTuple68, 75
58Literal
59ExprTuple64, 63
60ExprTuple74, 65, 66, 67, 64
61Literal
62ExprTuple74, 65, 66, 67, 68
63Operationoperator: 69
operand: 73
64Operationoperator: 71
operands: 72
65Literal
66Literal
67Literal
68Variable
69Literal
70ExprTuple73
71Literal
72ExprTuple74, 75
73Literal
74Literal
75Variable