Definition BDDmake (cfg : BDDconfig) (x : BDDvar)
(l r : ad) :=
if Neqb l r
then (cfg, l)
else
match cfg with
| (bs, (share, counter)) =>
match BDDshare_lookup share x l r with
| Some y => (cfg, y)
| None => BDDalloc cfg x l r
end
end.

(* Specifications: *)
Lemma BDDmake_semantics :
forall (cfg : BDDconfig) (l r : ad) (x : BDDvar),
BDDconfig_OK cfg ->
node_OK (fst cfg) l ->
node_OK (fst cfg) r ->
(forall (xl : BDDvar) (ll rl : ad),
MapGet _ (fst cfg) l = Some (xl, (ll, rl)) ->
BDDcompare xl x = Datatypes.Lt) ->
(forall (xr : BDDvar) (lr rr : ad),
MapGet _ (fst cfg) r = Some (xr, (lr, rr)) ->
BDDcompare xr x = Datatypes.Lt) ->
BDDconfig_OK (fst (BDDmake cfg x l r)) /\
(Neqb l r = false ->
MapGet _ (fst (fst (BDDmake cfg x l r))) (snd (BDDmake cfg x l r)) =
Some (x, (l, r))) /\
(Neqb l r = true -> snd (BDDmake cfg x l r) = l) /\
(forall (a l' r' : ad) (x' : BDDvar),
(MapGet _ (fst (fst (BDDmake cfg x l r))) a = Some (x', (l', r')) ->
MapGet _ (fst cfg) a = Some (x', (l', r')) \/
snd (BDDmake cfg x l r) = a) /\
(MapGet _ (fst cfg) a = Some (x', (l', r')) ->
MapGet _ (fst (fst (BDDmake cfg x l r))) a = Some (x', (l', r')))) /\
node_OK (fst (fst (BDDmake cfg x l r))) (snd (BDDmake cfg x l r)).