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
from proveit.linear_algebra import ScalarMult
from proveit.logic import And, 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(var_ket_u, Conditional(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))), And(InSet(var_ket_u, m_ket_domain), normalized_var_ket_u))))
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(\lvert u \rangle \mapsto \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) \textrm{ if } \lvert u \rangle \in \mathbb{C}^{2^{m}} ,  \left \|\lvert u \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
1Lambdaparameter: 96
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 9
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9
7Literal
8ExprTuple10, 11
9Lambdaparameter: 124
body: 13
10Operationoperator: 14
operands: 15
11Operationoperator: 22
operands: 16
12ExprTuple124
13Conditionalvalue: 17
condition: 18
14Literal
15ExprTuple96, 19
16ExprTuple20, 118
17Operationoperator: 22
operands: 21
18Operationoperator: 22
operands: 23
19Operationoperator: 24
operands: 25
20Operationoperator: 26
operand: 96
21ExprTuple28, 118
22Literal
23ExprTuple29, 30
24Literal
25ExprTuple31, 32
26Literal
27ExprTuple96
28Operationoperator: 33
operand: 39
29Operationoperator: 35
operands: 36
30Operationoperator: 101
operands: 37
31Literal
32Operationoperator: 112
operands: 38
33Literal
34ExprTuple39
35Literal
36ExprTuple92, 96
37ExprTuple107, 96
38ExprTuple121, 109
39Operationoperator: 40
operands: 41
40Literal
41ExprTuple42, 43, 44
42ExprTuple45, 46
43ExprTuple47, 48
44ExprTuple49, 50
45Operationoperator: 82
operands: 51
46ExprRangelambda_map: 52
start_index: 118
end_index: 57
47Operationoperator: 73
operands: 53
48ExprRangelambda_map: 54
start_index: 118
end_index: 57
49Operationoperator: 88
operands: 55
50ExprRangelambda_map: 56
start_index: 118
end_index: 57
51NamedExprsstate: 58
52Lambdaparameter: 97
body: 59
53NamedExprselement: 60
targets: 61
54Lambdaparameter: 97
body: 62
55NamedExprsstate: 63
56Lambdaparameter: 97
body: 65
57Operationoperator: 103
operands: 66
58Operationoperator: 114
operand: 75
59Operationoperator: 73
operands: 68
60Literal
61Operationoperator: 69
operand: 121
62Operationoperator: 73
operands: 71
63Operationoperator: 101
operands: 72
64ExprTuple97
65Operationoperator: 73
operands: 74
66ExprTuple109, 118
67ExprTuple75
68NamedExprselement: 76
targets: 81
69Literal
70ExprTuple121
71NamedExprselement: 77
targets: 81
72ExprTuple78, 79
73Literal
74NamedExprselement: 80
targets: 81
75Literal
76Operationoperator: 82
operands: 89
77Operationoperator: 83
operands: 84
78Operationoperator: 110
operands: 85
79Operationoperator: 86
operands: 87
80Operationoperator: 88
operands: 89
81Operationoperator: 90
operands: 91
82Literal
83Literal
84NamedExprsoperation: 92
part: 97
85ExprTuple118, 93
86Literal
87ExprTuple94, 95
88Literal
89NamedExprsstate: 96
part: 97
90Literal
91ExprTuple121, 98
92Variable
93Operationoperator: 112
operands: 99
94Operationoperator: 114
operand: 106
95Operationoperator: 101
operands: 102
96Variable
97Variable
98Operationoperator: 103
operands: 104
99ExprTuple121, 105
100ExprTuple106
101Literal
102ExprTuple107, 108
103Literal
104ExprTuple109, 121
105Operationoperator: 110
operands: 111
106Literal
107Operationoperator: 112
operands: 113
108Operationoperator: 114
operand: 118
109Variable
110Literal
111ExprTuple118, 121
112Literal
113ExprTuple116, 117
114Literal
115ExprTuple118
116Literal
117Operationoperator: 119
operands: 120
118Literal
119Literal
120ExprTuple121, 122, 123, 124
121Literal
122Literal
123Literal
124Variable