Lvc.Infra.Drop

Require Import Arith Coq.Lists.List Setoid Coq.Lists.SetoidList.
Require Export Infra.Option EqDec AutoIndTac Util Get.

Set Implicit Arguments.

Fixpoint drop {X} (n : nat) (xs : list X) : list X :=
  match n with
    | 0 ⇒ xs
    | S ndrop n (tl xs)
  end.

Fixpoint drop_error {X} (n : nat) (xs : list X) : option (list X) :=
  match n with
    | 0 ⇒ Some xs
    | S nmatch xs with
               | nilNone
               | _::xsdrop_error n xs
             end
  end.

Lemma drop_get X (L:list X) k n v
  : get L (k+n) vget (drop k L) n v.

Lemma get_drop_eq X (L :list X) n x y
  : get L n xy:: = drop n Lx = y.

Lemma drop_get_nil X k n (v:X)
  : get (drop k nil) n vFalse.

Lemma get_drop X (L:list X) k n v
  : get (drop k L) n vget L (k+n) v.

Lemma length_drop_cons X (L:list X) k a x
  : k length Llength (drop k L) = alength (drop k (x::L)) = S a.

Lemma length_drop X (L:list X) a
  : a length Llength (drop (length L - a) (L)) = a.

Lemma drop_nil X k
  : drop k nil = (@nil X).

Lemma length_drop_minus X (L:list X) k
  : length (drop k L) = length L - k.

Lemma drop_app X (L :list X) n
  : drop (length L + n) (L++) = drop n .

Lemma drop_tl X (L:list X) n
  : tl (drop n L) = drop n (tl L).

Lemma drop_drop X (L:list X) n
  : drop n (drop L) = drop (n+) L.


Lemma drop_swap X m n (L:list X)
  : drop m (drop n L) = drop n (drop m L).

Lemma drop_nth X k L (x:X) d
  : drop k L = x::nth k L d = x.

Lemma drop_map X Y (L:list X) n (f:XY)
  : List.map f (drop n L) = drop n (List.map f L).

Lemma drop_length_eq X (L :list X)
: drop (length ) ( ++ L) = L.

Lemma drop_length X (L :list X) n
: n < length drop n ( ++ L) = (drop n ++ L)%list.

Lemma drop_length_gr X (L :list X) n x
: n > length drop n ( ++ x::L) = (drop (n - S(length )) L)%list.

Lemma drop_eq X (L :list X) n y
: y:: = drop n Lget L n y.

Lemma drop_shift_1 X (L:list X) y YL i
: y :: YL = drop i L
  → YL = drop (S i) L.

Lemma drop_length_stable X Y (L:list X) (:list Y) i
: length L = length
  → length (drop i L) = length (drop i ).

Lemma get_eq_drop X (L :list X) n x
: get L n xx::drop (S n) L = drop n L.