Definition Array := list (D * R).Fixpoint arrayLookup(ls : list (D * R)) d :=
    match ls with
      | nil => None
      | (d', r') :: ls' =>
        if (eqb d d') 
          then Some r' 
          else (arrayLookup ls' d)
    end.Definition arrayEquiv(arr1 arr2 : Array) :=
    forall d, 
      (arrayLookup arr1 d) = (arrayLookup arr2 d).Definition arrayLookupDef(ls : list (D * R)) d def :=
    match arrayLookup ls d with
        | None => def
        | Some r => r
    end.Definition arrayUpdate (arr_opt : option Array) d r_opt :=
    let arr := match arr_opt with
                 | None => nil
                 | Some arr => arr
               end in
    match r_opt with
        | None => arr
        | Some r =>
          (d, r) :: arr
    end.

(* Specifications: *)
Lemma arrayLookup_app_some_eq : forall ls d v, arrayLookup ls d = None -> arrayLookup (ls ++ (d, v) :: nil) d = Some v.
Lemma arrayLookup_app_none : forall ls d d' v', arrayLookup ls d = None -> arrayLookup (ls ++ (d, v') :: nil) d' = arrayLookup ((d, v') :: ls) d'.
Lemma arrayLookup_app_ne : forall ls d r d', d <> d' -> arrayLookup (ls ++ (d, r) :: nil) d' = arrayLookup ls d'.
Lemma arrayLookup_app_some : forall ls d d' v v', arrayLookup ls d = Some v -> arrayLookup (ls ++ (d, v') :: nil) d' = arrayLookup ls d'.
Theorem arrayLookup_arrayUpdate_eq : forall arr p v, arrayLookup (arrayUpdate arr p (Some v)) p = (Some v).
Theorem arrayLookup_arrayUpdate_ne : forall arr p1 p2 v, p1 <> p2 -> arrayLookup (arrayUpdate (Some arr) p1 (Some v)) p2 = arrayLookup arr p2.
Theorem arrayLookup_arrayUpdate_None_ne : forall p1 p2 v, p1 <> p2 -> arrayLookup (arrayUpdate None p1 (Some v)) p2 = None.