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 Conditional, Lambda, k, m
from proveit.logic import Equals, Forall, Implies, InSet
from proveit.numbers import Exp, Mult, Neg, e, frac, i, one, pi, two
from proveit.physics.quantum.QPE import _m_domain, _phase, _t, _two_pow_t
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Exp(e, Mult(two, pi, i, _phase, k))
sub_expr2 = frac(one, Exp(two, frac(_t, two)))
sub_expr3 = Exp(e, Neg(frac(Mult(two, pi, i, k, m), _two_pow_t)))
sub_expr4 = InSet(k, _m_domain)
sub_expr5 = Conditional(Mult(sub_expr1, sub_expr2, sub_expr3), sub_expr4)
sub_expr6 = Conditional(Mult(sub_expr1, Mult(sub_expr2, sub_expr3)), sub_expr4)
expr = Implies(Forall(instance_param_or_params = [k], instance_expr = Equals(sub_expr6, sub_expr5)), Equals(Lambda(k, sub_expr6), Lambda(k, sub_expr5)).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[\forall_{k}~\left(\left\{\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \left(\frac{1}{2^{\frac{t}{2}}} \cdot \mathsf{e}^{-\frac{2 \cdot \pi \cdot \mathsf{i} \cdot k \cdot m}{2^{t}}}\right) \textrm{ if } k \in \{0~\ldotp \ldotp~2^{t} - 1\}\right.. = \left\{\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \frac{1}{2^{\frac{t}{2}}} \cdot \mathsf{e}^{-\frac{2 \cdot \pi \cdot \mathsf{i} \cdot k \cdot m}{2^{t}}} \textrm{ if } k \in \{0~\ldotp \ldotp~2^{t} - 1\}\right..\right)\right] \Rightarrow  \\ \left(\begin{array}{c} \begin{array}{l} \left[k \mapsto \left\{\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \left(\frac{1}{2^{\frac{t}{2}}} \cdot \mathsf{e}^{-\frac{2 \cdot \pi \cdot \mathsf{i} \cdot k \cdot m}{2^{t}}}\right) \textrm{ if } k \in \{0~\ldotp \ldotp~2^{t} - 1\}\right..\right] =  \\ \left[k \mapsto \left\{\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \frac{1}{2^{\frac{t}{2}}} \cdot \mathsf{e}^{-\frac{2 \cdot \pi \cdot \mathsf{i} \cdot k \cdot m}{2^{t}}} \textrm{ if } k \in \{0~\ldotp \ldotp~2^{t} - 1\}\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: 5
operand: 8
4Operationoperator: 13
operands: 7
5Literal
6ExprTuple8
7ExprTuple9, 10
8Lambdaparameter: 64
body: 11
9Lambdaparameter: 64
body: 15
10Lambdaparameter: 64
body: 16
11Operationoperator: 13
operands: 14
12ExprTuple64
13Literal
14ExprTuple15, 16
15Conditionalvalue: 17
condition: 19
16Conditionalvalue: 18
condition: 19
17Operationoperator: 58
operands: 20
18Operationoperator: 58
operands: 21
19Operationoperator: 22
operands: 23
20ExprTuple25, 24
21ExprTuple25, 31, 32
22Literal
23ExprTuple64, 26
24Operationoperator: 58
operands: 27
25Operationoperator: 60
operands: 28
26Operationoperator: 29
operands: 30
27ExprTuple31, 32
28ExprTuple42, 33
29Literal
30ExprTuple34, 35
31Operationoperator: 54
operands: 36
32Operationoperator: 60
operands: 37
33Operationoperator: 58
operands: 38
34Literal
35Operationoperator: 39
operands: 40
36ExprTuple52, 41
37ExprTuple42, 43
38ExprTuple66, 62, 63, 44, 64
39Literal
40ExprTuple57, 45
41Operationoperator: 60
operands: 46
42Literal
43Operationoperator: 48
operand: 51
44Literal
45Operationoperator: 48
operand: 52
46ExprTuple66, 50
47ExprTuple51
48Literal
49ExprTuple52
50Operationoperator: 54
operands: 53
51Operationoperator: 54
operands: 55
52Literal
53ExprTuple67, 66
54Literal
55ExprTuple56, 57
56Operationoperator: 58
operands: 59
57Operationoperator: 60
operands: 61
58Literal
59ExprTuple66, 62, 63, 64, 65
60Literal
61ExprTuple66, 67
62Literal
63Literal
64Variable
65Variable
66Literal
67Literal