coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Adam Chlipala <adamc AT hcoop.net>
- To: Venanzio Capretta <venanzio AT cs.ru.nl>
- Cc: coq-club AT pauillac.inria.fr
- Subject: Re: [Coq-Club] Prefixes of a vector
- Date: Wed, 20 Aug 2008 08:35:03 -0400
- List-archive: <http://pauillac.inria.fr/pipermail/coq-club/>
Programs written like this with proof scripts seem hard to read and maintain. Does anyone have any arguments for writing in this style instead of in the style I used in my solution?
Venanzio Capretta wrote:
Here is a solution. I'm not sure it is better than yours: it just hides the ugly parts (to do with inversions) into a couple of auxiliary functions (definitions below):
bound_0_elim: forall A:Type, (Bounded 0) -> A
bounded_zero_succ: forall (n:nat)(i:Bounded (S n)),
{j:Bounded n | i = Succ j} + {i=Zero n}.
But at least you can define prefix in a shorter and more intuitive way:
Definition prefix: forall (A:Set)(n:nat)(i:Bounded (S n)),
vector A n -> vector A (Bounded_to_nat i).
induction 1.
case (bounded_zero_succ 0 i).
intros [j Hij]; apply bound_0_elim with (1:=j).
intros Hi; rewrite Hi; exact (Vnil A).
case (bounded_zero_succ (S n) i).
intros [j Hij]; rewrite Hij; simpl.
apply Vcons.
exact a.
exact (IHvector j).
intro Hi; rewrite Hi; exact (Vnil A).
Defined.
- [Coq-Club] Prefixes of a vector, Samuel E. Moelius III
- Re: [Coq-Club] Prefixes of a vector,
Adam Chlipala
- Re: [Coq-Club] Prefixes of a vector,
Samuel E. Moelius III
- Re: [Coq-Club] Prefixes of a vector, Pierre Casteran
- Re: [Coq-Club] Prefixes of a vector,
Samuel E. Moelius III
- Re: [Coq-Club] Prefixes of a vector,
Venanzio Capretta
- Re: [Coq-Club] Prefixes of a vector, Adam Chlipala
- Re: [Coq-Club] Prefixes of a vector,
Venanzio Capretta
- Re: [Coq-Club] Prefixes of a vector,
Adam Chlipala
- Re: [Coq-Club] Prefixes of a vector,
Samuel E. Moelius III
- Re: [Coq-Club] Prefixes of a vector, Adam Chlipala
- Re: [Coq-Club] Prefixes of a vector,
Samuel E. Moelius III
- Re: [Coq-Club] Prefixes of a vector,
Conor McBride
- Re: [Coq-Club] Prefixes of a vector, Matthieu Sozeau
- Re: [Coq-Club] Prefixes of a vector,
Adam Chlipala
- Re: [Coq-Club] Prefixes of a vector,
Venanzio Capretta
- Re: [Coq-Club] Prefixes of a vector, Adam Chlipala
- Re: [Coq-Club] Prefixes of a vector,
Adam Chlipala
Archive powered by MhonArc 2.6.16.