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, e, m
from proveit.logic import And, InSet, TRUE
from proveit.numbers import ModAbs, greater, subtract
from proveit.physics.quantum.QPE import _b_floor, _m_domain, _two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda(m, Conditional(TRUE, And(InSet(m, _m_domain), greater(ModAbs(subtract(m, _b_floor), _two_pow_t), e)))))
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\{\top \textrm{ if } m \in \{0~\ldotp \ldotp~2^{t} - 1\} ,  \left|m - b_{\textit{f}}\right|_{\textup{mod}\thinspace 2^{t}} > e\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: 29
body: 3
2ExprTuple29
3Conditionalvalue: 4
condition: 5
4Literal
5Operationoperator: 6
operands: 7
6Literal
7ExprTuple8, 9
8Operationoperator: 10
operands: 11
9Operationoperator: 12
operands: 13
10Literal
11ExprTuple29, 14
12Literal
13ExprTuple15, 16
14Operationoperator: 17
operands: 18
15Variable
16Operationoperator: 19
operands: 20
17Literal
18ExprTuple21, 22
19Literal
20ExprTuple23, 27
21Literal
22Operationoperator: 25
operands: 24
23Operationoperator: 25
operands: 26
24ExprTuple27, 28
25Literal
26ExprTuple29, 30
27Operationoperator: 31
operands: 32
28Operationoperator: 34
operand: 38
29Variable
30Operationoperator: 34
operand: 39
31Literal
32ExprTuple36, 37
33ExprTuple38
34Literal
35ExprTuple39
36Literal
37Literal
38Literal
39Literal