Definition BDDalloc : BDDconfig * ad :=
match new_cfg with
| (bs, (share, (fl, (cnt, (negm, orm))))) =>
match fl with
| a :: fl' =>
(MapPut _ bs a (x, (l, r)),
(MapPut3 _ share l r x a, (fl', (cnt, (negm, orm)))), a)
| nil =>
(MapPut _ bs cnt (x, (l, r)),
(MapPut3 _ share l r x cnt, (fl, (ad_S cnt, (negm, orm)))), cnt)
end
end.

(* Specifications: *)
Lemma BDDalloc_lemma_1 :
forall a : ad,
MapGet _ (fst (fst BDDalloc)) a =
(if Neqb a (snd BDDalloc)
then Some (x, (l, r))
else MapGet _ (fst new_cfg) a).
Lemma BDDalloc_lemma_2 :
In (snd BDDalloc) (fl_of_cfg new_cfg) \/ cnt_of_cfg new_cfg = snd BDDalloc.
Lemma BDDalloc_lemma_3 : MapGet _ (bs_of_cfg new_cfg) (snd BDDalloc) = None.
Lemma BDDalloc_lemma_4 :
fst (fst BDDalloc) = MapPut _ (bs_of_cfg new_cfg) (snd BDDalloc) (x, (l, r)).
Lemma BDDalloc_lemma_5 :
fst (snd (fst BDDalloc)) =
MapPut3 _ (share_of_cfg new_cfg) l r x (snd BDDalloc).
Lemma BDDalloc_preserves_nodes :
nodes_preserved_bs (bs_of_cfg new_cfg) (fst (fst BDDalloc)).
Lemma BDDalloc_zero : MapGet _ (fst (fst BDDalloc)) BDDzero = None.
Lemma BDDalloc_one : MapGet _ (fst (fst BDDalloc)) BDDone = None.
Lemma BDDalloc_BDD_OK : BDD_OK (fst (fst BDDalloc)) (snd BDDalloc).
Lemma BDDalloc_keeps_state_OK : BDDstate_OK (fst (fst BDDalloc)).
Lemma BDDsharing_OK_1 :
forall a : ad,
MapGet _ (bs_of_cfg new_cfg) a = None ->
BDDsharing_OK (MapPut _ (bs_of_cfg new_cfg) a (x, (l, r)))
(MapPut3 _ (share_of_cfg new_cfg) l r x a).
Lemma BDDalloc_keeps_sharing_OK :
BDDsharing_OK (fst (fst BDDalloc)) (fst (snd (fst BDDalloc))).
Lemma BDDalloc_keeps_cnt_OK :
cnt_OK (fst (fst BDDalloc)) (fst (snd (snd (snd (fst BDDalloc))))).
Lemma BDDalloc_keeps_free_list_OK :
BDDfree_list_OK (fst (fst BDDalloc)) (fst (snd (snd (fst BDDalloc))))
(fst (snd (snd (snd (fst BDDalloc))))).
Lemma BDDalloc_orm_same : orm_of_cfg (fst BDDalloc) = orm_of_cfg new_cfg.
Lemma BDDalloc_negm_same : negm_of_cfg (fst BDDalloc) = negm_of_cfg new_cfg.
Lemma BDDalloc_um_same : um_of_cfg (fst BDDalloc) = um_of_cfg new_cfg.
Lemma BDDalloc_keeps_neg_memo_OK :
BDDneg_memo_OK (bs_of_cfg (fst BDDalloc)) (negm_of_cfg (fst BDDalloc)).
Lemma BDDalloc_keeps_or_memo_OK :
BDDor_memo_OK (bs_of_cfg (fst BDDalloc)) (orm_of_cfg (fst BDDalloc)).
Lemma BDDalloc_keeps_univ_memo_OK :
BDDuniv_memo_OK (bs_of_cfg (fst BDDalloc)) (um_of_cfg (fst BDDalloc)).
(* The following results are used for BDDmake *)
Lemma BDDalloc_keeps_config_OK : BDDconfig_OK (fst BDDalloc).
Lemma BDDalloc_preserves_used_nodes :
used_nodes_preserved cfg (fst BDDalloc) ul.
Lemma BDDalloc_node_OK : config_node_OK (fst BDDalloc) (snd BDDalloc).
Lemma BDDallocGet :
MapGet _ (fst (fst BDDalloc)) (snd BDDalloc) = Some (x, (l, r)).