Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Canonical Structures and Coercions?

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] Canonical Structures and Coercions?


Chronological Thread 
  • From: Bas Spitters <b.a.w.spitters AT gmail.com>
  • To: Coq Club <coq-club AT inria.fr>
  • Subject: Re: [Coq-Club] Canonical Structures and Coercions?
  • Date: Sat, 29 Feb 2020 19:20:22 +0100
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=b.a.w.spitters AT gmail.com; spf=Pass smtp.mailfrom=b.a.w.spitters AT gmail.com; spf=None smtp.helo=postmaster AT mail-yw1-f42.google.com
  • Ironport-phdr: 9a23:m3E5dBYVx2n1a6H1lEs52Jv/LSx+4OfEezUN459isYplN5qZrs2ybnLW6fgltlLVR4KTs6sC17OK9fm4ASdZuM/JmUtBWaIPfidNsd8RkQ0kDZzNImzAB9muURYHGt9fXkRu5XCxPBsdMs//Y1rPvi/6tmZKSV3wOgVvO+v6BJPZgdip2OCu4Z3TZBhDiCagbb9oIxi6sArcutMLjYd+Nqo9xQbFrmZVd+9L2W5mOFWfkgrz6cu34JNt6Tlbteg7985HX6X6fqA4QqJdAT87LW0759DluAfaQweX6XQSTmsZkhxTAwjY9x76RYv+sjH7tuVmxiaXO9D9QK0uVjSj66drTwLoiDsCOjUk/mzbltB8gaRGqx+6uRdx35Dbb52UNPpmf6PSY9UaRXZaXs1MUyBNG56wY5cTA+YEO+tXqJTzp0YVrRumGwajGP/vxDFPhn/zx6I60uIhGhzC0AEvG98CtXLZp8j3OqgPS+C41KbHzTvBYP1W1znz65XGfA49rvyXQbJ8bdDcxVUzGw/ZjFidr5HuMTOP1uQKtmiW9/dtWvi0i2U6tg9xujmvxtswiobXnIIV0U3P+CJiz4ovP9K0UkB6bcS/EJtItiGaK5d2Td04Q2Fzoys6xbgGtoS6fCgO0pgo2xnfa/mefoWO/xntWuGRITJii3JkfrKynwi9/lW6xuLmSsa4yktKrildntbRsXAN1gbf6s+dSvty5kuuwyyP1g/S6uFaO0w0krDbK5E5zr4/l5oTrUTDHjLtl0nsja+WcUMp8fWr5eT/erjquIOQOotuhgz9MqkigNGzDOUlPgQUUGWX5+Kx36D580LjWrVFlPg2n7HZsJ/EIcQboba0AwpP3YYi7xazFjen0doFkXUeIlJIdwyLg5LmO1HJJ/D4AvO/jEq2nDh3wPDGO6XtApTLLnfdjLfsZahx51JYxQYpzt1S54hYBqwALf7uQEP8u8LUAgc8MwOuwubnDNt91pkZWWKKGqKWK7nevkWS6uMhOeWMf5cVuDfhK/g5+fHul2Q5lEQSfamsx5QXaXS4Eu56LEWeZHrgms0BHnsSvgoiUOzqj0WPXiJUZ3arRq4z+jU7CJ+9AorYXYCsgLmB3D+hEZFMZ2BGDEqMEXbyeImeVfcMcnHaHsg0uTsdHZOlVoVpgRqprUrxz6dtBuvS4CwR85z5gotb/erWwDs77nRPF8WBz2yXVCkglCUBASBwx7h+vVBw0Eyr3q1xgvgeHttWsaAaGjwmPILRmrQpQ+v5XRjMK5LUEQ/3EOXjOik4S5cK+/FLZk98H9u4iRWahnilBrYUk/qAA5lmq/uAjUi0HN50zjP97Idkl0MvG5IdOmivh6o5/A/WVdaQzhep0p2yfKFZ5xbjsWeOyW3U4RNdWQ90FLTaBDUROhGQotP+6UfPCbSpDOZ/Pw==

Not a precise answer to your question, but ever since the introduction
of type classes, the type class of coercions between two types has
been a standard example,
In haskell:
https://homepages.inf.ed.ac.uk/wadler/papers/class/class.dvi
In our math-classes:
http://dx.doi.org/10.1017/S0960129511000119
In lean, coercions are even managed using type classes (IIUC). Sec 4 here:
https://arxiv.org/abs/2001.04301
They claim their algorithms can be ported to Coq, and would solve some
of the problems we are experiencing.

On Sat, Feb 29, 2020 at 5:27 PM Gregory Malecha
<gmalecha AT gmail.com>
wrote:
>
> Hello --
>
> It makes sense that it increases the size of the search space for CS. It
> sounds like the answer is that it isn't possible, and that the correct
> thing to do is to write all of the instances that you need.
>
> Thanks.
>
> On Sat, Feb 29, 2020 at 11:07 AM Beta Ziliani
> <beta AT mpi-sws.org>
> wrote:
>>
>> Sounds like that would bloat the search space of CS. In this case is
>> obvious, but how do you foresee if you need some coercion (and which one!)?
>>
>> Written from mobile. Excuse my limited communication.
>>
>> On Sat, Feb 29, 2020, 11:39 AM Gregory Malecha
>> <gmalecha AT gmail.com>
>> wrote:
>>>
>>> Hello --
>>>
>>> Is there a way to get canonical structures and coercions to work
>>> together? Here's my toy example:
>>>
>>> Structure EX : Type :=
>>> { t :> Type
>>> ; GET : t -> Prop }.
>>>
>>> Definition foo {e : EX} := e.(GET).
>>>
>>> Canonical Structure TrueEX : EX :=
>>> {| GET := fun _ : bool => true |}.
>>>
>>> Definition to_bool (n : nat) :=
>>> match n with
>>> | 0 => false
>>> | _ => true
>>> end.
>>>
>>> Coercion to_bool : nat >-> bool.
>>>
>>> Check (foo true). (* works great! *)
>>> Check (foo 1). (* fails *)
>>>
>>> Intuitively, I would expect the term [@foo boolEX (to_bool 1)] but
>>> instead I get a type error "the term 1 has type nat while it is expected
>>> to have type EX".
>>>
>>> Is there some way to make this work without making instances for, e.g.
>>> [natEX], which is the composition of [to_bool] and [foo]?
>>>
>>> Thanks.
>>>
>>> --
>>> gregory malecha
>>> gmalecha.github.io
>
>
>
> --
> gregory malecha
> gmalecha.github.io



Archive powered by MHonArc 2.6.18.

Top of Page