(*s Definition of [ad_0_path_dist_1] a more efficient version of [ad_simple_path_dist]: *)
Section CGDist1.
Variable cg : CGraph1.
Fixpoint ad_0_path_dist_1 (x y : ad) (l : list ad)
(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 =>
if ad_in_list x l
then None
else
let l' := x :: l in (* builds reverse path *)
all_min
(fun (z : ad) (d : D) =>
if ad_in_list z l'
then None
else Ddplus (ad_0_path_dist_1 z y l' n') d) edges
end
end.
Definition ad_0_path_dist (x y : ad) :=
ad_0_path_dist_1 x y nil (MapCard _ cg).

(* Specifications: *)
Lemma ad_0_path_dist_1_ge :
forall (n : nat) (l : list ad) (x y : ad),
Ddle (ad_simple_path_dist_1 cg x y l n) (ad_0_path_dist_1 x y l n) = true.
Lemma ad_0_path_dist_1_correct_1 :
(forall (x : ad) (d : D) (l : list ad),
CG_path cg x d (x :: l) -> Dle Dz d = true) ->
forall (n : nat) (x y : ad) (l : list ad) (d : D),
length l <= n ->
CG_path cg y d (x :: l) ->
forall prefix : list ad,
ad_list_stutters (rev prefix ++ x :: l) = false ->
Ddle (ad_0_path_dist_1 x y prefix n) (Some d) = true.
Lemma ad_0_path_dist_1_le :
(forall (x : ad) (d : D) (l : list ad),
CG_path cg x d (x :: l) -> Dle Dz d = true) ->
forall (n : nat) (x y : ad),
Ddle (ad_0_path_dist_1 x y nil n) (ad_simple_path_dist_1 cg x y nil n) =
true.
Lemma ad_0_path_dist_correct_1 :
CGconsistent cg ->
forall (x y : ad) (n : nat),
ad_0_path_dist_1 x y nil n = ad_simple_path_dist_1 cg x y nil n.
Lemma ad_0_path_dist_correct :
CGconsistent cg ->
forall x y : ad, ad_0_path_dist x y = ad_simple_path_dist cg x y.