let remove x =
Term.fold
(fun y acc ->
try
let uy = Map.find y acc in
let uy' = Set.remove x uy in
if Set.is_empty uy' then
Map.remove y acc
else if uy == uy' then
acc
else
Map.add y uy' acc
with
Not_found -> acc)