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 InSet
from proveit.numbers import IntervalCO, Neg, frac, one, subtract, two
from proveit.physics.quantum.QPE import _delta_b_floor, _full_domain, _two_pow_t
In [2]:
# build up the expression from sub-expressions
sub_expr1 = frac(one, two)
expr = ExprTuple(Lambda(l, Conditional(InSet(subtract(_delta_b_floor, frac(l, _two_pow_t)), IntervalCO(Neg(sub_expr1), sub_expr1)), InSet(l, _full_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\{\left(\delta_{b_{\textit{f}}} - \frac{l}{2^{t}}\right) \in \left[-\frac{1}{2},\frac{1}{2}\right) \textrm{ if } l \in \{-2^{t - 1} + 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: 34
body: 3
2ExprTuple34
3Conditionalvalue: 4
condition: 5
4Operationoperator: 7
operands: 6
5Operationoperator: 7
operands: 8
6ExprTuple9, 10
7Literal
8ExprTuple34, 11
9Operationoperator: 42
operands: 12
10Operationoperator: 13
operands: 14
11Operationoperator: 15
operands: 16
12ExprTuple17, 18
13Literal
14ExprTuple19, 28
15Literal
16ExprTuple20, 36
17Operationoperator: 21
operand: 26
18Operationoperator: 46
operand: 27
19Operationoperator: 46
operand: 28
20Operationoperator: 42
operands: 25
21Literal
22ExprTuple26
23ExprTuple27
24ExprTuple28
25ExprTuple29, 48
26Literal
27Operationoperator: 31
operands: 30
28Operationoperator: 31
operands: 32
29Operationoperator: 46
operand: 36
30ExprTuple34, 35
31Literal
32ExprTuple48, 40
33ExprTuple36
34Variable
35Operationoperator: 38
operands: 37
36Operationoperator: 38
operands: 39
37ExprTuple40, 44
38Literal
39ExprTuple40, 41
40Literal
41Operationoperator: 42
operands: 43
42Literal
43ExprTuple44, 45
44Literal
45Operationoperator: 46
operand: 48
46Literal
47ExprTuple48
48Literal