Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Pattern matching over elements of lists with unknown length

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] Pattern matching over elements of lists with unknown length


chronological Thread 
  • From: "Andrew McCreight" <continuation AT gmail.com>
  • Cc: coq-club AT pauillac.inria.fr
  • Subject: Re: [Coq-Club] Pattern matching over elements of lists with unknown length
  • Date: Sun, 5 Oct 2008 08:27:18 -0700
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:subject:cc:in-reply-to:mime-version :content-type:references; b=NgwkD6CjSWU+sTU12Hu1/XPeNRiBf0ppm+uo7EyphwNjThjxWyVRLApiAl/un2kr16 y/+jfaFO8LiOeBlorfa9LqiR65qCycOHIe7MIb6CQTFMqqxx3/8vL4ZnZsyZldMg9OgW CZ0uaM5SjN/fY4uFkh56S0HoX1+TLEOlNzxm0=
  • List-archive: <http://pauillac.inria.fr/pipermail/coq-club/>

I think the special 'context' pattern does what you want.  You should read about it in the manual, but I think something like this might work:

match goal with
  | [ H : context [7 :: _] |- _ ] => simpl in H
end


- Andrew

2008/10/5 <marko AT ffri.hr>
Dear Coq developers and users,

If I have in context hypothesis about some list, what is the most simple
manner to do pattern matching over those hypothesis to find if those
hypothesis contain some element or not. The problem is: The list increase
during proving some goals but I don't know how long these list is in some
subgoals.
I found these solution (this is example in which I don't know if list
contain number 7 and on what position number 7 is. If list contain number
7 anywhere I have to use one tactic but I have to use another tactic if
list not contain number 7):

Section Example.
Require Import List.
Parameter Lista : list nat.
Hypothesis H_lista : Lista = 3 :: 6 :: 5 :: 7 :: 2 :: nil.
Parameter goal_to_prove : Prop.
Goal goal_to_prove.
pattern 7 in H_lista;
match goal with
 | [ H_lista : (fun _ : nat => ?X) ?Y |- _ ] => simpl in H_lista
 | [ |- _ ] => assert (1=1)
end.

This work but I don't think this manner is "beautiful".

Is there some more simple (or good looking) manner?

Thank you,

Marko Malikoviæ

--------------------------------------------------------
Bug reports: http://logical.futurs.inria.fr/coq-bugs
Archives: http://pauillac.inria.fr/pipermail/coq-club
         http://pauillac.inria.fr/bin/wilma/coq-club
Info: http://pauillac.inria.fr/mailman/listinfo/coq-club




Archive powered by MhonArc 2.6.16.

Top of Page