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 = frac(one, Exp(_diff_l_scaled_delta_floor, two))
sub_expr4 = Sum(index_or_indices = sub_expr1, summand = sub_expr3, domain = _pos_domain)
sub_expr5 = Sum(index_or_indices = sub_expr1, summand = sub_expr3, domain = _neg_domain)
expr = Equals(Mult(sub_expr2, Add(sub_expr5, sub_expr4)), Add(Mult(sub_expr2, sub_expr5), Mult(sub_expr2, sub_expr4))).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} \left(\frac{1}{4} \cdot \left(\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) + \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) =  \\ \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) \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: 58
operands: 5
4Operationoperator: 63
operands: 6
5ExprTuple14, 7
6ExprTuple8, 9
7Operationoperator: 63
operands: 10
8Operationoperator: 58
operands: 11
9Operationoperator: 58
operands: 12
10ExprTuple13, 15
11ExprTuple14, 13
12ExprTuple14, 15
13Operationoperator: 18
operand: 20
14Operationoperator: 30
operands: 17
15Operationoperator: 18
operand: 22
16ExprTuple20
17ExprTuple75, 21
18Literal
19ExprTuple22
20Lambdaparameter: 49
body: 23
21Literal
22Lambdaparameter: 49
body: 25
23Conditionalvalue: 27
condition: 26
24ExprTuple49
25Conditionalvalue: 27
condition: 28
26Operationoperator: 32
operands: 29
27Operationoperator: 30
operands: 31
28Operationoperator: 32
operands: 33
29ExprTuple49, 34
30Literal
31ExprTuple75, 35
32Literal
33ExprTuple49, 36
34Operationoperator: 39
operands: 37
35Operationoperator: 65
operands: 38
36Operationoperator: 39
operands: 40
37ExprTuple41, 42
38ExprTuple43, 70
39Literal
40ExprTuple48, 54
41Operationoperator: 63
operands: 44
42Operationoperator: 73
operand: 48
43Operationoperator: 63
operands: 46
44ExprTuple47, 75
45ExprTuple48
46ExprTuple49, 50
47Operationoperator: 73
operand: 54
48Operationoperator: 63
operands: 52
49Variable
50Operationoperator: 73
operand: 56
51ExprTuple54
52ExprTuple55, 75
53ExprTuple56
54Operationoperator: 65
operands: 57
55Variable
56Operationoperator: 58
operands: 59
57ExprTuple70, 60
58Literal
59ExprTuple61, 62
60Operationoperator: 63
operands: 64
61Operationoperator: 65
operands: 66
62Operationoperator: 67
operand: 72
63Literal
64ExprTuple71, 69
65Literal
66ExprTuple70, 71
67Literal
68ExprTuple72
69Operationoperator: 73
operand: 75
70Literal
71Literal
72Literal
73Literal
74ExprTuple75
75Literal