logo

Expression of type Bijections

from the theory of proveit.physics.quantum.circuits

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 n
from proveit.logic import Bijections, SetOfAll
from proveit.physics.quantum import m_bit_interval
from proveit.physics.quantum.circuits import register_meas
In [2]:
# build up the expression from sub-expressions
expr = Bijections(m_bit_interval, SetOfAll(instance_param_or_params = [n], instance_element = register_meas, domain = m_bit_interval))
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[\{0~\ldotp \ldotp~2^{m} - 1\} \xrightarrow[\text{onto}]{\text{1-to-1}} \left\{\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\multiqin{3}{\lvert \psi \rangle} & \meter & \multiqout{3}{\lvert n \rangle_{m}} \\
\ghostqin{\lvert \psi \rangle} & \meter & \ghostqout{\lvert n \rangle_{m}} \\
\ghostqin{\lvert \psi \rangle} & \measure{\begin{array}{c}:\\ \left(m - 3\right) \times \\:\end{array}} \qw & \ghostqout{\lvert n \rangle_{m}} \\
\ghostqin{\lvert \psi \rangle} & \meter & \ghostqout{\lvert n \rangle_{m}}
} \end{array}\right\}_{n \in \{0~\ldotp \ldotp~2^{m} - 1\}}\right]
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
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',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 1
operands: 2
1Literal
2ExprTuple18, 3
3Operationoperator: 4
operand: 6
4Literal
5ExprTuple6
6Lambdaparameter: 62
body: 8
7ExprTuple62
8Conditionalvalue: 9
condition: 10
9Operationoperator: 11
operands: 12
10Operationoperator: 13
operands: 14
11Literal
12ExprTuple15, 16, 17
13Literal
14ExprTuple62, 18
15ExprTuple19
16ExprTuple20
17ExprTuple21
18Operationoperator: 53
operands: 22
19ExprRangelambda_map: 23
start_index: 59
end_index: 63
20ExprRangelambda_map: 24
start_index: 59
end_index: 63
21ExprRangelambda_map: 25
start_index: 59
end_index: 63
22ExprTuple26, 27
23Lambdaparameter: 58
body: 28
24Lambdaparameter: 58
body: 29
25Lambdaparameter: 58
body: 31
26Literal
27Operationoperator: 32
operands: 33
28Operationoperator: 37
operands: 34
29Operationoperator: 35
operands: 36
30ExprTuple58
31Operationoperator: 37
operands: 38
32Literal
33ExprTuple39, 40
34NamedExprselement: 41
targets: 44
35Literal
36NamedExprsbasis: 42
37Literal
38NamedExprselement: 43
targets: 44
39Operationoperator: 45
operands: 46
40Operationoperator: 47
operand: 59
41Operationoperator: 49
operands: 50
42Literal
43Operationoperator: 51
operands: 52
44Operationoperator: 53
operands: 54
45Literal
46ExprTuple55, 63
47Literal
48ExprTuple59
49Literal
50NamedExprsstate: 56
part: 58
51Literal
52NamedExprsstate: 57
part: 58
53Literal
54ExprTuple59, 63
55Literal
56Variable
57Operationoperator: 60
operands: 61
58Variable
59Literal
60Literal
61ExprTuple62, 63
62Variable
63Variable