Definition rotate {A} (l : list A) n m := sublist (m - n) (Zlength l) l ++
  sublist 0 (m - n) l.

(* Specifications: *)
Lemma sublist_0_cons : forall {A} j x (l : list A), j > 0 -> sublist 0 j (x :: l) = x :: sublist 0 (j - 1) l.
Lemma sublist_S_cons : forall {A} i j x (l : list A), i > 0 -> sublist i j (x :: l) = sublist (i - 1) (j - 1) l.
Lemma upd_rotate : forall {A} i (l : list A) n m x (Hl : Zlength l = m) (Hlt : 0 <= n <= m) (Hi : 0 <= i < Zlength l), upd_Znth i (rotate l n m) x = rotate (upd_Znth ((i - n) mod m) l x) n m.
Lemma Znth_cons_eq : forall {A}{d : Inhabitant A} i x l, Znth i (x :: l) = if eq_dec i 0 then x else Znth (i - 1) l.
Lemma Znth_rotate : forall {A} {d : Inhabitant A} i l n, 0 <= n <= Zlength l -> 0 <= i < Zlength l -> Znth i (rotate l n (Zlength l)) = Znth ((i - n) mod Zlength l) l.
Lemma Forall_sublist_le : forall {A} {d : Inhabitant A} (P : A -> Prop) i j l (Hrangei : 0 <= i) (Hrangej : j <= Zlength l) (Hi : ~P (Znth i l)) (Hj : Forall P (sublist 0 j l)), j <= i.