(*s Uses a set [s] of already visited nodes *)

Fixpoint ad_1_path_dist_1 (x y : ad) (s : FSet) (n : nat) {struct n} :
 option D :=
  if Neqb x y
  then Some Dz
  else
   match n with
   | O => None
   | S n' =>
       match MapGet _ cg x with
       | None => None
       | Some edges =>
           match MapGet _ s x with
           | Some _ => None
           | None =>
               let s' := MapPut unit s x tt in
               all_min
                 (fun (z : ad) (d : D) =>
                  match MapGet _ s' z with
                  | Some _ => None
                  | None => Ddplus (ad_1_path_dist_1 z y s' n') d
                  end) edges
           end
       end
   end.Definition ad_1_path_dist (x y : ad) :=
  ad_1_path_dist_1 x y (M0 unit) (MapCard _ cg).

Lemma ad_1_path_dist_big_enough : forall n : nat, MapCard _ cg <= n -> forall x y : ad, ad_1_path_dist x y = ad_1_path_dist_1 x y (M0 unit) n.