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.linear_algebra import ScalarMult, VecAdd, VecSum
from proveit.logic import Equals
from proveit.numbers import Exp, Interval, Mult, e, frac, i, one, pi, sqrt, two, zero
from proveit.physics.quantum import Ket, ket0, ket1
from proveit.physics.quantum.QPE import _phase
In [2]:
# build up the expression from sub-expressions
sub_expr1 = frac(one, sqrt(two))
expr = Equals(ScalarMult(sub_expr1, VecSum(index_or_indices = [k], summand = ScalarMult(Exp(e, Mult(two, pi, i, _phase, k)), Ket(k)), domain = Interval(zero, one))), ScalarMult(sub_expr1, VecAdd(ket0, ScalarMult(Exp(e, Mult(two, pi, i, _phase)), ket1))))
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}{\sqrt{2}} \cdot \left(\sum_{k=0}^{1} \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \lvert k \rangle\right)\right)\right) = \left(\frac{1}{\sqrt{2}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi} \cdot \lvert 1 \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: 28
operands: 5
4Operationoperator: 28
operands: 6
5ExprTuple8, 7
6ExprTuple8, 9
7Operationoperator: 10
operand: 15
8Operationoperator: 32
operands: 12
9Operationoperator: 13
operands: 14
10Literal
11ExprTuple15
12ExprTuple50, 16
13Literal
14ExprTuple17, 18
15Lambdaparameter: 57
body: 19
16Operationoperator: 40
operands: 20
17Operationoperator: 42
operand: 49
18Operationoperator: 28
operands: 22
19Conditionalvalue: 23
condition: 24
20ExprTuple53, 25
21ExprTuple49
22ExprTuple26, 27
23Operationoperator: 28
operands: 29
24Operationoperator: 30
operands: 31
25Operationoperator: 32
operands: 33
26Operationoperator: 40
operands: 34
27Operationoperator: 42
operand: 50
28Literal
29ExprTuple36, 37
30Literal
31ExprTuple57, 38
32Literal
33ExprTuple50, 53
34ExprTuple47, 39
35ExprTuple50
36Operationoperator: 40
operands: 41
37Operationoperator: 42
operand: 57
38Operationoperator: 44
operands: 45
39Operationoperator: 51
operands: 46
40Literal
41ExprTuple47, 48
42Literal
43ExprTuple57
44Literal
45ExprTuple49, 50
46ExprTuple53, 54, 55, 56
47Literal
48Operationoperator: 51
operands: 52
49Literal
50Literal
51Literal
52ExprTuple53, 54, 55, 56, 57
53Literal
54Literal
55Literal
56Literal
57Variable