logo

Expression of type ExprTuple

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 ExprTuple, Lambda, 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 = ExprTuple(Lambda(n, register_meas), 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(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), \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]\right)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
wrap_positionsposition(s) at which wrapping is to occur; 'n' is after the nth comma.()()('with_wrapping_at',)
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'leftleft('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1, 2
1Lambdaparameter: 64
body: 11
2Operationoperator: 3
operands: 4
3Literal
4ExprTuple20, 5
5Operationoperator: 6
operand: 8
6Literal
7ExprTuple8
8Lambdaparameter: 64
body: 10
9ExprTuple64
10Conditionalvalue: 11
condition: 12
11Operationoperator: 13
operands: 14
12Operationoperator: 15
operands: 16
13Literal
14ExprTuple17, 18, 19
15Literal
16ExprTuple64, 20
17ExprTuple21
18ExprTuple22
19ExprTuple23
20Operationoperator: 55
operands: 24
21ExprRangelambda_map: 25
start_index: 61
end_index: 65
22ExprRangelambda_map: 26
start_index: 61
end_index: 65
23ExprRangelambda_map: 27
start_index: 61
end_index: 65
24ExprTuple28, 29
25Lambdaparameter: 60
body: 30
26Lambdaparameter: 60
body: 31
27Lambdaparameter: 60
body: 33
28Literal
29Operationoperator: 34
operands: 35
30Operationoperator: 39
operands: 36
31Operationoperator: 37
operands: 38
32ExprTuple60
33Operationoperator: 39
operands: 40
34Literal
35ExprTuple41, 42
36NamedExprselement: 43
targets: 46
37Literal
38NamedExprsbasis: 44
39Literal
40NamedExprselement: 45
targets: 46
41Operationoperator: 47
operands: 48
42Operationoperator: 49
operand: 61
43Operationoperator: 51
operands: 52
44Literal
45Operationoperator: 53
operands: 54
46Operationoperator: 55
operands: 56
47Literal
48ExprTuple57, 65
49Literal
50ExprTuple61
51Literal
52NamedExprsstate: 58
part: 60
53Literal
54NamedExprsstate: 59
part: 60
55Literal
56ExprTuple61, 65
57Literal
58Variable
59Operationoperator: 62
operands: 63
60Variable
61Literal
62Literal
63ExprTuple64, 65
64Variable
65Variable