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, U, m
from proveit.linear_algebra import ScalarMult, Unitary
from proveit.logic import Equals, Forall, InSet
from proveit.numbers import Exp, Mult, e, i, one, pi, two
from proveit.physics.quantum import Qmult, m_ket_domain, normalized_var_ket_u, var_ket_u, varphi
from proveit.physics.quantum.circuits import phase_kickback_circuit
from proveit.statistics import Prob
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda(U, Conditional(Forall(instance_param_or_params = [var_ket_u], instance_expr = Forall(instance_param_or_params = [varphi], instance_expr = Equals(Prob(phase_kickback_circuit), one), condition = Equals(Qmult(U, var_ket_u), ScalarMult(Exp(e, Mult(two, pi, i, varphi)), var_ket_u))), domain = m_ket_domain, condition = normalized_var_ket_u), InSet(U, Unitary(Exp(two, m))))))
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(U \mapsto \left\{\forall_{\lvert u \rangle \in \mathbb{C}^{2^{m}}~|~\left \|\lvert u \rangle\right \| = 1}~\left[\forall_{\varphi~|~\left(U \thinspace \lvert u \rangle\right) = \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi} \cdot \lvert u \rangle\right)}~\left(\textrm{Pr}\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\qin{\lvert + \rangle} & \control{} \qw \qwx[1] & \qout{\frac{1}{\sqrt{2}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi} \cdot \lvert 1 \rangle\right)\right)} \\
\qin{\lvert u \rangle} & \gate{U} & \qout{\lvert u \rangle}
} \end{array}\right) = 1\right)\right] \textrm{ if } U \in \textrm{U}\left(2^{m}\right)\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: 102
body: 3
2ExprTuple102
3Conditionalvalue: 4
condition: 5
4Operationoperator: 15
operand: 8
5Operationoperator: 24
operands: 7
6ExprTuple8
7ExprTuple102, 9
8Lambdaparameter: 106
body: 10
9Operationoperator: 11
operand: 42
10Conditionalvalue: 13
condition: 14
11Literal
12ExprTuple42
13Operationoperator: 15
operand: 19
14Operationoperator: 17
operands: 18
15Literal
16ExprTuple19
17Literal
18ExprTuple20, 21
19Lambdaparameter: 134
body: 23
20Operationoperator: 24
operands: 25
21Operationoperator: 32
operands: 26
22ExprTuple134
23Conditionalvalue: 27
condition: 28
24Literal
25ExprTuple106, 29
26ExprTuple30, 128
27Operationoperator: 32
operands: 31
28Operationoperator: 32
operands: 33
29Operationoperator: 34
operands: 35
30Operationoperator: 36
operand: 106
31ExprTuple38, 128
32Literal
33ExprTuple39, 40
34Literal
35ExprTuple41, 42
36Literal
37ExprTuple106
38Operationoperator: 43
operand: 49
39Operationoperator: 45
operands: 46
40Operationoperator: 111
operands: 47
41Literal
42Operationoperator: 122
operands: 48
43Literal
44ExprTuple49
45Literal
46ExprTuple102, 106
47ExprTuple117, 106
48ExprTuple131, 119
49Operationoperator: 50
operands: 51
50Literal
51ExprTuple52, 53, 54
52ExprTuple55, 56
53ExprTuple57, 58
54ExprTuple59, 60
55Operationoperator: 92
operands: 61
56ExprRangelambda_map: 62
start_index: 128
end_index: 67
57Operationoperator: 83
operands: 63
58ExprRangelambda_map: 64
start_index: 128
end_index: 67
59Operationoperator: 98
operands: 65
60ExprRangelambda_map: 66
start_index: 128
end_index: 67
61NamedExprsstate: 68
62Lambdaparameter: 107
body: 69
63NamedExprselement: 70
targets: 71
64Lambdaparameter: 107
body: 72
65NamedExprsstate: 73
66Lambdaparameter: 107
body: 75
67Operationoperator: 113
operands: 76
68Operationoperator: 124
operand: 85
69Operationoperator: 83
operands: 78
70Literal
71Operationoperator: 79
operand: 131
72Operationoperator: 83
operands: 81
73Operationoperator: 111
operands: 82
74ExprTuple107
75Operationoperator: 83
operands: 84
76ExprTuple119, 128
77ExprTuple85
78NamedExprselement: 86
targets: 91
79Literal
80ExprTuple131
81NamedExprselement: 87
targets: 91
82ExprTuple88, 89
83Literal
84NamedExprselement: 90
targets: 91
85Literal
86Operationoperator: 92
operands: 99
87Operationoperator: 93
operands: 94
88Operationoperator: 120
operands: 95
89Operationoperator: 96
operands: 97
90Operationoperator: 98
operands: 99
91Operationoperator: 100
operands: 101
92Literal
93Literal
94NamedExprsoperation: 102
part: 107
95ExprTuple128, 103
96Literal
97ExprTuple104, 105
98Literal
99NamedExprsstate: 106
part: 107
100Literal
101ExprTuple131, 108
102Variable
103Operationoperator: 122
operands: 109
104Operationoperator: 124
operand: 116
105Operationoperator: 111
operands: 112
106Variable
107Variable
108Operationoperator: 113
operands: 114
109ExprTuple131, 115
110ExprTuple116
111Literal
112ExprTuple117, 118
113Literal
114ExprTuple119, 131
115Operationoperator: 120
operands: 121
116Literal
117Operationoperator: 122
operands: 123
118Operationoperator: 124
operand: 128
119Variable
120Literal
121ExprTuple128, 131
122Literal
123ExprTuple126, 127
124Literal
125ExprTuple128
126Literal
127Operationoperator: 129
operands: 130
128Literal
129Literal
130ExprTuple131, 132, 133, 134
131Literal
132Literal
133Literal
134Variable