X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Fcomponents%2Fng_paramodulation%2Fsuperposition.ml;h=61d6c0589f3ab9952e670ead382f71633ea00ef8;hb=1c9b8f3ba2c86446d44160ae494bc85624bc5eaf;hp=891c8dcacafaec6553e6884983448838fab7da1e;hpb=6f35dd77922431b667f7eb4669ab3fbb6092c343;p=helm.git diff --git a/helm/software/components/ng_paramodulation/superposition.ml b/helm/software/components/ng_paramodulation/superposition.ml index 891c8dcac..61d6c0589 100644 --- a/helm/software/components/ng_paramodulation/superposition.ml +++ b/helm/software/components/ng_paramodulation/superposition.ml @@ -178,12 +178,13 @@ module Superposition (B : Terms.Blob) = ;; (* move away *) - let is_identity_clause = function + let is_identity_clause ~unify = function | _, Terms.Equation (_,_,_,Terms.Eq), _, _ -> true - | _, Terms.Equation (l,r,_,_), vl, proof -> + | _, Terms.Equation (l,r,_,_), vl, proof when unify -> (try ignore(Unif.unification vl [] l r); true with FoUnif.UnificationFailure _ -> false) | _, Terms.Predicate _, _, _ -> assert false + | _ -> false ;; let build_new_clause bag maxvar filter rule t subst vl id id2 pos dir = @@ -205,46 +206,68 @@ module Superposition (B : Terms.Blob) = bag, maxvar, res ;; + + let rewrite_eq ~unify l r ty vl table = + let retrieve = if unify then IDX.DT.retrieve_unifiables + else IDX.DT.retrieve_generalizations in + let lcands = retrieve table l in + let rcands = retrieve table r in + let f b c = + let id, dir, l, r, vl = + match c with + | (d, (id,Terms.Equation (l,r,ty,_),vl,_))-> id, d, l, r, vl + |_ -> assert false + in + let reverse = (dir = Terms.Left2Right) = b in + let l, r, proof_rewrite_dir = if reverse then l,r,Terms.Left2Right + else r,l, Terms.Right2Left in + (id,proof_rewrite_dir,Terms.Node [ Terms.Leaf B.eqP; ty; l; r ], vl) + in + let cands1 = List.map (f true) (IDX.ClauseSet.elements lcands) in + let cands2 = List.map (f false) (IDX.ClauseSet.elements rcands) in + let t = Terms.Node [ Terms.Leaf B.eqP; ty; l; r ] in + let locked_vars = if unify then [] else vl in + let rec aux = function + | [] -> None + | (id2,dir,c,vl1)::tl -> + try + let subst,vl1 = Unif.unification (vl@vl1) locked_vars c t in + Some (id2, dir, subst) + with FoUnif.UnificationFailure _ -> aux tl + in + aux (cands1 @ cands2) + ;; + let is_subsumed ~unify bag maxvar (id, lit, vl, _) table = match lit with | Terms.Predicate _ -> assert false | Terms.Equation (l,r,ty,_) -> - let retrieve = if unify then IDX.DT.retrieve_unifiables - else IDX.DT.retrieve_generalizations in - let lcands = retrieve table l in - let rcands = retrieve table r in - let f b c = - let id, dir, l, r, vl = - match c with - | (d, (id,Terms.Equation (l,r,ty,_),vl,_))-> id, d, l, r, vl - |_ -> assert false - in - let reverse = (dir = Terms.Left2Right) = b in - let l, r, proof_rewrite_dir = if reverse then l,r,Terms.Left2Right - else r,l, Terms.Right2Left in - (id,proof_rewrite_dir,Terms.Node [ Terms.Leaf B.eqP; ty; l; r ], vl) - in - let cands1 = List.map (f true) (IDX.ClauseSet.elements lcands) in - let cands2 = List.map (f false) (IDX.ClauseSet.elements rcands) in - let t = Terms.Node [ Terms.Leaf B.eqP; ty; l; r ] in - let locked_vars = if unify then [] else vl in - let rec aux = function - | [] -> None - | (id2,dir,c,vl1)::tl -> - try - let subst,vl1 = Unif.unification (vl@vl1) locked_vars c t in - let id_t = Terms.Node [ Terms.Leaf B.eqP; ty; r; r ] in - build_new_clause bag maxvar (fun _ -> true) - Terms.Superposition id_t subst [] id id2 [2] dir - with FoUnif.UnificationFailure _ -> aux tl - in - aux (cands1 @ cands2) + match rewrite_eq ~unify l r ty vl table with + | None -> None + | Some (id2, dir, subst) -> + let id_t = Terms.Node [ Terms.Leaf B.eqP; ty; r; r ] in + build_new_clause bag maxvar (fun _ -> true) + Terms.Superposition id_t subst [] id id2 [2] dir ;; +(* + let rec deeply_subsumed ~unify bag maxvar (id, lit, vl, _) table = + match lit with + | Terms.Predicate _ -> assert false + | Terms.Equation (l,r,ty,_) -> + (match is_subsumed ~unify bag maxvar (id, lit, vl, _) table with + | Some((bag,maxvar),c) -> Some((bag,maxvar),c) + | None -> + match l,r with -> + Var i, _ -> + ;; +*) + + (* demodulate and check for subsumption *) let simplify table maxvar bag clause = let bag, clause = demodulate bag clause table in - if is_identity_clause clause then None + if is_identity_clause ~unify:false clause then None else match is_subsumed ~unify:false bag maxvar clause table with | None -> Some (bag, clause) @@ -350,7 +373,7 @@ module Superposition (B : Terms.Blob) = (* this is like simplify but raises Success *) let simplify_goal maxvar table bag g_actives clause = let bag, clause = demodulate bag clause table in - if (is_identity_clause clause) + if (is_identity_clause ~unify:true clause) then raise (Success (bag, maxvar, clause)) else match is_subsumed ~unify:true bag maxvar clause table with | None ->