Skip to Content.
Sympa Menu

coq-club - [Coq-Club] Mutual induction schemes and recursive function arguments

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

[Coq-Club] Mutual induction schemes and recursive function arguments


Chronological Thread 
  • From: "John Wiegley" <johnw AT newartisans.com>
  • To: coq-club AT inria.fr
  • Subject: [Coq-Club] Mutual induction schemes and recursive function arguments
  • Date: Tue, 16 Apr 2019 00:11:53 -0700
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=johnw AT newartisans.com; spf=Pass smtp.mailfrom=johnw AT newartisans.com; spf=Pass smtp.helo=postmaster AT out3-smtp.messagingengine.com
  • Ironport-phdr: 9a23:AAUZ+h8FJqoWbv9uRHKM819IXTAuvvDOBiVQ1KB31e4cTK2v8tzYMVDF4r011RmVBNydsKoP0rOK++C4ACpcuM7H6ChDOLV3FDY9wf0MmAIhBMPXQWbaF9XNKxIAIcJZSVV+9Gu6O0UGUOz3ZlnVv2HgpWVKQka3OgV6PPn6FZDPhMqrye+y54fTYwJVjzahfL9+Nhq7oRjMusUMj4ZuNqk9xgbUrnZHZu9awX9kKU+Jkxvz+8u84IRv/zhMt/4k6sVNTbj0c6MkQLJCET8oKXo15MrltRnCSQuA+H4RWXgInxRLHgbI8gj0Uo/+vSXmuOV93jKaPdDtQrAvRTui9aZrRwT2hyoBKjU07XvYis10jKJcvRKhuxlyyJPabY2JKPZzeL7WcNUHTmRDQ8lRTTRMDIOiYYUSAeQBOuVWoIfyqFQSohWzHhWsBPr1xzNUmnP7x6833uI8Gg/GxgwgGNcOvWzaoNvxM6cSUea1x7TIwjXCcfxW1jP955bIcxwvvPqBWrBwcc3RyUkpGQLIlVOQppLrPjyPzOQNr2mb7/F6WuKpkG4rsR1+oj+qxso1jITCm4wbylfB9SpjwYY1I8W1SEhlbt+qCpRQrT2aN4ptQsw4RWFoozw2xaEBuZ6+eiUB1ZcpxwbHZvGGcoWE+A/vWPuMLTtii39pYqyzihSq/US+xeDwTNS43VhWoiZfj9XBuXMA2wbN5sWITPZ2412v1iyV1w/J7+FJOUA0mrTfK54m2rMwkYcTsVjNEyPvg0X2ibOWdl0+9uit9evnea7mqYWTN491jAH+PbohmsqwAeQ5NAgBQXKX9vi71L3m5UH5QbNKgeMqkqTBsZ3XJN4XqrOkDwNIyIou5AyzAymk3dgAmHkINlNFeBaJj4jzPFHOJej1DfW4g1SsljdqyevLPrv/DZTDNHfDiqvhfbdm60FGzgoz1spT6I5TCrEEOP7zQFP+tMTEDh8lNAy52/roCNJk1o8HRW2PBrKZP7jJvF+T5uMvJvGMa5UPtDb8Lfgl/f/ugmUjlV8TZ6mk24YcZW68HvR7OEWZfWTjgs0cH2cLvwsxUvTnhEHRGQJUMn21Ruc34iwxIIOgF4bKAI6305Kb2yLuVL9RZmYONVGBHnPlZs/MD/ULaCSNCslsjTUeSbm6Qok6kxqpsVmpmPJcMuPI93hA5trY399v6riLzEBgxXlPF82Yllq1YSRxl2IMSSUx2fkg80pw1V6ZzaljivpDU9dU4qEQC1poBdvn1+V/TuvKdEfBc9OOEw/0Rci6WnQqS84phdoDeF10FNSkgR3F0CusDvkekLnZXcVooJKZ5GD4IoNG81iDzLMo1gZ0RMZQPHe6h7V28ROVDInMwR2U
  • Organization: New Artisans LLC

Hello,

I have a data structure, one of whose constructors takes a function whose
result is of the same type. I'd like to be able to recusively apply an 'f' to
this structure, and prove that this 'f' preserves certain properties. However,
the induction hypothesis generated by 'Function' is too weak. What is the best
way to match the strength given by the data structure's own induction
hypothesis? The reason I'm unable to use it directly is that I need to take
mutual recursion into account. A reduced code example showing the difficulty
follows.

Thank you,
John

Require Import FunInd.
Require Import Program.

Section Foo.

Variable a : Type.

Inductive Higher :=
| Ctor (f : a -> Higher)
| Neg (x : Higher)
| Rec (x : Higher).

Function foo (h : Higher) : Higher :=
match h with
| Ctor f => Ctor (foo ∘ f)
| Neg x => Rec (bar x)
| Rec x => Rec (foo x)
end
with
bar (h : Higher) : Higher :=
match h with
| Ctor f => Ctor (bar ∘ f)
| Neg x => Rec (foo x)
| Rec x => Rec (bar x)
end.

(* foo is defined
bar is defined
foo, bar are recursively defined (decreasing respectively on 1st,
1st arguments)
foo_equation is defined
foo_ind is defined
foo_rec is defined
foo_rect is defined
bar_equation is defined
bar_ind is defined
bar_rec is defined
bar_rect is defined
R_foo_correct is defined
R_bar_correct is defined
R_foo_complete is defined
R_bar_complete is defined *)

(** Note the induction hypothesis for Ctor:

(forall f : a -> Higher, (forall a : a, P (f a)) -> P (Ctor f)) *)

Print Higher_ind.

(** It is missing for foo_ind:

(forall (h : Higher) (f : a -> Higher),
h = Ctor f -> P (Ctor f) (Ctor (foo ∘ f))) *)

Print foo_ind.

Functional Scheme foo_ind2 := Induction for foo Sort Prop
with bar_ind2 := Induction for bar Sort Prop.

(** And also for foo_ind2:

(forall (h : Higher) (f : a -> Higher),
h = Ctor f -> P (Ctor f) (Ctor (foo ∘ f)))
(forall (h : Higher) (f2 : a -> Higher),
h = Ctor f2 -> P0 (Ctor f2) (Ctor (bar ∘ f2))) *)

Print foo_ind2.

Function foo' (h : Higher) : Higher :=
match h with
| Ctor f => Ctor (fun x => foo' (f x))
| Neg x => Rec (bar' x)
| Rec x => Rec (foo' x)
end
with
bar' (h : Higher) : Higher :=
match h with
| Ctor f => Ctor (fun x => bar' (f x))
| Neg x => Rec (foo' x)
| Rec x => Rec (bar' x)
end.

(** Why does it now fail to build the graph?

foo' is defined
bar' is defined
foo', bar' are recursively defined (decreasing respectively on 1st,
1st arguments)
Warning: Cannot define graph(s) for foo', bar'
[funind-cannot-define-graph,funind]
Warning: Cannot build inversion information
[funind-cannot-build-inversion,funind] *)

End Foo.

--
John Wiegley GPG fingerprint = 4710 CF98 AF9B 327B B80F
http://newartisans.com 60E1 46C4 BD1A 7AC1 4BA2



Archive powered by MHonArc 2.6.18.

Top of Page