Skip to Content.
Sympa Menu

coq-club - [Coq-Club] Coq pattern matching going crazy on me -> looks like a bug.

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

[Coq-Club] Coq pattern matching going crazy on me -> looks like a bug.


chronological Thread 
  • From: Chris Dams <chris.dams.nl AT gmail.com>
  • To: coq-club AT inria.fr
  • Subject: [Coq-Club] Coq pattern matching going crazy on me -> looks like a bug.
  • Date: Sun, 14 Feb 2010 15:13:07 +0100
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=doD6QW+klxNN9Q5EHCsP+PCRS3f3v9Cb4/6bs4MVb/3w4pbcaW6NEoY/M6NUNXPI2Q 1bSATiEe1qW1AIfcQ/2V3Po8/DF2Wt3ubBoB6YcU7Tx5n4fzTp0gS6oj33ETM8c0VBfm a1wMPy5bFL4EIPjvVOG0umpQY+BZJqK5w7Tks=

Dear all,

Try the following code in Coq (I was using a home-compiled 8.2pl1):

Inductive type: Set
:= | int: type
  | Cbool: type
  | ref: type -> type.

Definition value_set
  : type -> Set
  := fun type: type
     => match type with
        | int => nat
        | Cbool => bool
        | ref t => nat
        end.

Inductive test:
  forall t: type,
  forall v: value_set t,
  Prop
:= | test1:
       forall t: type,
       test (ref t) 3
  | test2:
       test Cbool true.

Check (
  fun H2: test int 5 =>
  match H2 as H2' in test t' v''
  return
     forall t'': type,
     t' = t'' ->
     False
  with
  | test1 t''' => 3
  | test2 => 2
  end).

In the final Check command Coq says that the 3 in the first branch of
the match is wrong (it is of course right about that!).
It says:
Error: In environment
H2 : test int 5
t''' : type
The term "3" has type "nat" while it is expected to have type
 "forall t'' : type, ref t'' = t'' -> False".

However, the type that Coq proposes is not right either!
The pattern of this branch is test1 t''' and that is of type  test (ref t''') 
3.
Hence in this case, to obtain the return type we should do the
substitutions t' -> ref t''' and v'' -> 3.
Hence the type that should be expected becomes
     forall t'': type,
     ref t''' = t'' ->
     False
However, Coq is requesting the type with t''' replaced with t''!

This is a simplification of the actual development. In that I am
trying to apply the refine tactic with the 3 in the above example
replaced by _ and that leads to an equally weird error that I traced
back to this problem.

All the best,
Chris




Archive powered by MhonArc 2.6.16.

Top of Page