diff options
author | Andres Erbsen <andreser@mit.edu> | 2015-11-03 18:10:14 -0500 |
---|---|---|
committer | Andres Erbsen <andreser@mit.edu> | 2015-11-03 18:10:14 -0500 |
commit | a167e155d96a3ea51397df254c515b6a7525890a (patch) | |
tree | ba8c35633735071d593b69e3531095fa8d4f8762 /src/Util/ListUtil.v | |
parent | 912f56db3bdb2c535a62b71b668448965aa23d26 (diff) |
set_nth_splice case coverage
Diffstat (limited to 'src/Util/ListUtil.v')
-rw-r--r-- | src/Util/ListUtil.v | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/Util/ListUtil.v b/src/Util/ListUtil.v index 4ef42a3ad..d1c12dbfd 100644 --- a/src/Util/ListUtil.v +++ b/src/Util/ListUtil.v @@ -100,12 +100,15 @@ Proof. destruct (eq_nat_dec n m), (eq_nat_dec (S n) (S m)); nth_tac. Qed. -Lemma set_nth_splice: forall {T} n x (xs:list T), - n < length xs -> - set_nth n x xs = firstn n xs ++ x :: skipn (S n) xs. +Lemma set_nth_equiv_splice: forall {T} n x (xs:list T), + set_nth n x xs = + if lt_dec n (length xs) + then firstn n xs ++ x :: skipn (S n) xs + else xs. Proof. induction n; destruct xs; intros; simpl in *; - try rewrite IHn; auto; omega. + try (rewrite IHn; clear IHn); auto. + destruct (lt_dec n (length xs)), (lt_dec (S n) (S (length xs))); try omega; trivial. Qed. Lemma combine_set_nth : forall {A B} n (x:A) xs (ys:list B), |