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, m
from proveit.linear_algebra import VecSum
from proveit.logic import Equals, Forall, Implies, InSet
from proveit.numbers import Complex, Exp, Mult, Sum, e, i, pi, two
from proveit.physics.quantum import NumBra, NumKet, Qmult
from proveit.physics.quantum.QFT import InverseFourierTransform
from proveit.physics.quantum.QPE import _m_domain, _phase, _t
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [k]
sub_expr2 = Mult(Exp(e, Mult(two, pi, i, _phase, k)), Qmult(NumBra(m, _t), InverseFourierTransform(_t), NumKet(k, _t)))
expr = Implies(Forall(instance_param_or_params = sub_expr1, instance_expr = InSet(sub_expr2, Complex), domain = _m_domain), Equals(VecSum(index_or_indices = sub_expr1, summand = sub_expr2, domain = _m_domain), Sum(index_or_indices = sub_expr1, summand = sub_expr2, domain = _m_domain))).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[\forall_{k \in \{0~\ldotp \ldotp~2^{t} - 1\}}~\left(\left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \left({_{t}}\langle m \rvert \thinspace {\mathrm {FT}}^{\dag}_{t} \thinspace \lvert k \rangle_{t}\right)\right) \in \mathbb{C}\right)\right] \Rightarrow  \\ \left(\left(\sum_{k=0}^{2^{t} - 1} \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \left({_{t}}\langle m \rvert \thinspace {\mathrm {FT}}^{\dag}_{t} \thinspace \lvert k \rangle_{t}\right)\right)\right) = \left(\sum_{k = 0}^{2^{t} - 1} \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \left({_{t}}\langle m \rvert \thinspace {\mathrm {FT}}^{\dag}_{t} \thinspace \lvert k \rangle_{t}\right)\right)\right)\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: 5
operand: 9
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9
7Literal
8ExprTuple10, 11
9Lambdaparameter: 56
body: 12
10Operationoperator: 13
operand: 17
11Operationoperator: 14
operand: 17
12Conditionalvalue: 16
condition: 23
13Literal
14Literal
15ExprTuple17
16Operationoperator: 25
operands: 18
17Lambdaparameter: 56
body: 20
18ExprTuple22, 21
19ExprTuple56
20Conditionalvalue: 22
condition: 23
21Literal
22Operationoperator: 42
operands: 24
23Operationoperator: 25
operands: 26
24ExprTuple27, 28
25Literal
26ExprTuple56, 29
27Operationoperator: 59
operands: 30
28Operationoperator: 31
operands: 32
29Operationoperator: 33
operands: 34
30ExprTuple35, 36
31Literal
32ExprTuple37, 38, 39
33Literal
34ExprTuple40, 41
35Literal
36Operationoperator: 42
operands: 43
37Operationoperator: 44
operands: 45
38Operationoperator: 46
operand: 64
39Operationoperator: 48
operands: 49
40Literal
41Operationoperator: 50
operands: 51
42Literal
43ExprTuple63, 52, 53, 54, 56
44Literal
45ExprTuple55, 64
46Literal
47ExprTuple64
48Literal
49ExprTuple56, 64
50Literal
51ExprTuple57, 58
52Literal
53Literal
54Literal
55Variable
56Variable
57Operationoperator: 59
operands: 60
58Operationoperator: 61
operand: 65
59Literal
60ExprTuple63, 64
61Literal
62ExprTuple65
63Literal
64Literal
65Literal