@@ -15,7 +15,8 @@ Set Asymmetric Patterns.
1515Set Universe Polymorphism.
1616Set 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.
1920Proof .
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
0 commit comments