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, _pos_domain
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Exp(_diff_l_scaled_delta_floor, two)
sub_expr2 = InSet(l, _pos_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 \{e + 1~\ldotp \ldotp~2^{t - 1}\}\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 \{e + 1~\ldotp \ldotp~2^{t - 1}\}\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
11ExprTuple45, 15
12ExprTuple16, 17
13Literal
14ExprTuple38, 18
15Operationoperator: 46
operands: 19
16Operationoperator: 21
operands: 20
17Operationoperator: 21
operands: 22
18Operationoperator: 23
operands: 24
19ExprTuple25, 26
20ExprTuple45, 25
21Literal
22ExprTuple45, 26
23Literal
24ExprTuple27, 28
25Literal
26Operationoperator: 50
operands: 29
27Operationoperator: 36
operands: 30
28Operationoperator: 50
operands: 31
29ExprTuple32, 54
30ExprTuple33, 45
31ExprTuple54, 34
32Operationoperator: 36
operands: 35
33Variable
34Operationoperator: 36
operands: 37
35ExprTuple38, 39
36Literal
37ExprTuple55, 40
38Variable
39Operationoperator: 42
operand: 44
40Operationoperator: 42
operand: 45
41ExprTuple44
42Literal
43ExprTuple45
44Operationoperator: 46
operands: 47
45Literal
46Literal
47ExprTuple48, 49
48Operationoperator: 50
operands: 51
49Operationoperator: 52
operand: 56
50Literal
51ExprTuple54, 55
52Literal
53ExprTuple56
54Literal
55Literal
56Literal