Fixpoint len(l:list):nat:=
  match l with
     lam => 0%nat
   | cons _ _ l0 => ((len l0) + 1)%nat
  end.Definition first(l:list):dart*dart :=
  match l with
     lam => (nil,nil)
   | cons x x' _ => (x,x')
  end.Definition tail(l:list):list :=
  match l with
     lam => lam
   | cons _ _ l0 => l0
  end.Fixpoint last(l:list):dart*dart :=
  match l with
     lam => (nil,nil)
   | cons x x' l0 =>
      match l0 with
        lam => (x, x')
      | cons _ _ l1 => last l0
      end
  end.Fixpoint nth(l:list)(k:nat){struct l}:dart*dart :=
  match l with
     lam => (nil,nil)
   | cons x x' l0 =>
        match k with
          0%nat => (nil,nil)
        | S 0%nat => (x,x')
        | S (S k0) => nth l0 (S k0)
        end
  end.Fixpoint double_link_list(m:fmap)(l:list){struct l}:Prop:=
   match l with
     lam => True
   | cons x x' l0 => double_link m x x' 
        /\ double_link_list m l0
   end.(* BREAKING THE 0-LINKS IN A MAP m 
   ALONG A DOUBLE-LINK LIST l: *) 

Fixpoint Br(m:fmap)(l:list){struct l}:fmap:=
  match l with
    lam => m
  | cons x x' l0 => Br (Br1 m x x') l0
  end.

(* Specifications: *)
Lemma exd_Br:forall(l:list)(m:fmap)(z:dart), exd m z <-> exd (Br m l) z.
Lemma inv_hmap_Br:forall(l:list)(m:fmap), inv_hmap m -> inv_hmap (Br m l).
Lemma not_succ_Br1_fst:forall(m:fmap)(x x':dart), inv_hmap m -> ~succ (Br1 m x x') zero x.
Lemma not_succ_Br1_snd:forall(m:fmap)(x x':dart), inv_hmap m -> ~succ (Br1 m x x') zero x'.
Lemma cA1_Br:forall(l:list)(m:fmap)(z:dart), inv_hmap m -> cA (Br m l) one z = cA m one z.
Lemma cA1_1_Br:forall(l:list)(m:fmap)(z:dart), inv_hmap m -> cA_1 (Br m l) one z = cA_1 m one z.