Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] are type indexes ever necessary?

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] are type indexes ever necessary?


Chronological Thread 
  • From: Matthieu Sozeau <mattam AT mattam.org>
  • To: coq-club AT inria.fr
  • Subject: Re: [Coq-Club] are type indexes ever necessary?
  • Date: Thu, 24 Mar 2016 23:59:40 +0000
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=mattam AT mattam.org; spf=Pass smtp.mailfrom=matthieu.sozeau AT gmail.com; spf=None smtp.helo=postmaster AT mail-wm0-f48.google.com
  • Ironport-phdr: 9a23:AiLk3xeZI6RfoD6xjHhJH2+hlGMj4u6mDksu8pMizoh2WeGdxc65Yh7h7PlgxGXEQZ/co6odzbGG4+a5CCdaud6oizMrTt9lb1c9k8IYnggtUoauKHbQC7rUVRE8B9lIT1R//nu2YgB/Ecf6YEDO8DXptWZBUiv2OQc9HOnpAIma153xjLDivcSCKF8QzBOGIppMbzyO5T3LsccXhYYwYo0Q8TDu5kVyRuJN2GlzLkiSlRuvru25/Zpk7jgC86l5r50IAu3GePEzSqUdBzA7OUg04tfqvF/NV1ih/HwZB0AfjgZIAgXYpCr9TJr4r2Ous+NhxCCfFcj/Uaw9XHKl9ag9G0ygszsOKzNsqDKfscd3lq8O+B8=

Hi Jonathan,

  you are right that having only the equality type as indexed
gives you theoretically the same expressivity.
This has been explored for example in the following two papers on the 
construction of indexed inductive types:

Peter Morris and Thorsten Altenkirch. Constructing strictly positive families. CATS ’07 Proceedings of the thirteenth Australasian symposium on Theory of computing, pages 111– 121, 2007. 10 
Peter Morris, Thorsten Altenkirch, and Neil Ghani. A universe of strictly positive families. IInternational journal of foundations of computer science, pages 83–107, 2009.

For a variation on these ideas to present Coq, see Spiwack and Herbelin's
"The Rooster and the Syntactic Bracket":
http://arxiv.org/abs/1309.5767

So, you're in good company.
-- Matthieu

On Wed, Mar 23, 2016 at 3:47 AM Jonathan Leivent <jonikelee AT gmail.com> wrote:


On 03/22/2016 02:37 PM, Cedric Auger wrote:
>
> 2016-03-21 20:03 GMT+01:00 Jonathan Leivent <jonikelee AT gmail.com
> <mailto:jonikelee AT gmail.com>>:
>
>      Is it true in Coq that any index on an inductive type could *always* be
>      replaced by a type parameter with an extra equality-typed field added to
>      each constructor tying the type parameter to that constructor's value for it?
>
> ...
>
>
> ​I think it is always the case. One cannot prove it directly in Coq as we would
> have to use "meta"functions taking a type as argument, and inspect its ​
> construction to build an other one which would be isomorphic.

Thanks.  I did not expect it to be provable in Coq.  I was just
wondering if, by avoiding type indexes, I'd eventually find a good
reason to have kept them.

> ...
>
>
> ​Now I tend to avoid that kind of annoyance with an other approach:
>
> Inductive finS(X:Set) : Set :=
> | Fin1
> | FinS : X -> finS X.
>
> Fixpoint fin(m:nat) : Set :=
>     match m with​
> ​  | O => emptySet​
>     | S n => finS (fin m)
>     end.
>
> I find this kind of type quite convenient to use. "inversion f." becomes
> "destruct n; destruct f." with no weirdness to deal with.
> Induction is done on the parameter rather than the type, and all basic operation
> have their counterparts in a not too artificial way.
>
> I find it nice to have the ability to "reduce" the type to only those which are
> possible in a given context.
>
> I am conscious on the fact that such a transcription of type is not always
> trivially existent, but in many cases, there is a strong relation between the
> constructor of the type and the constructors of the index, leading to a natural
> way to make it.
> Cases which do not apply still, are those where the index is not a constructed
> type (and I don’t pretend this to be the only case).
> Example: Inductive is_identity {A:Type} : (A->A)->Prop := Id : is_identity (fun
> x => x).
>

This construction is interesting, but not useful in most of my cases.
The issue is that I want the type parameters and indexes to vanish via
Extraction along with all trace of their trails through the code, and
incorporating one as a match discriminee will likely prevent that.

-- Jonathan




Archive powered by MHonArc 2.6.18.

Top of Page