Definition BDDiff (cfg : BDDconfig) (negm : BDDneg_memo)
(orm : BDDor_memo) (node1 node2 : ad) :=
match BDDimpl cfg negm orm node1 node2 with
| (cfg', (node1', (negm', orm'))) =>
match BDDimpl cfg' negm' orm' node2 node1 with
| (cfg'', (node2', (negm'', orm''))) =>
BDDand cfg'' negm'' orm'' node1' node2'
end
end.

Lemma BDDiff_preserves_nodes :
forall (cfg : BDDconfig) (negm : BDDneg_memo) (orm : BDDor_memo)
(node1 node2 : ad),
BDDconfig_OK cfg ->
BDDneg_memo_OK_2 cfg negm ->
BDDor_memo_OK cfg orm ->
config_node_OK cfg node1 ->
config_node_OK cfg node2 ->
nodes_preserved cfg (fst (BDDiff cfg negm orm node1 node2)).