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, b, l
from proveit.logic import And, InSet, NotEquals, NotInSet, Set
from proveit.numbers import Integer, frac, subtract, zero
from proveit.physics.quantum.QPE import _b_floor, _b_round, _delta_b, _full_domain, _two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda([b, l], Conditional(NotInSet(subtract(_delta_b, frac(l, _two_pow_t)), Integer), And(InSet(b, Set(_b_floor, _b_round)), 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(\left(b, l\right) \mapsto \left\{\left(\delta_{b} - \frac{l}{2^{t}}\right) \notin \mathbb{Z} \textrm{ if } b \in \left\{b_{\textit{f}}, b_{\textit{r}}\right\} ,  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
1Lambdaparameters: 2
body: 3
2ExprTuple33, 41
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operands: 7
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10, 11
8Literal
9ExprTuple12, 13, 14
10Operationoperator: 51
operands: 15
11Literal
12Operationoperator: 17
operands: 16
13Operationoperator: 17
operands: 18
14Operationoperator: 19
operands: 20
15ExprTuple21, 22
16ExprTuple33, 23
17Literal
18ExprTuple41, 24
19Literal
20ExprTuple41, 25
21Operationoperator: 26
operand: 33
22Operationoperator: 55
operand: 34
23Operationoperator: 29
operands: 30
24Operationoperator: 31
operands: 32
25Literal
26Literal
27ExprTuple33
28ExprTuple34
29Literal
30ExprTuple35, 36
31Literal
32ExprTuple37, 46
33Variable
34Operationoperator: 38
operands: 39
35Literal
36Literal
37Operationoperator: 51
operands: 40
38Literal
39ExprTuple41, 42
40ExprTuple43, 57
41Variable
42Operationoperator: 47
operands: 44
43Operationoperator: 55
operand: 46
44ExprTuple49, 53
45ExprTuple46
46Operationoperator: 47
operands: 48
47Literal
48ExprTuple49, 50
49Literal
50Operationoperator: 51
operands: 52
51Literal
52ExprTuple53, 54
53Literal
54Operationoperator: 55
operand: 57
55Literal
56ExprTuple57
57Literal