(*===========================================================
                   top, bottom
 
============================================================*)

(* top AND bottom :*)

Fixpoint top
   (m:fmap)(k:dim)(z:dart){struct m}:dart:=
 match m with
     V => nil
  |  I m0 x _ _ =>
       if eq_dart_dec x z then z
       else top m0 k z
  |  L m0 k0 x y =>
       if eq_dim_dec k0 k
       then
         if eq_dart_dec x (top m0 k0 z) 
         then top m0 k0 y
	 else top m0 k0 z
       else top m0 k z
 end.Fixpoint bottom
   (m:fmap)(k:dim)(z:dart){struct m}:dart:=
 match m with
     V => nil
  |  I m0 x _ _ =>
       if eq_dart_dec x z then z
       else bottom m0 k z
  |  L m0 k0 x y =>
       if (eq_dim_dec k0 k)
       then
         if eq_dart_dec y (bottom m0 k0 z)
         then bottom m0 k0 x
	 else bottom m0 k0 z
       else bottom m0 k z
 end.

Lemma cA_1_B_ter : forall (m:fmap)(k j:dim)(x z:dart), inv_hmap m -> k <> j -> cA_1 (B m k x) j z = cA_1 m j z.