Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Mutual inductive types with a predicate

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] Mutual inductive types with a predicate


Chronological Thread 
  • From: Matthieu Sozeau <mattam AT mattam.org>
  • To: coq-club AT inria.fr
  • Subject: Re: [Coq-Club] Mutual inductive types with a predicate
  • Date: Wed, 15 Nov 2017 10:26:11 +0000
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=mattam AT mattam.org; spf=Pass smtp.mailfrom=matthieu.sozeau AT gmail.com; spf=None smtp.helo=postmaster AT mail-vk0-f42.google.com
  • Ironport-phdr: 9a23:hBJoLBJojY7oeg6l7NmcpTZWNBhigK39O0sv0rFitYgXL/rxwZ3uMQTl6Ol3ixeRBMOAtKIC1rKempujcFJDyK7JiGoFfp1IWk1NouQttCtkPvS4D1bmJuXhdS0wEZcKflZk+3amLRodQ56mNBWB6kG1uDUVA1D0MRd/DuXzAI/bycqthM6o/JiGRgxUmDq8bK46FxKkoAzM/p0TiJd+I6MZzxLVvnJNPeNMyjU7dhqogx/g65Lor9ZY+CNKtqd5+g==

Hi,

  What you’re trying to formalize are known as inductive-inductive types, when an inductive can depend through its indices on a previous inductive in the same mutual block, and constructors of later inductives can refer to constructors of the previous inductives (the exact order constraints varies, Agda implements this in a more flexible way for example). There is an experimental branch IR on my GitHub [1] which implements those, based on Coq 8.7. You have to write the eliminators by hand though and consistency is not proven for this version of the calculus yet. Maybe there are other non ind-ind encodings of your types that solve your problem though. 

[1] https://github.com/mattam82/coq/tree/IR?files=1

Best,
— Matthieu

Le mer. 15 nov. 2017 à 10:23, Merlin Göttlinger <megoettlinger AT gmail.com> a écrit :
Hi,

what I want to implement is a more complicated version of this:

Inductive A :=
| a1 : nat -> A
| a2 : nat -> A
| a3 : B -> A -> A
with B :=
     | b1 : nat -> B
     | b2 : { ae : A | P ae} -> B
with P : A -> Prop :=
     | pa3 : forall b a, P a -> P (a3 b a)
     | pa1 : forall n, P (a1 n).

However that is rejected by coq (8.6.1) with the error The reference A was not found in the current environment. at the Type of P.
Why is that the case?

One way I found to avoid this is to "bake the predicate into the type":

Inductive A : bool -> Set :=
| a1 : nat -> A true
| a2 : nat -> A false
| a3 {b} : B -> A b -> A b
with B : Set :=
     | b1 : nat -> B
     | b2 : A true -> B.

But this forces you to wrap and unwrap A everywhere where you do not care about the predicate.
Is there a better way?

Cheers,
Merlin



Archive powered by MHonArc 2.6.18.

Top of Page