-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMain.v
More file actions
1163 lines (1158 loc) · 33.2 KB
/
Main.v
File metadata and controls
1163 lines (1158 loc) · 33.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Require Import Proof.UnitaryMatrices.
Require Import Proof.AlgebraHelpers.
Require Import Proof.MatrixHelpers.
Require Import Proof.GateHelpers.
Require Import Proof.EigenvalueHelpers.
Require Import QuantumLib.Complex.
Require Import QuantumLib.Quantum.
Require Import QuantumLib.Eigenvectors.
Require Import QuantumLib.Matrix.
Lemma m3_1 : forall (u0 u1 : C),
Cmod u0 = 1 -> Cmod u1 = 1 ->
forall (U : Square 8), WF_Unitary U ->
(U × ((diag2 u0 u1) ⊗ (I 2) ⊗ (I 2)) = ((diag2 u0 u1) ⊗ (I 2) ⊗ (I 2)) × U <->
u0 = u1 \/ (exists (V00 V11 : Square 4),
WF_Unitary V00 /\ WF_Unitary V11 /\
U = ∣0⟩⟨0∣ ⊗ V00 .+ ∣1⟩⟨1∣ ⊗ V11)).
Proof.
intros u0 u1 unit_u0 unit_u1 U Unitary_U.
split.
{
intro H.
destruct (Ceq_dec u0 u1) as [u0_eq_u1 | u0_neq_u1].
{
left.
exact u0_eq_u1.
}
{
right.
assert (block_matrices_U : exists V00 V01 V10 V11 : Square 4,
WF_Matrix V00 /\
WF_Matrix V01 /\
WF_Matrix V10 /\
WF_Matrix V11 /\
U = ∣0⟩⟨0∣ ⊗ V00 .+ ∣0⟩⟨1∣ ⊗ V01 .+ ∣1⟩⟨0∣ ⊗ V10 .+ ∣1⟩⟨1∣ ⊗ V11
).
{
apply block_decomp_general; auto.
destruct Unitary_U; assumption.
}
destruct block_matrices_U as [V00 [V01 [V10 [V11 block_matrices_U]]]].
destruct block_matrices_U as [WF_V00 [WF_V01 [WF_V10 [WF_V11 U_eq_blocks]]]].
exists V00, V11.
assert (W_eq_blocks : (diag2 u0 u1) ⊗ (I 2) ⊗ (I 2) = ∣0⟩⟨0∣ ⊗ (u0 .*(I 4)) .+ ∣0⟩⟨1∣ ⊗ Zero .+ ∣1⟩⟨0∣ ⊗ Zero .+ ∣1⟩⟨1∣ ⊗ (u1 .* (I 4))).
{
unfold diag2.
lma'.
solve_WF_matrix; apply WF_diag2.
solve_WF_matrix.
}
assert (UW : U × (diag2 u0 u1 ⊗ I 2 ⊗ I 2) = ∣0⟩⟨0∣ ⊗ (u0 .* V00) .+ ∣0⟩⟨1∣ ⊗ (u1 .* V01) .+ ∣1⟩⟨0∣ ⊗ (u0 .* V10) .+ ∣1⟩⟨1∣ ⊗ (u1 .* V11)).
{
rewrite U_eq_blocks, W_eq_blocks; clear U_eq_blocks W_eq_blocks.
rewrite block_multiply with
(P00 := V00)
(P01 := V01)
(P10 := V10)
(P11 := V11)
(Q00 := u0 .* I 4)
(Q01 := Zero)
(Q10 := Zero)
(Q11 := u1 .* I 4)
(U := (∣0⟩⟨0∣ ⊗ V00 .+ ∣0⟩⟨1∣ ⊗ V01 .+ ∣1⟩⟨0∣ ⊗ V10 .+ ∣1⟩⟨1∣ ⊗ V11))
(V := (∣0⟩⟨0∣ ⊗ (u0 .* I 4) .+ ∣0⟩⟨1∣ ⊗ Zero .+ ∣1⟩⟨0∣ ⊗ Zero .+ ∣1⟩⟨1∣ ⊗ (u1 .* I 4))) at 1; try solve_WF_matrix.
repeat rewrite Mscale_mult_dist_r.
Msimpl.
reflexivity.
}
assert (WU : (diag2 u0 u1 ⊗ I 2 ⊗ I 2) × U = ∣0⟩⟨0∣ ⊗ (u0 .* V00) .+ ∣0⟩⟨1∣ ⊗ (u0 .* V01) .+ ∣1⟩⟨0∣ ⊗ (u1 .* V10) .+ ∣1⟩⟨1∣ ⊗ (u1 .* V11)).
{
rewrite U_eq_blocks, W_eq_blocks; clear U_eq_blocks W_eq_blocks.
rewrite block_multiply with
(P00 := u0 .* I 4)
(P01 := Zero)
(P10 := Zero)
(P11 := u1 .* I 4)
(Q00 := V00)
(Q01 := V01)
(Q10 := V10)
(Q11 := V11)
(U := (∣0⟩⟨0∣ ⊗ (u0 .* I 4) .+ ∣0⟩⟨1∣ ⊗ Zero .+ ∣1⟩⟨0∣ ⊗ Zero .+ ∣1⟩⟨1∣ ⊗ (u1 .* I 4)))
(V := (∣0⟩⟨0∣ ⊗ V00 .+ ∣0⟩⟨1∣ ⊗ V01 .+ ∣1⟩⟨0∣ ⊗ V10 .+ ∣1⟩⟨1∣ ⊗ V11)) at 1; try solve_WF_matrix.
repeat rewrite Mscale_mult_dist_l.
Msimpl.
reflexivity.
}
rewrite UW, WU in H; clear UW WU W_eq_blocks.
apply (@block_equalities_general
4%nat
(∣0⟩⟨0∣ ⊗ (u0 .* V00) .+ ∣0⟩⟨1∣ ⊗ (u1 .* V01) .+ ∣1⟩⟨0∣ ⊗ (u0 .* V10) .+ ∣1⟩⟨1∣ ⊗ (u1 .* V11))
(∣0⟩⟨0∣ ⊗ (u0 .* V00) .+ ∣0⟩⟨1∣ ⊗ (u0 .* V01) .+ ∣1⟩⟨0∣ ⊗ (u1 .* V10) .+ ∣1⟩⟨1∣ ⊗ (u1 .* V11))
(u0 .* V00)
(u1 .* V01)
(u0 .* V10)
(u1 .* V11)
(u0 .* V00)
(u0 .* V01)
(u1 .* V10)
(u1 .* V11)
) in H; try solve_WF_matrix; try lia.
destruct H as [_ [V01_mult [V10_mult _]]].
assert (H : forall {m n} (a b : C) (M : Matrix m n),
WF_Matrix M -> a <> b -> a .* M = b .* M -> M = Zero).
{
intros.
assert (H2 : a - b <> C0).
{
intro H2.
apply H0.
rewrite <- Cplus_0_l.
rewrite <- H2.
lca.
}
apply Mscale_cancel_l with (c := a - b); auto.
unfold Cminus.
rewrite Mscale_plus_distr_l.
rewrite H1.
lma'.
}
assert (Zero_V01 : V01 = Zero).
{
apply (H 4%nat 4%nat u1 u0); auto.
}
assert (Zero_V10 : V10 = Zero).
{
apply (H 4%nat 4%nat u0 u1); auto.
}
destruct Unitary_U as [WF_U Unitary_U].
rewrite U_eq_blocks in Unitary_U.
repeat rewrite Mplus_adjoint in Unitary_U.
repeat rewrite kron_adjoint in Unitary_U.
rewrite adjoint00, adjoint01, adjoint10, adjoint11 in Unitary_U.
rewrite block_multiply with
(P00 := V00†)
(P01 := V10†)
(P10 := V01†)
(P11 := V11†)
(Q00 := V00)
(Q01 := V01)
(Q10 := V10)
(Q11 := V11)
(U := (∣0⟩⟨0∣ ⊗ (V00) † .+ ∣1⟩⟨0∣ ⊗ (V01) † .+ ∣0⟩⟨1∣ ⊗ (V10) † .+ ∣1⟩⟨1∣ ⊗ (V11) †))
(V := (∣0⟩⟨0∣ ⊗ V00 .+ ∣0⟩⟨1∣ ⊗ V01 .+ ∣1⟩⟨0∣ ⊗ V10 .+ ∣1⟩⟨1∣ ⊗ V11)) in Unitary_U at 1; solve_WF_matrix.
{
assert (H0 : I 8 = ∣0⟩⟨0∣ ⊗ I 4 .+ ∣0⟩⟨1∣ ⊗ Zero .+ ∣1⟩⟨0∣ ⊗ Zero .+ ∣1⟩⟨1∣ ⊗ I 4).
{
Msimpl.
rewrite <- kron_plus_distr_r, Mplus01, id_kron.
replace (2 * 4)%nat with 8%nat by lia.
reflexivity.
}
rewrite H0 in Unitary_U; clear H0.
rewrite Zero_V01, Zero_V10 in Unitary_U.
repeat rewrite zero_adjoint_eq in Unitary_U.
repeat rewrite Mmult_0_l in Unitary_U.
repeat rewrite Mmult_0_r in Unitary_U.
repeat rewrite Mplus_0_l in Unitary_U.
repeat rewrite Mplus_0_r in Unitary_U.
apply (
@block_equalities_general
4%nat
(∣0⟩⟨0∣ ⊗ ((V00) † × V00) .+ ∣0⟩⟨1∣ ⊗ Zero .+ ∣1⟩⟨0∣ ⊗ Zero .+ ∣1⟩⟨1∣ ⊗ ((V11) † × V11))
(∣0⟩⟨0∣ ⊗ I 4 .+ ∣0⟩⟨1∣ ⊗ Zero .+ ∣1⟩⟨0∣ ⊗ Zero .+ ∣1⟩⟨1∣ ⊗ I 4)
(V00† × V00)
Zero
Zero
(V11† × V11)
(I 4)
Zero
Zero
(I 4)
) in Unitary_U; try solve_WF_matrix; try lia.
destruct Unitary_U as [Unitary_V00 [_ [_ Unitary_V11]]].
split.
{
split; auto.
}
split.
{
split; auto.
}
{
revert U_eq_blocks; rewrite Zero_V01, Zero_V10; Msimpl; intro U_eq_blocks.
exact U_eq_blocks.
}
}
{
rewrite Zero_V01, Zero_V10; Msimpl.
reflexivity.
}
}
}
{
intro H.
destruct H as [u0_eq_u1 | H].
{
rewrite u0_eq_u1.
assert (diag_scale : diag2 u1 u1 = u1 .* I 2).
{
unfold diag2.
lma'.
apply WF_diag2.
}
rewrite diag_scale; clear diag_scale.
repeat rewrite Mscale_kron_dist_l.
replace (I 2 ⊗ I 2 ⊗ I 2) with (I 8) by lma'.
rewrite Mscale_mult_dist_l.
rewrite Mscale_mult_dist_r.
destruct Unitary_U as [WF_U _].
Msimpl; auto.
}
{
destruct H as [V00 [V11 [[WF_V00 Unitary_V00] [[WF_V01 Unitary_V01] U_eq_blocks]]]].
rewrite U_eq_blocks; clear U_eq_blocks.
assert (H0 : ∣0⟩⟨0∣ ⊗ V00 .+ ∣1⟩⟨1∣ ⊗ V11 = ∣0⟩⟨0∣ ⊗ V00 .+ ∣0⟩⟨1∣ ⊗ Zero .+ ∣1⟩⟨0∣ ⊗ Zero .+ ∣1⟩⟨1∣ ⊗ V11).
{
Msimpl.
reflexivity.
}
assert (H1 : diag2 u0 u1 ⊗ I 2 ⊗ I 2 = ∣0⟩⟨0∣ ⊗ (u0 .* I 4) .+ ∣0⟩⟨1∣ ⊗ Zero .+ ∣1⟩⟨0∣ ⊗ Zero .+ ∣1⟩⟨1∣ ⊗ (u1 .* I 4)).
{
unfold diag2; Msimpl; lma'.
solve_WF_matrix; apply WF_diag2.
}
rewrite H0, H1; clear H0 H1.
rewrite block_multiply with
(P00 := V00)
(P01 := Zero)
(P10 := Zero)
(P11 := V11)
(Q00 := u0 .* I 4)
(Q01 := Zero)
(Q10 := Zero)
(Q11 := u1 .* I 4)
(U := (∣0⟩⟨0∣ ⊗ V00 .+ ∣0⟩⟨1∣ ⊗ Zero .+ ∣1⟩⟨0∣ ⊗ Zero .+ ∣1⟩⟨1∣ ⊗ V11))
(V := (∣0⟩⟨0∣ ⊗ (u0 .* I 4) .+ ∣0⟩⟨1∣ ⊗ Zero .+ ∣1⟩⟨0∣ ⊗ Zero .+ ∣1⟩⟨1∣ ⊗ (u1 .* I 4))) at 1; try solve_WF_matrix.
rewrite block_multiply with
(P00 := u0 .* I 4)
(P01 := Zero)
(P10 := Zero)
(P11 := u1 .* I 4)
(Q00 := V00)
(Q01 := Zero)
(Q10 := Zero)
(Q11 := V11)
(U := (∣0⟩⟨0∣ ⊗ (u0 .* I 4) .+ ∣0⟩⟨1∣ ⊗ Zero .+ ∣1⟩⟨0∣ ⊗ Zero .+ ∣1⟩⟨1∣ ⊗ (u1 .* I 4)))
(V := (∣0⟩⟨0∣ ⊗ V00 .+ ∣0⟩⟨1∣ ⊗ Zero .+ ∣1⟩⟨0∣ ⊗ Zero .+ ∣1⟩⟨1∣ ⊗ V11)) at 1; try solve_WF_matrix.
repeat rewrite Mscale_mult_dist_l.
repeat rewrite Mscale_mult_dist_r.
Msimpl.
reflexivity.
}
}
Qed.
Lemma m3_2 : forall (u0 u1 : C),
Cmod u0 = 1 -> Cmod u1 = 1 ->
(exists (P Q : Square 2),
WF_Unitary P /\ WF_Unitary Q /\
(exists (a b p q : C) (v1 v2 v3 v4 : Vector 2),
WF_Matrix v1 /\ WF_Matrix v2 /\ WF_Matrix v3 /\ WF_Matrix v4 /\
v1 <> Zero /\ v2 <> Zero /\ v3 <> Zero /\ v4 <> Zero /\
Eigenpair P (v1, a) /\ Eigenpair P (v2, b) /\
Eigenpair Q (v3, p) /\ Eigenpair Q (v4, q) /\
(Eigenpair (P ⊗ Q) (v1 ⊗ v3, C1) /\
Eigenpair (P ⊗ Q) (v1 ⊗ v4, C1) /\
Eigenpair (P ⊗ Q) (v2 ⊗ v3, u0) /\
Eigenpair (P ⊗ Q) (v2 ⊗ v4, u1) \/
Eigenpair (P ⊗ Q) (v1 ⊗ v3, C1) /\
Eigenpair (P ⊗ Q) (v1 ⊗ v4, u1) /\
Eigenpair (P ⊗ Q) (v2 ⊗ v3, u0) /\
Eigenpair (P ⊗ Q) (v2 ⊗ v4, C1))))
<-> u0 = u1 \/ u0 * u1 = C1.
Proof.
intros u0 u1 unit_u0 unit_u1.
split.
{
intro.
destruct H as [P [Q [Unitary_P [Unitary_Q H]]]].
destruct H as [a [b [p [q [v1 [v2 [v3 [v4 H]]]]]]]].
destruct H as [WF_v1 [WF_v2 [WF_v3 [WF_v4 H]]]].
destruct H as [v1_nonzero [v2_nonzero [v3_nonzero [v4_nonzero H]]]].
destruct H as [epair1 [epair2 [epair3 [epair4 H]]]].
assert (WF_P : WF_Matrix P).
{
destruct Unitary_P.
assumption.
}
assert (WF_Q : WF_Matrix Q).
{
destruct Unitary_Q.
assumption.
}
destruct H.
{
destruct H as [epair5 [epair6 [epair7 epair8]]].
assert (help1 : a * p = C1).
{
pose proof (
a5_left
P Q
Unitary_P Unitary_Q
a p v1 v3
WF_v1 WF_v3
epair1 epair3
) as H.
unfold Eigenpair in epair5, H; simpl in epair5, H.
rewrite epair5 in H.
apply @Mscale_cancel_r with (A := v1 ⊗ v3) (m := 4%nat) (n := 1%nat); auto.
solve_WF_matrix.
apply nonzero_kron; auto.
}
assert (help2 : a * q = C1).
{
pose proof (
a5_left
P Q
Unitary_P Unitary_Q
a q v1 v4
WF_v1 WF_v4
epair1 epair4
) as H.
unfold Eigenpair in epair6, H; simpl in epair6, H.
rewrite epair6 in H.
apply @Mscale_cancel_r with (A := v1 ⊗ v4) (m := 4%nat) (n := 1%nat); auto.
solve_WF_matrix.
apply nonzero_kron; auto.
}
assert (help3 : b * p = u0).
{
pose proof (
a5_left
P Q
Unitary_P Unitary_Q
b p v2 v3
WF_v2 WF_v3
epair2 epair3
) as H.
unfold Eigenpair in epair7, H; simpl in epair7, H.
rewrite epair7 in H.
apply @Mscale_cancel_r with (A := v2 ⊗ v3) (m := 4%nat) (n := 1%nat); auto.
solve_WF_matrix.
apply nonzero_kron; auto.
}
assert (help4 : b * q = u1).
{
pose proof (
a5_left
P Q
Unitary_P Unitary_Q
b q v2 v4
WF_v2 WF_v4
epair2 epair4
) as H.
unfold Eigenpair in epair8, H; simpl in epair8, H.
rewrite epair8 in H.
apply @Mscale_cancel_r with (A := v2 ⊗ v4) (m := 4%nat) (n := 1%nat); auto.
solve_WF_matrix.
apply nonzero_kron; auto.
}
left.
rewrite <- help3, <- help4.
rewrite <- Cmult_1_l with (x := b).
rewrite <- help2 at 1.
rewrite <- help1 at 1.
lca.
}
{
destruct H as [epair5 [epair6 [epair7 epair8]]].
assert (help1 : a * p = C1).
{
pose proof (
a5_left
P Q
Unitary_P Unitary_Q
a p v1 v3
WF_v1 WF_v3
epair1 epair3
) as H.
unfold Eigenpair in epair5, H; simpl in epair5, H.
rewrite epair5 in H.
apply @Mscale_cancel_r with (A := v1 ⊗ v3) (m := 4%nat) (n := 1%nat); auto.
solve_WF_matrix.
apply nonzero_kron; auto.
}
assert (help2 : a * q = u1).
{
pose proof (
a5_left
P Q
Unitary_P Unitary_Q
a q v1 v4
WF_v1 WF_v4
epair1 epair4
) as H.
unfold Eigenpair in epair6, H; simpl in epair6, H.
rewrite epair6 in H.
apply @Mscale_cancel_r with (A := v1 ⊗ v4) (m := 4%nat) (n := 1%nat); auto.
solve_WF_matrix.
apply nonzero_kron; auto.
}
assert (help3 : b * p = u0).
{
pose proof (
a5_left
P Q
Unitary_P Unitary_Q
b p v2 v3
WF_v2 WF_v3
epair2 epair3
) as H.
unfold Eigenpair in epair7, H; simpl in epair7, H.
rewrite epair7 in H.
apply @Mscale_cancel_r with (A := v2 ⊗ v3) (m := 4%nat) (n := 1%nat); auto.
solve_WF_matrix.
apply nonzero_kron; auto.
}
assert (help4 : b * q = C1).
{
pose proof (
a5_left
P Q
Unitary_P Unitary_Q
b q v2 v4
WF_v2 WF_v4
epair2 epair4
) as H.
unfold Eigenpair in epair8, H; simpl in epair8, H.
rewrite epair8 in H.
apply @Mscale_cancel_r with (A := v2 ⊗ v4) (m := 4%nat) (n := 1%nat); auto.
solve_WF_matrix.
apply nonzero_kron; auto.
}
right.
rewrite <- help2, <- help3.
rewrite <- Cmult_1_l with (x := C1).
rewrite <- help1 at 1.
rewrite <- help4 at 1.
lca.
}
}
{
intros.
destruct H.
{
exists (diag2 1 u1), (I 2).
split.
{
unfold WF_Unitary.
split.
{
apply WF_diag2.
}
{
lma'.
solve_WF_matrix.
apply WF_diag2.
apply WF_diag2.
unfold diag2, I, adjoint, Mmult; simpl.
Csimpl.
rewrite <- Cmod_sqr.
rewrite unit_u1.
lca.
}
}
split.
{
apply id_unitary.
}
exists C1, u1, C1, C1.
exists ∣0⟩, ∣1⟩, ∣0⟩, ∣1⟩.
split.
{
apply WF_qubit0.
}
split.
{
apply WF_qubit1.
}
split.
{
apply WF_qubit0.
}
split.
{
apply WF_qubit1.
}
split.
{
apply nonzero_qubit0.
}
split.
{
apply nonzero_qubit1.
}
split.
{
apply nonzero_qubit0.
}
split.
{
apply nonzero_qubit1.
}
split.
{
apply diag2_eigenpairs.
}
split.
{
apply diag2_eigenpairs.
}
split.
{
apply id2_eigenpairs.
}
split.
{
apply id2_eigenpairs.
}
left.
split.
{
unfold Eigenpair.
lma'; simpl.
solve_WF_matrix.
apply WF_diag2.
solve_WF_matrix.
}
split.
{
unfold Eigenpair.
lma'; simpl.
solve_WF_matrix.
apply WF_diag2.
solve_WF_matrix.
}
split.
{
rewrite H.
unfold Eigenpair.
lma'; simpl.
solve_WF_matrix.
apply WF_diag2.
solve_WF_matrix.
unfold scale, Mmult, kron, diag2, I; simpl.
lca.
}
{
unfold Eigenpair.
lma'; simpl.
solve_WF_matrix.
apply WF_diag2.
solve_WF_matrix.
unfold scale, Mmult, kron, diag2, I; simpl.
lca.
}
}
{
exists (diag2 1 u0), (diag2 1 u1).
split.
{
unfold WF_Unitary.
split.
{
apply WF_diag2.
}
{
lma'.
solve_WF_matrix.
apply WF_diag2.
apply WF_diag2.
unfold diag2, I, adjoint, Mmult; simpl.
Csimpl.
rewrite <- Cmod_sqr.
rewrite unit_u0.
lca.
}
}
split.
{
unfold WF_Unitary.
split.
{
apply WF_diag2.
}
{
lma'.
solve_WF_matrix.
apply WF_diag2.
apply WF_diag2.
unfold diag2, I, adjoint, Mmult; simpl.
Csimpl.
rewrite <- Cmod_sqr.
rewrite unit_u1.
lca.
}
}
exists C1, u0, C1, u1.
exists ∣0⟩, ∣1⟩, ∣0⟩, ∣1⟩.
split.
{
apply WF_qubit0.
}
split.
{
apply WF_qubit1.
}
split.
{
apply WF_qubit0.
}
split.
{
apply WF_qubit1.
}
split.
{
apply nonzero_qubit0.
}
split.
{
apply nonzero_qubit1.
}
split.
{
apply nonzero_qubit0.
}
split.
{
apply nonzero_qubit1.
}
split.
{
apply diag2_eigenpairs.
}
split.
{
apply diag2_eigenpairs.
}
split.
{
apply diag2_eigenpairs.
}
split.
{
apply diag2_eigenpairs.
}
right.
split.
{
lma'.
solve_WF_matrix.
apply WF_diag2.
apply WF_diag2.
solve_WF_matrix.
}
split.
{
lma'.
solve_WF_matrix.
apply WF_diag2.
apply WF_diag2.
solve_WF_matrix.
unfold scale, Mmult, kron, diag2, I, qubit0, qubit1; simpl.
lca.
}
split.
{
lma'.
solve_WF_matrix.
apply WF_diag2.
apply WF_diag2.
solve_WF_matrix.
unfold scale, Mmult, kron, diag2, I, qubit0, qubit1; simpl.
lca.
}
{
lma'.
solve_WF_matrix.
apply WF_diag2.
apply WF_diag2.
solve_WF_matrix.
unfold scale, Mmult, kron, diag2, I, qubit0, qubit1; simpl.
rewrite H.
lca.
}
}
}
Qed.
Lemma m4_1 : forall (u0 u1 : C),
Cmod u0 = 1 -> Cmod u1 = 1 ->
(exists (U V : Square 4) (P0 P1 Q0 Q1: Square 2),
WF_Unitary U /\ WF_Unitary V /\ WF_Unitary P0 /\ WF_Unitary P1 /\ WF_Unitary Q0 /\ WF_Unitary Q1 /\
∣0⟩⟨0∣ ⊗ (U × (P0 ⊗ Q0) × V) .+ ∣1⟩⟨1∣ ⊗ (U × (P1 ⊗ Q1) × V) = ccu (diag2 u0 u1))
<-> u0 = u1 \/ u0 * u1 = 1.
Proof.
split.
- admit.
- intros.
destruct H1.
+ exists (I 4), (I 4), (I 2), (diag2 1 u1), (I 2), (I 2).
assert (diag2_unitary : WF_Unitary (diag2 1 u1)).
{
split.
- apply WF_diag2.
- solve_matrix.
unfold diag2; simpl.
rewrite <- Cmod_sqr.
rewrite H0.
lca.
}
split. apply id_unitary.
split. apply id_unitary.
split. apply id_unitary.
split. apply diag2_unitary.
split. apply id_unitary.
split. apply id_unitary.
(* This line removes a lot of subgoals created by the following Msimpl *)
assert (WF_my_diag2 : WF_Matrix (diag2 1 u1)). apply WF_diag2.
Msimpl.
lma'.
do 2 apply WF_control; apply WF_diag2.
{
unfold kron, adjoint, Mmult, Mplus, ccu, control, diag2, I, qubit0, qubit1; simpl.
Csimpl.
symmetry; exact H1.
}
{
unfold kron, adjoint, Mmult, Mplus, ccu, control, diag2, I, qubit0, qubit1; simpl.
Csimpl.
reflexivity.
}
+ exists notc, notc, (I 2), (diag2 1 u0), (I 2), (diag2 1 u1).
assert (diag2_unitary : forall u, Cmod u = 1 -> WF_Unitary (diag2 1 u)).
{
split.
- apply WF_diag2.
- solve_matrix.
unfold diag2; simpl.
rewrite <- Cmod_sqr.
rewrite H2.
lca.
}
split. apply notc_unitary.
split. apply notc_unitary.
split. apply id_unitary.
split. apply diag2_unitary; exact H.
split. apply id_unitary.
split. apply diag2_unitary; exact H0.
(* This line removes a lot of subgoals created by the following Msimpl *)
assert (WF_my_diag2 : WF_Matrix (diag2 u0 1)). apply WF_diag2.
Msimpl.
lma'.
{
apply WF_plus.
- apply WF_kron. lia. lia.
solve_WF_matrix.
apply WF_mult.
solve_WF_matrix.
apply WF_notc.
- apply WF_kron. lia. lia.
solve_WF_matrix.
apply WF_mult.
solve_WF_matrix.
apply WF_diag2.
apply WF_diag2.
apply WF_notc.
}
do 2 apply WF_control; apply WF_diag2.
{
unfold kron, adjoint, Mmult, Mplus, ccu, control, diag2, I, qubit0, qubit1; simpl.
Csimpl.
assumption.
}
{
unfold kron, adjoint, Mmult, Mplus, ccu, control, diag2, I, qubit0, qubit1; simpl.
Csimpl.
reflexivity.
}
{
unfold kron, adjoint, Mmult, Mplus, ccu, control, diag2, I, qubit0, qubit1; simpl.
Csimpl.
reflexivity.
}
Admitted.
Lemma m4_2 : forall (u0 u1 : C),
Cmod u0 = 1 -> Cmod u1 = 1 ->
forall (Q : Square 2),
WF_Unitary Q ->
let beta : Vector 2 := Q × ∣0⟩ in
let beta_perp := Q × ∣1⟩ in
(exists (P0 P1 : Square 2) (a b p q : C) (v1 v2 v3 v4 : Vector 2),
WF_Unitary P0 /\ WF_Unitary P1 /\
WF_Matrix v1 /\ WF_Matrix v2 /\ WF_Matrix v3 /\ WF_Matrix v4 /\
v1 <> Zero /\ v2 <> Zero /\ v3 <> Zero /\ v4 <> Zero /\
Eigenpair P0 (v1, a) /\ Eigenpair P0 (v2, b) /\
Eigenpair P1 (v3, p) /\ Eigenpair P1 (v4, q) /\
I 2 ⊗ I 2 ⊗ (beta × beta†) .+ P0 ⊗ P1 ⊗ (beta_perp × beta_perp†) = ccu (diag2 u0 u1))
<-> u0 = 1 /\ u1 = 1.
Proof.
intros.
assert (WF_Q : WF_Matrix Q).
{
destruct H1.
assumption.
}
assert (WF_beta : WF_Matrix beta) by solve_WF_matrix.
assert (WF_beta_perp : WF_Matrix beta_perp) by solve_WF_matrix.
assert (WF_beta_beta : WF_Matrix (beta × beta†)).
{
apply WF_mult.
assumption.
apply WF_adjoint.
assumption.
}
pose (a := beta 0%nat 0%nat).
pose (b := beta 1%nat 0%nat).
split.
- intros.
destruct H2 as [P0 [P1 [c1 [c2 [c3 [c4 [v1 [v2 [v3 [v4 H2]]]]]]]]]].
destruct H2 as [Unitary_P0 [Unitary_P1 H2]].
destruct H2 as [WF_v1 [WF_v2 [WF_v3 [WF_v4 H2]]]].
destruct H2 as [v1_nonzero [v2_nonzero [v3_nonzero [v4_nonzero H2]]]].
destruct H2 as [epair1 [epair2 [epair3 [epair4 H2]]]].
destruct (Ceq_dec a C0) as [a_zero | a_nonzero].
+ assert (unit_b : b^* * b = 1).
{
destruct H1.
apply (f_equal (fun f => f 0%nat 0%nat)) in H3.
unfold Mmult, adjoint, I in H3.
simpl in H3.
replace (Q 0%nat 0%nat) with a in H3 by lca.
replace (Q 1%nat 0%nat) with b in H3 by lca.
rewrite <- H3.
rewrite a_zero.
lca.
}
assert (beta_mult_1_1 : beta × beta† = ∣1⟩⟨1∣).
{
unfold beta, adjoint, qubit0, qubit1, Mmult.
simpl.
lma'.
all: replace (Q 0%nat 0%nat) with a by lca.
all: replace (Q 1%nat 0%nat) with b by lca.
- rewrite a_zero.
Csimpl.
reflexivity.
- rewrite a_zero.
Csimpl.
reflexivity.
- rewrite a_zero.
Csimpl.
reflexivity.
- Csimpl.
rewrite Cmult_comm.
rewrite unit_b.
reflexivity.
}
assert (beta_perp_mult_0_0 : beta_perp × (beta_perp) † = ∣0⟩⟨0∣).
{
pose proof (a8 Q H1) as H3.
unfold beta, beta_perp.
apply Mplus_cancel_l with (A := ∣1⟩⟨1∣).
rewrite Mplus10.
rewrite <- H3.
rewrite <- beta_mult_1_1.
unfold beta.
reflexivity.
}
rewrite beta_mult_1_1 in H2.
rewrite beta_perp_mult_0_0 in H2.
assert (u1_is_1 : u1 = C1).
{
apply f_equal with (f := fun f => f 7%nat 7%nat) in H2.
unfold kron, Mmult, Mplus, adjoint, ccu, control, diag2, I, qubit0, qubit1 in H2; simpl in H2.
revert H2; Csimpl; intro H2.
auto.
}
assert (u0_is_1 : u0 = C1).
{
pose proof H2 as H3.
pose proof H2 as H4.
pose proof H2 as H5.
pose proof H2 as H6.
apply f_equal with (f := fun f => f 0%nat 0%nat) in H3.
unfold kron, Mmult, Mplus, adjoint, ccu, control, diag2, I, qubit0, qubit1 in H3; simpl in H3.
revert H3; Csimpl; intro H3.
apply f_equal with (f := fun f => f 2%nat 2%nat) in H4.
unfold kron, Mmult, Mplus, adjoint, ccu, control, diag2, I, qubit0, qubit1 in H4; simpl in H4.
revert H4; Csimpl; intro H4.
apply f_equal with (f := fun f => f 4%nat 4%nat) in H5.
unfold kron, Mmult, Mplus, adjoint, ccu, control, diag2, I, qubit0, qubit1 in H5; simpl in H5.
revert H5; Csimpl; intro H5.
apply f_equal with (f := fun f => f 6%nat 6%nat) in H6.
unfold kron, Mmult, Mplus, adjoint, ccu, control, diag2, I, qubit0, qubit1 in H6; simpl in H6.
revert H6; Csimpl; intro H6.
rewrite <- Cmult_1_l at 1.
rewrite <- Cmult_1_l.
rewrite <- H3 at 1.
rewrite <- H4 at 1.
rewrite <- H5 at 1.
rewrite <- H6 at 1.
lca.
}
split; auto.
+ destruct (Ceq_dec b C0) as [b_zero | b_nonzero].
* assert (unit_a : a^* * a = 1).
{
destruct H1.
apply (f_equal (fun f => f 0%nat 0%nat)) in H3.
unfold Mmult, adjoint, I in H3.
simpl in H3.
replace (Q 0%nat 0%nat) with a in H3 by lca.
replace (Q 1%nat 0%nat) with b in H3 by lca.
rewrite <- H3.
rewrite b_zero.
lca.
}
assert (beta_mult_0_0 : beta × beta† = ∣0⟩⟨0∣).
{
unfold beta, adjoint, qubit0, qubit1, Mmult.
simpl.
lma'.
all: replace (Q 0%nat 0%nat) with a by lca.
all: replace (Q 1%nat 0%nat) with b by lca.
Csimpl.
rewrite Cmult_comm.
rewrite unit_a.
reflexivity.
rewrite b_zero.
Csimpl.
reflexivity.
rewrite b_zero.
Csimpl.
reflexivity.
rewrite b_zero.
Csimpl.
reflexivity.
}
assert (beta_perp_mult_1_1 : beta_perp × (beta_perp) † = ∣1⟩⟨1∣).
{
pose proof (a8 Q H1) as H3.
replace (Q × ∣0⟩) with beta in H3 by reflexivity.
replace (Q × ∣1⟩) with beta_perp in H3 by reflexivity.
rewrite beta_mult_0_0 in H3.
rewrite <- Mplus01 in H3.
apply Mplus_cancel_l in H3.
assumption.
}
rewrite beta_mult_0_0 in H2.
rewrite beta_perp_mult_1_1 in H2.
assert (u0_is_1 : u0 = C1).
{
apply f_equal with (f := fun f => f 6%nat 6%nat) in H2.
unfold kron, Mmult, Mplus, adjoint, ccu, control, diag2, I, qubit0, qubit1 in H2; simpl in H2.
revert H2; Csimpl; intro H2.
auto.
}
assert (u1_is_1 : u1 = C1).
{
pose proof H2 as H3.
pose proof H2 as H4.
pose proof H2 as H5.
pose proof H2 as H6.
apply f_equal with (f := fun f => f 1%nat 1%nat) in H3.
unfold kron, Mmult, Mplus, adjoint, ccu, control, diag2, I, qubit0, qubit1 in H3; simpl in H3.
revert H3; Csimpl; intro H3.
apply f_equal with (f := fun f => f 3%nat 3%nat) in H4.
unfold kron, Mmult, Mplus, adjoint, ccu, control, diag2, I, qubit0, qubit1 in H4; simpl in H4.
revert H4; Csimpl; intro H4.
apply f_equal with (f := fun f => f 5%nat 5%nat) in H5.
unfold kron, Mmult, Mplus, adjoint, ccu, control, diag2, I, qubit0, qubit1 in H5; simpl in H5.
revert H5; Csimpl; intro H5.
apply f_equal with (f := fun f => f 7%nat 7%nat) in H6.
unfold kron, Mmult, Mplus, adjoint, ccu, control, diag2, I, qubit0, qubit1 in H6; simpl in H6.
revert H6; Csimpl; intro H6.
rewrite <- Cmult_1_l at 1.
rewrite <- Cmult_1_l.
rewrite <- H3 at 1.
rewrite <- H4 at 1.
rewrite <- H5 at 1.
rewrite <- H6 at 1.
lca.
}
split; assumption.
* apply (f_equal (fun f => f × (∣1⟩ ⊗ ∣1⟩ ⊗ beta))) in H2.
assert (H3 : beta_perp† × beta = Zero).
{
unfold beta_perp, beta.
rewrite Mmult_adjoint.
rewrite <- Mmult_assoc.
rewrite Mmult_assoc with (A := ⟨1∣).
destruct H1.
rewrite H3.
rewrite Mmult_1_r. 2: exact (WF_bra 1).
exact Mmult10.
}