(******************************)
(******************************)
(* Custom lemmas about arrays *)
(******************************)
(******************************)
Definition indx {I : finType} (x : I) := index x (enum I).
Prenex Implicits indx.
(***********************************)
(* Arrays indexed by a finite type *)
(***********************************)
Section Array.
Variables (p : ptr) (I : finType).
(* helper lemmas *)

(* Specifications: *)
Lemma enum_split k :
enum I = take (indx k) (enum I) ++ k :: drop (indx k).+1 (enum I).
Lemma updi_split T k (f : {ffun I -> T}) :
updi p (fgraph f) = updi p (take (indx k) (fgraph f)) \+
p.+(indx k) :-> f k \+
updi (p.+(indx k).+1) (drop (indx k).+1 (fgraph f)).
Lemma takeord T k x (f : {ffun I -> T}) :
take (indx k) (fgraph [ffun y => [eta f with k |-> x] y]) =
take (indx k) (fgraph f).
Lemma dropord T k x (f : {ffun I -> T}) :
drop (indx k).+1 (fgraph [ffun y => [eta f with k |->x] y]) =
drop (indx k).+1 (fgraph f).
Lemma size_fgraph T1 T2 (r1 : {ffun I -> T1}) (r2 : {ffun I -> T2}) :
size (fgraph r1) = size (fgraph r2).