Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Use a map in an inductive type

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] Use a map in an inductive type


Chronological Thread 
  • From: Nicolas Osborne <nicolas.osborne.etu AT univ-lille.fr>
  • To: coq-club AT inria.fr
  • Subject: Re: [Coq-Club] Use a map in an inductive type
  • Date: Thu, 11 Apr 2019 14:10:05 +0200
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=nicolas.osborne.etu AT univ-lille.fr; spf=Pass smtp.mailfrom=nicolas.osborne.etu AT univ-lille.fr; spf=None smtp.helo=postmaster AT mx1.univ-lille.fr
  • Ironport-phdr: 9a23:LzWvaxX6PL8H8pYOvJOl1GynBYXV8LGtZVwlr6E/grcLSJyIuqrYbBSPt8tkgFKBZ4jH8fUM07OQ7/m5HzVRqsre+DBaKdoQDkdD0Z1X1yUbQ+e9QXXhK/DrayFoVO9jb3RCu0+BDE5OBczlbEfTqHDhpRQbGxH4KBYnbr+tQt2agMu4zf299IPOaAtUmjW9falyLBKrpgnNq8Uam4RvJrssxhfTv3dFf+tayGxqKFmOmxrw+tq88IRs/ihNp/4t7dJMXbn/c68lUbFWETMqPnwv6sb2rxfDVwyP5nUdUmUSjBVFBhXO4Q/5UJnsrCb0r/Jx1yaGM8L4S7A0Qimi4LxwSBD0kicHNiU2/3/Rh8dtka9UuhOhpxh4w47JfIGYMed1c63Bcd8GQ2dKQ8BcXDFDDIyhdYsCF+oPMvpXoYbyulUAoxW+CxeuC+3szTFFnWP23bQ/0+g9EQHKwA4tEtQTu3rUttX1M6ISXPitwqnJ0TrDaPdW1i3m6IPVax4huuqDXbVqccrX10YkCgTIjlORqYP5ODOV0v4Cs3OB4+pnTuKgkGknqxt3ojex3MsjlJXJhp8Ox1DZ8yV5wZg1KcS8SE56Zd6kFIVfuzuUN4tsW84vRXxjtiUiyrAepJK2eCcHxI45yxPfZPGLaZWE7gznWeqLLzp1inRoc6+liRmo60iv0Oj8W9G00FlUqipFlcHBtnUC1hDO8MSHV/19/ka/2TqW0wDT6+VEIUQqmqbBJZ4h2KY8lpsVsUvdAi/7gFj6gauZe0k+5OSl6+vqbq/7qpOCM4J4kA/zP6o2lsy6G+s4MwwOX2aB+eS70b3u5Uv5QLRWgf0xlqnWqovaKd4cpq6iGABV1Zwj6xChADu8ztsYgWQHIUlYeBKBjojpJUjCIPT5Dfe7h1Sjji1nx/7cPrH5GJXCMmDDkKv9fbZ680NT1A0zzclG651IDrEBPen8V1TqtN3YCx85Kxa7z/zmCNV7zIMeWHiADrWXMKPI4he04bckJPDJb4sIsh78LeIk7rjglywXg1gYKI+o1pwTYWvwOe9sJF+fbDK4hNYKFmMDpUw5V+btkluPFzNPel6vWaMiozU6DIarS4nZENP+yIed1Tu2S8UFLltNDUqBRC+xKte0HswUYSfXGfdP1zwJUb/4Gt0kxUjoqQn71f9jL+7Q92sWr8C7jYQn16jojRg3sAdMIYGFyWjUEjNpmGIWAjs32KRy50JnmA/agPpIxsdAHNkW3MtnFwIzNJrS1et/Uo2gRwTAYJKNSVKiT5OoG2NoQw==

Thanks for the answer Sylvain.

I played a little with your proposition. The problem is that when I want to
use one
of the primitives of M.t, I have to open the tree, rebuild an M.t, use the
primitive and
rebuild the tree.

As I don’t have a lot of experience with Records and dependent types in
general, this
should prove to be difficult to implement in the current project.

Nicolas

> Le 10 avr. 2019 à 14:03, Sylvain Boulmé
> <Sylvain.Boulme AT univ-grenoble-alpes.fr>
> a écrit :
>
> Hello Nicolas,
>
> The error is induced by the "NoDup" field of M.t.
>
> One workaround could be to split the inductive definition in two parts:
>
> Inductive raw_tree: Type :=
> mkRawTree: T -> M.Raw.t raw_tree -> raw_tree.
>
> Import M.
>
> Inductive wf_tree: raw_tree -> Prop :=
> mkRawTree_wf (x:T) (l: M.t raw_tree):
> (forall p, List.In p l.(this) -> wf_tree (snd p))
> -> wf_tree (mkRawTree x l.(this)).
>
> Record tree : Type := { raw: raw_tree; wf: wf_tree raw }.
>
>
> But, I do not know if such an approach works well in practice...
>
> S.
>
>
> Le 10/04/2019 à 11:23, Nicolas Osborne a écrit :
>> Dear Coq-Club,
>> I need to define a rose tree with a map instead of a list. As I don’t have
>> any reason to care about efficiency in this context, I use FMapWeakList
>> from the Standard Library and declare the following:
>> Require Import Coq.Structures.DecidableTypeEx.
>> Require Import Coq.FSets.FMapWeakList.
>> Variable T:Type.
>> Module M := FMapWeakList.Make(Nat_as_DT).
>> Inductive tree: Type := mkTree: T -> M.t tree -> tree.
>> Then, Coq greets me with the following error message:
>> Error: Non strictly positive occurrence of "tree" in "nat -> M.t
>> tree -> tree".
>> As I understand it, this means that "tree" occurs at the left of an arrow
>> in one of the argument of the constructor (namely "M.t tree"), which is
>> forbidden for consistency reasons.
>> Is there any way around ?
>> My first guess would be to use a list of products in the tree:
>> Inductive tree’: Type := mkTree’: T -> list (nat * tree’) -> tree’.
>> and then make sure that this list behaves like a map when writing the
>> functions handling the modifications of the tree.
>> But if there is a way to use directly a map in the tree, that would be a
>> relief.
>> Thanks,
>> Nicolas Osborne




Archive powered by MHonArc 2.6.18.

Top of Page