- let bag, maxvar, g_actives, g_passives =
- match select g_passives with
- | None -> bag, maxvar, g_actives, g_passives
- | Some (g_current, g_passives) ->
- debug ("Selected goal : " ^ Pp.pp_unit_clause g_current);
- let bag, g_current =
- Sup.simplify_goal maxvar (snd actives) bag g_current
- in
- debug "Simplified goal";
- let bag, maxvar, new_goals =
- Sup.infer_left bag maxvar g_current actives
- in
- debug "Performed infer_left step";
- let new_goals = List.fold_left add_passive_clause
- PassiveSet.empty new_goals
- in
- bag, maxvar, g_current::g_actives,
- (PassiveSet.union new_goals g_passives)
+ let bag, maxvar, new_goals =
+ Sup.infer_left bag maxvar g_current actives
+ in
+ debug "Performed infer_left step";
+ bag, maxvar, actives, passives, g_current::g_actives,
+ (add_passive_clauses g_passives new_goals)
+ ;;
+
+ let forward_infer_step bag maxvar actives passives g_actives
+ g_passives current =
+ (* forward step *)
+
+ (* e = select P *
+ * e' = demod A e *
+ * A' = demod [e'] A *
+ * A'' = A' + e' *
+ * e'' = fresh e' *
+ * new = supright e'' A'' *
+ * new'= demod A'' new *
+ * P' = P + new' *)
+ debug "Forward infer step...";
+ let bag, maxvar, actives, new_clauses =
+ Sup.infer_right bag maxvar current actives
+ in
+ debug "Demodulating goals with actives...";
+ (* keep goals demodulated w.r.t. actives and check if solved *)
+ let bag, g_actives =
+ List.fold_left
+ (fun (bag,acc) c ->
+ match Sup.simplify_goal maxvar (snd actives) bag acc c with
+ | None -> bag, acc
+ | Some (bag,c) -> bag,c::acc)
+ (bag,[]) g_actives
+ in
+ let ctable = IDX.index_unit_clause IDX.DT.empty current in
+ let bag, maxvar, new_goals =
+ List.fold_left
+ (fun (bag,m,acc) g ->
+ let bag, m, ng = Sup.infer_left bag m g
+ ([current],ctable) in
+ bag,m,ng@acc)
+ (bag,maxvar,[]) g_actives
+ in
+ bag, maxvar, actives,
+ add_passive_clauses passives new_clauses, g_actives,
+ add_passive_clauses g_passives new_goals
+ ;;
+
+ let rec given_clause
+ bag maxvar iterno max_steps timeout
+ actives passives g_actives g_passives
+ =
+ let iterno = iterno + 1 in
+ if iterno = max_steps then
+ raise (Failure ("No iterations left !",bag,maxvar,iterno));
+ (* timeout check: gettimeofday called only if timeout set *)
+ (match timeout with
+ | None -> ()
+ | Some timeout ->
+ if Unix.gettimeofday () > timeout then
+ raise (Failure ("Timeout !",bag,maxvar,iterno)));
+
+ let use_age = iterno mod 10 = 0 in
+
+ let rec aux_select passives g_passives =
+ let backward,current,passives,g_passives =
+ select ~use_age:false passives g_passives
+ in
+ if backward then
+ match Sup.simplify_goal maxvar (snd actives) bag g_actives current with
+ | None -> aux_select passives g_passives
+ | Some x -> let bag,g_current = x in
+ backward_infer_step bag maxvar actives passives
+ g_actives g_passives g_current
+ else
+ (* debug ("Selected fact : " ^ Pp.pp_unit_clause current); *)
+ match Sup.keep_simplified current actives bag maxvar with
+ (* match Sup.one_pass_simplification current actives bag maxvar with*)
+ | None -> aux_select passives g_passives
+ | Some x -> let (current, bag, actives) = x in
+ forward_infer_step bag maxvar actives passives
+ g_actives g_passives current
+ in
+
+ (* prerr_endline "Bag :"; prerr_endline (Pp.pp_bag bag);
+ prerr_endline "Active table :";
+ (List.iter (fun x -> prerr_endline (Pp.pp_unit_clause x))
+ (fst actives)); *)
+
+ let bag,maxvar,actives,passives,g_actives,g_passives =
+ aux_select passives g_passives