logo

Expression of type ExprTuple

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, ExprTuple, 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)
expr = ExprTuple(Lambda(l, Conditional(Equals(frac(one, Mult(four, sub_expr1)), Mult(frac(one, four), frac(one, sub_expr1))), InSet(l, _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(l \mapsto \left\{\frac{1}{4 \cdot \left(l - \left(2^{t} \cdot \delta_{b_{\textit{f}}}\right)\right)^{2}} = \left(\frac{1}{4} \cdot \frac{1}{\left(l - \left(2^{t} \cdot \delta_{b_{\textit{f}}}\right)\right)^{2}}\right) \textrm{ if } l \in \{e + 1~\ldotp \ldotp~2^{t - 1}\}\right..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameter: 39
body: 3
2ExprTuple39
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operands: 7
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10, 11
8Literal
9ExprTuple39, 12
10Operationoperator: 24
operands: 13
11Operationoperator: 45
operands: 14
12Operationoperator: 15
operands: 16
13ExprTuple41, 17
14ExprTuple18, 19
15Literal
16ExprTuple20, 21
17Operationoperator: 45
operands: 22
18Operationoperator: 24
operands: 23
19Operationoperator: 24
operands: 25
20Operationoperator: 36
operands: 26
21Operationoperator: 49
operands: 27
22ExprTuple28, 29
23ExprTuple41, 28
24Literal
25ExprTuple41, 29
26ExprTuple30, 41
27ExprTuple53, 31
28Literal
29Operationoperator: 49
operands: 32
30Variable
31Operationoperator: 36
operands: 33
32ExprTuple34, 53
33ExprTuple54, 35
34Operationoperator: 36
operands: 37
35Operationoperator: 42
operand: 41
36Literal
37ExprTuple39, 40
38ExprTuple41
39Variable
40Operationoperator: 42
operand: 44
41Literal
42Literal
43ExprTuple44
44Operationoperator: 45
operands: 46
45Literal
46ExprTuple47, 48
47Operationoperator: 49
operands: 50
48Operationoperator: 51
operand: 55
49Literal
50ExprTuple53, 54
51Literal
52ExprTuple55
53Literal
54Literal
55Literal