coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Chan Ngo <chan.ngo2203 AT gmail.com>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] Local Universes in Sections?
- Date: Wed, 25 Nov 2015 22:29:43 +0100
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=chan.ngo2203 AT gmail.com; spf=Pass smtp.mailfrom=chan.ngo2203 AT gmail.com; spf=None smtp.helo=postmaster AT mail-wm0-f45.google.com
- Ironport-phdr: 9a23:fXbyJxGRcMk0USXyuPen/51GYnF86YWxBRYc798ds5kLTJ75pMqwAkXT6L1XgUPTWs2DsrQf27eQ7PCrADBRqb+681k8M7V0HycfjssXmwFySOWkMmbcaMDQUiohAc5ZX0Vk9XzoeWJcGcL5ekGA6ibqtW1aJBzzOEJPK/jvHcaK1oLsh730pM2YOlkZzBOGIppMbzyO5T3LsccXhYYwYo0Q8TDu5kVyRuJN2GlzLkiSlRuvru25/Zpk7jgC86l5r50IAu3GePEzSqUdBzA7OUg04tfqvF/NV1ih/HwZB04WmxwAJQfCpEXxXp739C31sbAngHKyMsj/TLRyUjOnufQ4ACT0gTsKYmZquFrcjdZ92fpW
Hello,
As we know that programming in Coq, inductive structured data and recursive function definition (i.e, with the keyword Fixpoint) are used intensively. I am curious about the performance of them. Does any one give me some pointers about that?
Thanks,
Chan
On Nov 25, 2015, at 8:40 AM, Gregory Malecha <gmalecha AT gmail.com> wrote:Hello --I've been playing with the new universe polymorphism code in 8.5 and it is great, but I'm wondering if there is any way to declare a universe in a section and have them "cooked" at the end?Thanks a lot.Here is a concrete example. Suppose that I have polymorphic lists.Set Printing Universes.Polymorphic Inductive plist@{i} (T : Type@{i}) : Type@{i} :=| pnil| pcons : T -> plist T -> plist T.Arguments pnil {_}.Arguments pcons {_} _ _.And I'd like to write the polymorphic map function. Normally (without polymorphism) I would use sections like this since the termination checker does better with this:Section pmap.Variable T : Type.Variable U : Type.Variable f : T -> U.Polymorphic Fixpoint pmap (ls : plist T) : plist U :=match ls with| pnil => pnil| pcons l ls => pcons (f l) (pmap ls)end.End pmap.However, this gives me a quite strange definition.About pmap.(*pmap@{Top.9 Top.13} :forall (T : Type@{Top.7}) (U : Type@{Top.8}),(T -> U) -> plist@{Top.9} T -> plist@{Top.13} U(* Top.9 Top.13 |= Set <= Top.9Set <= Top.13Top.7 <= Top.9Top.8 <= Top.13*)*)What I'd like to get is something like this:Polymorphic Definition pmap'@{i j} {T : Type@{i}} {U : Type@{j}} (f : T -> U): plist@{i} T -> plist@{j} U :=fix pmap ls :=match ls with| pnil => pnil| pcons l ls => pcons (f l) (pmap ls)end.Which has exactly the definition that I want.About pmap'.(*pmap'@{i j} :forall (T : Type@{i}) (U : Type@{j}), (T -> U) -> plist@{i} T -> plist@{j} U(* i j |= Set <= iSet <= j*)pmap' is universe polymorphicArguments T, U are implicit and maximally insertedArgument scopes are [type_scope type_scope _ _]pmap' is transparentExpands to: Constant Top.pmap'*)Unfortunately, it can be quite annoying to write a bunch of functions out like this explicitly. The problem seems to come from the inability to name the universes in the types of T and U and continue using them later in the section.--gregory malecha
- [Coq-Club] Local Universes in Sections?, Gregory Malecha, 11/25/2015
- Re: [Coq-Club] Local Universes in Sections?, Chan Ngo, 11/25/2015
- Re: [Coq-Club] Local Universes in Sections?, Matthieu Sozeau, 11/26/2015
- Re: [Coq-Club] Local Universes in Sections?, Gregory Malecha, 11/27/2015
Archive powered by MHonArc 2.6.18.