+ match is_subsumed ~unify:false bag maxvar clause table with
+ | None -> bag, Some clause
+ | Some _ -> bag, None
+ ;;
+
+ let simplify table maxvar bag clause =
+ match simplify table maxvar bag clause with
+ | bag, None ->
+ let (id,_,_,_) = clause in
+ let (_,_,iter) = Terms.get_from_bag id bag in
+ Terms.replace_in_bag (clause,true,iter) bag, None
+ | bag, Some clause -> bag, Some clause
+ (*let (id,_,_,_) = clause in
+ if orphan_murder bag clause then
+ Terms.M.add id (clause,true) bag, Some clause
+ else bag, Some clause*)
+ ;;
+
+ let one_pass_simplification new_clause (alist,atable) bag maxvar =
+ match simplify atable maxvar bag new_clause with
+ | bag,None -> bag,None (* new_clause has been discarded *)
+ | bag,(Some clause) ->
+ let ctable = IDX.index_unit_clause IDX.DT.empty clause in
+ let bag, alist, atable =
+ List.fold_left
+ (fun (bag, alist, atable) c ->
+ match simplify ctable maxvar bag c with
+ |bag,None -> (bag,alist,atable)
+ (* an active clause as been discarded *)
+ |bag,Some c1 ->
+ bag, c :: alist, IDX.index_unit_clause atable c)
+ (bag,[],IDX.DT.empty) alist
+ in
+ bag, Some (clause, (alist,atable))
+ ;;
+
+ let simplification_step ~new_cl cl (alist,atable) bag maxvar new_clause =
+ let atable1 =
+ if new_cl then atable else
+ IDX.index_unit_clause atable cl
+ in
+ (* Simplification of new_clause with : *
+ * - actives and cl if new_clause is not cl *
+ * - only actives otherwise *)
+ match
+ simplify atable1 maxvar bag new_clause with
+ | bag,None -> bag,(Some cl, None) (* new_clause has been discarded *)
+ | bag,Some clause ->
+ (* Simplification of each active clause with clause *
+ * which is the simplified form of new_clause *)
+ let ctable = IDX.index_unit_clause IDX.DT.empty clause in
+ let bag, newa, alist, atable =
+ List.fold_left
+ (fun (bag, newa, alist, atable) c ->
+ match simplify ctable maxvar bag c with
+ |bag,None -> (bag, newa, alist, atable)
+ (* an active clause as been discarded *)
+ |bag,Some c1 ->
+ if (c1 == c) then
+ bag, newa, c :: alist,
+ IDX.index_unit_clause atable c
+ else
+ bag, c1 :: newa, alist, atable)
+ (bag,[],[],IDX.DT.empty) alist
+ in
+ if new_cl then
+ bag, (Some cl, Some (clause, (alist,atable), newa))
+ else
+ (* if new_clause is not cl, we simplify cl with clause *)
+ match simplify ctable maxvar bag cl with
+ | bag,None ->
+ (* cl has been discarded *)
+ bag,(None, Some (clause, (alist,atable), newa))
+ | bag,Some cl1 ->
+ bag,(Some cl1, Some (clause, (alist,atable), newa))
+ ;;
+
+ let keep_simplified cl (alist,atable) bag maxvar =
+ let rec keep_simplified_aux ~new_cl cl (alist,atable) bag newc =
+ if new_cl then
+ match simplification_step ~new_cl cl (alist,atable) bag maxvar cl with
+ | _,(None, _) -> assert false
+ | bag,(Some _, None) -> bag,None
+ | bag,(Some _, Some (clause, (alist,atable), newa)) ->
+ keep_simplified_aux ~new_cl:(cl!=clause) clause (alist,atable)
+ bag (newa@newc)
+ else
+ match newc with
+ | [] -> bag, Some (cl, (alist,atable))
+ | hd::tl ->
+ match simplification_step ~new_cl cl
+ (alist,atable) bag maxvar hd with
+ | _,(None,None) -> assert false
+ | bag,(Some _,None) ->
+ keep_simplified_aux ~new_cl cl (alist,atable) bag tl
+ | bag,(None, Some _) -> bag,None
+ | bag,(Some cl1, Some (clause, (alist,atable), newa)) ->
+ let alist,atable =
+ (clause::alist, IDX.index_unit_clause atable clause)
+ in
+ keep_simplified_aux ~new_cl:(cl!=cl1) cl1 (alist,atable)
+ bag (newa@tl)
+ in
+ keep_simplified_aux ~new_cl:true cl (alist,atable) bag []