logo

Expression of type InSet

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 Lambda, n
from proveit.logic import Bijections, InSet, 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 = InSet(Lambda(n, register_meas), Bijections(m_bit_interval, SetOfAll(instance_param_or_params = [n], instance_element = register_meas, domain = m_bit_interval))).with_wrapping_at(2)
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())
\begin{array}{c} \begin{array}{l} \left[n \mapsto \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)\right] \in  \\ \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] \end{array} \end{array}
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.()(2)('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: 16
operands: 1
1ExprTuple2, 3
2Lambdaparameter: 65
body: 12
3Operationoperator: 4
operands: 5
4Literal
5ExprTuple21, 6
6Operationoperator: 7
operand: 9
7Literal
8ExprTuple9
9Lambdaparameter: 65
body: 11
10ExprTuple65
11Conditionalvalue: 12
condition: 13
12Operationoperator: 14
operands: 15
13Operationoperator: 16
operands: 17
14Literal
15ExprTuple18, 19, 20
16Literal
17ExprTuple65, 21
18ExprTuple22
19ExprTuple23
20ExprTuple24
21Operationoperator: 56
operands: 25
22ExprRangelambda_map: 26
start_index: 62
end_index: 66
23ExprRangelambda_map: 27
start_index: 62
end_index: 66
24ExprRangelambda_map: 28
start_index: 62
end_index: 66
25ExprTuple29, 30
26Lambdaparameter: 61
body: 31
27Lambdaparameter: 61
body: 32
28Lambdaparameter: 61
body: 34
29Literal
30Operationoperator: 35
operands: 36
31Operationoperator: 40
operands: 37
32Operationoperator: 38
operands: 39
33ExprTuple61
34Operationoperator: 40
operands: 41
35Literal
36ExprTuple42, 43
37NamedExprselement: 44
targets: 47
38Literal
39NamedExprsbasis: 45
40Literal
41NamedExprselement: 46
targets: 47
42Operationoperator: 48
operands: 49
43Operationoperator: 50
operand: 62
44Operationoperator: 52
operands: 53
45Literal
46Operationoperator: 54
operands: 55
47Operationoperator: 56
operands: 57
48Literal
49ExprTuple58, 66
50Literal
51ExprTuple62
52Literal
53NamedExprsstate: 59
part: 61
54Literal
55NamedExprsstate: 60
part: 61
56Literal
57ExprTuple62, 66
58Literal
59Variable
60Operationoperator: 63
operands: 64
61Variable
62Literal
63Literal
64ExprTuple65, 66
65Variable
66Variable