Skip to content

Commit b8f7334

Browse files
committed
compatability with coq 8.7
1 parent 974a79e commit b8f7334

File tree

6 files changed

+102
-95
lines changed

6 files changed

+102
-95
lines changed

theories/Data/Fin.v

Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -43,26 +43,26 @@ Qed.
4343

4444
Definition fin0_elim (f : fin 0) : forall T, T :=
4545
match f in fin n return match n with
46-
| 0 => forall T, T
47-
| _ => unit
46+
| 0 => forall T, T
47+
| _ => unit
4848
end with
49-
| F0 _ => tt
50-
| FS _ _ => tt
49+
| F0 _ => tt
50+
| FS _ _ => tt
5151
end.
5252

5353
Fixpoint pf_lt (n m : nat) : Prop :=
5454
match n , m with
55-
| 0 , S _ => True
56-
| S n , S m => pf_lt n m
57-
| _ , _ => False
55+
| 0 , S _ => True
56+
| S n , S m => pf_lt n m
57+
| _ , _ => False
5858
end.
5959

6060
Fixpoint make (m n : nat) {struct m} : pf_lt n m -> fin m :=
6161
match n as n , m as m return pf_lt n m -> fin m with
62-
| 0 , 0 => @False_rect _
63-
| 0 , S n => fun _ => F0
64-
| S n , 0 => @False_rect _
65-
| S n , S m => fun pf => FS (make m n pf)
62+
| 0 , 0 => @False_rect _
63+
| 0 , S n => fun _ => F0
64+
| S n , 0 => @False_rect _
65+
| S n , S m => fun pf => FS (make m n pf)
6666
end.
6767

6868
Notation "'##' n" := (@make _ n I) (at level 0).
@@ -75,34 +75,41 @@ Defined.
7575

7676
Fixpoint fin_eq_dec {n} (x : fin n) {struct x} : fin n -> bool :=
7777
match x in fin n' return fin n' -> bool with
78-
| F0 _ => fun y => match y with
79-
| F0 _ => true
80-
| _ => false
81-
end
82-
| FS n' x' => fun y : fin (S n') =>
83-
match y in fin n'' return (match n'' with
84-
| 0 => unit
85-
| S n'' => fin n''
86-
end -> bool) -> bool with
87-
| F0 _ => fun _ => false
88-
| FS _ y' => fun f => f y'
89-
end (fun y => fin_eq_dec x' y)
90-
end.
78+
| F0 _ => fun y => match y with
79+
| F0 _ => true
80+
| _ => false
81+
end
82+
| FS n' x' => fun y : fin (S n') =>
83+
match y in fin n'' return (match n'' with
84+
| 0 => unit
85+
| S n'' => fin n''
86+
end -> bool) -> bool with
87+
| F0 _ => fun _ => false
88+
| FS _ y' => fun f => f y'
89+
end (fun y => fin_eq_dec x' y)
90+
end.
9191

9292
Global Instance RelDec_fin_eq (n : nat) : RelDec (@eq (fin n)) :=
9393
{ rel_dec := fin_eq_dec }.
9494

9595
Global Instance RelDec_Correct_fin_eq (n : nat)
96-
: RelDec_Correct (RelDec_fin_eq n).
96+
: RelDec_Correct (RelDec_fin_eq n).
9797
Proof.
9898
constructor.
99-
induction x.
100-
{ intro. destruct (fin_case y) ; subst.
101-
{ split; reflexivity. }
102-
{ destruct H. subst. simpl. split; congruence. } }
103-
{ intro; destruct (fin_case y) ; subst ; simpl.
104-
{ split; congruence. }
105-
{ destruct H. subst. simpl. split.
106-
{ intro; f_equal. eapply IHx. assumption. }
107-
{ intro. inv_all. apply IHx in H. assumption. } } }
99+
induction x. simpl.
100+
intro. destruct (fin_case y) ; subst.
101+
intuition.
102+
destruct H ; subst.
103+
intuition ; try congruence.
104+
(* inversion H.*)
105+
intro ; destruct (fin_case y) ; subst ; simpl.
106+
intuition ; try congruence.
107+
inversion H.
108+
destruct H ; subst.
109+
split ; intro.
110+
f_equal ; eauto.
111+
eapply IHx.
112+
eapply H.
113+
inv_all ; subst.
114+
apply IHx. reflexivity.
108115
Qed.

theories/Data/HList.v

Lines changed: 61 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ Set Asymmetric Patterns.
1515
Set Universe Polymorphism.
1616
Set Printing Universes.
1717

18-
Lemma app_ass_trans@{X} : forall {T : Type@{X} } (a b c : list T), (a ++ b) ++ c = a ++ b ++ c.
18+
Lemma app_ass_trans@{X}
19+
: forall {T : Type@{X} } (a b c : list T), (a ++ b) ++ c = a ++ b ++ c.
1920
Proof.
2021
induction a; simpl.
2122
reflexivity.
@@ -62,24 +63,25 @@ Section hlist.
6263

6364
Lemma hlist_eta : forall ls (h : hlist ls),
6465
h = match ls as ls return hlist ls -> hlist ls with
65-
| nil => fun _ => Hnil
66-
| a :: b => fun h => Hcons (hlist_hd h) (hlist_tl h)
66+
| nil => fun _ => Hnil
67+
| a :: b => fun h => Hcons (hlist_hd h) (hlist_tl h)
6768
end h.
6869
Proof.
6970
intros. destruct h; auto.
7071
Qed.
7172

7273
Fixpoint hlist_app ll lr (h : hlist ll) : hlist lr -> hlist (ll ++ lr) :=
7374
match h in hlist ll return hlist lr -> hlist (ll ++ lr) with
74-
| Hnil => fun x => x
75-
| Hcons _ _ hd tl => fun r => Hcons hd (hlist_app tl r)
75+
| Hnil => fun x => x
76+
| Hcons _ _ hd tl => fun r => Hcons hd (hlist_app tl r)
7677
end.
7778

7879
Lemma hlist_app_nil_r
7980
: forall ls (h : hlist ls),
80-
hlist_app h Hnil = match eq_sym (app_nil_r_trans ls) in _ = t return hlist t with
81-
| eq_refl => h
82-
end.
81+
hlist_app h Hnil =
82+
match eq_sym (app_nil_r_trans ls) in _ = t return hlist t with
83+
| eq_refl => h
84+
end.
8385
Proof.
8486
induction h; simpl; intros; auto.
8587
rewrite IHh at 1.
@@ -91,11 +93,13 @@ Section hlist.
9193

9294
Fixpoint hlist_rev' ls ls' (h : hlist ls) : hlist ls' -> hlist (rev ls ++ ls') :=
9395
match h in hlist ls return hlist ls' -> hlist (rev ls ++ ls') with
94-
| Hnil => fun h => h
95-
| Hcons l ls0 x h' => fun hacc =>
96-
match app_ass_trans (rev ls0) (l :: nil) ls' in _ = t return hlist t -> hlist _ with
97-
| eq_refl => fun x => x
98-
end (@hlist_rev' _ (l :: ls') h' (Hcons x hacc))
96+
| Hnil => fun h => h
97+
| Hcons l ls0 x h' => fun hacc =>
98+
match app_ass_trans (rev ls0) (l :: nil) ls' in _ = t
99+
return hlist t -> hlist _
100+
with
101+
| eq_refl => fun x => x
102+
end (@hlist_rev' _ (l :: ls') h' (Hcons x hacc))
99103
end.
100104

101105
Definition hlist_rev ls (h : hlist ls) : hlist (rev ls) :=
@@ -302,43 +306,43 @@ Section hlist.
302306
| hlist_eqv_nil => I
303307
| hlist_eqv_cons l ls x y h1 h2 pf1 pf2 => _
304308
end IHx).
305-
simpl in *.
309+
simpl.
306310
subst. intros.
307-
f_equal. tauto. }
311+
f_equal. apply H0. assumption. }
308312
{ intros; subst. constructor; auto.
309313
reflexivity. } }
310314
Qed.
311315

312316
Fixpoint hlist_get ls a (m : member a ls) : hlist ls -> F a :=
313317
match m in member _ ls return hlist ls -> F a with
314-
| MZ _ => hlist_hd
315-
| MN _ _ r => fun hl => hlist_get r (hlist_tl hl)
318+
| MZ _ => hlist_hd
319+
| MN _ _ r => fun hl => hlist_get r (hlist_tl hl)
316320
end.
317321

318322
Fixpoint hlist_nth_error {ls} (hs : hlist ls) (n : nat)
319-
: option match nth_error ls n with
320-
| None => unit
321-
| Some x => F x
322-
end :=
323-
match hs in hlist ls return option match nth_error ls n with
324-
| None => unit
325-
| Some x => F x
326-
end
327-
with
328-
| Hnil => None
329-
| Hcons l ls h hs =>
330-
match n as n return option match nth_error (l :: ls) n with
331-
| None => unit
332-
| Some x => F x
333-
end
323+
: option (match nth_error ls n with
324+
| None => unit
325+
| Some x => F x
326+
end) :=
327+
match hs in hlist ls return option (match nth_error ls n with
328+
| None => unit
329+
| Some x => F x
330+
end)
334331
with
335-
| 0 => Some h
336-
| S n => hlist_nth_error hs n
337-
end
332+
| Hnil => None
333+
| Hcons l ls h hs =>
334+
match n as n return option (match nth_error (l :: ls) n with
335+
| None => unit
336+
| Some x => F x
337+
end)
338+
with
339+
| 0 => Some h
340+
| S n => hlist_nth_error hs n
341+
end
338342
end.
339343

340-
Polymorphic Fixpoint hlist_nth ls (h : hlist ls) (n : nat)
341-
: match nth_error ls n return Type with
344+
Polymorphic Fixpoint hlist_nth ls (h : hlist ls) (n : nat) :
345+
match nth_error ls n return Type with
342346
| None => unit
343347
| Some t => F t
344348
end :=
@@ -584,9 +588,9 @@ Section hlist.
584588
match goal with
585589
| |- context [ match ?X with _ => _ end ] =>
586590
remember X
587-
end. destruct p. simpl in *.
591+
end. destruct p. simpl.
588592
change h0 with (fst (h0, h1)).
589-
f_equal. assumption.
593+
f_equal; trivial.
590594
Qed.
591595

592596
Lemma hlist_tl_snd_hlist_split
@@ -604,29 +608,29 @@ Section hlist.
604608
rewrite Heqp. reflexivity.
605609
Qed.
606610

607-
Polymorphic Fixpoint nth_error_get_hlist_nth (ls : list iT) (n : nat) {struct ls}
608-
: option {t : iT & hlist ls -> F t} :=
611+
Polymorphic Fixpoint nth_error_get_hlist_nth (ls : list iT) (n : nat) {struct ls} :
612+
option {t : iT & hlist ls -> F t} :=
609613
match
610614
ls as ls0
611615
return option {t : iT & hlist ls0 -> F t}
612616
with
613-
| nil => None
614-
| l :: ls0 =>
615-
match
616-
n as n0
617-
return option {t : iT & hlist (l :: ls0) -> F t}
618-
with
619-
| 0 =>
620-
Some (@existT _ (fun t => hlist (l :: ls0) -> F t)
621-
l (@hlist_hd _ _))
622-
| S n0 =>
623-
match nth_error_get_hlist_nth ls0 n0 with
624-
| Some (existT x f) =>
625-
Some (@existT _ (fun t => hlist _ -> F t)
626-
x (fun h : hlist (l :: ls0) => f (hlist_tl h)))
627-
| None => None
617+
| nil => None
618+
| l :: ls0 =>
619+
match
620+
n as n0
621+
return option {t : iT & hlist (l :: ls0) -> F t}
622+
with
623+
| 0 =>
624+
Some (@existT _ (fun t => hlist (l :: ls0) -> F t)
625+
l (@hlist_hd _ _))
626+
| S n0 =>
627+
match nth_error_get_hlist_nth ls0 n0 with
628+
| Some (existT x f) =>
629+
Some (@existT _ (fun t => hlist _ -> F t)
630+
x (fun h : hlist (l :: ls0) => f (hlist_tl h)))
631+
| None => None
632+
end
628633
end
629-
end
630634
end.
631635

632636
Theorem nth_error_get_hlist_nth_Some

theories/Structures/MonadFix.v

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
Require Import ExtLib.Structures.Monad.
22

33
Set Implicit Arguments.
4-
Set Maximal Implicit Arguments.
54

65
Class MonadFix (m : Type -> Type) : Type :=
76
{ mfix : forall {T U}, ((T -> m U) -> T -> m U) -> T -> m U }.

theories/Structures/MonadPlus.v

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
Require Import ExtLib.Structures.Monad.
22

33
Set Implicit Arguments.
4-
Set Maximal Implicit Arguments.
54

65
Class MonadPlus (m : Type -> Type) : Type :=
76
{ mplus : forall {A B:Type}, m A -> m B -> m (A + B)%type }.

theories/Structures/MonadTrans.v

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
Require Import ExtLib.Structures.Monad.
22

33
Set Implicit Arguments.
4-
Set Maximal Implicit Arguments.
54

65
Class MonadT (m : Type -> Type) (mt : Type -> Type) : Type :=
76
{ lift : forall {t}, mt t -> m t }.

theories/Structures/MonadZero.v

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
Require Import ExtLib.Structures.Monad.
22

33
Set Implicit Arguments.
4-
Set Maximal Implicit Arguments.
54

65
Class MonadZero (m : Type -> Type) : Type :=
76
{ mzero : forall {T}, m T }.

0 commit comments

Comments
 (0)