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, Mult(four, sub_expr2))
sub_expr4 = Sum(index_or_indices = sub_expr1, summand = sub_expr3, domain = _pos_domain)
expr = Equals(Add(Sum(index_or_indices = sub_expr1, summand = sub_expr3, domain = _neg_domain), sub_expr4), Add(Mult(frac(one, four), Sum(index_or_indices = sub_expr1, summand = frac(one, sub_expr2), domain = _neg_domain)), sub_expr4))
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(\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)
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: 67
operands: 5
4Operationoperator: 67
operands: 6
5ExprTuple7, 9
6ExprTuple8, 9
7Operationoperator: 19
operand: 13
8Operationoperator: 62
operands: 11
9Operationoperator: 19
operand: 16
10ExprTuple13
11ExprTuple14, 15
12ExprTuple16
13Lambdaparameter: 53
body: 17
14Operationoperator: 33
operands: 18
15Operationoperator: 19
operand: 22
16Lambdaparameter: 53
body: 21
17Conditionalvalue: 23
condition: 30
18ExprTuple79, 40
19Literal
20ExprTuple22
21Conditionalvalue: 23
condition: 24
22Lambdaparameter: 53
body: 26
23Operationoperator: 33
operands: 27
24Operationoperator: 35
operands: 28
25ExprTuple53
26Conditionalvalue: 29
condition: 30
27ExprTuple79, 31
28ExprTuple53, 32
29Operationoperator: 33
operands: 34
30Operationoperator: 35
operands: 36
31Operationoperator: 62
operands: 37
32Operationoperator: 42
operands: 38
33Literal
34ExprTuple79, 41
35Literal
36ExprTuple53, 39
37ExprTuple40, 41
38ExprTuple52, 58
39Operationoperator: 42
operands: 43
40Literal
41Operationoperator: 69
operands: 44
42Literal
43ExprTuple45, 46
44ExprTuple47, 74
45Operationoperator: 67
operands: 48
46Operationoperator: 77
operand: 52
47Operationoperator: 67
operands: 50
48ExprTuple51, 79
49ExprTuple52
50ExprTuple53, 54
51Operationoperator: 77
operand: 58
52Operationoperator: 67
operands: 56
53Variable
54Operationoperator: 77
operand: 60
55ExprTuple58
56ExprTuple59, 79
57ExprTuple60
58Operationoperator: 69
operands: 61
59Variable
60Operationoperator: 62
operands: 63
61ExprTuple74, 64
62Literal
63ExprTuple65, 66
64Operationoperator: 67
operands: 68
65Operationoperator: 69
operands: 70
66Operationoperator: 71
operand: 76
67Literal
68ExprTuple75, 73
69Literal
70ExprTuple74, 75
71Literal
72ExprTuple76
73Operationoperator: 77
operand: 79
74Literal
75Literal
76Literal
77Literal
78ExprTuple79
79Literal