| 1 |
(* We copy some proofs from the standard library so we can use them in older versions of Coq; once we get a new enough Coq, this file should go away *) |
| 2 |
From Coq Require Import List. |
| 3 |
From Coq Require Import Arith. |
| 4 |
Import ListNotations. |
| 5 |
Local Open Scope list_scope. |
| 6 |
Module Export List. |
| 7 |
(* This is in the stdlib since Coq 8.12 *) |
| 8 |
Section Elts. |
| 9 |
Variable A : Type. |
| 10 |
|
| 11 |
Lemma nth_ext : forall (l l' : list A) d d', length l = length l' -> |
| 12 |
(forall n, n < length l -> nth n l d = nth n l' d') -> l = l'. |
| 13 |
Proof. |
| 14 |
intro l; induction l as [|a l IHl]; |
| 15 |
intros l' d d' Hlen Hnth; destruct l' as [| b l']. |
| 16 |
- reflexivity. |
| 17 |
- inversion Hlen. |
| 18 |
- inversion Hlen. |
| 19 |
- change a with (nth 0 (a :: l) d). |
| 20 |
change b with (nth 0 (b :: l') d'). |
| 21 |
rewrite Hnth; f_equal. |
| 22 |
+ apply IHl with d d'; [ now inversion Hlen | ]. |
| 23 |
intros n Hlen'; apply (Hnth (S n)). |
| 24 |
now apply (Nat.succ_lt_mono n (length l)). |
| 25 |
+ simpl; apply Nat.lt_0_succ. |
| 26 |
Qed. |
| 27 |
End Elts. |
| 28 |
End List. |