Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] template polymorphism of Fixpoints

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] template polymorphism of Fixpoints


Chronological Thread 
  • From: Cedric Auger <sedrikov AT gmail.com>
  • To: "coq-club AT inria.fr" <coq-club AT inria.fr>
  • Subject: Re: [Coq-Club] template polymorphism of Fixpoints
  • Date: Tue, 24 Jan 2017 14:27:58 +0100
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=sedrikov AT gmail.com; spf=Pass smtp.mailfrom=sedrikov AT gmail.com; spf=None smtp.helo=postmaster AT mail-yw0-f181.google.com
  • Ironport-phdr: 9a23:ph1LmBCuxC7YYl7+XpuFUyQJP3N1i/DPJgcQr6AfoPdwSP3ypsbcNUDSrc9gkEXOFd2CrakV16yL6uu9ASRAuc/H6y9SNsQUFlcssoY/oU8JOIa9E0r1LfrnPWQRPf9pcxtbxUy9KlVfA83kZlff8TWY5D8WHQjjZ0IufrymUt2as8Pineu14tjYZxhCrDu7e7J7ahus502Fvc4PxIBmN6wZyx3To3IOdf4Alk1yIlfGtBvw/Ma7tLd+/ClK86Y6+sJaUKb9YYw3SLVZCHItNGVjt56jjgXKUQbavihUaW4RiBcdWwU=

Same problem if you use unit instead of True, and Empty_set instead of False?

I do not remember if they are expected to have the same behaviour or not, but as your list_R is in type and not in Prop, I think it is clearer to use unit and Empty_set instead of True and False.

2017-01-24 0:53 GMT+01:00 Abhishek Anand <abhishek.anand.iitg AT gmail.com>:
Consider the following two ways of defining the same relation:
(this relation is the parametricity translation of list)

Fixpoint list_RF (A A₂ : Type) (A_R : A -> A₂ -> Type) 
                                  (l : list A) (l₂ : list A₂) {struct l} :
   Type :=
   match l with
   | nil =>
       match l₂ with
       | nil => True
       | cons _ _ => False
       end
   | cons h tl =>
       match l₂ with
       | nil  => False
       | cons h₂ tl₂ =>
           A_R h h₂ * list_RF A A₂ A_R tl tl₂
       end
   end.

Inductive list_R (A₁ A₂ : Type) (A_R : A₁ -> A₂ -> Type) : list A₁ -> list A₂ -> Type :=
| nil_R : list_R A₁ A₂ A_R nil nil
| cons_R : forall (h : A₁) (h₂ : A₂),
    A_R h h₂ ->
    forall (tl : list A₁) (tl₂ : list A₂),
    list_R A₁ A₂ A_R tl tl₂ -> list_R A₁ A₂ A_R (cons h tl) (cons h₂ tl₂).

Template Polymorphism works better for the latter definition:

Fail Check  ((list_RF nat nat (fun _ _ => True) nil nil):Set).
Check  ((list_R nat nat (fun _ _ => True) nil nil):Set).

Is there a way to make the first Check succeed?
Is there a theoretical problem in making the Check succeed, or just something that hasn't been implemented yet?

Although this is a simple example, in case of indexed inductives, I find the 
first style (using Fixpoint instead of Inductive) much easier to use.
Is there some documentation for template polymorphism?

Thanks,




Archive powered by MHonArc 2.6.18.

Top of Page