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(Abs(frac(subtract(one, Exp(e, Mult(two, pi, i, _delta_b_round, _two_pow_t))), subtract(one, Exp(e, Mult(two, pi, i, _delta_b_round))))), frac(Sin(Mult(_two_pow_t, pi, sub_expr1)), Sin(Mult(pi, sub_expr1))))
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 - \mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \delta_{b_{\textit{r}}} \cdot 2^{t}}}{1 - \mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \delta_{b_{\textit{r}}}}}\right| = \frac{\sin{\left(2^{t} \cdot \pi \cdot \left|\delta_{b_{\textit{r}}}\right|\right)}}{\sin{\left(\pi \cdot \left|\delta_{b_{\textit{r}}}\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: 31
operand: 7
4Operationoperator: 10
operands: 6
5ExprTuple7
6ExprTuple8, 9
7Operationoperator: 10
operands: 11
8Operationoperator: 13
operand: 17
9Operationoperator: 13
operand: 18
10Literal
11ExprTuple15, 16
12ExprTuple17
13Literal
14ExprTuple18
15Operationoperator: 20
operands: 19
16Operationoperator: 20
operands: 21
17Operationoperator: 41
operands: 22
18Operationoperator: 41
operands: 23
19ExprTuple25, 24
20Literal
21ExprTuple25, 26
22ExprTuple43, 44, 27
23ExprTuple44, 27
24Operationoperator: 29
operand: 33
25Literal
26Operationoperator: 29
operand: 34
27Operationoperator: 31
operand: 46
28ExprTuple33
29Literal
30ExprTuple34
31Literal
32ExprTuple46
33Operationoperator: 47
operands: 35
34Operationoperator: 47
operands: 36
35ExprTuple38, 37
36ExprTuple38, 39
37Operationoperator: 41
operands: 40
38Literal
39Operationoperator: 41
operands: 42
40ExprTuple51, 44, 45, 46, 43
41Literal
42ExprTuple51, 44, 45, 46
43Operationoperator: 47
operands: 48
44Literal
45Literal
46Operationoperator: 49
operand: 53
47Literal
48ExprTuple51, 52
49Literal
50ExprTuple53
51Literal
52Literal
53Literal