Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] nested inductive termination check

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] nested inductive termination check


Chronological Thread 
  • From: Jason Gross <jasongross9 AT gmail.com>
  • To: coq-club <coq-club AT inria.fr>
  • Subject: Re: [Coq-Club] nested inductive termination check
  • Date: Mon, 26 Oct 2020 20:17:19 -0400
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=jasongross9 AT gmail.com; spf=Pass smtp.mailfrom=jasongross9 AT gmail.com; spf=None smtp.helo=postmaster AT mail-ej1-f45.google.com
  • Ironport-phdr: 9a23:4Su2ZxwIo4XKFtDXCy+O+j09IxM/srCxBDY+r6Qd2+4VIJqq85mqBkHD//Il1AaPAdyEraIUwLOI+4nbGkU4qa6bt34DdJEeHzQksu4x2zIaPcieFEfgJ+TrZSFpVO5LVVti4m3peRMNQJW2aFLduGC94iAPERvjKwV1Ov71GonPhMiryuy+4ZLebxhKiTanYr5/Lxq6oRjQu8ILnYZsN6E9xwfTrHBVYepW32RoJVySnxb4+Mi9+YNo/jpTtfw86cNOSL32cKskQ7NWCjQmKH0169bwtRbfVwuP52ATXXsQnxFVHgXK9hD6XpP2sivnqupw3TSRMMPqQbwoXzmp8qFmQwLqhigaLT406G7YisJyg6xbrhyvpAFxzZDIb4yOLvVyYrnQcMkGSWZdXMtcUTFKDIOmb4sICuoMJeJWoJPmp1sJqxu1GAiiBPnoyj9TnX/9wKo30+Y7HgHd2wwgGd0OsG7TrNXuL6cfVfu4zKbNzTrZbvNW3S3x55TPchAkuPyBW697fsXNx0c1DQzFkkmQppL/PzOTzukAt2aV4up8We+gl2MqqwF/riahy8ovlIXEmJ4Zx17Y+Ch4xIs4KtK2RFJlbNCkEpZdtiGUOoRqT80tQGxmtjg3x7sbspC1eygKzY4oxx/Za/Gfb4eI5QjjVOCPLjd8gHJpYqywiAuv8UWm1+byVdG03U5UoiZZltTArHMA2hzJ5sSZV/dw/V2t1DmP2g3V9+pKO1o7lbDBJJ4k2rMwloQcsUDEHiLunUX5lq6WdkE99ue26eTrf6zqppGTOoJ0kA3+PaMumsuwAeQ8LAcCRXSU+eO51LH7/E35RqtFjuEun6XHrJzXId4Xq625DgNPzIov9hWyAy2p3dkYhXUHKUhKeBODj4jnIVHOJ/X4AO+9g1u2izdrwPbGPrL7ApXKNXjDi7PscK1y605Z0gUzzNRf64hIBbEGJfL/QlXxu8DADh8lLwy0xP7qB8l61oMHQG6AHquZML7JvlKT/eIuI+yMZJcPtzrnKvgl4eTujX4jllMHc6mpx8hfVHftFfN/Zk6dfHCk1twGCCIBuhc0ZO3sklyLFzBJMSWcRaU5sxMyE4WgRajZQZu2yOiD1Ty8GJJMYXtdW3iDFH7pc8OPXPJaO3HaGdNojjFRDevpcIQmzxz77FammYoiFfLd/2gjjbymzMJ8vrSBmhQ79DgyBMOYgTnUEjNE21gQTjpz55hR5ExwzlDZjPp9iv1cUNFRvrZHDlp8OpnbwOh3Tdv1X1CZJ4bbeBOdWtyjRAoJYJc0yt4KbVx6Hoz73B/G1iuuRbQSku7SCQ==

To answer your practical question, this works:
Require Import Coq.Lists.List.
Import ListNotations.
Open Scope list_scope.
Inductive tree :=
| node (data : bool) (children : list_tree)
with list_tree :=
| nil
| cons (x : tree) (xs : list_tree).

Fixpoint nodesWithCont (nodes : list_tree): list (tree * list_tree)
  := match nodes with
     | nil => []
     | cons (node d children) tl
       => [(node d children, tl)] ++ nodesWithCont children ++ nodesWithCont tl
     end.

(Presumably you can use notations or coercions to make this not too unpleasant.)

As far as your theoretical question, I'm not aware of any such issues; I'd suggest opening a feature request and seeing what the devs say.

On Mon, Oct 26, 2020 at 7:19 PM Abhishek Anand <abhishek.anand.iitg AT gmail.com> wrote:
It is surprising to me that in the fixpoint below, Coq cannot figure out that `children` is
a subterm of nodes. Theoretically, it seems that as long as a term is produced by peeling off one or more constructors (and doing nothing else), it should be considered a subterm. Are there some soundness or practicality issues in supporting such fixpoints?
Meanwhile, is there a way to write the fixpoint below without complicating the definition too much?

Require Import Coq.Lists.List.
Import ListNotations.

Inductive tree :=
| node (data: bool) (children: list tree).

Fixpoint nodesWithCont (nodes: list tree): list (tree* list tree) :=
   match nodes with
   | [] => []
   | (node d children)::tl =>  [(node d children, tl)] ++ (nodesWithCont children)++
                                                       nodesWithCont tl
   end.

Error: Recursive call to nodesWithCont has principal argument equal to "children" instead of
"tl".




Archive powered by MHonArc 2.6.19+.

Top of Page