Skip to content

Commit 38e5fc5

Browse files
committed
continous case
1 parent 69ae8a4 commit 38e5fc5

File tree

1 file changed

+53
-9
lines changed

1 file changed

+53
-9
lines changed

examples/error-correction/NineQubitCode.v

Lines changed: 53 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Ltac reorder_scalars :=
4343
repeat rewrite Mscale_assoc;
4444
repeat rewrite Cmult_comm with (x := ((-1)%R : C));
4545
repeat rewrite <- Mscale_assoc with (y := ((-1)%R : C));
46-
repeat rewrite <- Mscale_plus_distr_r.
46+
repeat rewrite <- Mscale_plus_distr_r.
4747

4848
Ltac normalize_kron_notation :=
4949
repeat rewrite <- kron_assoc by auto 8 with wf_db;
@@ -153,6 +153,11 @@ Definition block_no := up_to_three.
153153
(* Qubits in a single block *)
154154
Definition block_offset := up_to_three.
155155

156+
157+
Definition block_to_qubit (n : block_no) (off : block_offset) : nat :=
158+
n * 3 + off.
159+
160+
156161
(**
157162
Encoding
158163
*)
@@ -163,15 +168,15 @@ Definition encode_block : base_ucom block_dim :=
163168
CNOT 0 2.
164169

165170
Theorem encode_block_zero :
166-
uc_eval encode_block × ∣0,0,0
171+
uc_eval encode_block × ∣ 0, 0, 0
167172
= / √ 2 .* (∣ 0, 0, 0 ⟩ .+ ∣ 1, 1, 1 ⟩).
168173
Proof.
169174
rewrite Common.zero_3_f_to_vec.
170175
now compute_vec.
171176
Qed.
172177

173178
Theorem encode_block_one :
174-
uc_eval encode_block × ∣1,0,0
179+
uc_eval encode_block × ∣ 1, 0 , 0
175180
= / √ 2 .* (∣ 0, 0, 0 ⟩ .+ (-1)%R .* ∣ 1, 1, 1 ⟩).
176181
Proof.
177182
rewrite Common.one_3_f_to_vec.
@@ -509,6 +514,9 @@ Proof.
509514
now compute_decoding.
510515
Qed.
511516

517+
(**
518+
Correctness
519+
*)
512520

513521
Theorem error_decode_correct_no_error :
514522
forall (α β : C),
@@ -911,6 +919,9 @@ Proof.
911919
Qed.
912920

913921

922+
(**
923+
Main correctness proof for the discrete error case.
924+
*)
914925
Theorem shor_correct (e : error) : forall (α β : C),
915926
(@uc_eval dim (shor e)) × ((α .* ∣0⟩ .+ β .* ∣1⟩) ⊗ 8 ⨂ ∣0⟩)
916927
= (α .* ∣0⟩ .+ β .* ∣1⟩) ⊗ ancillae_for e.
@@ -941,6 +952,10 @@ Proof.
941952
apply H.
942953
Qed.
943954

955+
(**
956+
Generalized errors on single qubits
957+
*)
958+
944959
Lemma pauli_spans_2_by_2 :
945960
forall (M : Square 2), WF_Matrix M ->
946961
exists λ₁ λ₂ λ₃ λ₄,
@@ -1027,9 +1042,6 @@ Lemma YeqiXZ :
10271042
σy = Ci .* σx × σz.
10281043
Proof. solve_matrix. Qed.
10291044

1030-
Definition block_to_qubit (n : block_no) (off : block_offset) : nat :=
1031-
n * 3 + off.
1032-
10331045
Definition ancillae_for_arbitrary
10341046
(λ₁ λ₂ λ₃ λ₄ : C)
10351047
(n : block_no)
@@ -1083,23 +1095,33 @@ Proof.
10831095
all : now rewrite Mscale_1_l.
10841096
Qed.
10851097

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.
10861102

1103+
(**
1104+
Main correctness proof for the continuous error case.
1105+
*)
10871106
Theorem shor_arbitrary_correct (M : Square 2) :
10881107
WF_Unitary M ->
10891108
forall (α β : C) (n : block_no) (off : block_offset),
10901109
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⟩)
10941112
= (α .* ∣0⟩ .+ β .* ∣1⟩) ⊗ φ.
10951113
Proof.
10961114
intros.
10971115
repeat rewrite Mmult_assoc.
1116+
unfold shor_arbitrary_unitary_matrix.
1117+
repeat rewrite Mmult_assoc.
10981118
rewrite encode_correct.
10991119
specialize (pauli_spans_unitary_2_by_2 M H) as Hpauli.
11001120
destruct Hpauli as [λ₁ [λ₂ [λ₃ [λ₄ [Hpauli Hmod]]]]].
11011121
rewrite Hpauli.
11021122
exists (ancillae_for_arbitrary λ₁ λ₂ λ₃ λ₄ n off).
1123+
split.
1124+
1 : exact (ancillae_pure_vector_cond λ₁ λ₂ λ₃ λ₄ n off Hmod).
11031125
destruct n; destruct off.
11041126
all : cbn.
11051127
all : repeat rewrite kron_1_l by auto with wf_db.
@@ -1252,5 +1274,27 @@ Proof.
12521274
all : reflexivity.
12531275
Qed.
12541276

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.
12551299

12561300
End NineQubitCode.

0 commit comments

Comments
 (0)