@@ -43,7 +43,7 @@ Ltac reorder_scalars :=
43
43
repeat rewrite Mscale_assoc;
44
44
repeat rewrite Cmult_comm with (x := ((-1)%R : C));
45
45
repeat rewrite <- Mscale_assoc with (y := ((-1)%R : C));
46
- repeat rewrite <- Mscale_plus_distr_r.
46
+ repeat rewrite <- Mscale_plus_distr_r.
47
47
48
48
Ltac normalize_kron_notation :=
49
49
repeat rewrite <- kron_assoc by auto 8 with wf_db;
@@ -153,6 +153,11 @@ Definition block_no := up_to_three.
153
153
(* Qubits in a single block *)
154
154
Definition block_offset := up_to_three.
155
155
156
+
157
+ Definition block_to_qubit (n : block_no) (off : block_offset) : nat :=
158
+ n * 3 + off.
159
+
160
+
156
161
(**
157
162
Encoding
158
163
*)
@@ -163,15 +168,15 @@ Definition encode_block : base_ucom block_dim :=
163
168
CNOT 0 2.
164
169
165
170
Theorem encode_block_zero :
166
- uc_eval encode_block × ∣0,0,0 ⟩
171
+ uc_eval encode_block × ∣ 0, 0, 0 ⟩
167
172
= / √ 2 .* (∣ 0, 0, 0 ⟩ .+ ∣ 1, 1, 1 ⟩).
168
173
Proof .
169
174
rewrite Common.zero_3_f_to_vec.
170
175
now compute_vec.
171
176
Qed .
172
177
173
178
Theorem encode_block_one :
174
- uc_eval encode_block × ∣1,0,0 ⟩
179
+ uc_eval encode_block × ∣ 1, 0 , 0 ⟩
175
180
= / √ 2 .* (∣ 0, 0, 0 ⟩ .+ (-1)%R .* ∣ 1, 1, 1 ⟩).
176
181
Proof .
177
182
rewrite Common.one_3_f_to_vec.
@@ -509,6 +514,9 @@ Proof.
509
514
now compute_decoding.
510
515
Qed .
511
516
517
+ (**
518
+ Correctness
519
+ *)
512
520
513
521
Theorem error_decode_correct_no_error :
514
522
forall (α β : C),
@@ -911,6 +919,9 @@ Proof.
911
919
Qed .
912
920
913
921
922
+ (**
923
+ Main correctness proof for the discrete error case.
924
+ *)
914
925
Theorem shor_correct (e : error) : forall (α β : C),
915
926
(@uc_eval dim (shor e)) × ((α .* ∣0⟩ .+ β .* ∣1⟩) ⊗ 8 ⨂ ∣0⟩)
916
927
= (α .* ∣0⟩ .+ β .* ∣1⟩) ⊗ ancillae_for e.
@@ -941,6 +952,10 @@ Proof.
941
952
apply H.
942
953
Qed .
943
954
955
+ (**
956
+ Generalized errors on single qubits
957
+ *)
958
+
944
959
Lemma pauli_spans_2_by_2 :
945
960
forall (M : Square 2), WF_Matrix M ->
946
961
exists λ₁ λ₂ λ₃ λ₄,
@@ -1027,9 +1042,6 @@ Lemma YeqiXZ :
1027
1042
σy = Ci .* σx × σz.
1028
1043
Proof . solve_matrix. Qed .
1029
1044
1030
- Definition block_to_qubit (n : block_no) (off : block_offset) : nat :=
1031
- n * 3 + off.
1032
-
1033
1045
Definition ancillae_for_arbitrary
1034
1046
(λ₁ λ₂ λ₃ λ₄ : C)
1035
1047
(n : block_no)
@@ -1083,23 +1095,33 @@ Proof.
1083
1095
all : now rewrite Mscale_1_l.
1084
1096
Qed .
1085
1097
1098
+ Definition shor_arbitrary_unitary_matrix (M : Square 2) (n : block_no) (off : block_offset) :=
1099
+ uc_eval decode
1100
+ × pad_u dim (block_to_qubit n off) M
1101
+ × uc_eval encode.
1086
1102
1103
+ (**
1104
+ Main correctness proof for the continuous error case.
1105
+ *)
1087
1106
Theorem shor_arbitrary_correct (M : Square 2) :
1088
1107
WF_Unitary M ->
1089
1108
forall (α β : C) (n : block_no) (off : block_offset),
1090
1109
exists (φ : Vector (2^8)),
1091
- ( uc_eval decode
1092
- × pad_u dim (block_to_qubit n off) M
1093
- × uc_eval encode) × ((α .* ∣0⟩ .+ β .* ∣1⟩) ⊗ 8 ⨂ ∣0⟩)
1110
+ Pure_State_Vector φ /\
1111
+ shor_arbitrary_unitary_matrix M n off × ((α .* ∣0⟩ .+ β .* ∣1⟩) ⊗ 8 ⨂ ∣0⟩)
1094
1112
= (α .* ∣0⟩ .+ β .* ∣1⟩) ⊗ φ.
1095
1113
Proof .
1096
1114
intros.
1097
1115
repeat rewrite Mmult_assoc.
1116
+ unfold shor_arbitrary_unitary_matrix.
1117
+ repeat rewrite Mmult_assoc.
1098
1118
rewrite encode_correct.
1099
1119
specialize (pauli_spans_unitary_2_by_2 M H) as Hpauli.
1100
1120
destruct Hpauli as [λ₁ [λ₂ [λ₃ [λ₄ [Hpauli Hmod]]]]].
1101
1121
rewrite Hpauli.
1102
1122
exists (ancillae_for_arbitrary λ₁ λ₂ λ₃ λ₄ n off).
1123
+ split.
1124
+ 1 : exact (ancillae_pure_vector_cond λ₁ λ₂ λ₃ λ₄ n off Hmod).
1103
1125
destruct n; destruct off.
1104
1126
all : cbn.
1105
1127
all : repeat rewrite kron_1_l by auto with wf_db.
@@ -1252,5 +1274,27 @@ Proof.
1252
1274
all : reflexivity.
1253
1275
Qed .
1254
1276
1277
+ Theorem shor_arbitrary_correct_prob (M : Square 2) :
1278
+ WF_Unitary M ->
1279
+ forall (α β : C) (n : block_no) (off : block_offset),
1280
+ let r := shor_arbitrary_unitary_matrix M n off × ((α .* ∣0⟩ .+ β .* ∣1⟩) ⊗ 8 ⨂ ∣0⟩) in
1281
+ @prob_partial_meas 1 (dim - 1) ∣0⟩ r = (Cmod α ^ 2)%R
1282
+ /\ @prob_partial_meas 1 (dim - 1) ∣1⟩ r = (Cmod β ^ 2)%R.
1283
+ Proof .
1284
+ intros.
1285
+ specialize (shor_arbitrary_correct M H α β n off) as [R [[HWFR HDag] HR]].
1286
+ subst r.
1287
+ rewrite HR.
1288
+ do 2 rewrite prob_partial_meas_alt.
1289
+ distribute_adjoint.
1290
+ Msimpl.
1291
+ autorewrite with ket_db.
1292
+ do 2 rewrite norm_scale.
1293
+ unfold norm.
1294
+ unfold inner_product.
1295
+ restore_dims.
1296
+ rewrite HDag.
1297
+ split; simpl; rewrite sqrt_1; repeat rewrite Rmult_1_r; easy.
1298
+ Qed .
1255
1299
1256
1300
End NineQubitCode.
0 commit comments