Skip to Content.
Sympa Menu

coq-club - [Coq-Club] How to make mutual recursive theorems?

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

[Coq-Club] How to make mutual recursive theorems?


chronological Thread 
  • From: Chris Dams <chris.dams.nl AT gmail.com>
  • To: coq-club AT pauillac.inria.fr
  • Subject: [Coq-Club] How to make mutual recursive theorems?
  • Date: Sat, 30 May 2009 08:58:26 +0200
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type :content-transfer-encoding; b=s0vpYwELzjUyaIGnm0ayu/h2Vr9W19Hzx9oWV4CH7TJmg54Jlj/Nja8QOFFaq7aBFX edLA9CeUVQuQB0JuabCmm9ICBEApvbfNuIz2aycUWi8e0jTHYWONzsEHmoNeKwTlLKrQ T4n2cqIqlKi3RHSRdVqmOY74KEqC/4zKviZt4=
  • List-archive: <http://pauillac.inria.fr/pipermail/coq-club/>

Dear all,

Imagine that I have a mutually recursive inductive definition like

Inductive A: Set
:= | mk_a: A
   | S: B -> A
with B: Set
:= | mk_b: B
   | T: A -> B.

And I want induction theorems for this like

Theorem mutual_ind_A:
   forall P: A -> Prop,
   forall Q: B -> Prop,
   P mk_a ->
   Q mk_b ->
   (forall b: B, Q b -> P (S b)) ->
   (forall a: A, P a -> Q (T a)) ->
   forall a: A, P a.

Theorem mutual_ind_B:
   forall P: A -> Prop,
   forall Q: B -> Prop,
   P mk_a ->
   Q mk_b ->
   (forall b: B, Q b -> P (S b)) ->
   (forall a: A, P a -> Q (T a)) ->
   forall b: B, Q b.

The only way I know to prove this involves much code duplication. It goes like

Theorem mutual_ind_A:
   forall P: A -> Prop,
   forall Q: B -> Prop,
   P mk_a ->
   Q mk_b ->
   (forall b: B, Q b -> P (S b)) ->
   (forall a: A, P a -> Q (T a)) ->
   forall a: A, P a.
Proof.
intros P Q H1 H2 IH1 IH2.
refine
   (fix f (a: A): P a := _
   with g (b: B): Q b := _
   for f).
(* first branch of the fix *)
destruct a as [|b].
assumption.
apply IH1.
apply g.
(* seconc branch of the fix *)
destruct b as [|b].
assumption.
apply IH2.
apply f.
Qed.

Theorem mutual_ind_B:
   forall P: A -> Prop,
   forall Q: B -> Prop,
   P mk_a ->
   Q mk_b ->
   (forall b: B, Q b -> P (S b)) ->
   (forall a: A, P a -> Q (T a)) ->
   forall b: B, Q b.
Proof.
intros P Q H1 H2 IH1 IH2.
refine
   (fix g (b: B): Q b := _
   with f (a: A): P a := _
   for g).
(* first branch of the fix *)
destruct b as [|a].
assumption.
apply IH2.
apply f.
(* seconc branch of the fix *)
destruct a as [|a].
assumption.
apply IH1.
apply g.
Qed.

I am aware of the Cofix ... with .... construction, but as far as I
know I cannot use tactics with that. Is there a way to avoid the code
duplication and to still use tactics?

All the best,
Chris





Archive powered by MhonArc 2.6.16.

Top of Page