aboutsummaryrefslogtreecommitdiffhomepage
path: root/theories/Lists
diff options
context:
space:
mode:
authorGravatar Sébastien Hinderer <Sebastien.Hinderer@inria.fr>2014-12-17 15:13:32 +0100
committerGravatar Pierre Letouzey <pierre.letouzey@inria.fr>2014-12-18 20:36:30 +0100
commitece8843f95a28c3ac123cda70c9a870a90a37b85 (patch)
tree14fab6f9706ec90362f0895fa9c185d2a24e31a7 /theories/Lists
parentc78dd97a0ad6c37e6a5ac5fff666178bc3cb41e0 (diff)
Adds two lemmas about hderror to the List standard library.
Diffstat (limited to 'theories/Lists')
-rw-r--r--theories/Lists/List.v12
1 files changed, 12 insertions, 0 deletions
diff --git a/theories/Lists/List.v b/theories/Lists/List.v
index da851aae0..c004b156b 100644
--- a/theories/Lists/List.v
+++ b/theories/Lists/List.v
@@ -87,6 +87,18 @@ Section Facts.
left; exists a, tail; reflexivity.
Qed.
+ Lemma hd_error_tl_repr : forall l (a:A) r,
+ hd_error l = Some a /\ tl l = r <-> l = a :: r.
+ Proof. destruct l as [|x xs].
+ - unfold hd_error, tl; intros a r. split; firstorder discriminate.
+ - intros. simpl. split.
+ * intros (H1, H2). inversion H1. rewrite H2. reflexivity.
+ * inversion 1. subst. auto.
+ Qed.
+
+ Lemma hd_error_some_nil : forall l (a:A), hd_error l = Some a -> l <> nil.
+ Proof. unfold hd_error. destruct l; now discriminate. Qed.
+
Theorem length_zero_iff_nil (l : list A):
length l = 0 <-> l=[].
Proof.