coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Pierre Courtieu <pierre.courtieu AT gmail.com>
- To: Coq Club <coq-club AT inria.fr>
- Subject: Re: [Coq-Club] Mutual Fixpoints into mutual inductive types
- Date: Fri, 5 Jan 2018 18:04:41 +0100
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=pierre.courtieu AT gmail.com; spf=Pass smtp.mailfrom=pierre.courtieu AT gmail.com; spf=None smtp.helo=postmaster AT mail-ot0-f170.google.com
- Ironport-phdr: 9a23:OkL+8RKqjHvMgU7fjtmcpTZWNBhigK39O0sv0rFitYgeK/XxwZ3uMQTl6Ol3ixeRBMOHs6sC07KempujcFRI2YyGvnEGfc4EfD4+ouJSoTYdBtWYA1bwNv/gYn9yNs1DUFh44yPzahANS47xaFLIv3K98yMZFAnhOgppPOT1HZPZg9iq2+yo9JDffxhEiCChbb9uMR67sRjfus4KjIV4N60/0AHJonxGe+RXwWNnO1eelAvi68mz4ZBu7T1et+ou+MBcX6r6eb84TaFDAzQ9L281/szrugLdQgaJ+3ART38ZkhtMAwjC8RH6QpL8uTb0u+ZhxCWXO9D9QKsqUjq+8ahkVB7oiD8GNzEn9mHXltdwh79frB64uhBz35LYbISTOfFjfK3SYMkaSHJDUcZfVyJPDICyYZYRAeUdMuhVtJX9p0IUoBeiGQWgGOHixzlVjXH2x6061OEhHBnc0gwhAd0Oqm7Uo8voP6oMVuC10bPIzSnCb/xIxDf29Y/Fcgggof6SR7Jwa9TexVMzGAPCk1WQs5DlPzKL2eQQqGWb4O9gWviui24jsQ1+vj+vxsI1h4TPm4kbxFfE9SBjz4Y0I921UEF7Yd+4EJtQqiGVLJF6Td8lQ2Ftvisx174IuYajcSUIx5kr3QPTZ+KHfoSS4R/vSvydLSp6iX55fr+0mgy8/lK6yuLmU8m5yFZKoTRBktnLrn0N0gbc6smDSvdk+UehxSqD2xnd6u1ZI004ibDXK5Emwr43mZoTtVrMEjXql0Xxia+abkQk+u625OT7erjrpJCRO5Vphg3gMqkigM+yDfoiPgQTXWWX5fyw1Lj58k34RLVKgOc2kq7csJ3CPcQbp7C2AxVP0ok98RqwEzCm0MkCnXkbLVJKZg+HgpPmO1HLOv/4DPO/j06wnzdswvDKJqfhDYnVLnjfjLfheq5w5FJbyAoq1NxQ+5ZUCqwaL//oQU/wtNnYDgcjPACuwubnDs991oIEVm6VDK+ZKvCajVjdzeU2a8KIeYVd7D36Mr0u4+PkpX4/g14UO6ezi8g5cne9S8xnLl+DbDLHhcobDWYHo0JqVO3nkkePFzVUemyuXq8hzj4+AYOiS4zEQ9b+0/S6wC6nE8gONSh9AVeWHCKtLt3cVg==
I think this problem is the usual one when defining inductives
containing nested inductives (Vector of t1 inside defintion if t1).
There are lot of discussions about this in this list.
The syntactic guard condition of coq is not smart enough to "see" that
"(VectorUtils.traverse f1 x)" is actually a finite sequence of calls
to f1, each on a smaller or equal argument than x. This is not
necessarily true and depends on the definition of traverse (Suppose
for example that traverse f x = f (d3 x)..., you would create a
recursive loop). In some cases the guard condition detects such things
by unfolding but here it is not the case. And since it is not possible
in general you should adopt one of the two usual solutions I guess:
Either you encode your vectors as one more inductive in your inductive
family t1 t2, and then traverse is one more mutual functions in the
same mutual family than f1/f2.
Or you use a nested "fix" built to satisfy the guard condition instead
of traverse.
Hope this helps,
P.
2018-01-05 12:54 GMT+01:00 Merlin Göttlinger
<megoettlinger AT gmail.com>:
> Pierre Courtieu
> <pierre.courtieu AT gmail.com>
> schrieb am Fr., 5. Jan. 2018 um
> 12:01 Uhr:
>>
>> 2018-01-05 10:29 GMT+01:00 Merlin Göttlinger
>> <megoettlinger AT gmail.com>:
>> > Hi,
>> >
>> > simplified I have the following mutualy inductive type:
>> >
>> > Inductive t1 : Set :=
>> > | a1 : t1
>> > | a2 {n} : Vector.t t1 n -> t1
>> > | a3 {n} : Vector.t t2 n -> t1
>> > with t2 : Set :=
>> > | b1 : t2
>> > | b2 {n} : Vector.t t1 n -> t2
>> > | b3 {n} : Vector.t t2 n -> t2.
>> >
>> > I also have two other inductive types:
>> >
>> > Inductive t3 : Set :=
>> > | c1 : t3 -> t3 -> t3
>> > | c2 {n} : Vector.t t1 n -> t3
>> > | c3 {n} : Vector.t t2 n -> t3.
>> >
>> > Inductive t4 : Set :=
>> > | d1 : t4
>> > | d2 : t4 -> t4 -> t4
>> > | d3 {n} : Vector.t t4 n -> t4
>> > | d4 {n} : Vector.t t4 n -> t4.
>>
>> is it really Vector.t t4 n in d3 and d4? Given you comments I would
>> have expected Vector.t t1 n and Vector.t t2 n.
>
> Yes it is. This datatype represents a more general variant which allows more
> general arguments for those two "operators". The two fixpoints then
> transform the arguments into an allowed form (a kind of normal form).
>>
>>
>> Can you give the function you tried to write? I can't infer it from
>> what you gave.
>
>
> Fixpoint f1 f : list t1 :=
> match f with
> | d1 => [a1]
> | d2 x x0 => f1 x ++ f1 x0
> | d3 x => map a2 (VectorUtils.traverse (fun g => f1 g) x)
> | d4 x => map a3 (VectorUtils.traverse f2 x)
> end
> with f2 f : list t2 :=
> match f with
> | d1 => [b1]
> | d2 x x0 => f2 x ++ f2 x0
> | d3 x => map b2 (VectorUtils.traverse f1 x)
> | d4 x => map b3 (VectorUtils.traverse f2 x)
> end.
>
> The list part gets handeled in the conversion to t3 but the problem is in
> defining f1/f2.
>
> VectorUtils.traverse depends on a bunch of stuff I implemented and is the
> usual operation known from e.g. Haskell with signature G A -> (A -> F B) ->
> F (G B) where G is (fun T => Vector.t T n) and F is list in my case.
>
> Attatched stripped down versions of all necessary files in a gist for
> completeness:
> https://gist.github.com/mgttlinger/a80087e450a1e36963fa3c9cad4794ba
>
>>
>> > The problem I'm having is I am trying to convert t4 into t3 (its a kind
>> > of
>> > normalization). The issue comes with handling the cases d3 and d4 which
>> > corrspond to c2 and c3 respectively. There I essentially need to map a
>> > function converting to t1/t2 over the vector. Given that t1 and t2 are
>> > recursive and mutual these functions have to be mutual fixpoints (lets
>> > call
>> > those f1 : t4 -> t1 and f2 : f4 -> t2).
>> >
>> > I have played around with this for a while now and I can't get coq to
>> > accept
>> > my definitions for these mutual fixpoints. When I try to map f2 over the
>> > input vector in the definition of f1, coq produces somewhat strange
>> > errors
>> > like "Not enough arguments" which if i write (fun f => f2 f) turns into
>> > a
>> > complaint that I apply f2 to something which should rather be the whole
>> > vector (to which it can't even be applied for typing reasons).
>>
>> Maybe the problem comes more from the fact that your types use
>> Vector.t in a nested way. Using list would be a problem too.
>
> It probably does.
>
> Cheers,
> Merlin
- [Coq-Club] Mutual Fixpoints into mutual inductive types, Merlin Göttlinger, 01/05/2018
- Re: [Coq-Club] Mutual Fixpoints into mutual inductive types, Pierre Courtieu, 01/05/2018
- Re: [Coq-Club] Mutual Fixpoints into mutual inductive types, Merlin Göttlinger, 01/05/2018
- Re: [Coq-Club] Mutual Fixpoints into mutual inductive types, Pierre Courtieu, 01/05/2018
- Re: [Coq-Club] Mutual Fixpoints into mutual inductive types, Joachim Breitner, 01/05/2018
- Re: [Coq-Club] Mutual Fixpoints into mutual inductive types, Merlin Göttlinger, 01/05/2018
- Re: [Coq-Club] Mutual Fixpoints into mutual inductive types, Joachim Breitner, 01/05/2018
- Re: [Coq-Club] Mutual Fixpoints into mutual inductive types, Merlin Göttlinger, 01/07/2018
- Re: [Coq-Club] Mutual Fixpoints into mutual inductive types, Joachim Breitner, 01/07/2018
- Re: [Coq-Club] Mutual Fixpoints into mutual inductive types, Merlin Göttlinger, 01/08/2018
- Re: [Coq-Club] Mutual Fixpoints into mutual inductive types, Joachim Breitner, 01/08/2018
- Re: [Coq-Club] Mutual Fixpoints into mutual inductive types, Merlin Göttlinger, 01/08/2018
- Re: [Coq-Club] Mutual Fixpoints into mutual inductive types, Joachim Breitner, 01/08/2018
- Re: [Coq-Club] Mutual Fixpoints into mutual inductive types, Merlin Göttlinger, 01/08/2018
- Re: [Coq-Club] Mutual Fixpoints into mutual inductive types, Merlin Göttlinger, 01/07/2018
- Re: [Coq-Club] Mutual Fixpoints into mutual inductive types, Joachim Breitner, 01/05/2018
- Re: [Coq-Club] Mutual Fixpoints into mutual inductive types, Merlin Göttlinger, 01/05/2018
- Re: [Coq-Club] Mutual Fixpoints into mutual inductive types, Merlin Göttlinger, 01/05/2018
- Re: [Coq-Club] Mutual Fixpoints into mutual inductive types, Pierre Courtieu, 01/05/2018
Archive powered by MHonArc 2.6.18.