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 And, InSet, NotEquals
from proveit.numbers import Abs, IntervalOC, Mult, frac, pi, subtract, two, zero
from proveit.physics.quantum.QPE import _delta_b_floor, _full_domain, _two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda(l, Conditional(InSet(Mult(pi, Abs(subtract(_delta_b_floor, frac(l, _two_pow_t)))), IntervalOC(zero, frac(pi, two))), And(InSet(l, _full_domain), NotEquals(l, zero)))))
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\{\left(\pi \cdot \left|\delta_{b_{\textit{f}}} - \frac{l}{2^{t}}\right|\right) \in \left(0,\frac{\pi}{2}\right] \textrm{ if } l \in \{-2^{t - 1} + 1~\ldotp \ldotp~2^{t - 1}\} ,  l \neq 0\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: 48
body: 3
2ExprTuple48
3Conditionalvalue: 4
condition: 5
4Operationoperator: 17
operands: 6
5Operationoperator: 7
operands: 8
6ExprTuple9, 10
7Literal
8ExprTuple11, 12
9Operationoperator: 13
operands: 14
10Operationoperator: 15
operands: 16
11Operationoperator: 17
operands: 18
12Operationoperator: 19
operands: 20
13Literal
14ExprTuple31, 21
15Literal
16ExprTuple24, 22
17Literal
18ExprTuple48, 23
19Literal
20ExprTuple48, 24
21Operationoperator: 25
operand: 30
22Operationoperator: 45
operands: 27
23Operationoperator: 28
operands: 29
24Literal
25Literal
26ExprTuple30
27ExprTuple31, 55
28Literal
29ExprTuple32, 44
30Operationoperator: 53
operands: 33
31Literal
32Operationoperator: 53
operands: 34
33ExprTuple35, 36
34ExprTuple37, 60
35Operationoperator: 38
operand: 42
36Operationoperator: 58
operand: 43
37Operationoperator: 58
operand: 44
38Literal
39ExprTuple42
40ExprTuple43
41ExprTuple44
42Literal
43Operationoperator: 45
operands: 46
44Operationoperator: 51
operands: 47
45Literal
46ExprTuple48, 49
47ExprTuple55, 50
48Variable
49Operationoperator: 51
operands: 52
50Operationoperator: 53
operands: 54
51Literal
52ExprTuple55, 56
53Literal
54ExprTuple56, 57
55Literal
56Literal
57Operationoperator: 58
operand: 60
58Literal
59ExprTuple60
60Literal