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 Conditional, ExprTuple, Lambda, n
from proveit.logic import InSet
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, Conditional(register_meas, InSet(n, 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} \textrm{ if } n \in \{0~\ldotp \ldotp~2^{m} - 1\}\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: 57
body: 3
2ExprTuple57
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operands: 7
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10, 11, 12
8Literal
9ExprTuple57, 13
10ExprTuple14
11ExprTuple15
12ExprTuple16
13Operationoperator: 48
operands: 17
14ExprRangelambda_map: 18
start_index: 54
end_index: 58
15ExprRangelambda_map: 19
start_index: 54
end_index: 58
16ExprRangelambda_map: 20
start_index: 54
end_index: 58
17ExprTuple21, 22
18Lambdaparameter: 53
body: 23
19Lambdaparameter: 53
body: 24
20Lambdaparameter: 53
body: 26
21Literal
22Operationoperator: 27
operands: 28
23Operationoperator: 32
operands: 29
24Operationoperator: 30
operands: 31
25ExprTuple53
26Operationoperator: 32
operands: 33
27Literal
28ExprTuple34, 35
29NamedExprselement: 36
targets: 39
30Literal
31NamedExprsbasis: 37
32Literal
33NamedExprselement: 38
targets: 39
34Operationoperator: 40
operands: 41
35Operationoperator: 42
operand: 54
36Operationoperator: 44
operands: 45
37Literal
38Operationoperator: 46
operands: 47
39Operationoperator: 48
operands: 49
40Literal
41ExprTuple50, 58
42Literal
43ExprTuple54
44Literal
45NamedExprsstate: 51
part: 53
46Literal
47NamedExprsstate: 52
part: 53
48Literal
49ExprTuple54, 58
50Literal
51Variable
52Operationoperator: 55
operands: 56
53Variable
54Literal
55Literal
56ExprTuple57, 58
57Variable
58Variable