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, m, n
from proveit.logic import And, Bijections, InSet, SetOfAll
from proveit.numbers import NaturalPos
from proveit.physics.quantum import m_bit_interval, m_ket_domain, normalized_var_ket_psi, var_ket_psi
from proveit.physics.quantum.circuits import register_meas
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda([m, var_ket_psi], Conditional(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), And(InSet(m, NaturalPos), InSet(var_ket_psi, m_ket_domain), normalized_var_ket_psi))))
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(\left(m, \lvert \psi \rangle\right) \mapsto \left\{\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} \textrm{ if } m \in \mathbb{N}^+ ,  \lvert \psi \rangle \in \mathbb{C}^{2^{m}} ,  \left \|\lvert \psi \rangle\right \| = 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
1Lambdaparameters: 2
body: 3
2ExprTuple88, 81
3Conditionalvalue: 4
condition: 5
4Operationoperator: 38
operands: 6
5Operationoperator: 7
operands: 8
6ExprTuple9, 10
7Literal
8ExprTuple11, 12, 13
9Lambdaparameter: 87
body: 34
10Operationoperator: 14
operands: 15
11Operationoperator: 38
operands: 16
12Operationoperator: 38
operands: 17
13Operationoperator: 18
operands: 19
14Literal
15ExprTuple43, 20
16ExprTuple88, 21
17ExprTuple81, 22
18Literal
19ExprTuple23, 84
20Operationoperator: 24
operand: 30
21Literal
22Operationoperator: 26
operands: 27
23Operationoperator: 28
operand: 81
24Literal
25ExprTuple30
26Literal
27ExprTuple31, 64
28Literal
29ExprTuple81
30Lambdaparameter: 87
body: 33
31Literal
32ExprTuple87
33Conditionalvalue: 34
condition: 35
34Operationoperator: 36
operands: 37
35Operationoperator: 38
operands: 39
36Literal
37ExprTuple40, 41, 42
38Literal
39ExprTuple87, 43
40ExprTuple44
41ExprTuple45
42ExprTuple46
43Operationoperator: 78
operands: 47
44ExprRangelambda_map: 48
start_index: 84
end_index: 88
45ExprRangelambda_map: 49
start_index: 84
end_index: 88
46ExprRangelambda_map: 50
start_index: 84
end_index: 88
47ExprTuple51, 52
48Lambdaparameter: 83
body: 53
49Lambdaparameter: 83
body: 54
50Lambdaparameter: 83
body: 56
51Literal
52Operationoperator: 57
operands: 58
53Operationoperator: 62
operands: 59
54Operationoperator: 60
operands: 61
55ExprTuple83
56Operationoperator: 62
operands: 63
57Literal
58ExprTuple64, 65
59NamedExprselement: 66
targets: 69
60Literal
61NamedExprsbasis: 67
62Literal
63NamedExprselement: 68
targets: 69
64Operationoperator: 70
operands: 71
65Operationoperator: 72
operand: 84
66Operationoperator: 74
operands: 75
67Literal
68Operationoperator: 76
operands: 77
69Operationoperator: 78
operands: 79
70Literal
71ExprTuple80, 88
72Literal
73ExprTuple84
74Literal
75NamedExprsstate: 81
part: 83
76Literal
77NamedExprsstate: 82
part: 83
78Literal
79ExprTuple84, 88
80Literal
81Variable
82Operationoperator: 85
operands: 86
83Variable
84Literal
85Literal
86ExprTuple87, 88
87Variable
88Variable