Set Implicit Arguments.
Set Strict Implicit.
Set Asymmetric Patterns.
Set Universe Polymorphism.
Set Printing Universes.
Fixpoint hlist_app ll lr (h : hlist ll) : hlist lr -> hlist (ll ++ lr) :=
match h in hlist ll return hlist lr -> hlist (ll ++ lr) with
| Hnil => fun x => x
| Hcons _ _ hd tl => fun r => Hcons hd (hlist_app tl r)
end.
Fixpoint hlist_rev' ls ls' (h : hlist ls) : hlist ls' -> hlist (rev ls ++ ls') :=
match h in hlist ls return hlist ls' -> hlist (rev ls ++ ls') with
| Hnil => fun h => h
| Hcons l ls0 x h' => fun hacc =>
match app_ass_trans (rev ls0) (l :: nil) ls' in _ = t
return hlist t -> hlist _
with
| eq_refl => fun x => x
end (@hlist_rev' _ (l :: ls') h' (Hcons x hacc))
end.
Definition hlist_rev ls (h : hlist ls) : hlist (rev ls) :=
match app_nil_r_trans (rev ls) in _ = t return hlist t with
| eq_refl => hlist_rev' h Hnil
end.

Lemma hlist_rev_nil : hlist_rev Hnil = Hnil.