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, m
from proveit.logic import And, InSet
from proveit.numbers import Exp, LessEq, ModAbs, one, subtract, two
from proveit.physics.quantum.QPE import _b_floor, _m_domain, _n, _success_cond, _t, _two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda(m, Conditional(_success_cond, And(InSet(m, _m_domain), LessEq(ModAbs(subtract(m, _b_floor), _two_pow_t), subtract(Exp(two, subtract(_t, _n)), one))))))
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(m \mapsto \left\{\left|\frac{m}{2^{t}} - \varphi\right|_{\textup{mod}\thinspace 1} \leq 2^{-n} \textrm{ if } m \in \{0~\ldotp \ldotp~2^{t} - 1\} ,  \left|m - b_{\textit{f}}\right|_{\textup{mod}\thinspace 2^{t}} \leq \left(2^{t - n} - 1\right)\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: 44
body: 3
2ExprTuple44
3Conditionalvalue: 4
condition: 5
4Operationoperator: 17
operands: 6
5Operationoperator: 7
operands: 8
6ExprTuple9, 10
7Literal
8ExprTuple11, 12
9Operationoperator: 26
operands: 13
10Operationoperator: 47
operands: 14
11Operationoperator: 15
operands: 16
12Operationoperator: 17
operands: 18
13ExprTuple19, 54
14ExprTuple53, 57
15Literal
16ExprTuple44, 20
17Literal
18ExprTuple21, 22
19Operationoperator: 51
operands: 23
20Operationoperator: 24
operands: 25
21Operationoperator: 26
operands: 27
22Operationoperator: 51
operands: 28
23ExprTuple29, 30
24Literal
25ExprTuple31, 32
26Literal
27ExprTuple33, 42
28ExprTuple34, 43
29Operationoperator: 35
operands: 36
30Operationoperator: 58
operand: 41
31Literal
32Operationoperator: 51
operands: 38
33Operationoperator: 51
operands: 39
34Operationoperator: 47
operands: 40
35Literal
36ExprTuple44, 42
37ExprTuple41
38ExprTuple42, 43
39ExprTuple44, 45
40ExprTuple53, 46
41Literal
42Operationoperator: 47
operands: 48
43Operationoperator: 58
operand: 54
44Variable
45Operationoperator: 58
operand: 55
46Operationoperator: 51
operands: 52
47Literal
48ExprTuple53, 56
49ExprTuple54
50ExprTuple55
51Literal
52ExprTuple56, 57
53Literal
54Literal
55Literal
56Literal
57Operationoperator: 58
operand: 60
58Literal
59ExprTuple60
60Literal