Debian Codegraph @

test-suite/bugs/bug_3262.v

raw
1 (* Not having a [return] clause causes the [refine] at the bottom to stack overflow before f65fa9de8a4c9c12d933188a755b51508bd51921 *)
2
3 Require Import Corelib.Lists.ListDef.
4 Require Import Relation_Definitions RelationClasses.
5
6 Set Implicit Arguments.
7 Set Strict Implicit.
8 Set Asymmetric Patterns.
9
10 Section hlist.
11 Context {iT : Type}.
12 Variable F : iT -> Type.
13
14 Inductive hlist : list iT -> Type :=
15 | Hnil : hlist nil
16 | Hcons : forall l ls, F l -> hlist ls -> hlist (l :: ls).
17
18 Definition hlist_hd {a b} (hl : hlist (a :: b)) : F a :=
19 match hl in hlist x return match x with
20 | nil => unit
21 | l :: _ => F l
22 end with
23 | Hnil => tt
24 | Hcons _ _ x _ => x
25 end.
26
27 Definition hlist_tl {a b} (hl : hlist (a :: b)) : hlist b :=
28 match hl in hlist x return match x with
29 | nil => unit
30 | _ :: ls => hlist ls
31 end with
32 | Hnil => tt
33 | Hcons _ _ _ x => x
34 end.
35
36 Lemma hlist_eta : forall ls (h : hlist ls),
37 h = match ls as ls return hlist ls -> hlist ls with
38 | nil => fun _ => Hnil
39 | a :: b => fun h => Hcons (hlist_hd h) (hlist_tl h)
40 end h.
41 Proof.
42 intros. destruct h; auto.
43 Qed.
44
45 Variable eqv : forall x, relation (F x).
46
47 Inductive equiv_hlist : forall ls, hlist ls -> hlist ls -> Prop :=
48 | hlist_eqv_nil : equiv_hlist Hnil Hnil
49 | hlist_eqv_cons : forall l ls x y h1 h2, eqv x y -> equiv_hlist h1 h2 ->
50 @equiv_hlist (l :: ls) (Hcons x h1) (Hcons y h2).
51
52 Global Instance Reflexive_equiv_hlist (R : forall t, Reflexive (@eqv t)) ls
53 : Reflexive (@equiv_hlist ls).
54 Proof.
55 red. induction x; constructor; auto. reflexivity.
56 Qed.
57
58 Global Instance Transitive_equiv_hlist (R : forall t, Transitive (@eqv t)) ls
59 : Transitive (@equiv_hlist ls).
60 Proof.
61 red. induction 1.
62 { intro; assumption. }
63 { rewrite (hlist_eta z).
64 Timeout 2 Fail refine
65 (fun H =>
66 match H in @equiv_hlist ls X Y
67 return
68 (* Uncommenting the following gives an immediate error in 8.4pl3; commented out results in a stack overflow *)
69 match ls (*as ls return hlist ls -> hlist ls -> Type*) with
70 | nil => fun _ _ : hlist nil => True
71 | l :: ls => fun (X Y : hlist (l :: ls)) =>
72 equiv_hlist (Hcons x h1) Y
73 end X Y
74 with
75 | hlist_eqv_nil => I
76 | hlist_eqv_cons l ls x y h1 h2 pf pf' =>
77 _
78 end).
79 Abort.
80 End hlist.