Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Unification problem with type classes (substructures)

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] Unification problem with type classes (substructures)


chronological Thread 
  • From: Matthieu Sozeau <mattam AT mattam.org>
  • To: Alexandre Pilkiewicz <alexandre.pilkiewicz AT polytechnique.org>
  • Cc: Coq Club <coq-club AT inria.fr>
  • Subject: Re: [Coq-Club] Unification problem with type classes (substructures)
  • Date: Thu, 10 Mar 2011 16:52:15 +0100
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer; b=JkDLCevG9TUK5ktuiPgXl78BKA4Y6vVNug18KF7SXr3KM2Zp69JamqJkfQik0B2nej U77gvD818Oin4g7Wk4rUMZMCpZMm80CUuDxYl/kXcsgd4S57zkD64ZpTym7RVdKFgqLM 4i/zipICpa9A0DzuhXaKx4ZE/7q6MV1dCITAE=


Le 10 mars 2011 à 15:22, Alexandre Pilkiewicz a écrit :

> Dear list
> 
> I'm using coq 8.3-pl1
> 
> 
> <<<<<<<<<<<<<<<<<<<<<<<<
> (* Suppose I have a type class for almost monad *)
> 
> Class Monadish (M:Type -> Type) :=
>  bind: forall {A B :Type}, M A -> (A -> M B) -> M B.
> 
> (*And a type class for monad, that encapsulate the first (in real
> code, it has more, but lets keep it simpl) *)
> 
> Class Monad (M:Type -> Type) := {
>  Monad_Monadish :> Monadish M
> }.
> 
> 
> (* I can statethat option is a monad *)
> 
> Instance Monad_option: Monad option :=
> {
>  Monad_Monadish := fun _ _ oa f =>
>    match oa with
>      | None => None
>      | Some a => f a
>    end
> }.
> 
> (* and I can prove lemmas with one bind *)
> Goal (bind (Some O) (fun n => Some n) = Some O).
> compute. reflexivity. Qed.
> 
> (* or two binds *)
> Goal (bind (Some O) (fun n => bind (Some n) (fun x => Some x)) = Some O).
> compute. reflexivity. Qed.
> 
> 
> (* now let us pollute things with a second monadish *)
> 
> Inductive box (A:Type) : Type :=
>  | BOX: A -> box A.
> 
> Instance Monadish_box: Monadish box:=
>  { bind := fun A B ba f =>
>    match ba with BOX a => f a end}.
> 
> (* the first lemma still works fine *)
> Goal (bind (Some O) (fun n => Some n) = Some O).
> compute. reflexivity. Qed.
> 
> (* the second fails ! *)
> Goal (bind (Some O) (fun n => bind (Some n) (fun x => Some x)) = Some O).
> (* Error: Impossible to unify "option ?649" with "?645 ?647". *)

Hi Alexandre,

  This is a bug in the unification code indeed, a constraint of the form
[option ?649 <= ?645 ?647] was ignored and suddenly we allowed ?645 to be 
instantiated with [box] making the constraints unsolvable... It is now
fixed in the 8.3 and trunk branches.
-- Matthieu





Archive powered by MhonArc 2.6.16.

Top of Page