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, IndexedVar, Variable, a, c, l
from proveit.logic import Equals
from proveit.numbers import Exp, Mult, Sum, frac, one, two, zero
from proveit.physics.quantum.QPE import _diff_l_scaled_delta_floor, _neg_domain
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = [l]
sub_expr3 = IndexedVar(a, one)
sub_expr4 = ExprRange(sub_expr1, IndexedVar(c, sub_expr1), one, zero)
sub_expr5 = frac(one, Exp(_diff_l_scaled_delta_floor, two))
expr = Equals(Mult(sub_expr3, Sum(index_or_indices = sub_expr2, summand = sub_expr5, domain = _neg_domain), sub_expr4), Sum(index_or_indices = sub_expr2, summand = Mult(sub_expr3, sub_expr5, sub_expr4), domain = _neg_domain)).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(a_{1} \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)\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{0}\right) =  \\ \left(\sum_{l = -2^{t - 1} + 1}^{-\left(e + 1\right)} \left(a_{1} \cdot \frac{1}{\left(l - \left(2^{t} \cdot \delta_{b_{\textit{f}}}\right)\right)^{2}}\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{0}\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: 54
operands: 5
4Operationoperator: 9
operand: 8
5ExprTuple18, 7, 20
6ExprTuple8
7Operationoperator: 9
operand: 12
8Lambdaparameter: 45
body: 11
9Literal
10ExprTuple12
11Conditionalvalue: 13
condition: 17
12Lambdaparameter: 45
body: 15
13Operationoperator: 54
operands: 16
14ExprTuple45
15Conditionalvalue: 19
condition: 17
16ExprTuple18, 19, 20
17Operationoperator: 21
operands: 22
18IndexedVarvariable: 23
index: 71
19Operationoperator: 24
operands: 25
20ExprRangelambda_map: 26
start_index: 71
end_index: 27
21Literal
22ExprTuple45, 28
23Variable
24Literal
25ExprTuple71, 29
26Lambdaparameter: 39
body: 30
27Literal
28Operationoperator: 31
operands: 32
29Operationoperator: 61
operands: 33
30IndexedVarvariable: 34
index: 39
31Literal
32ExprTuple36, 37
33ExprTuple38, 66
34Variable
35ExprTuple39
36Operationoperator: 59
operands: 40
37Operationoperator: 69
operand: 44
38Operationoperator: 59
operands: 42
39Variable
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