X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Fcomponents%2Fng_paramodulation%2FfoUtils.ml;h=7b57e5bb3d2037b98ff681521c3b55d1ecd6a2cc;hb=db7f6d6b32515c091e0f338dd4903624f35f27ac;hp=69e451e2e000ef738f8cfd81bb5d24bc5218f951;hpb=6b0a195b180e3526af7b55771b2df7b10acd7c30;p=helm.git diff --git a/helm/software/components/ng_paramodulation/foUtils.ml b/helm/software/components/ng_paramodulation/foUtils.ml index 69e451e2e..7b57e5bb3 100644 --- a/helm/software/components/ng_paramodulation/foUtils.ml +++ b/helm/software/components/ng_paramodulation/foUtils.ml @@ -11,10 +11,19 @@ (* $Id: terms.ml 9836 2009-06-05 15:33:35Z denes $ *) - -module Utils (B : Terms.Blob) = struct - module Subst = FoSubst.Subst(B) ;; - module Order = Orderings.Orderings(B) ;; +let rec lexicograph f l1 l2 = + match l1, l2 with + | [], [] -> 0 + | x::xs, y::ys -> + let c = f x y in + if c <> 0 then c else lexicograph f xs ys + | [],_ -> ~-1 + | _,[] -> 1 +;; + +module Utils (B : Orderings.Blob) = struct + module Subst = FoSubst;; + module Order = B;; let rec eq_foterm x y = x == y || @@ -25,15 +34,6 @@ module Utils (B : Terms.Blob) = struct | _ -> false ;; - let rec lexicograph f l1 l2 = - match l1, l2 with - | [], [] -> 0 - | x::xs, y::ys -> - let c = f x y in - if c <> 0 then c else lexicograph f xs ys - | [],_ -> ~-1 - | _,[] -> 1 - ;; let rec compare_foterm x y = match x, y with @@ -72,15 +72,15 @@ module Utils (B : Terms.Blob) = struct let eq_unit_clause (id1,_,_,_) (id2,_,_,_) = id1 = id2 let compare_unit_clause (id1,_,_,_) (id2,_,_,_) = Pervasives.compare id1 id2 - let relocate maxvar varlist = + let relocate maxvar varlist subst = List.fold_right (fun i (maxvar, varlist, s) -> maxvar+1, maxvar::varlist, Subst.build_subst i (Terms.Var maxvar) s) - varlist (maxvar+1, [], Subst.id_subst) + varlist (maxvar+1, [], subst) ;; let fresh_unit_clause maxvar (id, lit, varlist, proof) = - let maxvar, varlist, subst = relocate maxvar varlist in + let maxvar, varlist, subst = relocate maxvar varlist Subst.id_subst in let lit = match lit with | Terms.Equation (l,r,ty,o) -> @@ -102,11 +102,6 @@ module Utils (B : Terms.Blob) = struct ;; (* may be moved inside the bag *) - let mk_id = - let id = ref 0 in - fun () -> incr id; !id - ;; - let mk_unit_clause maxvar ty proofterm = let varlist = let rec aux acc = function @@ -118,13 +113,30 @@ module Utils (B : Terms.Blob) = struct in let lit = match ty with - | Terms.Node [ Terms.Leaf eq ; ty; l; r ] when B.is_eq_predicate eq -> + | Terms.Node [ Terms.Leaf eq ; ty; l; r ] when B.eq B.eqP eq -> let o = Order.compare_terms l r in Terms.Equation (l, r, ty, o) | t -> Terms.Predicate t in let proof = Terms.Exact proofterm in - fresh_unit_clause maxvar (mk_id (), lit, varlist, proof) + fresh_unit_clause maxvar (0, lit, varlist, proof) + ;; + + let mk_passive_clause cl = + (Order.compute_unit_clause_weight cl, cl) + ;; + + let mk_passive_goal g = + (Order.compute_unit_clause_weight g, g) + ;; + + let compare_passive_clauses_weight (w1,(id1,_,_,_)) (w2,(id2,_,_,_)) = + if w1 = w2 then id1 - id2 + else w1 - w2 + ;; + + let compare_passive_clauses_age (_,(id1,_,_,_)) (_,(id2,_,_,_)) = + id1 - id2 ;; end