logo

Expression of type Lambda

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.physics.quantum.circuits import register_meas
In [2]:
# build up the expression from sub-expressions
expr = Lambda(n, register_meas)
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())
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)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 39
body: 2
1ExprTuple39
2Operationoperator: 3
operands: 4
3Literal
4ExprTuple5, 6, 7
5ExprTuple8
6ExprTuple9
7ExprTuple10
8ExprRangelambda_map: 11
start_index: 36
end_index: 40
9ExprRangelambda_map: 12
start_index: 36
end_index: 40
10ExprRangelambda_map: 13
start_index: 36
end_index: 40
11Lambdaparameter: 35
body: 14
12Lambdaparameter: 35
body: 15
13Lambdaparameter: 35
body: 17
14Operationoperator: 21
operands: 18
15Operationoperator: 19
operands: 20
16ExprTuple35
17Operationoperator: 21
operands: 22
18NamedExprselement: 23
targets: 26
19Literal
20NamedExprsbasis: 24
21Literal
22NamedExprselement: 25
targets: 26
23Operationoperator: 27
operands: 28
24Literal
25Operationoperator: 29
operands: 30
26Operationoperator: 31
operands: 32
27Literal
28NamedExprsstate: 33
part: 35
29Literal
30NamedExprsstate: 34
part: 35
31Literal
32ExprTuple36, 40
33Variable
34Operationoperator: 37
operands: 38
35Variable
36Literal
37Literal
38ExprTuple39, 40
39Variable
40Variable