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, IndexedVar, Variable, a, c, k, m
from proveit.logic import Equals, Forall, Implies, InSet
from proveit.numbers import Complex, Exp, Mult, Neg, Sum, e, frac, i, one, pi, two, zero
from proveit.physics.quantum.QPE import _m_domain, _phase, _two_pow_t
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = [k]
sub_expr3 = IndexedVar(a, one)
sub_expr4 = ExprRange(sub_expr1, IndexedVar(c, sub_expr1), one, zero)
sub_expr5 = Mult(Exp(e, Mult(two, pi, i, _phase, k)), Exp(e, Neg(frac(Mult(two, pi, i, k, m), _two_pow_t))))
expr = Implies(Forall(instance_param_or_params = sub_expr2, instance_expr = InSet(sub_expr5, Complex), domain = _m_domain), Forall(instance_param_or_params = [sub_expr3, sub_expr4], instance_expr = Equals(Mult(sub_expr3, Sum(index_or_indices = sub_expr2, summand = sub_expr5, domain = _m_domain), sub_expr4), Sum(index_or_indices = sub_expr2, summand = Mult(sub_expr3, sub_expr5, sub_expr4), domain = _m_domain)).with_wrapping_at(2), domain = Complex).with_wrapping()).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 \mathsf{e}^{-\frac{2 \cdot \pi \cdot \mathsf{i} \cdot k \cdot m}{2^{t}}}\right) \in \mathbb{C}\right)\right] \Rightarrow  \\ \left[\begin{array}{l}\forall_{a_{1}, c_{1}, c_{2}, \ldots, c_{0} \in \mathbb{C}}~\\
\left(\begin{array}{c} \begin{array}{l} \left(a_{1} \cdot \left(\sum_{k = 0}^{2^{t} - 1} \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \mathsf{e}^{-\frac{2 \cdot \pi \cdot \mathsf{i} \cdot k \cdot m}{2^{t}}}\right)\right)\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{0}\right) =  \\ \left(\sum_{k = 0}^{2^{t} - 1} \left(a_{1} \cdot \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \mathsf{e}^{-\frac{2 \cdot \pi \cdot \mathsf{i} \cdot k \cdot m}{2^{t}}}\right)\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{0}\right)\right) \end{array} \end{array}\right)\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: 6
operand: 8
4Operationoperator: 6
operand: 9
5ExprTuple8
6Literal
7ExprTuple9
8Lambdaparameter: 87
body: 10
9Lambdaparameters: 11
body: 12
10Conditionalvalue: 13
condition: 42
11ExprTuple43, 45
12Conditionalvalue: 14
condition: 15
13Operationoperator: 46
operands: 16
14Operationoperator: 17
operands: 18
15Operationoperator: 19
operands: 20
16ExprTuple44, 38
17Literal
18ExprTuple21, 22
19Literal
20ExprTuple23, 24
21Operationoperator: 81
operands: 25
22Operationoperator: 32
operand: 30
23Operationoperator: 46
operands: 27
24ExprRangelambda_map: 28
start_index: 78
end_index: 61
25ExprTuple43, 29, 45
26ExprTuple30
27ExprTuple43, 38
28Lambdaparameter: 66
body: 31
29Operationoperator: 32
operand: 36
30Lambdaparameter: 87
body: 34
31Operationoperator: 46
operands: 35
32Literal
33ExprTuple36
34Conditionalvalue: 37
condition: 42
35ExprTuple54, 38
36Lambdaparameter: 87
body: 40
37Operationoperator: 81
operands: 41
38Literal
39ExprTuple87
40Conditionalvalue: 44
condition: 42
41ExprTuple43, 44, 45
42Operationoperator: 46
operands: 47
43IndexedVarvariable: 48
index: 78
44Operationoperator: 81
operands: 49
45ExprRangelambda_map: 50
start_index: 78
end_index: 61
46Literal
47ExprTuple87, 51
48Variable
49ExprTuple52, 53
50Lambdaparameter: 66
body: 54
51Operationoperator: 55
operands: 56
52Operationoperator: 83
operands: 57
53Operationoperator: 83
operands: 58
54IndexedVarvariable: 59
index: 66
55Literal
56ExprTuple61, 62
57ExprTuple64, 63
58ExprTuple64, 65
59Variable
60ExprTuple66
61Literal
62Operationoperator: 67
operands: 68
63Operationoperator: 81
operands: 69
64Literal
65Operationoperator: 74
operand: 73
66Variable
67Literal
68ExprTuple80, 71
69ExprTuple89, 85, 86, 72, 87
70ExprTuple73
71Operationoperator: 74
operand: 78
72Literal
73Operationoperator: 76
operands: 77
74Literal
75ExprTuple78
76Literal
77ExprTuple79, 80
78Literal
79Operationoperator: 81
operands: 82
80Operationoperator: 83
operands: 84
81Literal
82ExprTuple89, 85, 86, 87, 88
83Literal
84ExprTuple89, 90
85Literal
86Literal
87Variable
88Variable
89Literal
90Literal