Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Need help for manual induction scheme definition

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] Need help for manual induction scheme definition


Chronological Thread 
  • From: Vincent <vincent.siles AT gmail.com>
  • To: Coq-Club Club <coq-club AT inria.fr>
  • Subject: Re: [Coq-Club] Need help for manual induction scheme definition
  • Date: Tue, 24 Sep 2019 17:59:57 +0200
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=vincent.siles AT gmail.com; spf=Pass smtp.mailfrom=vincent.siles AT gmail.com; spf=None smtp.helo=postmaster AT mail-io1-f53.google.com
  • Ironport-phdr: 9a23:pTGD0RwZA/MWAm3XCy+O+j09IxM/srCxBDY+r6Qd1O8fIJqq85mqBkHD//Il1AaPAdyArakcwLuN+4nbGkU4qa6bt34DdJEeHzQksu4x2zIaPcieFEfgJ+TrZSFpVO5LVVti4m3peRMNQJW2aFLduGC94iAPERvjKwV1Ov71GonPhMiryuy+4ZLebxhGiTanb75+MBq6oAHfu8ILnYZsN6E9xwfTrHBVYepW32RoJVySnxb4+Mi9+YNo/jpTtfw86cNOSL32cKskQ7NWCjQmKH0169bwtRbfVwuP52ATXXsQnxFVHgXK9hD6XpP2sivnqupw3TSRMMPqQbwoXzmp8rxmQwH0higZKzE58XnXis1ug6JdvBKhvAF0z4rNbI2IKPZyYqbRcNUHTmRDQ8lRTTRMDYyyb4QND+QPM+VWoZTjqVQSthaxHxWgCfn1xzNUmnP736s32PkhHwHc2wwgGsoDv3vVrNXzKKgdT+a1zLXVxjjEcfNW2DH955TWfRAnvfGAR6lwccvVyUYxDAPIlVqQqYn/MDOU0uQBqXSU7+1lVe+2jWMstgJ/oiC3y8syloXEgpgZx1PE+Clj3Yo4JNy1RFR7bNOqFpZbqjuUOJFsQsw4RmFloCY6xaMCuZ68ZCUKzY4oxx/ba/CecoiI5Q/vWP+fITp4in9pYr2/hxG18Uivzu3zSNO430pNripAitXMt3YN2ALP6sWfVPdx4kOs1SyM2g3T8O1IPEE5mKvBJ5MhzLM8jp8Tvl7CHi/ylkX2lqiWdkA89+i26uTnZKnpqYGaN49okA3+KaUumsihDuQjKQUOUG2b9v691L3n50H2XLJKjvgunqnDrJ/aPdgbprK+AwJNzokj7A+/Ay6639QcgHkIN0lIeAmHjojsI1HBOur0Dfa5g1S2kTdk3erKPrP7AsaFEn+Wu7D4OJ159kQU4w4ux5gL7JVNT7oFPfjbW0nrtdWeAAVvYCKuxOOyNtR73Y4YRSrbHK6fO67UrRmT5+YiOMGDYYYUvHD2LP1ztK2mtmMwhVJIJfrh5pAQcn3tW60+exzEM0qpuc8IFCIxhiR7TOHujwffAztaZnL3XqVloz9mU8SpCoDMQo3ri7uEjn/iQs9mI1teA1XJKk/GMp2eUq5VOi2XK85l1DcDUOr5Et5z5VSVrAb/joFfAK/R8ywcu4jk0YEsteLWnBA2szdzCpbE3g==

I tried to prove it using tactics and check the proof term and that's what is happening, but I can't managed to replicate it, now I get:
In environment
induc : forall u : t, P u
u : t
l : list (option t)
x : t
induc_rec :
forall l : list (option t),
All (option t)
  (fun x : option t => match x with
                       | Some x0 => P x0
                       | None => True
                       end) l
l0 : list (option t)
hd : option t
tl : list (option t)
The term
 "match hd as o return match o with
                       | Some x0 => P x0
                       | None => True
                       end with
  | Some e => induc e
  | None => I
  end" has type "match hd with
                 | Some x0 => P x0
                 | None => True
                 end" while it is expected to have type
"?A@{l0:=l; l:=l0}" (unable to find a well-typed instantiation for
"?A": cannot ensure that "Type" is a subtype of "Prop").

I guess I'll go with the tactic solution, it's a bit more readable anyway :D

Le mar. 24 sept. 2019 à 17:50, Matthieu Sozeau <matthieu.sozeau AT inria.fr> a écrit :
Hi Vincent,

  You should write a return clause `match e as e’ return match e’ with None => True | Some t => P t end with ...` for the match on the option value, I guess. Coq cannot infer its type automatically. The error message is sadly misleading.

Best,
-- Matthieu

> Le 24 sept. 2019 à 17:41, Vincent Siles <vincent.siles AT ens-lyon.org> a écrit :
>
> Hi !
> I'm facing an somehow complex inductive type, for which I have to write the induction scheme by hand. Here is a stripped down example of what I'm doing:
>
> Require Import List.
>
> Inductive t : Set :=
> | Base : t
> | Rec : list (option t) -> t -> t
> .
>
> Section All.
>    Variables (T: Set) (P: T -> Prop).
>
>    Fixpoint All (l : list T) : Prop :=
>        match l with
>        | nil => True
>        | hd :: tl => P hd /\ All tl
>        end.
> End All.
>
> Section Induc.
>    Parameter P: t -> Prop.
>    Parameter HBase : P Base.
>    Parameter HRec: forall l x,
>        All
>          (option t)
>          (fun x => match x with Some e => P e | None => True end)
>          l ->
>        P x ->
>        P (Rec l x).
>
>    Fixpoint induc (e : t) { struct e } : P e :=
>        match e with
>        | Base => HBase
>        | Rec l x => HRec l x
>                ((fix induc_rec l := match l with
>                   | nil => I
>                   | hd :: tl =>
>                           conj (match hd with
>                                 | Some e => induc e  (* error here *)
>                                 | None => I
>                                 end) (induc_rec tl)
>                end) l) (induc x)
>        end.
> End Induc.
>
> Coq complains that:
> In environment
> induc : forall e : t, P e
> e : t
> l : list (option t)
> x : t
> induc_rec : list (option t) -> True
> l0 : list (option t)
> hd : option t
> tl : list (option t)
> e0 : t
> The term "induc e0" has type "P e0" while it is expected to have type
> "?P@{l0:=l; l:=l0; h0:=Some e0}" (cannot instantiate
> "?P" because "e" is not in its scope: available arguments are
> "induc" "e" "l" "x" "induc_rec" "l" "hd" "tl" "Some e").
>
> I'm still investigating, but I think I need some external help on that one :D
>
> Best regards,
> V.




Archive powered by MHonArc 2.6.18.

Top of Page