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.logic import Equals
from proveit.numbers import Abs, Exp, Mult, e, frac, i, one, pi, subtract, two
from proveit.physics.quantum.QPE import _delta_b_round, _two_pow_t
from proveit.trigonometry import Sin
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Abs(_delta_b_round)
expr = Equals(frac(Abs(subtract(one, Exp(e, Mult(two, pi, i, _delta_b_round, _two_pow_t)))), Abs(subtract(one, Exp(e, Mult(two, pi, i, _delta_b_round))))), frac(Mult(two, Sin(Mult(_two_pow_t, pi, sub_expr1))), Mult(two, Sin(Mult(pi, sub_expr1))))).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} \frac{\left|1 - \mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \delta_{b_{\textit{r}}} \cdot 2^{t}}\right|}{\left|1 - \mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \delta_{b_{\textit{r}}}}\right|} =  \\ \frac{2 \cdot \sin{\left(2^{t} \cdot \pi \cdot \left|\delta_{b_{\textit{r}}}\right|\right)}}{2 \cdot \sin{\left(\pi \cdot \left|\delta_{b_{\textit{r}}}\right|\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
operands: 5
4Operationoperator: 6
operands: 7
5ExprTuple8, 9
6Literal
7ExprTuple10, 11
8Operationoperator: 41
operand: 16
9Operationoperator: 41
operand: 17
10Operationoperator: 47
operands: 14
11Operationoperator: 47
operands: 15
12ExprTuple16
13ExprTuple17
14ExprTuple57, 18
15ExprTuple57, 19
16Operationoperator: 21
operands: 20
17Operationoperator: 21
operands: 22
18Operationoperator: 24
operand: 29
19Operationoperator: 24
operand: 30
20ExprTuple27, 26
21Literal
22ExprTuple27, 28
23ExprTuple29
24Literal
25ExprTuple30
26Operationoperator: 32
operand: 36
27Literal
28Operationoperator: 32
operand: 37
29Operationoperator: 47
operands: 34
30Operationoperator: 47
operands: 35
31ExprTuple36
32Literal
33ExprTuple37
34ExprTuple49, 50, 38
35ExprTuple50, 38
36Operationoperator: 53
operands: 39
37Operationoperator: 53
operands: 40
38Operationoperator: 41
operand: 52
39ExprTuple44, 43
40ExprTuple44, 45
41Literal
42ExprTuple52
43Operationoperator: 47
operands: 46
44Literal
45Operationoperator: 47
operands: 48
46ExprTuple57, 50, 51, 52, 49
47Literal
48ExprTuple57, 50, 51, 52
49Operationoperator: 53
operands: 54
50Literal
51Literal
52Operationoperator: 55
operand: 59
53Literal
54ExprTuple57, 58
55Literal
56ExprTuple59
57Literal
58Literal
59Literal