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 ExprRange, Variable, l
from proveit.core_expr_types import Len
from proveit.logic import Equals
from proveit.numbers import Exp, Sum, 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 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = [l]
sub_expr3 = frac(one, Exp(_diff_l_scaled_delta_floor, two))
expr = Equals(Len(operands = [Sum(index_or_indices = sub_expr2, summand = sub_expr3, domain = _neg_domain), Sum(index_or_indices = sub_expr2, summand = sub_expr3, domain = _pos_domain)]), Len(operands = [ExprRange(sub_expr1, sub_expr1, one, two)]))
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(\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}}, \sum_{l = e + 1}^{2^{t - 1}} \frac{1}{\left(l - \left(2^{t} \cdot \delta_{b_{\textit{f}}}\right)\right)^{2}}\right)| = |\left(1, \ldots, 2\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: 6
operands: 5
4Operationoperator: 6
operands: 7
5ExprTuple8, 9
6Literal
7ExprTuple10
8Operationoperator: 12
operand: 15
9Operationoperator: 12
operand: 16
10ExprRangelambda_map: 14
start_index: 71
end_index: 66
11ExprTuple15
12Literal
13ExprTuple16
14Lambdaparameter: 21
body: 21
15Lambdaparameter: 45
body: 18
16Lambdaparameter: 45
body: 20
17ExprTuple21
18Conditionalvalue: 23
condition: 22
19ExprTuple45
20Conditionalvalue: 23
condition: 24
21Variable
22Operationoperator: 28
operands: 25
23Operationoperator: 26
operands: 27
24Operationoperator: 28
operands: 29
25ExprTuple45, 30
26Literal
27ExprTuple71, 31
28Literal
29ExprTuple45, 32
30Operationoperator: 35
operands: 33
31Operationoperator: 61
operands: 34
32Operationoperator: 35
operands: 36
33ExprTuple37, 38
34ExprTuple39, 66
35Literal
36ExprTuple44, 50
37Operationoperator: 59
operands: 40
38Operationoperator: 69
operand: 44
39Operationoperator: 59
operands: 42
40ExprTuple43, 71
41ExprTuple44
42ExprTuple45, 46
43Operationoperator: 69
operand: 50
44Operationoperator: 59
operands: 48
45Variable
46Operationoperator: 69
operand: 52
47ExprTuple50
48ExprTuple51, 71
49ExprTuple52
50Operationoperator: 61
operands: 53
51Variable
52Operationoperator: 54
operands: 55
53ExprTuple66, 56
54Literal
55ExprTuple57, 58
56Operationoperator: 59
operands: 60
57Operationoperator: 61
operands: 62
58Operationoperator: 63
operand: 68
59Literal
60ExprTuple67, 65
61Literal
62ExprTuple66, 67
63Literal
64ExprTuple68
65Operationoperator: 69
operand: 71
66Literal
67Literal
68Literal
69Literal
70ExprTuple71
71Literal