Skip to content

Commit b5ef8ba

Browse files
authored
feat: Prove Lemma M7.5. (#58)
* feat(M7.5): Mostly proven. * feat(M7.5): Finish proving forwards direction. * feat(M7.5): Fully proven. There's most likely a cleaner way to do this, rather than brute-forcing both directions of the proof.
1 parent ee490f0 commit b5ef8ba

9 files changed

+804
-60
lines changed

Appendix/A2_UnitaryMatrices.v

+1-1
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ Proof.
261261
P01† × P01 .+ P11† × P11 = I 2).
262262
{
263263
apply block_equalities; solve_WF_matrix.
264-
rewrite V_inv.
264+
rewrite V_inv at 1.
265265
Msimpl_light.
266266
rewrite <- kron_plus_distr_r.
267267
rewrite Mplus01, id_kron.

Appendix/A5_ControlledUnitaries.v

+3-4
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ assert (equal_blocks: (P00) † × P00 = I 2 /\ (Zero (m:= 2) (n:=2)) = (Zero (m
187187
/\ (Zero (m:= 2) (n:=2)) = (Zero (m:= 2) (n:=2)) /\ (P11) † × P11 = I 2).
188188
{
189189
apply block_equalities; solve_WF_matrix.
190-
rewrite <- U_adj_mult_1, <- I_4_block_decomp.
190+
rewrite <- U_adj_mult_1, <- I_4_block_decomp at 1.
191191
apply U_unitary.
192192
}
193193
split.
@@ -331,8 +331,7 @@ assert (Main: ∣0⟩ ⊗ psi ⊗ beta .+ ∣0⟩ ⊗ phi ⊗ beta_p =
331331
rewrite <- swapbc_3q; solve_WF_matrix.
332332
rewrite <- swapbc_3q with (b := beta_p); solve_WF_matrix.
333333
rewrite <- Mmult_plus_distr_l.
334-
rewrite kron_assoc; solve_WF_matrix.
335-
rewrite kron_assoc; solve_WF_matrix.
334+
repeat rewrite (@kron_assoc 2 1 2 1 2 1); solve_WF_matrix.
336335
}
337336
rewrite Step1. clear Step1.
338337
assert (Step2: swapbc × (∣0⟩ ⊗ (beta ⊗ psi) .+ ∣0⟩ ⊗ (beta_p ⊗ phi)) = swapbc × (∣0⟩ ⊗ w)).
@@ -372,7 +371,7 @@ assert (Main: ∣0⟩ ⊗ psi ⊗ beta .+ ∣0⟩ ⊗ phi ⊗ beta_p =
372371
unfold abgate.
373372
rewrite kron_mixed_product. rewrite kron_mixed_product.
374373
Msimpl_light; solve_WF_matrix.
375-
repeat rewrite <- Mscale_kron_dist_l.
374+
repeat rewrite <- (@Mscale_kron_dist_l 4 1 2 1).
376375
reflexivity.
377376
}
378377
(* Moving terms in main to apply a16*)

Appendix/A6_TensorProducts.v

+4-4
Original file line numberDiff line numberDiff line change
@@ -421,10 +421,10 @@ destruct (Classical_Prop.classic (TensorProd (U × (∣0⟩ ⊗ ∣0⟩)))).
421421
unfold a. unfold not. intro.
422422
apply H.
423423
rewrite a20; solve_WF_matrix.
424-
fold a00 a11 a01 a10.
425424
apply (f_equal (fun f => f + a01 * a10)) in H0.
426425
rewrite Cplus_0_l in H0.
427-
rewrite <- H0.
426+
unfold a00, a11, a01, a10 in H0.
427+
rewrite <- H0 at 1.
428428
lca.
429429
}
430430
Qed.
@@ -586,10 +586,10 @@ destruct (Classical_Prop.classic (TensorProd (U × (∣1⟩ ⊗ ∣0⟩)))).
586586
unfold a. unfold not. intro.
587587
apply H.
588588
rewrite a20; solve_WF_matrix.
589-
fold a00 a11 a01 a10.
590589
apply (f_equal (fun f => f + a01 * a10)) in H0.
591590
rewrite Cplus_0_l in H0.
592-
rewrite <- H0.
591+
unfold a00, a11, a01, a10 in H0.
592+
rewrite <- H0 at 1.
593593
lca.
594594
}
595595
Qed.

Appendix/A7_OtherProperties.v

+6-25
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ Zero = I 2 ⊗ Q10 /\
185185
{
186186
apply block_eq.
187187
all: solve_WF_matrix.
188-
rewrite <- V3_way1. apply V3_way2.
188+
rewrite <- V3_way1 at 1. apply V3_way2.
189189
}
190190
destruct eq as [q00_val [q01_zero [q10_zero q11_val]]].
191191
assert (ztotens: (@Zero 4 4) = I 2 ⊗ (@Zero 2 2)). lma'.
@@ -896,7 +896,7 @@ split.
896896
apply (f_equal (fun f => I 2 ⊗ U2 × f)).
897897
assert (assoc_help: I 2 ⊗ (I 2 ⊗ W1) = I 2 ⊗ I 2 ⊗ W1). symmetry. apply kron_assoc. 1,2,3: solve_WF_matrix.
898898
rewrite assoc_help at 1.
899-
rewrite <- swapbc_3gate. 2,3,4: solve_WF_matrix.
899+
rewrite <- swapbc_3gate; solve_WF_matrix.
900900
unfold acgate at 1.
901901
unfold abgate at 1.
902902
unfold V3.
@@ -908,14 +908,7 @@ split.
908908
repeat rewrite Mmult_assoc.
909909
rewrite <- Mmult_assoc with (A:= swapbc) (B:= swapbc).
910910
rewrite swapbc_inverse at 1.
911-
rewrite Mmult_1_l.
912-
2: {
913-
apply WF_mult. solve_WF_matrix.
914-
apply WF_mult. solve_WF_matrix.
915-
apply WF_mult. solve_WF_matrix.
916-
apply WF_mult. solve_WF_matrix.
917-
apply WF_bcgate. solve_WF_matrix.
918-
}
911+
rewrite Mmult_1_l; solve_WF_matrix.
919912
rewrite <- Mmult_assoc with (A:= I 2 ⊗ W1 ⊗ I 2).
920913
assert (kron_mix_help: I 2 ⊗ W1 ⊗ I 2 × ((W0) † ⊗ (W1) † ⊗ I 2) =
921914
(I 2 ⊗ W1 × ((W0) † ⊗ (W1) †)) ⊗ (I 2 × I 2)). apply kron_mixed_product.
@@ -930,16 +923,8 @@ split.
930923
repeat rewrite Mmult_assoc.
931924
rewrite <- Mmult_assoc with (A:= swapbc).
932925
rewrite swapbc_inverse at 1.
933-
rewrite Mmult_1_l.
934-
2: {
935-
apply WF_mult. solve_WF_matrix.
936-
apply WF_mult. solve_WF_matrix.
937-
apply WF_mult. solve_WF_matrix.
938-
apply WF_mult. solve_WF_matrix.
939-
apply WF_mult. solve_WF_matrix.
940-
apply WF_bcgate. solve_WF_matrix.
941-
}
942-
rewrite kron_assoc. 2,3,4: solve_WF_matrix.
926+
rewrite Mmult_1_l; solve_WF_matrix.
927+
rewrite (@kron_assoc 2 2 2 2). 2,3,4: solve_WF_matrix.
943928
rewrite <- Mmult_assoc with (A:= W0 ⊗ I 4).
944929
rewrite id_kron. simpl.
945930
assert (kron_mix_help: W0 ⊗ I 4 × ((W0) † ⊗ I 4) = (W0 × (W0) †) ⊗ (I 4 × I 4)). apply kron_mixed_product.
@@ -950,11 +935,7 @@ split.
950935
rewrite Mmult_1_l.
951936
2:
952937
{
953-
apply WF_mult. solve_WF_matrix.
954-
apply WF_mult. solve_WF_matrix.
955-
apply WF_mult. solve_WF_matrix.
956-
apply WF_mult. solve_WF_matrix.
957-
apply WF_bcgate. solve_WF_matrix.
938+
solve_WF_matrix.
958939
}
959940
rewrite <- swapbc_3gate. 2,3,4: solve_WF_matrix.
960941
repeat rewrite <- Mmult_assoc.

Helpers/GateHelpers.v

+28-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ Definition bcgate (U : Square 4) := I 2 ⊗ U.
1111
Definition acgate (U : Square 4) := swapbc × (abgate U) × swapbc.
1212
Definition ccu (U : Square 2) := control (control U).
1313

14-
Definition TwoQubitGate (U : Square 8) := exists (V : Square 4), WF_Unitary V /\ (U = abgate V \/ U = acgate V \/ U = bcgate V).
15-
16-
1714
#[global] Hint Unfold abgate bcgate acgate ccu : M_db.
1815

1916
Lemma WF_abgate : forall (U : Square 4), WF_Matrix U -> WF_Matrix (abgate U).
@@ -1264,3 +1261,31 @@ rewrite Mmult_1_l. 2: solve_WF_matrix.
12641261
reflexivity.
12651262
Qed.
12661263

1264+
Definition TwoQubitGate (U : Square 8) := exists (V : Square 4), WF_Unitary V /\ (U = abgate V \/ U = acgate V \/ U = bcgate V).
1265+
1266+
Lemma abgate_twoqubitgate : forall (U : Square 4), WF_Unitary U -> TwoQubitGate (abgate U).
1267+
Proof.
1268+
intros U U_unitary.
1269+
unfold TwoQubitGate.
1270+
exists U.
1271+
split. assumption.
1272+
left. reflexivity.
1273+
Qed.
1274+
1275+
Lemma acgate_twoqubitgate : forall (U : Square 4), WF_Unitary U -> TwoQubitGate (acgate U).
1276+
Proof.
1277+
intros U U_unitary.
1278+
unfold TwoQubitGate.
1279+
exists U.
1280+
split. assumption.
1281+
right. left. reflexivity.
1282+
Qed.
1283+
1284+
Lemma bcgate_twoqubitgate : forall (U : Square 4), WF_Unitary U -> TwoQubitGate (bcgate U).
1285+
Proof.
1286+
intros U U_unitary.
1287+
unfold TwoQubitGate.
1288+
exists U.
1289+
split. assumption.
1290+
right. right. reflexivity.
1291+
Qed.

Helpers/TraceoutHelpers.v

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ assert (kron_mix_help: U ⊗ I 2 × (a × (a) † ⊗ (c × (c) †) ⊗ (b × (
4949
(U × (a × (a) † ⊗ (c × (c) †))) ⊗ (b × (b) †) ).
5050
{
5151
rewrite <- Mmult_1_l with (A:= (b × (b) †)) at 2; solve_WF_matrix.
52-
apply kron_mixed_product.
52+
apply (@kron_mixed_product 4 4 4 2 2 2).
5353
}
5454
rewrite kron_mix_help at 1.
5555
clear kron_mix_help.
@@ -61,7 +61,7 @@ assert (kron_mix_help: U × (a × (a) † ⊗ (c × (c) †)) ⊗ (b × (b) †)
6161
(U × (a × (a) † ⊗ (c × (c) †)) × (U) †) ⊗ (b × (b) †)).
6262
{
6363
rewrite <- Mmult_1_r with (A:= (b × (b) †)) at 2; solve_WF_matrix.
64-
apply kron_mixed_product.
64+
apply (@kron_mixed_product 4 4 4 2 2 2).
6565
}
6666
rewrite kron_mix_help at 1.
6767
assert (WF_helper1: WF_Matrix (U × (a × (a) † ⊗ (c × (c) †)) × (U) † ⊗ (b × (b) †) × swapbc)).

Helpers/UnitaryHelpers.v

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Proof.
3535
repeat rewrite kron_0_l.
3636
rewrite Mplus_0_l, Mplus_0_r.
3737
rewrite Unitary_P, Unitary_Q.
38-
rewrite <- kron_plus_distr_r.
38+
rewrite <- (@kron_plus_distr_r 2 2 n n).
3939
rewrite Mplus01.
4040
rewrite id_kron.
4141
reflexivity.

Helpers/WFHelpers.v

+8-5
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,22 @@ Ltac solve_WF_matrix :=
2525
| |- WF_Matrix ?A => match goal with
2626
| [ H : WF_Matrix A |- _ ] => apply H
2727
| [ H : WF_Unitary A |- _ ] => apply H
28+
| [ H : WF_Diagonal A |- _ ] => apply H
2829
| [ H : WF_Qubit A |- _ ] => apply H
2930
| _ => auto_wf; autounfold with M_db; try unfold A
3031
end
3132
| |- WF_Unitary (adjoint _) => apply adjoint_unitary
3233
| |- WF_Unitary (Mopp _) => unfold Mopp
33-
| |- WF_Unitary (_ × _) => apply Mmult_unitary
34+
| |- WF_Unitary (?A × _) => match type of A with
35+
| Square ?n => apply (@Mmult_unitary n)
36+
end
3437
(* TODO: Upstream `direct_sum_unitary`, otherwise we can't have this case *)
3538
(*| |- WF_Unitary (_ .⊕ _) => apply direct_sum_unitary *)
3639
| |- WF_Unitary (?A ⊗ ?B) => match type of A with
37-
| Square ?m => match type of B with
38-
| Square ?n => apply (@kron_unitary m n)
39-
end
40-
end
40+
| Square ?m => match type of B with
41+
| Square ?n => apply (@kron_unitary m n)
42+
end
43+
end
4144
| |- WF_Unitary (control ?A) => match type of A with
4245
| Square ?n => apply (@control_unitary n)
4346
end

0 commit comments

Comments
 (0)