logo

Expression of type Equals

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
from proveit.logic import Equals
from proveit.numbers import Exp, Mult, Neg, Sum, e, frac, i, one, pi, two
from proveit.physics.quantum.QPE import _m_domain, _phase, _two_pow_t
In [2]:
# build up the expression from sub-expressions
sub_expr1 = frac(one, _two_pow_t)
expr = Equals(Mult(sub_expr1, Sum(index_or_indices = [k], summand = Mult(Exp(e, Neg(frac(Mult(two, pi, i, k, Mult(_two_pow_t, _phase)), _two_pow_t))), Exp(e, Mult(two, pi, i, _phase, k))), domain = _m_domain)), Mult(sub_expr1, _two_pow_t))
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(\frac{1}{2^{t}} \cdot \left(\sum_{k = 0}^{2^{t} - 1} \left(\mathsf{e}^{-\frac{2 \cdot \pi \cdot \mathsf{i} \cdot k \cdot \left(2^{t} \cdot \varphi\right)}{2^{t}}} \cdot \mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k}\right)\right)\right) = \left(\frac{1}{2^{t}} \cdot 2^{t}\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: 49
operands: 5
4Operationoperator: 49
operands: 6
5ExprTuple8, 7
6ExprTuple8, 51
7Operationoperator: 9
operand: 12
8Operationoperator: 38
operands: 11
9Literal
10ExprTuple12
11ExprTuple43, 51
12Lambdaparameter: 47
body: 14
13ExprTuple47
14Conditionalvalue: 15
condition: 16
15Operationoperator: 49
operands: 17
16Operationoperator: 18
operands: 19
17ExprTuple20, 21
18Literal
19ExprTuple47, 22
20Operationoperator: 53
operands: 23
21Operationoperator: 53
operands: 24
22Operationoperator: 25
operands: 26
23ExprTuple28, 27
24ExprTuple28, 29
25Literal
26ExprTuple30, 31
27Operationoperator: 40
operand: 36
28Literal
29Operationoperator: 49
operands: 33
30Literal
31Operationoperator: 34
operands: 35
32ExprTuple36
33ExprTuple55, 45, 46, 52, 47
34Literal
35ExprTuple51, 37
36Operationoperator: 38
operands: 39
37Operationoperator: 40
operand: 43
38Literal
39ExprTuple42, 51
40Literal
41ExprTuple43
42Operationoperator: 49
operands: 44
43Literal
44ExprTuple55, 45, 46, 47, 48
45Literal
46Literal
47Variable
48Operationoperator: 49
operands: 50
49Literal
50ExprTuple51, 52
51Operationoperator: 53
operands: 54
52Literal
53Literal
54ExprTuple55, 56
55Literal
56Literal