Skip to Content.
Sympa Menu

coq-club - [Coq-Club] Fwd: Question about Fixpoint

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

[Coq-Club] Fwd: Question about Fixpoint


chronological Thread 
  • From: mulhern <mulhern AT gmail.com>
  • To: coq-club AT pauillac.inria.fr
  • Subject: [Coq-Club] Fwd: Question about Fixpoint
  • Date: Thu, 3 Feb 2005 08:32:07 -0600
  • Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=iLySODniBbh3VvMUEHDMU+/BLuFiknYEsa+IZxVcUYPBldWTV3wGKlW15DSKwfs7zfRd8laQ3A/xA22yVUNdWzqBX0ZwtHNm4mSRB/INP7/PpSNfgISFotM853REgx8iAtTE06Hwf3ZXfDxRF0blrS2pl0hkgH1sQSMyZCLNM/4=
  • List-archive: <http://pauillac.inria.fr/pipermail/coq-club/>

Hi!

Suppose I have the following two Fixpoint definitions:

Fixpoint lookup_sub (tcs_var:tcs) (name:String.string) {struct
tcs_var} : Sool.ty := match tcs_var with
          List.nil => Sool.TyId(name)
        | List.cons (Sool.IdType(name'),(ty, ct)) tl =>
                if (String.equals name name')
                        then match ct with
                                  Constraint.Equality => ty
                                | Constraint.SubtypeBound => Sool.TyId(name)
                        end
                        else lookup_sub tl name
end.

Fixpoint lookup (tcs_var:tcs) (ty:Sool.ty) {struct ty} : Sool.ty :=
match ty with
    Sool.TyConstant _ => ty
  | Sool.TyId name => lookup_sub tcs_var name
  | Sool.TyReference ty => Sool.TyReference (lookup tcs_var ty)
end.

In that case, Coq considers them well formed. However, suppose I
change them to two mutually recursive Fixpoints by introducing a with,
thus:

Fixpoint lookup_sub (tcs_var:tcs) (name:String.string) {struct
tcs_var} : Sool.ty := match tcs_var with
          List.nil => Sool.TyId(name)
        | List.cons (Sool.IdType(name'),(ty, ct)) tl =>
                if (String.equals name name')
                        then match ct with
                                  Constraint.Equality => ty
                                | Constraint.SubtypeBound => Sool.TyId(name)
                        end
                        else lookup_sub tl name
end
with
 lookup (tcs_var:tcs) (ty:Sool.ty) {struct ty} : Sool.ty := match ty with
    Sool.TyConstant _ => ty
  | Sool.TyId name => lookup_sub tcs_var name
  | Sool.TyReference ty => Sool.TyReference (lookup tcs_var ty)
end.

Then Coq gives me the following error message.

Error while reading /Users/mulhern/mulhern/cs/translator/coq/load.v :
File "/Users/mulhern/mulhern/cs/translator/coq/sooltypechecker/tcs.v",
line 9, characters 0-601
Error:
Recursive definition of lookup is ill-formed.
In environment
lookup_sub : tcs -> String.string -> Sool.ty
lookup : tcs -> Sool.ty -> Sool.ty
tcs_var : tcs
ty : Sool.ty
name : String.string
Recursive call to lookup_sub has principal argument equal to
"tcs_var"
instead of a subterm of ty

Could someone tell me why, in the one case, I don't receive any error
and in the other case I do?

In the example you see, lookup_sub doesn't have a call to lookup. I've
omitted the call I want to have to make my example clearer.

What I really want to have is two mutually dependent Fixpoint
definitions which decrease in different arguments. If there is a
reason why that is impossible could someone let me know?

Thanks,

-mulhern




Archive powered by MhonArc 2.6.16.

Top of Page