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 Equals, Forall, InSet
from proveit.numbers import Abs, Exp, NaturalPos, two
from proveit.physics.quantum import NumBra, Qmult, m_bit_interval, m_ket_domain, normalized_var_ket_psi, var_ket_psi
from proveit.physics.quantum.circuits import register_meas
from proveit.statistics import Prob
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda(m, Conditional(Forall(instance_param_or_params = [n], instance_expr = Forall(instance_param_or_params = [var_ket_psi], instance_expr = Equals(Prob(register_meas), Exp(Abs(Qmult(NumBra(n, m), var_ket_psi)), two)), domain = m_ket_domain, condition = normalized_var_ket_psi), domain = m_bit_interval), InSet(m, NaturalPos))))
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(m \mapsto \left\{\forall_{n \in \{0~\ldotp \ldotp~2^{m} - 1\}}~\left[\forall_{\lvert \psi \rangle \in \mathbb{C}^{2^{m}}~|~\left \|\lvert \psi \rangle\right \| = 1}~\left(\textrm{Pr}\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|{_{m}}\langle n \rvert \thinspace \lvert \psi \rangle\right|^{2}\right)\right] \textrm{ if } m \in \mathbb{N}^+\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: 101
body: 3
2ExprTuple101
3Conditionalvalue: 4
condition: 5
4Operationoperator: 14
operand: 8
5Operationoperator: 38
operands: 7
6ExprTuple8
7ExprTuple101, 9
8Lambdaparameter: 100
body: 11
9Literal
10ExprTuple100
11Conditionalvalue: 12
condition: 13
12Operationoperator: 14
operand: 17
13Operationoperator: 38
operands: 16
14Literal
15ExprTuple17
16ExprTuple100, 18
17Lambdaparameter: 94
body: 19
18Operationoperator: 92
operands: 20
19Conditionalvalue: 21
condition: 22
20ExprTuple23, 24
21Operationoperator: 40
operands: 25
22Operationoperator: 26
operands: 27
23Literal
24Operationoperator: 28
operands: 29
25ExprTuple30, 31
26Literal
27ExprTuple32, 33
28Literal
29ExprTuple61, 34
30Operationoperator: 35
operand: 44
31Operationoperator: 67
operands: 37
32Operationoperator: 38
operands: 39
33Operationoperator: 40
operands: 41
34Operationoperator: 42
operand: 97
35Literal
36ExprTuple44
37ExprTuple45, 73
38Literal
39ExprTuple94, 46
40Literal
41ExprTuple47, 97
42Literal
43ExprTuple97
44Operationoperator: 48
operands: 49
45Operationoperator: 50
operand: 59
46Operationoperator: 52
operands: 53
47Operationoperator: 54
operand: 94
48Literal
49ExprTuple56, 57, 58
50Literal
51ExprTuple59
52Literal
53ExprTuple60, 61
54Literal
55ExprTuple94
56ExprTuple62
57ExprTuple63
58ExprTuple64
59Operationoperator: 65
operands: 66
60Literal
61Operationoperator: 67
operands: 68
62ExprRangelambda_map: 69
start_index: 97
end_index: 101
63ExprRangelambda_map: 70
start_index: 97
end_index: 101
64ExprRangelambda_map: 71
start_index: 97
end_index: 101
65Literal
66ExprTuple72, 94
67Literal
68ExprTuple73, 101
69Lambdaparameter: 96
body: 74
70Lambdaparameter: 96
body: 75
71Lambdaparameter: 96
body: 77
72Operationoperator: 78
operands: 99
73Literal
74Operationoperator: 82
operands: 79
75Operationoperator: 80
operands: 81
76ExprTuple96
77Operationoperator: 82
operands: 83
78Literal
79NamedExprselement: 84
targets: 87
80Literal
81NamedExprsbasis: 85
82Literal
83NamedExprselement: 86
targets: 87
84Operationoperator: 88
operands: 89
85Literal
86Operationoperator: 90
operands: 91
87Operationoperator: 92
operands: 93
88Literal
89NamedExprsstate: 94
part: 96
90Literal
91NamedExprsstate: 95
part: 96
92Literal
93ExprTuple97, 101
94Variable
95Operationoperator: 98
operands: 99
96Variable
97Literal
98Literal
99ExprTuple100, 101
100Variable
101Variable