Section CGDist1.
Variable cg : CGraph1.
Fixpoint ad_0_path_dist_1 (x y : ad) (l : list ad)
(n : nat) {struct n} : option D :=
if N.eqb 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).
(*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 N.eqb 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).
End CGDist1.
(*s Definition of concrete formulas : [(CGleq x y d)] means $x\leq y+d$, [(CGeq x y d)] means $x=y+d$ *)
Inductive CGForm : Set :=
| CGleq : ad -> ad -> D -> CGForm
| CGeq : ad -> ad -> D -> CGForm
| CGand : CGForm -> CGForm -> CGForm
| CGor : CGForm -> CGForm -> CGForm
| CGimp : CGForm -> CGForm -> CGForm
| CGnot : CGForm -> CGForm.
(*s Interpretation of concrete formulas as proposition *)
Fixpoint CGeval (rho : ad -> D) (f : CGForm) {struct f} : Prop :=
match f with
| CGleq x y d => Dle (rho x) (Dplus (rho y) d) = true
| CGeq x y d => rho x = Dplus (rho y) d
| CGand f0 f1 => CGeval rho f0 /\ CGeval rho f1
| CGor f0 f1 => CGeval rho f0 \/ CGeval rho f1
| CGimp f0 f1 => CGeval rho f0 -> CGeval rho f1
| CGnot f0 => ~ CGeval rho f0
end.
(*s Decidability of satisfaction *)

Lemma CGeval_dec :
forall (f : CGForm) (rho : ad -> D), {CGeval rho f} + {~ CGeval rho f}.