Skip to Content.
Sympa Menu

coq-club - [Coq-Club] Function problem when executing Defined

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

[Coq-Club] Function problem when executing Defined


Chronological Thread 
  • From: sorin stratulat <sorinica AT gmail.com>
  • To: coq-club AT inria.fr
  • Subject: [Coq-Club] Function problem when executing Defined
  • Date: Sun, 17 Jul 2016 13:38:55 +0200
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=sorinica AT gmail.com; spf=Pass smtp.mailfrom=sorinica AT gmail.com; spf=None smtp.helo=postmaster AT mail-lf0-f50.google.com
  • Ironport-phdr: 9a23:AcXdwxDC2NKt0+gNiWZ9UyQJP3N1i/DPJgcQr6AfoPdwSP78pcbcNUDSrc9gkEXOFd2CrakV06yK7Ou7CCQp2tWoiDg6aptCVhsI2409vjcLJ4q7M3D9N+PgdCcgHc5PBxdP9nC/NlVJSo6lPwWB6kO74TNaIBjjLw09fr2zQd+KyZjonLvjs7ToICxwzAKnZr1zKBjk5S7wjeIxxbVYF6Aq1xHSqWFJcekFjUlhJFaUggqurpzopM0roGxsvKcq8NcFWqHndYw5S6ZZBXIoKTMP6dXvpCXEGBCI/HoaFH4KiBNUHgzM8DnnWJbv9y/9rPB02S+Xe8PsHp4uXjH39KBxSRmgkzsdPiIk9GjLwphri7haphOqrjRwxofVZMeeM/8oLfCVRs8TWWcUBpUZbCdGGI7pN4Y=

Dear Coq-club,

I have encountered a problem when defining a recursive function on binary trees. A simplified version of the problem is given below: 

-----------
Require Import Recdef.
Require Import Program.
Require Import List.

Inductive Btree : Set :=
  | Epsilon : Btree
  | Node : Btree -> nat -> Btree -> Btree.

Fixpoint nr_nodes (t: Btree) : nat :=
  match t with
    | Epsilon =>  0
    | Node tl n tr => S ((nr_nodes tl) + (nr_nodes tr))
  end.

Require Import Omega.

Function  f (t: Btree){wf (fun t1 t2: Btree => (nr_nodes t1) < ( nr_nodes t2)) t}: Btree :=
  match t with
    | Epsilon => Epsilon
    | Node tl _ tr =>  
      match f tl with
      | Epsilon => Epsilon
      | _ => 
        match f tr with
        | Epsilon => Epsilon
         |  _ => Epsilon
        end
      end
  end.
Proof.
intros. simpl. omega.
intros. simpl. omega.
apply (well_founded_lt_compat Btree nr_nodes).
intros. trivial.
Defined.

--------

When Defined is executed (the last line), Coq yields "Anomaly: Cannot create equation Lemma. Please report.". This is exactly what I am doing, i.e. reporting this problem.

Is there any way to avoid this problem or should I wait for the next release (I am using 8.5pl2 new version) ?

Thanks for any help,

Sorin



Archive powered by MHonArc 2.6.18.

Top of Page