coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Jasper Hugunin <jasperh AT cs.washington.edu>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] A reduction for the nat recursor
- Date: Wed, 3 Jan 2018 11:13:36 +0900
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=jasperh AT cs.washington.edu; spf=None smtp.mailfrom=jasperh AT cs.washington.edu; spf=None smtp.helo=postmaster AT mail-ot0-f176.google.com
- Ironport-phdr: 9a23:TOqpHRWVG3xC+1aYoJCG2NgDVyDV8LGtZVwlr6E/grcLSJyIuqrYYxyFt8tkgFKBZ4jH8fUM07OQ7/i5HzRYqb+681k6OKRWUBEEjchE1ycBO+WiTXPBEfjxciYhF95DXlI2t1uyMExSBdqsLwaK+i764jEdAAjwOhRoLerpBIHSk9631+ev8JHPfglEnjWwba9vIBmssQndqtQdjJd/JKo21hbHuGZDdf5MxWNvK1KTnhL86dm18ZV+7SleuO8v+tBZX6nicKs2UbJXDDI9M2Ao/8LrrgXMTRGO5nQHTGoblAdDDhXf4xH7WpfxtTb6tvZ41SKHM8D6Uaw4VDK/5KptVRTmijoINyQh/W7VhMx+jKxVrhG8qRJh34HZe4SVOOZkc67HYd8WWWhMU8BMXCJBGIO8aI4PAvIFM+lCtIn9v0UBrQGjDgeuGePvxSJIhnn33a08zu8sFgPG0xY7H9IWrnvUttX1ObwOXuCu1qXJwy/Mb+hW2Tf87ojIfQwhofaKXb5qb8Xe1FQvGhrDg16Np4LlODaV2f4Ms2id9+dgWuOvi3InqwFsuTej3MYsio7RioIay1DE6SV5wJsuKtGiVEF7ZtukHZ1NvC+ZL4t7WsEvTm5ytCon1LELuYS3cSsUxJg92hLSaf2Kfo6V6Rz5TumROy13hHd9dbK/mRmy9U+gx/X5Vsau0VZKqjNJkt7QtnwRzhDT5NWLR/l880u71jaP0AfT6u5AIU8qj6bUN5khwrsompoSt0TMADP2lV30gaKZbEko5/ak5uT9brjluJOQLZJ4hwP/P6g2n8ywG+U4MgwAX2iB/uS80aXu/U/jT7VRlv05jLPZsJDBKMsHva61GQFU3Zw46xa/Djem1tsYnWUALFJDYh6IkZXmO0zWLPDiEfi/m0iskCtsx/3eIrLhBYzNImHfn7flYLZy8FVRyBEzzNBa/5JbEKsNIPP1Wk/rtdzXFAU1MwKuw7WvNNIo3YQHHGmLH6WxMaXIsFbO6Ph8DfOLYdo3sS3lJuJtx+PhkHk4nxdJf6CyxZYNaFizBbJ5Kl6ZYHzjntAHV2oGo1xtH6TRlFSeXGsLND6JVKUm62RjBQ==
Hi Cody,
Thanks for your response.
Neither of the rules you mentioned seem to quite match what I am looking for (though maybe they imply it).
As I understand it, eta for inductives reduces (fix id n := match n with O => O | S m => S (id m) end) to (fun n => n),
or reduces (match n with O => O | S m => S m end) to n.
Neither of these seem to apply when defining a function (nat -> A).
Commutative conversions allow to move the application of a function across a match (into and out of the branches).
But there is no function applied to the match in (fix shift n := match n with O => a | S m => shift m end),
and no shared function that I see applied to the branches (a) and (shift m).
Perhaps you know of a more general meaning for these rules or some tricky set of rewrites to use to derive it?
I'll attach my example below. Modulo this reduction, it is an implementation of coinductive types from nat, pi, and sigma,
with an anamorphism and eliminator such that the eliminator computes on the anamorphism.
Under the univalence axiom, these types should be equivalent to the ones in the paper below,
which were shown to have the correct equality types.
The main ideas are all in
NON-WELLFOUNDED TREES IN HOMOTOPY TYPE THEORY
BY: BENEDIKT AHRENS, PAOLO CAPRIOTTI, AND RÉGIS SPADOTTI
this development just improves the computational behavior.
I don't have much hope for adding this reduction to Coq, since it seems very specific to nat,
but I was thinking it could be interesting to develop a type theory with such a rule,
and then get coinductive types for free.
Best,
- Jasper Hugunin
On Tue, Jan 2, 2018 at 9:47 PM, roux cody <cody.roux AT gmail.com> wrote:
CodyBest,If you post your complete example, someone may have a workaround which does not require such a powerful conversion rule!See also this discussion: https://github.com/coq/coq/issues/3119Hi Jasper!This rule is sometimes called "eta for inductives" or "commutative conversions". In some versions it may break confluence, and in general is quite difficult to implement in Coq.On Tue, Jan 2, 2018 at 2:20 AM, Jasper Hugunin <jasperh AT cs.washington.edu> wrote:Hello,I ran into the following function:(fix shift n := match n with O => a | S m => shift m end) : nat -> Awhich clearly on any concrete n reduces to a.It would be very convenient if this was judgmentally equal to (fun _ => a).Of course, this is not implemented in Coq, but I haven't been able find any references discussing such a reduction. Does anyone know what the cost of adding such a reduction would be?(does it break decidable type-checking, or introduce unreasonable computational overhead?)Where this comes from, is that I actually have a family of types A : nat -> Type, along withforall n, A n = A (S n), and a0 : A 0. My function then looks like (fun n => nat_rect A a0 (coerce) n),but for some specific instances A is actually independent of n, and the equalities are eq_refl.In the general case, I don't see how to do a useful reduction, but when given such nice data I wouldhave liked to return just a, independent of n.- Jasper Hugunin
Attachment:
Coalgebra2.v
Description: Binary data
- [Coq-Club] A reduction for the nat recursor, Jasper Hugunin, 01/02/2018
- Re: [Coq-Club] A reduction for the nat recursor, roux cody, 01/02/2018
- Re: [Coq-Club] A reduction for the nat recursor, Jasper Hugunin, 01/03/2018
- Re: [Coq-Club] A reduction for the nat recursor, Frédéric Blanqui, 01/03/2018
- Re: [Coq-Club] A reduction for the nat recursor, Jasper Hugunin, 01/03/2018
- Re: [Coq-Club] A reduction for the nat recursor, Felix Rech, 01/08/2018
- Re: [Coq-Club] A reduction for the nat recursor, Jasper Hugunin, 01/03/2018
- Re: [Coq-Club] A reduction for the nat recursor, Frédéric Blanqui, 01/03/2018
- Re: [Coq-Club] A reduction for the nat recursor, Jasper Hugunin, 01/03/2018
- Re: [Coq-Club] A reduction for the nat recursor, roux cody, 01/02/2018
Archive powered by MHonArc 2.6.18.