X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Fcomponents%2Fng_paramodulation%2Fparamod.ml;h=a6f3a93c789f086a4848f3959e9183511a5251fc;hb=68a557b997805b4a96fb2851cb4d2ab2076bba36;hp=43b57b6cd0b8da83f116eda2b4c6fc6a827782ec;hpb=a232a59672817abd3d6ec07db0b20d8b3fe5ad3b;p=helm.git diff --git a/helm/software/components/ng_paramodulation/paramod.ml b/helm/software/components/ng_paramodulation/paramod.ml index 43b57b6cd..a6f3a93c7 100644 --- a/helm/software/components/ng_paramodulation/paramod.ml +++ b/helm/software/components/ng_paramodulation/paramod.ml @@ -14,7 +14,7 @@ let debug s = prerr_endline s ;; let debug _ = ();; -let monster = 500;; +let monster = 100;; module Paramod (B : Terms.Blob) = struct exception Failure of string * B.t Terms.bag * int * int @@ -45,6 +45,12 @@ module Paramod (B : Terms.Blob) = struct WeightPassiveSet.add cl passives_w, AgePassiveSet.add cl passives_a ;; + let add_passive_goal ?(no_weight=false) (passives_w,passives_a) g = + let g = if no_weight then (0,g) + else Utils.mk_passive_goal g in + WeightPassiveSet.add g passives_w, AgePassiveSet.add g passives_a + ;; + let remove_passive_clause (passives_w,passives_a) cl = let passives_w = WeightPassiveSet.remove cl passives_w in let passives_a = AgePassiveSet.remove cl passives_a in @@ -61,6 +67,16 @@ module Paramod (B : Terms.Blob) = struct AgePassiveSet.union new_clauses_a passives_a) ;; + let add_passive_goals ?(no_weight=false) + (passives_w,passives_a) new_clauses = + let new_clauses_w,new_clauses_a = + List.fold_left (add_passive_goal ~no_weight) + (WeightPassiveSet.empty,AgePassiveSet.empty) new_clauses + in + (WeightPassiveSet.union new_clauses_w passives_w, + AgePassiveSet.union new_clauses_a passives_a) + ;; + let is_passive_set_empty (passives_w,passives_a) = if (WeightPassiveSet.is_empty passives_w) then begin assert (AgePassiveSet.is_empty passives_a); true @@ -83,7 +99,7 @@ module Paramod (B : Terms.Blob) = struct let mk_clause bag maxvar (t,ty) = let (proof,ty) = B.saturate t ty in let c, maxvar = Utils.mk_unit_clause maxvar ty proof in - let bag, c = Utils.add_to_bag bag c in + let bag, c = Terms.add_to_bag c bag in (bag, maxvar), c ;; @@ -102,7 +118,11 @@ module Paramod (B : Terms.Blob) = struct (false,cl,remove_passive_clause passives cl,g_passives) else let g_cl = pick_min_passive ~use_age:use_age g_passives in - if (fst cl <= fst g_cl) then + let (id1,_,_,_),(id2,_,_,_) = snd cl, snd g_cl in + let cmp = if use_age then id1 <= id2 + else fst cl <= fst g_cl + in + if cmp then (false,cl,remove_passive_clause passives cl,g_passives) else (true,g_cl,passives,remove_passive_clause g_passives g_cl) @@ -117,7 +137,7 @@ module Paramod (B : Terms.Blob) = struct in debug "Performed infer_left step"; bag, maxvar, actives, passives, g_current::g_actives, - (add_passive_clauses g_passives new_goals) + (add_passive_goals g_passives new_goals) ;; let forward_infer_step bag maxvar actives passives g_actives @@ -152,14 +172,13 @@ module Paramod (B : Terms.Blob) = struct 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 + 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 + add_passive_goals g_passives new_goals ;; let rec given_clause ~noinfer @@ -203,13 +222,21 @@ module Paramod (B : Terms.Blob) = struct end else raise (Failure ("Timeout !",bag,maxvar,iterno)); - (* let use_age = iterno mod 10 = 0 in *) + let use_age = iterno mod 5 = 0 in let rec aux_select bag passives g_passives = let backward,(weight,current),passives,g_passives = select ~use_age:false passives g_passives in + if use_age && weight > monster then + let bag,cl = Terms.add_to_bag current bag in + if backward then + aux_select bag passives (add_passive_clause g_passives cl) + else + aux_select bag (add_passive_clause passives cl) g_passives + else if backward then + let _ = debug ("Selected goal : " ^ Pp.pp_unit_clause current) in match if noinfer then if weight > monster then None else Some (bag,current) @@ -233,8 +260,8 @@ module Paramod (B : Terms.Blob) = struct if weight > monster then bag,None else bag, Some (current,actives) else if Sup.orphan_murder bag (fst actives) current then - let (id,_,_,_) = current in - let bag = Terms.M.add id (current,true) bag in + let _ = debug "Orphan murdered" in + let bag = Terms.replace_in_bag (current,true) bag in bag, None else Sup.keep_simplified current actives bag maxvar with @@ -293,7 +320,7 @@ module Paramod (B : Terms.Blob) = struct add_passive_clauses ~no_weight:true passive_empty_set passives in let g_passives = - add_passive_clauses ~no_weight:true passive_empty_set g_passives + add_passive_goals ~no_weight:true passive_empty_set g_passives in let g_actives = [] in let actives = [], IDX.DT.empty in @@ -304,7 +331,7 @@ module Paramod (B : Terms.Blob) = struct | Sup.Success (bag, _, (i,_,_,_)) -> let l = let rec traverse ongoal (accg,acce) i = - match Terms.M.find i bag with + match Terms.get_from_bag i bag with | (id,_,_,Terms.Exact _),_ -> if ongoal then [i],acce else if (List.mem i acce) then accg,acce else accg,acce@[i]