Skip to content

Commit 47abf88

Browse files
committed
port to Rocq 9.0
1 parent c3e22cd commit 47abf88

File tree

21 files changed

+156
-126
lines changed

21 files changed

+156
-126
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ jobs:
2727
ocaml-compiler: ${{ matrix.ocaml-compiler }}
2828

2929
- run: opam repo add coq-released https://coq.inria.fr/opam/released
30-
- run: opam install coq-equations.1.3+8.17 coq-stdpp.1.8.0 coq-metacoq-template.1.2+8.17 coq-library-undecidability.1.1+8.17
31-
- run: cd theories && opam exec -- make models -j 2
30+
- run: opam install rocq-equations.1.3.1+9.0 coq-stdpp
31+
- run: cd theories && opam exec -- make
3232

3333
# name: Test compilation
3434

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
- Niklas Mück
1212
- Haoyi Zeng
1313
- Maintainer:
14-
- Yannick Forster ([**@yforster**](https://github.com/yfrster))
14+
- Yannick Forster ([**@yforster**](https://github.com/yforster))
1515
- License: [MIT License](LICENSE)
16-
- Compatible Coq versions: 8.17
16+
- Compatible Coq versions: 9.0
1717
- Additional dependencies:
1818
- the [`stdpp` library](https://gitlab.mpi-sws.org/iris/stdpp)
1919
- optionally, the [Coq Library of Undecidability Proofs](https://github.com/uds-psl/coq-library-undecidability)
@@ -48,7 +48,7 @@ This library contains results on synthetic computability theory.
4848
opam switch create coq-synthetic-computability --packages=ocaml-variants.4.14.0+options,ocaml-option-flambda
4949
eval $(opam env)
5050
opam repo add coq-released https://coq.inria.fr/opam/released
51-
opam install coq.8.17.0 coq-equations.1.3+8.17 coq-metacoq-template.1.2+8.17 coq-stdpp.1.8.0
51+
opam install rocq-prover.9.0.0 rocq-equations rocq-metarocq-template coq-stdpp
5252
cd theories
5353
make
5454
make install
@@ -57,7 +57,7 @@ make install
5757
To build the part of the development relying on models of computation, in addition you have to
5858

5959
```sh
60-
opam install coq-library-undecidability.1.1+8.17
60+
opam install coq-library-undecidability
6161
make models
6262
make install-models
6363
```

theories/Axioms/halting.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Proof.
4444
- exists (fun f x => negb (Nat.eqb (f x) 0)).
4545
intros f. unfold K_nat_nat, K_nat_bool.
4646
setoid_rewrite Bool.negb_true_iff.
47-
now setoid_rewrite NPeano.Nat.eqb_neq.
47+
now setoid_rewrite PeanoNat.Nat.eqb_neq.
4848
Qed.
4949

5050
Lemma K_nat_equiv :

theories/Basic/CB.v

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ Section Def_F.
164164
forall x : X, index x < length (e (gen (map f (e (occ x))))).
165165
Proof.
166166
intros x.
167-
eapply lt_le_trans.
167+
eapply Nat.lt_le_trans.
168168
2: eapply gen_spec. 2:eapply NoDup_map; eauto.
169169
rewrite map_length.
170170
eapply nth_error_Some.
@@ -176,7 +176,7 @@ Section Def_F.
176176
nth_error (e (gen (map f (e (occ x))))) (index x) <> None.
177177
Proof.
178178
intros E. eapply nth_error_None in E. revert E.
179-
eapply lt_not_le, index_length.
179+
pose proof (index_length x). lia.
180180
Qed.
181181

182182
Definition F_ (x : X) : Y :=

theories/Basic/CB_PHP.v

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ Section fixes.
130130
- destruct (in_dec eY x l2) as [Hi | Hni].
131131
2: firstorder.
132132
destruct (IHNoDup (remove eY x l2)) as (x0 & H1 & H2 & H3).
133-
+ eapply lt_le_trans. eapply remove_length_lt. 1: eauto. lia.
133+
+ eapply Nat.lt_le_trans. eapply remove_length_lt. 1: eauto. lia.
134134
+ exists x0. firstorder. intros Hx0.
135135
eapply H3. eapply in_in_remove. 2: eauto.
136136
congruence.
@@ -276,8 +276,8 @@ Section fixes2.
276276
eapply build_corr_mono; eauto.
277277
Qed.
278278

279-
Definition f' x := proj1_sig (In1_compute _ _ (build_corrX x (S (IX x)) ltac:(abstract lia))).
280-
Definition g' y := proj1_sig (In2_compute _ _ (build_corrY y (S (IY y)) ltac:(abstract lia))).
279+
#[program] Definition f' x := proj1_sig (In1_compute _ _ (build_corrX x (S (IX x)) _)).
280+
#[program] Definition g' y := proj1_sig (In2_compute _ _ (build_corrY y (S (IY y)) _)).
281281

282282
Lemma f'_g' y :
283283
f' (g' y) = y.

theories/Basic/Myhill.v

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,17 +99,16 @@ Section fixes.
9999
(p x <-> p (γ C x)) /\ In (γ C x) (x :: map fst C) /\ ~ In2 (f (γ C x)) C.
100100
Proof.
101101
funelim (γ C x); try rename H0 into IH.
102-
- intros Hx HC. rewrite <- Heqcall. eauto.
102+
- intros Hx HC. eauto.
103103
- intros Hx HC.
104104
specialize (IH ) as (IH1 & IH2 & IH3).
105105
{ intros ([] & E & [] % in_remove) % in_map_iff; cbn in E; subst.
106106
apply H1. f_equal. eapply HC; eauto. }
107107
{ eapply correspondence_remove; eauto. }
108108
split. 2:split.
109109
+ etransitivity. eapply f_red.
110-
rewrite <- Heqcall.
111110
rewrite <- IH1. symmetry. now eapply HC.
112-
+ rewrite <- Heqcall. specialize IH2 as [EE | ([] & E & [] % in_remove) % in_map_iff]; eauto.
111+
+ specialize IH2 as [EE | ([] & E & [] % in_remove) % in_map_iff]; eauto.
113112
rewrite <- EE. right. eapply in_map_iff. eexists (_, _). eauto.
114113
+ rewrite Heqcall in IH3, IH2, IH1 |- *.
115114
intros ([] & E & ?) % (in_map_iff). cbn in E. subst.
@@ -258,8 +257,8 @@ Section fixes2.
258257
eapply build_corr_mono; eauto.
259258
Qed.
260259

261-
Definition f' x := proj1_sig (In1_compute _ _ (build_corrX x (S (IX x)) ltac:(abstract lia))).
262-
Definition g' y := proj1_sig (In2_compute _ _ (build_corrY y (S (IY y)) ltac:(abstract lia))).
260+
Program Definition f' x := proj1_sig (In1_compute _ _ (build_corrX x (S (IX x)) _)).
261+
Program Definition g' y := proj1_sig (In2_compute _ _ (build_corrY y (S (IY y)) _)).
263262

264263
Lemma f'_red : reduces_m f' p q.
265264
Proof.

theories/CRM/baire_cantor.v

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Lemma max_list_incl A B :
6161
Proof.
6262
induction A.
6363
- cbn. lia.
64-
- cbn. intros H. eapply Max.max_lub.
64+
- cbn. intros H. eapply Nat.max_lub.
6565
2: firstorder. eapply max_list_spec, H. firstorder.
6666
Qed.
6767

@@ -89,7 +89,7 @@ Proof.
8989

9090
specialize (H (map f_N (seq 0 n))).
9191
rewrite map_length seq_length in H.
92-
specialize (H (le_refl _)).
92+
specialize (H (Nat.le_refl _)).
9393
edestruct (listable_exists_dec (p := fun i => 0 < i <= n) ( q := fun i => ~ Exists (le i) (M (extend (take i (map f_N (seq 0 n)))) 0))).
9494
+ exists (seq 1 n). clear. intros. rewrite in_seq. lia.
9595
+ intros x. eapply not_dec. eapply Exists_dec. intros. eapply le_dec.
@@ -125,31 +125,31 @@ Proof.
125125
exists N. intros H.
126126
enough (N < N) by lia.
127127

128-
eapply lt_le_trans with (m := 1 + max_list (M (extend (map f (seq 0 N))) 0)).
128+
eapply Nat.lt_le_trans with (m := 1 + max_list (M (extend (map f (seq 0 N))) 0)).
129129
+ specialize (H N). setoid_rewrite List.Exists_exists in H.
130130
destruct H as [i Hi].
131131
* split. unfold N. cbn. lia. now rewrite map_length seq_length.
132-
* eapply le_lt_trans. eapply Hi.
132+
* eapply Nat.le_lt_trans. eapply Hi.
133133
enough (max_list [i] <= max_list (M (extend (map f (seq 0 N))) 0)) as H0.
134-
unfold max_list in H0 at 1. rewrite Max.max_0_r in H0. unfold id in H0 at 1. lia.
134+
unfold max_list in H0 at 1. rewrite Nat.max_0_r in H0. unfold id in H0 at 1. lia.
135135
eapply max_list_incl. intros ? [-> | []].
136136
replace N with (length (map f (seq 0 N))) in Hi at 1.
137137
rewrite firstn_all in Hi. eapply Hi.
138138
now rewrite map_length seq_length.
139139
+ unfold N. rewrite <- HL.
140-
eapply plus_le_compat_l.
140+
enough (max_list (M f 0) ≤ max_list (1 + length L :: L ++ M f 0)). lia.
141141
eapply max_list_incl, incl_tl, incl_appr, incl_refl.
142142
eapply map_ext_in.
143143
intros a Ha. unfold extend.
144144
erewrite nth_indep.
145145
erewrite map_nth, seq_nth.
146146
* reflexivity.
147147
* enough (max_list [a] <= max_list (1 + length L :: L ++ M f 0)) as H0.
148-
unfold max_list in H0 at 1. rewrite Max.max_0_r in H0. unfold id in H0 at 1. lia.
148+
unfold max_list in H0 at 1. rewrite Nat.max_0_r in H0. unfold id in H0 at 1. lia.
149149
eapply max_list_incl. intros ? [-> | []]. eapply in_cons, in_app_iff. eauto.
150150
* rewrite map_length seq_length.
151151
enough (max_list [a] <= max_list (1 + length L :: L ++ M f 0)) as H0.
152-
unfold max_list in H0 at 1. rewrite Max.max_0_r in H0. unfold id in H0 at 1. lia.
152+
unfold max_list in H0 at 1. rewrite Nat.max_0_r in H0. unfold id in H0 at 1. lia.
153153
eapply max_list_incl. intros ? [-> | []]. eapply in_cons, in_app_iff. eauto.
154154
Unshelve. all:econstructor.
155155
Qed.
@@ -239,9 +239,15 @@ Proof.
239239
rewrite <- app_assoc in Heq.
240240
destruct (lt_eq_lt_dec (length l2') (length l1')) as [[Hlt|e] | Hgt].
241241
- eapply (f_equal (take (length l1'))) in Heq.
242-
rewrite take_app take_ge in Heq.
243-
rewrite app_length. cbn. lia.
244-
subst. exfalso. eauto.
242+
rewrite take_app in Heq.
243+
rewrite take_app_ge in Heq. lia.
244+
cbn in Heq.
245+
exfalso. destruct (length l1' - length l2') eqn:E. lia.
246+
cbn in *. subst.
247+
eapply nH2, tree_p. eapply (Kleene_T T_K). 2:exact H1.
248+
rewrite Nat.sub_diag in Heq. cbn in Heq.
249+
rewrite app_nil_r in Heq. rewrite <- Heq.
250+
rewrite take_ge. lia. destruct n; cbn; eauto.
245251
- eapply app_inj_1 in Heq as [-> Heq]; eauto.
246252
destruct l3; cbn in *; congruence.
247253
- eapply (f_equal (take (length l2'))) in Heq.
@@ -251,6 +257,8 @@ Proof.
251257
exfalso. destruct (length l2' - length l1') eqn:E. lia.
252258
cbn in *. subst.
253259
eapply nH1, tree_p. eapply (Kleene_T T_K). 2:exact H2.
260+
rewrite Nat.sub_diag in Heq. cbn in Heq.
261+
rewrite app_nil_r in Heq. rewrite firstn_all in Heq. subst.
254262
eexists. now rewrite <- app_assoc.
255263
Qed.
256264

@@ -311,12 +319,12 @@ Proof.
311319
rewrite IHk. f_equal.
312320
destruct (drop k (F' f 0 k ++ ℓ (f k))) eqn:E1.
313321
+ eapply (f_equal length) in E1.
314-
rewrite drop_length in E1. cbn in E1.
322+
rewrite skipn_length in E1. cbn in E1.
315323
pose proof (F'_length f 0 (S k)). cbn in H2. rewrite app_length in H2, E1.
316324
lia.
317325
+ destruct (drop k (F' g 0 k ++ ℓ (g k))) eqn:E2.
318326
* eapply (f_equal length) in E2.
319-
rewrite drop_length in E2. cbn in E2.
327+
rewrite skipn_length in E2. cbn in E2.
320328
pose proof (F'_length g 0 (S k)). cbn in H2. rewrite app_length in H2, E2.
321329
lia.
322330
* cbn. rewrite !firstn_O. f_equal.
@@ -405,16 +413,16 @@ Proof.
405413
assert (k''' <= k''). {
406414
subst k''' k'' k.
407415
cbn. rewrite app_length. lia.
408-
}
416+
}
409417
rewrite !take_take in Heq; eauto.
410418
rewrite firstn_app in Heq.
411419
rewrite !Nat.add_0_r in Heq.
412420
unfold k''' in Heq at 3.
413-
rewrite take_app in Heq.
421+
rewrite take_app_length in Heq.
414422
setoid_rewrite take_ge in Heq at 1. 2:eassumption.
415423
eapply leaf_prefix. eauto. eauto.
416424
eapply prefix_take_iff. rewrite <- Heq.
417-
now rewrite take_app.
425+
now rewrite take_app_length.
418426
* pose (k := (length (F' f 0 (S (S n))))).
419427
pose proof (F_inj_help H k) as Heq.
420428
pose proof (F'_eq_lt (o := 0) IH) as Hpref.
@@ -443,13 +451,13 @@ Proof.
443451
rewrite firstn_app in Heq.
444452
rewrite !Nat.add_0_r in Heq.
445453
unfold k''' in Heq at 3.
446-
rewrite take_app in Heq.
454+
rewrite take_app_length in Heq.
447455
setoid_rewrite take_ge in Heq at 1. 2:eassumption.
448456
symmetry.
449457
eapply leaf_prefix. eauto. eauto.
450458
eapply prefix_take_iff. rewrite <- Heq.
451-
now rewrite take_app.
452-
Qed.
459+
now rewrite take_app_length.
460+
Qed.
453461

454462
Lemma exists_leaf l2 :
455463
~ T_K l2 -> exists l1, l1 `prefix_of` l2 /\ leaf l1.
@@ -767,7 +775,7 @@ Proof.
767775
- reflexivity.
768776
- cbn. rewrite app_length seq_app map_app.
769777
cbn. rewrite app_nth2. lia.
770-
rewrite minus_diag. cbn. f_equal.
778+
rewrite Nat.sub_diag. cbn. f_equal.
771779
rewrite <- IHl at 2.
772780
eapply map_ext_in.
773781
intros ? [_ ?] % in_seq. cbn in *.

theories/CRM/kleenetree.v

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ Proof.
297297
move => H n Hn x Hx.
298298
assert (Hg : D (length l1 + length l3) n = Some x). {
299299
eapply seval_mono. eassumption. lia. }
300-
specialize (H n (lt_plus_trans _ _ (length l3) Hn) x Hg).
300+
specialize (H n (Arith_base.lt_plus_trans_stt _ _ (length l3) Hn) x Hg).
301301
erewrite <- (lookup_app_l _ _ _ Hn). eassumption.
302302
- eapply decidable_iff. econstructor. move => a. generalize (length a) at 2 as k.
303303
induction a as [ | b a] using rev_rect; move => k; cbn.
@@ -308,11 +308,11 @@ Proof.
308308
++ left. rewrite app_length. cbn. move => n Hn x' Hx'.
309309
destruct (nat_eq_dec n (length a)).
310310
** subst. rewrite lookup_app_r. lia.
311-
rewrite minus_diag. cbn. congruence.
311+
rewrite Nat.sub_diag. cbn. congruence.
312312
** rewrite lookup_app_l. lia.
313313
eapply L. lia. eassumption.
314314
++ right. rewrite app_length. cbn. move => / (fun H => H (length a)) H.
315-
rewrite lookup_app_r ?minus_diag in H. lia. cbn in H.
315+
rewrite lookup_app_r ?Nat.sub_diag in H. lia. cbn in H.
316316
eapply n.
317317
eapply Some_inj. symmetry. eapply H. lia. eauto.
318318
-- left. rewrite app_length. cbn. move => n Hn x' Hx'.
@@ -341,7 +341,7 @@ Proof.
341341
* cbn. destruct (nat_eq_dec n m).
342342
-- subst. rewrite Hx. destruct m. cbn. reflexivity.
343343
rewrite lookup_app_r. rewrite H_length. lia.
344-
rewrite H_length minus_diag. reflexivity.
344+
rewrite H_length Nat.sub_diag. reflexivity.
345345
-- rewrite lookup_app_l. rewrite H_length. lia.
346346
eapply IHm. lia.
347347
+ rewrite H_length. lia.
@@ -434,7 +434,7 @@ Proof.
434434
- intros [k Hb].
435435
specialize (Hb (map (fun _ => true) (seq 0 k))).
436436
rewrite map_length seq_length in Hb.
437-
specialize (Hb (le_refl _)).
437+
specialize (Hb (Nat.le_refl _)).
438438
unfold tree_from in Hb. cbn in Hb.
439439
rewrite <- Is_true_iff in Hb.
440440
setoid_rewrite forallb_True in Hb.
@@ -544,8 +544,8 @@ Proof.
544544
exists (1 + Nat.max b1 b2). intros l Hl.
545545
destruct l; cbn in *; try lia.
546546
eapply le_S_n in Hl.
547-
pose proof (Max.max_lub_l _ _ _ Hl).
548-
pose proof (Max.max_lub_r _ _ _ Hl).
547+
pose proof (Nat.max_lub_l _ _ _ Hl).
548+
pose proof (Nat.max_lub_r _ _ _ Hl).
549549
destruct b; intros HT.
550550
* assert (T [true]). eapply tree_p. eapply T. 2:eauto. now eexists.
551551
eapply is_tree_subtree_at in H1.
@@ -701,7 +701,7 @@ Proof.
701701
intros Hl [w ->].
702702
rewrite <- firstn_all.
703703
rewrite <- (firstn_all u) at 1.
704-
now rewrite Hl firstn_app Hl minus_diag firstn_O app_nil_r.
704+
now rewrite Hl firstn_app Hl Nat.sub_diag firstn_O app_nil_r.
705705
Qed.
706706

707707
Lemma take_prefix {X} n (l : list X) :
@@ -929,7 +929,7 @@ Proof.
929929
intros i Hi'. rewrite app_length in Hi'; cbn in *.
930930
assert (i = length u \/ i < length u) as [-> | Hi] by lia.
931931
+ subst. rewrite app_nth2. lia.
932-
intros. rewrite minus_diag. cbn. now eapply Hf.
932+
intros. rewrite Nat.sub_diag. cbn. now eapply Hf.
933933
+ intros. rewrite app_nth1. lia. now eapply IH.
934934
}
935935
exists g. intros n. cbn in *. eapply Hf. intros m.

theories/CRM/principles.v

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ Proof.
358358
+ intros. eapply H. lia.
359359
+ destruct (H (S n) (Nat.le_refl _)).
360360
* right. eauto.
361-
* left. intros m [Hle | ->] % le_lt_or_eq; eauto.
361+
* left. intros m [Hle | ->] % Nat.lt_eq_cases; eauto.
362362
eapply H1. lia.
363363
+ right. exists m. split. lia. eassumption.
364364
Qed.
@@ -410,7 +410,7 @@ Proof.
410410
destruct (dec_bounded_quant (fun n => g n = true) n).
411411
+ intros m ?; destruct (g m); firstorder congruence.
412412
+ exfalso. enough (alpha' (2 * n) = true). rewrite H0 in H3. congruence.
413-
rewrite mult_comm. unfold alpha'.
413+
rewrite Nat.mul_comm. unfold alpha'.
414414
eapply andb_true_iff. split. eauto.
415415
eapply forallb_forall.
416416
intros b. rewrite in_map_iff. setoid_rewrite in_seq.
@@ -435,7 +435,7 @@ Proof.
435435
destruct (dec_bounded_quant (fun n => f n = true) (S n)).
436436
+ intros m ?; destruct (f m); firstorder congruence.
437437
+ exfalso. enough (H3 : alpha' (1 + 2 * n) = true). rewrite H0 in H3. congruence.
438-
rewrite mult_comm. unfold alpha'.
438+
rewrite Nat.mul_comm. unfold alpha'.
439439
eapply andb_true_iff. split. eauto.
440440
eapply forallb_forall.
441441
intros b. rewrite in_map_iff. setoid_rewrite in_seq.
@@ -854,10 +854,11 @@ Goal ADC -> ACC.
854854
Proof.
855855
intros C X R Htot.
856856
destruct (Htot 0) as [y0 Hy0].
857-
unshelve specialize (C (∑ '(n, x), R n x) (fun '(exist _ (n, x) H) '(exist _ (m, y) H2) => m = S n)) as [f].
857+
unshelve epose proof (C (∑ '(n, x), R n x) (fun '(exist _ (n, x) H) '(exist _ (m, y) H2) => m = S n)).
858+
unshelve edestruct H as [f].
858859
- eexists (_, _). eauto.
859-
- intros [(n, x) H]. destruct (Htot (S n)) as [y Hy]. now exists (exist _ (S n, y) Hy).
860-
- destruct H as [H0 H].
860+
- intros [(n, x) H']. destruct (Htot (S n)) as [y Hy]. now exists (exist _ (S n, y) Hy).
861+
- clear H. destruct H0 as [H0 H].
861862
pose (N n := fst (proj1_sig (f n))).
862863
pose (s n := snd (proj1_sig (f n))).
863864
assert (HN : forall n, N (S n) = S (N n)). {

0 commit comments

Comments
 (0)