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 = Exp(_diff_l_scaled_delta_floor, two)
sub_expr3 = frac(one, sub_expr2)
sub_expr4 = frac(one, Mult(four, sub_expr2))
expr = Equals(Add(Sum(index_or_indices = sub_expr1, summand = sub_expr4, domain = _neg_domain), Sum(index_or_indices = sub_expr1, summand = sub_expr4, domain = _pos_domain)), Mult(frac(one, four), Add(Sum(index_or_indices = sub_expr1, summand = sub_expr3, domain = _neg_domain), Sum(index_or_indices = sub_expr1, summand = sub_expr3, 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(\sum_{l = -2^{t - 1} + 1}^{-\left(e + 1\right)} \frac{1}{4 \cdot \left(l - \left(2^{t} \cdot \delta_{b_{\textit{f}}}\right)\right)^{2}}\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(\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)
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: 71
operands: 5
4Operationoperator: 66
operands: 6
5ExprTuple7, 8
6ExprTuple9, 10
7Operationoperator: 22
operand: 15
8Operationoperator: 22
operand: 16
9Operationoperator: 37
operands: 13
10Operationoperator: 71
operands: 14
11ExprTuple15
12ExprTuple16
13ExprTuple83, 41
14ExprTuple17, 18
15Lambdaparameter: 57
body: 19
16Lambdaparameter: 57
body: 20
17Operationoperator: 22
operand: 25
18Operationoperator: 22
operand: 26
19Conditionalvalue: 24
condition: 32
20Conditionalvalue: 24
condition: 34
21ExprTuple25
22Literal
23ExprTuple26
24Operationoperator: 37
operands: 27
25Lambdaparameter: 57
body: 28
26Lambdaparameter: 57
body: 30
27ExprTuple83, 31
28Conditionalvalue: 33
condition: 32
29ExprTuple57
30Conditionalvalue: 33
condition: 34
31Operationoperator: 66
operands: 35
32Operationoperator: 39
operands: 36
33Operationoperator: 37
operands: 38
34Operationoperator: 39
operands: 40
35ExprTuple41, 43
36ExprTuple57, 42
37Literal
38ExprTuple83, 43
39Literal
40ExprTuple57, 44
41Literal
42Operationoperator: 47
operands: 45
43Operationoperator: 73
operands: 46
44Operationoperator: 47
operands: 48
45ExprTuple49, 50
46ExprTuple51, 78
47Literal
48ExprTuple56, 62
49Operationoperator: 71
operands: 52
50Operationoperator: 81
operand: 56
51Operationoperator: 71
operands: 54
52ExprTuple55, 83
53ExprTuple56
54ExprTuple57, 58
55Operationoperator: 81
operand: 62
56Operationoperator: 71
operands: 60
57Variable
58Operationoperator: 81
operand: 64
59ExprTuple62
60ExprTuple63, 83
61ExprTuple64
62Operationoperator: 73
operands: 65
63Variable
64Operationoperator: 66
operands: 67
65ExprTuple78, 68
66Literal
67ExprTuple69, 70
68Operationoperator: 71
operands: 72
69Operationoperator: 73
operands: 74
70Operationoperator: 75
operand: 80
71Literal
72ExprTuple79, 77
73Literal
74ExprTuple78, 79
75Literal
76ExprTuple80
77Operationoperator: 81
operand: 83
78Literal
79Literal
80Literal
81Literal
82ExprTuple83
83Literal