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 ExprRange, Variable, t
from proveit.linear_algebra import MatrixExp, MatrixMult, ScalarMult
from proveit.logic import And, Equals, Forall, Implies
from proveit.numbers import Add, Exp, Interval, Mult, Neg, e, i, one, pi, two, zero
from proveit.physics.quantum.QPE import _U, _ket_u, _phase
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = Exp(two, Neg(sub_expr1))
sub_expr3 = Add(Neg(t), one)
sub_expr4 = Equals(MatrixMult(MatrixExp(_U, sub_expr2), _ket_u), ScalarMult(Exp(e, Mult(two, pi, i, Mult(sub_expr2, _phase))), _ket_u))
expr = Implies(Forall(instance_param_or_params = [sub_expr1], instance_expr = sub_expr4, domain = Interval(sub_expr3, zero)), And(ExprRange(sub_expr1, sub_expr4, sub_expr3, zero)))
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[\forall_{{_{-}a} \in \{-t + 1~\ldotp \ldotp~0\}}~\left(\left(U^{2^{-{_{-}a}}} \thinspace \lvert u \rangle\right) = \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \left(2^{-{_{-}a}} \cdot \varphi\right)} \cdot \lvert u \rangle\right)\right)\right] \Rightarrow \left(\left(\left(U^{2^{-\left(-t + 1\right)}} \thinspace \lvert u \rangle\right) = \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \left(2^{-\left(-t + 1\right)} \cdot \varphi\right)} \cdot \lvert u \rangle\right)\right) \land  \left(\left(U^{2^{-\left(-t + 2\right)}} \thinspace \lvert u \rangle\right) = \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \left(2^{-\left(-t + 2\right)} \cdot \varphi\right)} \cdot \lvert u \rangle\right)\right) \land  \ldots \land  \left(\left(U^{2^{-0}} \thinspace \lvert u \rangle\right) = \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \left(2^{-0} \cdot \varphi\right)} \cdot \lvert u \rangle\right)\right)\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: 1
operands: 2
1Literal
2ExprTuple3, 4
3Operationoperator: 5
operand: 9
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9
7Literal
8ExprTuple10
9Lambdaparameter: 59
body: 11
10ExprRangelambda_map: 12
start_index: 28
end_index: 29
11Conditionalvalue: 14
condition: 13
12Lambdaparameter: 59
body: 14
13Operationoperator: 15
operands: 16
14Operationoperator: 17
operands: 18
15Literal
16ExprTuple59, 19
17Literal
18ExprTuple20, 21
19Operationoperator: 22
operands: 23
20Operationoperator: 24
operands: 25
21Operationoperator: 26
operands: 27
22Literal
23ExprTuple28, 29
24Literal
25ExprTuple30, 32
26Literal
27ExprTuple31, 32
28Operationoperator: 33
operands: 34
29Literal
30Operationoperator: 35
operands: 36
31Operationoperator: 53
operands: 37
32Literal
33Literal
34ExprTuple38, 39
35Literal
36ExprTuple40, 51
37ExprTuple41, 42
38Operationoperator: 57
operand: 45
39Literal
40Literal
41Literal
42Operationoperator: 49
operands: 44
43ExprTuple45
44ExprTuple55, 46, 47, 48
45Variable
46Literal
47Literal
48Operationoperator: 49
operands: 50
49Literal
50ExprTuple51, 52
51Operationoperator: 53
operands: 54
52Literal
53Literal
54ExprTuple55, 56
55Literal
56Operationoperator: 57
operand: 59
57Literal
58ExprTuple59
59Variable