Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] problem with recursion op

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] problem with recursion op


chronological Thread 
  • From: Daniel Schepler <dschepler AT gmail.com>
  • To: Patricia Peratto <psperatto AT adinet.com.uy>
  • Cc: coqclub <coq-club AT inria.fr>
  • Subject: Re: [Coq-Club] problem with recursion op
  • Date: Sat, 7 Apr 2012 17:42:39 -0700

If, for some reason, you can't recast the inductive definition, you
could also use the following:

Definition map {A B:Type} (f:A->B) (l:List A) : List B :=
List_rect (fun A' _ => A = A' -> List B)
  (fun _ _ => nil B)
  (fun A' (a:A') (l':List A') (recval: A=A' -> List B)
     (e: A = A') =>
   cons B
     (f (match e in (_ = T) return (T -> A) with
         | eq_refl => fun a' => a'
         end a))
     (recval e))
  A l (eq_refl A).

The fundamental idea here is that P A' l reduces to "A = A' -> List
B", and then you use the equality hypothesis to cast a from type A' to
A.

As you can probably see, rewriting the inductive definition as
guillaume suggested is much simpler...
-- 
Daniel Schepler



Archive powered by MhonArc 2.6.16.

Top of Page