(*s [(ad_simple_path_naive_search x y prefix n)] is true when there esists a path [x::l] from [y] to [x] of length less than [n] with edges not in prefix *)
Fixpoint ad_simple_path_naive_search (x y : ad) (l : list ad)
(n : nat) {struct n} : bool :=
Neqb x y
|| match n with
| O => false
| S n' =>
match MapGet _ cg x with
| None => false
| Some edges =>
let l' := x :: l in (* builds reverse path *)
match
MapSweep D
(fun (z : ad) (d : D) =>
if ad_in_list z l'
then false
else ad_simple_path_naive_search z y l' n') edges
with
| None => false
| Some _ => true
end
end
end.

(* Specifications: *)
Lemma ad_simple_path_naive_search_correct_1 :
forall (n : nat) (x y : ad) (l : list ad) (d : D),
length l <= n ->
CG_path y d (x :: l) ->
forall prefix : list ad,
ad_list_stutters (rev prefix ++ x :: l) = false ->
ad_simple_path_naive_search x y prefix n = true.
Lemma ad_simple_path_naive_search_correct :
forall (n : nat) (x y : ad) (l : list ad) (d : D),
length l <= n ->
CG_path y d (x :: l) ->
ad_list_stutters (x :: l) = false ->
ad_simple_path_naive_search x y nil n = true.
Lemma ad_simple_path_naive_search_complete_1 :
forall (n : nat) (x y : ad) (prefix : list ad) (d' : D),
CG_path x d' (rev (x :: prefix)) ->
ad_list_stutters (x :: prefix) = false ->
ad_simple_path_naive_search x y prefix n = true ->
{d : D &
{l : list ad &
and_sp (CG_path y d (rev (x :: prefix) ++ l))
(ad_list_stutters (rev (x :: prefix) ++ l) = false)}}.
Lemma ad_simple_path_naive_search_complete :
forall (n : nat) (x y : ad),
ad_simple_path_naive_search x y nil n = true ->
{d : D &
{l : list ad &
and_sp (CG_path y d (x :: l)) (ad_list_stutters (x :: l) = false)}}.