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 l
from proveit.logic import Equals
from proveit.numbers import Add, Exp, Mult, Sum, four, frac, one, two
from proveit.physics.quantum.QPE import _diff_l_scaled_delta_floor, _neg_domain, _pos_domain
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [l]
sub_expr2 = frac(one, four)
sub_expr3 = Exp(_diff_l_scaled_delta_floor, two)
sub_expr4 = frac(one, sub_expr3)
sub_expr5 = Mult(sub_expr2, Sum(index_or_indices = sub_expr1, summand = sub_expr4, domain = _neg_domain))
expr = Equals(Add(sub_expr5, Sum(index_or_indices = sub_expr1, summand = frac(one, Mult(four, sub_expr3)), domain = _pos_domain)), Add(sub_expr5, Mult(sub_expr2, Sum(index_or_indices = sub_expr1, summand = sub_expr4, domain = _pos_domain))))
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(\left(\frac{1}{4} \cdot \left(\sum_{l = -2^{t - 1} + 1}^{-\left(e + 1\right)} \frac{1}{\left(l - \left(2^{t} \cdot \delta_{b_{\textit{f}}}\right)\right)^{2}}\right)\right) + \left(\sum_{l = e + 1}^{2^{t - 1}} \frac{1}{4 \cdot \left(l - \left(2^{t} \cdot \delta_{b_{\textit{f}}}\right)\right)^{2}}\right)\right) = \left(\left(\frac{1}{4} \cdot \left(\sum_{l = -2^{t - 1} + 1}^{-\left(e + 1\right)} \frac{1}{\left(l - \left(2^{t} \cdot \delta_{b_{\textit{f}}}\right)\right)^{2}}\right)\right) + \left(\frac{1}{4} \cdot \left(\sum_{l = e + 1}^{2^{t - 1}} \frac{1}{\left(l - \left(2^{t} \cdot \delta_{b_{\textit{f}}}\right)\right)^{2}}\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: 69
operands: 5
4Operationoperator: 69
operands: 6
5ExprTuple8, 7
6ExprTuple8, 9
7Operationoperator: 20
operand: 13
8Operationoperator: 64
operands: 11
9Operationoperator: 64
operands: 12
10ExprTuple13
11ExprTuple15, 14
12ExprTuple15, 16
13Lambdaparameter: 55
body: 17
14Operationoperator: 20
operand: 23
15Operationoperator: 35
operands: 19
16Operationoperator: 20
operand: 24
17Conditionalvalue: 22
condition: 32
18ExprTuple23
19ExprTuple81, 39
20Literal
21ExprTuple24
22Operationoperator: 35
operands: 25
23Lambdaparameter: 55
body: 26
24Lambdaparameter: 55
body: 28
25ExprTuple81, 29
26Conditionalvalue: 31
condition: 30
27ExprTuple55
28Conditionalvalue: 31
condition: 32
29Operationoperator: 64
operands: 33
30Operationoperator: 37
operands: 34
31Operationoperator: 35
operands: 36
32Operationoperator: 37
operands: 38
33ExprTuple39, 41
34ExprTuple55, 40
35Literal
36ExprTuple81, 41
37Literal
38ExprTuple55, 42
39Literal
40Operationoperator: 45
operands: 43
41Operationoperator: 71
operands: 44
42Operationoperator: 45
operands: 46
43ExprTuple47, 48
44ExprTuple49, 76
45Literal
46ExprTuple54, 60
47Operationoperator: 69
operands: 50
48Operationoperator: 79
operand: 54
49Operationoperator: 69
operands: 52
50ExprTuple53, 81
51ExprTuple54
52ExprTuple55, 56
53Operationoperator: 79
operand: 60
54Operationoperator: 69
operands: 58
55Variable
56Operationoperator: 79
operand: 62
57ExprTuple60
58ExprTuple61, 81
59ExprTuple62
60Operationoperator: 71
operands: 63
61Variable
62Operationoperator: 64
operands: 65
63ExprTuple76, 66
64Literal
65ExprTuple67, 68
66Operationoperator: 69
operands: 70
67Operationoperator: 71
operands: 72
68Operationoperator: 73
operand: 78
69Literal
70ExprTuple77, 75
71Literal
72ExprTuple76, 77
73Literal
74ExprTuple78
75Operationoperator: 79
operand: 81
76Literal
77Literal
78Literal
79Literal
80ExprTuple81
81Literal