Skip to Content.
Sympa Menu

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

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

[Coq-Club] template polymorphism of Fixpoints


Chronological Thread 
  • From: Abhishek Anand <abhishek.anand.iitg AT gmail.com>
  • To: coq-club <coq-club AT inria.fr>
  • Subject: [Coq-Club] template polymorphism of Fixpoints
  • Date: Mon, 23 Jan 2017 18:53:46 -0500
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=abhishek.anand.iitg AT gmail.com; spf=Pass smtp.mailfrom=abhishek.anand.iitg AT gmail.com; spf=None smtp.helo=postmaster AT mail-qt0-f171.google.com
  • Ironport-phdr: 9a23:KSBmJh2HRAdyF4o3smDT+DRfVm0co7zxezQtwd8ZseIWLvad9pjvdHbS+e9qxAeQG96Kt7QZ06GP4ujJYi8p2d65qncMcZhBBVcuqP49uEgeOvODElDxN/XwbiY3T4xoXV5h+GynYwAOQJ6tL1LdrWev4jEMBx7xKRR6JvjvGo7Vks+7y/2+94fdbghMizexe7N/IAm5oQnMssQdnJdvJLs2xhbVuHVDZv5YxXlvJVKdnhb84tm/8Zt++ClOuPwv6tBNX7zic6s3UbJXAjImM3so5MLwrhnMURGP5noHXWoIlBdDHhXI4wv7Xpf1tSv6q/Z91SyHNsD4Ubw4RTKv5LptRRT1iikIKiQ5/XnXhMJ+j6xVvQyvqABkzoHOfI2YLuBzcr/Bcd4YQ2dKQ8ZfVzZGAoO5d4YCE/EOPeZZr4nmp1sBsxi+DhSwCePp0DBIgGL51rA93us7Cg7G3A0gH8kOsHvKr9X5Lr0dUeavw6nO0DrPdfJW2Tbh6IjHaR0hrvSMUqhxccrV00UgCwTFjlCJpIHjIjib2OMNs22B4OphU+Kik3IoqwZrojip2Mgsjo3JipgLxV/Z6CV0xps+K96gSENjf9KoDJ9duzuZOoZ2WM8uXXxktScgxrEbu5O3YS4Hw4k9yRHFcfyIaY2I7wrjVOmPJTd4g2poeLeliBaz9Uis0/T8VtWo3FpToCpJj9vBum0X2xzc7ciHTfR9/kO/1jqVyw/T7eRELVg1lardNZEh3qY9moQPvUnHBCP7m0X7gLWIekk5++Wk8fnrb7f7qpOEMo97kAD+MqAgmsylBuQ4NxADUHKA9uS81b3j5k35T6tJjvEsiKbZtorVJcIGqaKjAg9V05oj6xmkAjep1dQXh3gHLFZfdB2biIjpPknCIOrkAvenn1SsjDBryujaMb3mG5XBN2TMkLP8fblm8ENc0woyzdVH551OEL0BIfTzWlXwtNPCFBM5PRa0kK7bD4B20ZpbUmaSCOfNO6TL9FSM++gHIu+WZYZTtiyreNY/4Pu7pHU5mEQdcKrh9J0ebnzwSv1sI0SCYXfvxN4HGGEG+As/UOPCh1iLUDoVbHG3CfFvrgonAZ6rWN+QDrumh6aMiX+2

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