logo

Expression of type InSet

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 Lambda, l
from proveit.logic import Bijections, InSet
from proveit.numbers import Add, Mod
from proveit.physics.quantum.QPE import _b_floor, _full_domain, _m_domain, _two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = InSet(Lambda(l, Mod(Add(_b_floor, l), _two_pow_t)), Bijections(_full_domain, _m_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(b_{\textit{f}} + l\right) ~\textup{mod}~ 2^{t}\right)\right] \in \left[\{-2^{t - 1} + 1~\ldotp \ldotp~2^{t - 1}\} \xrightarrow[\text{onto}]{\text{1-to-1}} \{0~\ldotp \ldotp~2^{t} - 1\}\right]
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
operation'infix' or 'function' style formattinginfixinfix
wrap_positionsposition(s) at which wrapping is to occur; '2 n - 1' is after the nth operand, '2 n' is after the nth operation.()()('with_wrapping_at', 'with_wrap_before_operator', 'with_wrap_after_operator', 'without_wrapping', 'wrap_positions')
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'centercenter('with_justification',)
directionDirection of the relation (normal or reversed)normalnormal('with_direction_reversed', 'is_reversed')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 1
operands: 2
1Literal
2ExprTuple3, 4
3Lambdaparameter: 22
body: 6
4Operationoperator: 7
operands: 8
5ExprTuple22
6Operationoperator: 9
operands: 10
7Literal
8ExprTuple11, 12
9Literal
10ExprTuple13, 26
11Operationoperator: 15
operands: 14
12Operationoperator: 15
operands: 16
13Operationoperator: 34
operands: 17
14ExprTuple18, 29
15Literal
16ExprTuple19, 20
17ExprTuple21, 22
18Operationoperator: 34
operands: 23
19Literal
20Operationoperator: 34
operands: 24
21Literal
22Variable
23ExprTuple25, 40
24ExprTuple26, 37
25Operationoperator: 38
operand: 29
26Operationoperator: 30
operands: 28
27ExprTuple29
28ExprTuple32, 36
29Operationoperator: 30
operands: 31
30Literal
31ExprTuple32, 33
32Literal
33Operationoperator: 34
operands: 35
34Literal
35ExprTuple36, 37
36Literal
37Operationoperator: 38
operand: 40
38Literal
39ExprTuple40
40Literal