(*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).

(* Specifications: *)
Lemma ad_1_path_dist_correct_1 :
forall (n : nat) (x y : ad) (l : list ad),
ad_1_path_dist_1 x y (Elems l) n = ad_0_path_dist_1 x y l n.
Lemma ad_1_path_dist_correct_2 :
forall x y : ad, ad_1_path_dist x y = ad_0_path_dist x y.
Lemma ad_1_path_dist_correct_3 :
CGconsistent cg ->
forall (n : nat) (x y : ad),
ad_1_path_dist_1 x y (M0 unit) n = ad_simple_path_dist_1 cg x y nil n.
Lemma ad_1_path_dist_correct :
CGconsistent cg ->
forall x y : ad, ad_1_path_dist x y = ad_simple_path_dist cg x y.
Lemma ad_1_path_dist_big_enough_1 :
forall (n : nat) (s : FSet),
MapSubset _ _ s (MapDom _ cg) ->
MapCard _ cg <= n + MapCard _ s ->
forall x y : ad, ad_1_path_dist_1 x y s n = ad_1_path_dist_1 x y s (S n).
Lemma ad_1_path_dist_big_enough_2 :
forall (n : nat) (x y : ad),
ad_1_path_dist x y = ad_1_path_dist_1 x y (M0 unit) (n + 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.