Skip to content

Commit df9378e

Browse files
authored
Merge pull request #40 from inQWIRE/update/v8.16-v8.19
Update QuantumLib for compatibility with Coq v8.16-8.19
2 parents 95bbfdd + 96a18ae commit df9378e

22 files changed

+157
-148
lines changed

.github/workflows/coq-action.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,10 @@ jobs:
1313
strategy:
1414
matrix:
1515
coq_version:
16-
- '8.12'
17-
- '8.13'
18-
- '8.14'
19-
- '8.15'
2016
- '8.16'
2117
- '8.17'
2218
- '8.18'
23-
- 'dev'
19+
- '8.19'
2420
ocaml_version:
2521
- 'default'
2622
fail-fast: false # don't stop jobs if one fails

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ time-of-build-pretty.log
4949
.CoqMakefile.d
5050
CoqMakefile*
5151
Makefile.coq*
52+
Makefile.conf
5253

5354
_build
5455

55-
docs
56+
docs
57+
/.vscode
58+
.DS_Store

CITATION.cff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: "INQWIRE QuantumLib"
44
abstract: "QuantumLib is a Coq library for reasoning about quantum programs."
55
authors:
66
- name: "The INQWIRE Developers"
7-
version: 1.0.0
7+
version: 1.3.0
88
date-released: 2022-01-06
99
license: MIT
1010
repository-code: "https://github.com/inQWIRE/QuantumLib"

Complex.v

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,7 @@ Proof. intros.
624624
rewrite <- H' in H2. easy.
625625
Qed.
626626

627+
627628
Lemma Cinv_mult_distr : forall c1 c2 : C, c1 <> 0 -> c2 <> 0 -> / (c1 * c2) = / c1 * / c2.
628629
Proof.
629630
intros.
@@ -634,7 +635,7 @@ Proof.
634635
rewrite Rmult_div.
635636
rewrite Rmult_opp_opp.
636637
unfold Rminus.
637-
rewrite <- RIneq.Ropp_div.
638+
rewrite <- Ropp_div.
638639
rewrite <- Rdiv_plus_distr.
639640
rewrite Rmult_plus_distr_r.
640641
rewrite Rmult_plus_distr_l.
@@ -1397,7 +1398,7 @@ Proof.
13971398
lca.
13981399
Qed.
13991400

1400-
Hint Rewrite Cexp_0 Cexp_PI Cexp_PI2 Cexp_2PI Cexp_3PI2 Cexp_PI4 Cexp_PIm4
1401+
#[global] Hint Rewrite Cexp_0 Cexp_PI Cexp_PI2 Cexp_2PI Cexp_3PI2 Cexp_PI4 Cexp_PIm4
14011402
Cexp_1PI4 Cexp_2PI4 Cexp_3PI4 Cexp_4PI4 Cexp_5PI4 Cexp_6PI4 Cexp_7PI4 Cexp_8PI4
14021403
Cexp_add Cexp_neg Cexp_plus_PI Cexp_minus_PI : Cexp_db.
14031404

@@ -1442,28 +1443,28 @@ Ltac nonzero :=
14421443
| |- Rle _ _ => lra
14431444
end.
14441445

1445-
Hint Rewrite Cminus_unfold Cdiv_unfold Ci2 Cconj_R Cconj_opp Cconj_rad2
1446+
#[global] Hint Rewrite Cminus_unfold Cdiv_unfold Ci2 Cconj_R Cconj_opp Cconj_rad2
14461447
Cinv_sqrt2_sqrt Cplus_div2
14471448
Cplus_0_l Cplus_0_r Cplus_opp_r Cplus_opp_l Copp_0 Copp_involutive
14481449
Cmult_0_l Cmult_0_r Cmult_1_l Cmult_1_r : C_db.
14491450

1450-
Hint Rewrite <- Copp_mult_distr_l Copp_mult_distr_r Cdouble : C_db.
1451-
Hint Rewrite Csqrt_sqrt using Psatz.lra : C_db.
1452-
Hint Rewrite Cinv_l Cinv_r using nonzero : C_db.
1451+
#[global] Hint Rewrite <- Copp_mult_distr_l Copp_mult_distr_r Cdouble : C_db.
1452+
#[global] Hint Rewrite Csqrt_sqrt using Psatz.lra : C_db.
1453+
#[global] Hint Rewrite Cinv_l Cinv_r using nonzero : C_db.
14531454
(* Previously in the other direction *)
1454-
Hint Rewrite Cinv_mult_distr using nonzero : C_db.
1455+
#[global] Hint Rewrite Cinv_mult_distr using nonzero : C_db.
14551456

14561457
(* Light rewriting db *)
1457-
Hint Rewrite Cplus_0_l Cplus_0_r Cmult_0_l Cmult_0_r Copp_0
1458+
#[global] Hint Rewrite Cplus_0_l Cplus_0_r Cmult_0_l Cmult_0_r Copp_0
14581459
Cconj_R Cmult_1_l Cmult_1_r : C_db_light.
14591460

14601461
(* Distributing db *)
1461-
Hint Rewrite Cmult_plus_distr_l Cmult_plus_distr_r Copp_plus_distr Copp_mult_distr_l
1462+
#[global] Hint Rewrite Cmult_plus_distr_l Cmult_plus_distr_r Copp_plus_distr Copp_mult_distr_l
14621463
Copp_involutive : Cdist_db.
14631464

1464-
Hint Rewrite RtoC_opp RtoC_mult RtoC_minus RtoC_plus : RtoC_db.
1465-
Hint Rewrite RtoC_inv using nonzero : RtoC_db.
1466-
Hint Rewrite RtoC_pow : RtoC_db.
1465+
#[global] Hint Rewrite RtoC_opp RtoC_mult RtoC_minus RtoC_plus : RtoC_db.
1466+
#[global] Hint Rewrite RtoC_inv using nonzero : RtoC_db.
1467+
#[global] Hint Rewrite RtoC_pow : RtoC_db.
14671468

14681469
Ltac Csimpl :=
14691470
repeat match goal with

DiscreteProb.v

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ Lemma sample_ub_lt : forall l r,
102102
Proof.
103103
induction l; intros. unfold sum_over_list in H. simpl in H. lra.
104104
simpl. destruct (Rlt_le_dec r a). lia.
105-
apply lt_n_S. apply IHl. rewrite sum_over_list_cons in H. lra.
105+
apply -> Nat.succ_lt_mono. apply IHl. rewrite sum_over_list_cons in H. lra.
106106
Qed.
107107

108108
Lemma sample_lb : forall l r, (0 <= sample l r)%nat.
@@ -1472,6 +1472,10 @@ Proof.
14721472
assumption.
14731473
Qed.
14741474

1475+
(* This was removed from std lib without replacement in 8.19 *)
1476+
Lemma mult_O_le_stt : forall n m : nat, (m = 0 \/ n <= m * n)%nat.
1477+
Proof. intros. induction m. auto. right. lia. Qed.
1478+
14751479
Lemma rewrite_pr_outcome_sum : forall n k (u : Square (2 ^ (n + k))) f,
14761480
WF_Matrix u ->
14771481
pr_outcome_sum (apply_u u) (fun x => f (fst k x))
@@ -1498,12 +1502,12 @@ Proof.
14981502
replace (2 ^ (n + k))%nat with (2 ^ n * 2 ^ k)%nat by unify_pows_two.
14991503
apply (Nat.mul_le_mono_r _ _ (2^k)%nat) in H0.
15001504
rewrite Nat.mul_sub_distr_r in H0.
1501-
rewrite mult_1_l in H0.
1505+
rewrite Nat.mul_1_l in H0.
15021506
apply (Nat.add_lt_le_mono x0 (2^k)%nat) in H0; auto.
1503-
rewrite <- le_plus_minus in H0.
1504-
rewrite plus_comm in H0.
1507+
rewrite <- le_plus_minus' in H0.
1508+
rewrite Nat.add_comm in H0.
15051509
assumption.
1506-
destruct (mult_O_le (2^k) (2^n))%nat; auto.
1510+
destruct (mult_O_le_stt (2^k) (2^n))%nat; auto.
15071511
assert (2 <> 0)%nat by lia.
15081512
apply (pow_positive 2 n) in H2.
15091513
lia.

Eigenvectors.v

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ Lemma Y_eq_iXZ : σy = Ci .* σx × σz. Proof. lma'. Qed.
2525
Lemma H_eq_Hadjoint : hadamard† = hadamard. Proof. lma'. Qed.
2626

2727

28-
Hint Rewrite Y_eq_iXZ H_eq_Hadjoint : Q_db.
28+
#[global] Hint Rewrite Y_eq_iXZ H_eq_Hadjoint : Q_db.
2929

3030
Lemma ItimesIid : I 2 × I 2 = I 2. Proof. lma'. Qed.
3131
Lemma XtimesXid : σx × σx = I 2. Proof. lma'. Qed.
3232
Lemma YtimesYid : σy × σy = I 2. Proof. lma'. Qed.
3333
Lemma ZtimesZid : σz × σz = I 2. Proof. lma'. Qed.
3434
Lemma HtimesHid : hadamard × hadamard = I 2. Proof. lma'; Hhelper. Qed.
3535

36-
Hint Rewrite ItimesIid XtimesXid YtimesYid ZtimesZid HtimesHid : Q_db.
36+
#[global] Hint Rewrite ItimesIid XtimesXid YtimesYid ZtimesZid HtimesHid : Q_db.
3737

3838
Lemma ZH_eq_HX : σz × hadamard = hadamard × σx. Proof. lma'. Qed.
3939
Lemma XH_eq_HZ : σx × hadamard = hadamard × σz. Proof. lma'. Qed.
@@ -46,7 +46,7 @@ Lemma cnotX2 : cnot × (I 2 ⊗ σx) = (I 2 ⊗ σx) × cnot. Proof. lma'. Qed.
4646
Lemma cnotZ1 : cnot × (σz ⊗ I 2) = (σz ⊗ I 2) × cnot. Proof. lma'. Qed.
4747
Lemma cnotZ2 : cnot × (I 2 ⊗ σz) = (σz ⊗ σz) × cnot. Proof. lma'. Qed.
4848

49-
Hint Rewrite ZH_eq_HX XH_eq_HZ SX_eq_YS SZ_eq_ZS cnotX1 cnotX2 cnotZ1 cnotZ2 : Q_db.
49+
#[global] Hint Rewrite ZH_eq_HX XH_eq_HZ SX_eq_YS SZ_eq_ZS cnotX1 cnotX2 cnotZ1 cnotZ2 : Q_db.
5050

5151

5252
(*******************************)
@@ -259,7 +259,7 @@ Proof. induction n as [| n'].
259259
rewrite p in H1; easy. }
260260
rewrite H', Pplus_comm, Pplus_degree2; auto.
261261
rewrite H1.
262-
apply le_lt_n_Sm.
262+
apply Nat.lt_succ_r.
263263
apply Psum_degree; intros.
264264
assert (H2 : prep_mat A (S i) 0 = [A (S i) 0]).
265265
{ unfold prep_mat.
@@ -356,7 +356,7 @@ Proof. intros.
356356
prep_matrix_equality.
357357
unfold get_vec, form_basis.
358358
bdestruct (y =? 0).
359-
rewrite <- beq_nat_refl, H0; easy.
359+
rewrite Nat.eqb_refl, H0; easy.
360360
unfold WF_Matrix in H.
361361
rewrite H; try easy.
362362
right.
@@ -885,7 +885,7 @@ Proof. induction m2 as [| m2'].
885885
exists Zero.
886886
split. easy.
887887
rewrite smash_zero; try easy.
888-
rewrite plus_0_r.
888+
rewrite Nat.add_0_r.
889889
apply H2.
890890
- intros.
891891
rewrite (split_col T2) in *.
@@ -1180,8 +1180,8 @@ Proof. intros a b m H0 Hdiv Hmod.
11801180
rewrite Hdiv in Hmod.
11811181
assert (H : m * (b / m) + (a - m * (b / m)) = m * (b / m) + (b - m * (b / m))).
11821182
{ rewrite Hmod. reflexivity. }
1183-
rewrite <- (le_plus_minus (m * (b / m)) a) in H.
1184-
rewrite <- (le_plus_minus (m * (b / m)) b) in H.
1183+
rewrite <- (le_plus_minus' (m * (b / m)) a) in H.
1184+
rewrite <- (le_plus_minus' (m * (b / m)) b) in H.
11851185
apply H.
11861186
apply Nat.mul_div_le; apply H0.
11871187
rewrite <- Hdiv; apply Nat.mul_div_le; apply H0.

FiniteGroups.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Global Program Instance list_is_monoid {X} : Monoid (list X) :=
1616
{ Gzero := []
1717
; Gplus := @app X
1818
}.
19-
Next Obligation. rewrite app_nil_end; easy. Qed.
19+
Next Obligation. rewrite <- app_nil_r; easy. Qed.
2020
Next Obligation. rewrite app_assoc; easy. Qed.
2121

2222

GenMatrix.v

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,8 @@ Ltac by_cell :=
316316
let Hi := fresh "Hi" in
317317
let Hj := fresh "Hj" in
318318
intros i j Hi Hj; try solve_end;
319-
repeat (destruct i as [|i]; simpl; [|apply Nat.succ_lt_mono in Hi]; try solve_end); clear Hi;
320-
repeat (destruct j as [|j]; simpl; [|apply Nat.succ_lt_mono in Hj]; try solve_end); clear Hj.
319+
repeat (destruct i as [|i]; simpl; [|apply <- Nat.succ_lt_mono in Hi]; try solve_end); clear Hi;
320+
repeat (destruct j as [|j]; simpl; [|apply <- Nat.succ_lt_mono in Hj]; try solve_end); clear Hj.
321321

322322
Ltac lgma' :=
323323
apply genmat_equiv_eq;
@@ -3639,7 +3639,7 @@ Proof. intros.
36393639
simpl.
36403640
autorewrite with R_db.
36413641
rewrite Rmult_comm.
3642-
rewrite Rinv_mult_distr; try easy.
3642+
rewrite Rinv_mult; try easy.
36433643
rewrite <- Rmult_comm.
36443644
rewrite <- Rmult_assoc.
36453645
rewrite Rinv_r; try easy.
@@ -3648,7 +3648,7 @@ Proof. intros.
36483648
unfold Cinv.
36493649
simpl.
36503650
autorewrite with R_db.
3651-
rewrite Rinv_mult_distr; try easy.
3651+
rewrite Rinv_mult; try easy.
36523652
rewrite <- Rmult_assoc.
36533653
rewrite Rinv_r; try easy.
36543654
autorewrite with R_db.

0 commit comments

Comments
 (0)