Skip to content

Commit 4f7ff06

Browse files
committed
feat(M7.1): Stated + proven.
TODO: We really need something similar to `list2DtoMatrix` but for diagonal matrices in general, so we can stop proving these specific cases.
1 parent 5778e79 commit 4f7ff06

File tree

3 files changed

+138
-38
lines changed

3 files changed

+138
-38
lines changed

Helpers/DiagonalHelpers.v

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,65 @@ Require Import QuantumLib.Eigenvectors.
22
Require Import MatrixHelpers.
33
Require Import GateHelpers.
44

5+
Lemma Diag_diag2: forall (c1 c2 : C), WF_Diagonal (diag2 c1 c2).
6+
Proof.
7+
intros.
8+
unfold WF_Diagonal.
9+
split. apply WF_diag2.
10+
intros.
11+
unfold diag2; simpl.
12+
destruct i.
13+
- destruct j.
14+
+ contradiction.
15+
+ reflexivity.
16+
- destruct i.
17+
+ destruct j.
18+
* reflexivity.
19+
* destruct j.
20+
-- contradiction.
21+
-- reflexivity.
22+
+ reflexivity.
23+
Qed.
24+
25+
Lemma Diag_diag4: forall (c1 c2 c3 c4 : C), WF_Diagonal (diag4 c1 c2 c3 c4).
26+
Proof.
27+
intros.
28+
unfold WF_Diagonal.
29+
split; try apply WF_diag4.
30+
intros.
31+
unfold diag4; simpl.
32+
destruct i.
33+
- destruct j.
34+
+ contradiction.
35+
+ reflexivity.
36+
- destruct i.
37+
+ destruct j.
38+
* reflexivity.
39+
* destruct j.
40+
-- contradiction.
41+
-- reflexivity.
42+
+ destruct i.
43+
* destruct j.
44+
-- reflexivity.
45+
-- destruct j.
46+
++ reflexivity.
47+
++ destruct j.
48+
** contradiction.
49+
** reflexivity.
50+
* destruct i.
51+
-- destruct j.
52+
++ reflexivity.
53+
++ destruct j.
54+
** reflexivity.
55+
** destruct j.
56+
--- reflexivity.
57+
--- destruct j.
58+
+++ contradiction.
59+
+++ reflexivity.
60+
-- reflexivity.
61+
Qed.
62+
63+
564
Lemma diag00 : WF_Diagonal ∣0⟩⟨0∣.
665
Proof.
766
split; auto with wf_db.

Helpers/MatrixHelpers.v

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -82,44 +82,6 @@ Proof.
8282
unfold diag2, Determinant, big_sum, parity, get_minor; lca.
8383
Qed.
8484

85-
Lemma Diag_diag4: forall (c1 c2 c3 c4 : C), WF_Diagonal (diag4 c1 c2 c3 c4).
86-
Proof.
87-
intros.
88-
unfold WF_Diagonal.
89-
split; try apply WF_diag4.
90-
intros.
91-
unfold diag4; simpl.
92-
destruct i.
93-
- destruct j.
94-
+ contradiction.
95-
+ reflexivity.
96-
- destruct i.
97-
+ destruct j.
98-
* reflexivity.
99-
* destruct j.
100-
-- contradiction.
101-
-- reflexivity.
102-
+ destruct i.
103-
* destruct j.
104-
-- reflexivity.
105-
-- destruct j.
106-
++ reflexivity.
107-
++ destruct j.
108-
** contradiction.
109-
** reflexivity.
110-
* destruct i.
111-
-- destruct j.
112-
++ reflexivity.
113-
++ destruct j.
114-
** reflexivity.
115-
** destruct j.
116-
--- reflexivity.
117-
--- destruct j.
118-
+++ contradiction.
119-
+++ reflexivity.
120-
-- reflexivity.
121-
Qed.
122-
12385
Lemma row_out_of_bounds: forall {m n} (A : Matrix m n) (i : nat),
12486
WF_Matrix A -> (i >= m)%nat -> forall (j : nat), A i j = C0.
12587
Proof.

Main.v

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3095,3 +3095,82 @@ Proof.
30953095
assumption.
30963096
}
30973097
Qed.
3098+
3099+
Lemma m7_1 : forall (u0 u1 : C), Cmod u0 = 1 -> Cmod u1 = 1 ->
3100+
forall (U : Square 8), WF_Unitary U ->
3101+
forall (W : Square 4), WF_Unitary W ->
3102+
ccu (diag2 u0 u1) = abgate W × U -> exists (V : Square 4), WF_Unitary V /\
3103+
ccu (diag2 C1 (u0^* * u1)) = abgate V × U.
3104+
Proof.
3105+
intros u0 u1 u0_unit u1_unit U U_unitary W W_unitary H.
3106+
exists (control (diag2 C1 (u0^*)) × W).
3107+
split.
3108+
{
3109+
solve_WF_matrix.
3110+
apply diag2_unitary.
3111+
apply Cmod_1.
3112+
rewrite Cmod_Cconj.
3113+
exact u0_unit.
3114+
}
3115+
{
3116+
unfold abgate.
3117+
rewrite <- Mmult_1_l with (A := I 2); solve_WF_matrix.
3118+
rewrite <- kron_mixed_product.
3119+
unfold abgate in H.
3120+
rewrite Mmult_assoc.
3121+
rewrite <- H at 1; clear H.
3122+
(* For performance reasons, we'll show both sides are diagonal first,
3123+
instead of directly invoking lma'. *)
3124+
assert (WF_Diagonal (ccu (diag2 C1 (u0 ^* * u1)))).
3125+
{
3126+
apply ccu_diag.
3127+
apply Diag_diag2.
3128+
}
3129+
assert (WF_Diagonal (control (diag2 C1 (u0 ^*)) ⊗ I 2 × ccu (diag2 u0 u1))).
3130+
{
3131+
apply diag_mult.
3132+
apply diag_kron.
3133+
apply diag_control.
3134+
apply Diag_diag2.
3135+
apply diag_I.
3136+
apply ccu_diag.
3137+
apply Diag_diag2.
3138+
}
3139+
prep_matrix_equality.
3140+
bdestruct (x =? y).
3141+
{
3142+
rewrite <- H1; clear H1.
3143+
destruct H as [H _].
3144+
destruct H0 as [H0 _].
3145+
specialize (H x x).
3146+
specialize (H0 x x).
3147+
destruct x.
3148+
unfold ccu, control, diag2, I, kron, Mmult; lca.
3149+
destruct x.
3150+
unfold ccu, control, diag2, I, kron, Mmult; lca.
3151+
destruct x.
3152+
unfold ccu, control, diag2, I, kron, Mmult; lca.
3153+
destruct x.
3154+
unfold ccu, control, diag2, I, kron, Mmult; lca.
3155+
destruct x.
3156+
unfold ccu, control, diag2, I, kron, Mmult; lca.
3157+
destruct x.
3158+
unfold ccu, control, diag2, I, kron, Mmult; lca.
3159+
destruct x.
3160+
unfold ccu, control, diag2, I, kron, Mmult; simpl; Csimpl.
3161+
rewrite <- Cmod_sqr, u0_unit; lca.
3162+
destruct x.
3163+
unfold ccu, control, diag2, I, kron, Mmult; lca.
3164+
rewrite H, <- H0.
3165+
reflexivity.
3166+
all: lia.
3167+
}
3168+
{
3169+
destruct H as [_ H].
3170+
destruct H0 as [_ H0].
3171+
specialize (H x y H1).
3172+
specialize (H0 x y H1).
3173+
rewrite H, <- H0; reflexivity.
3174+
}
3175+
}
3176+
Qed.

0 commit comments

Comments
 (0)