coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Gregory Malecha <gmalecha AT gmail.com>
- To: Coq Club <coq-club AT inria.fr>
- Subject: [Coq-Club] Local Universes in Sections?
- Date: Tue, 24 Nov 2015 23:40:19 -0800
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=gmalecha AT gmail.com; spf=Pass smtp.mailfrom=gmalecha AT gmail.com; spf=None smtp.helo=postmaster AT mail-yk0-f182.google.com
- Ironport-phdr: 9a23:YECNSBOpHGKU3higfx4l6mtUPXoX/o7sNwtQ0KIMzox0KPv5rarrMEGX3/hxlliBBdydsKIZzbWJ+Pm5AyQp2tWojjMrSNR0TRgLiMEbzUQLIfWuLgnFFsPsdDEwB89YVVVorDmROElRH9viNRWJ+iXhpQAbFhi3DwdpPOO9QteU1JTqkb/tsMSKOU1hv3mUX/BbFF2OtwLft80b08NJC50a7V/3mEZOYPlc3mhyJFiezF7W78a0+4N/oWwL46pyv+YJa6jxfrw5QLpEF3xmdjltvIy4/SXEGCCI/zM3Vngc2k5DBBGA5xXnVL/wtDH7v6xzwn/JE9fxSOUbQzmt6L16ADrhjCoMNzdxpG7Sg8h9h6JSiB2krh17hYXTZdfGZ7JFYqrBcIZCFiJ6VcFLWnkEW9vkYg==
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.9
Set <= Top.13
Top.7 <= Top.9
Top.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 <= i
Set <= j
*)
pmap' is universe polymorphic
Arguments T, U are implicit and maximally inserted
Argument scopes are [type_scope type_scope _ _]
pmap' is transparent
Expands 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.