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 Conditional, Lambda, l
from proveit.logic import Equals, InSet
from proveit.numbers import Exp, Mult, four, frac, one, two
from proveit.physics.quantum.QPE import _diff_l_scaled_delta_floor, _neg_domain
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Exp(_diff_l_scaled_delta_floor, two)
sub_expr2 = InSet(l, _neg_domain)
expr = Equals(Lambda(l, Conditional(frac(one, Mult(four, sub_expr1)), sub_expr2)), Lambda(l, Conditional(Mult(frac(one, four), frac(one, sub_expr1)), sub_expr2))).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[l \mapsto \left\{\frac{1}{4 \cdot \left(l - \left(2^{t} \cdot \delta_{b_{\textit{f}}}\right)\right)^{2}} \textrm{ if } l \in \{-2^{t - 1} + 1~\ldotp \ldotp~-\left(e + 1\right)\}\right..\right] =  \\ \left[l \mapsto \left\{\frac{1}{4} \cdot \frac{1}{\left(l - \left(2^{t} \cdot \delta_{b_{\textit{f}}}\right)\right)^{2}} \textrm{ if } l \in \{-2^{t - 1} + 1~\ldotp \ldotp~-\left(e + 1\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
3Lambdaparameter: 38
body: 5
4Lambdaparameter: 38
body: 7
5Conditionalvalue: 8
condition: 10
6ExprTuple38
7Conditionalvalue: 9
condition: 10
8Operationoperator: 21
operands: 11
9Operationoperator: 46
operands: 12
10Operationoperator: 13
operands: 14
11ExprTuple62, 15
12ExprTuple16, 17
13Literal
14ExprTuple38, 18
15Operationoperator: 46
operands: 19
16Operationoperator: 21
operands: 20
17Operationoperator: 21
operands: 22
18Operationoperator: 23
operands: 24
19ExprTuple25, 26
20ExprTuple62, 25
21Literal
22ExprTuple62, 26
23Literal
24ExprTuple27, 28
25Literal
26Operationoperator: 53
operands: 29
27Operationoperator: 48
operands: 30
28Operationoperator: 57
operand: 34
29ExprTuple32, 59
30ExprTuple33, 62
31ExprTuple34
32Operationoperator: 48
operands: 35
33Operationoperator: 57
operand: 40
34Operationoperator: 48
operands: 37
35ExprTuple38, 39
36ExprTuple40
37ExprTuple41, 62
38Variable
39Operationoperator: 57
operand: 44
40Operationoperator: 53
operands: 43
41Variable
42ExprTuple44
43ExprTuple59, 45
44Operationoperator: 46
operands: 47
45Operationoperator: 48
operands: 49
46Literal
47ExprTuple50, 51
48Literal
49ExprTuple60, 52
50Operationoperator: 53
operands: 54
51Operationoperator: 55
operand: 61
52Operationoperator: 57
operand: 62
53Literal
54ExprTuple59, 60
55Literal
56ExprTuple61
57Literal
58ExprTuple62
59Literal
60Literal
61Literal
62Literal