]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/components/tactics/paramodulation/saturation.ml
...
[helm.git] / helm / software / components / tactics / paramodulation / saturation.ml
index 7ddfd86fcb61cc8cbb8d27c3173ce5753ed8b577..1d5d9783fb3bdf4a7df250f67f5b3691e6990183 100644 (file)
@@ -444,15 +444,15 @@ let forward_simplify bag eq_uri env current (active_list, active_table) =
       Indexing.demodulation_equality bag eq_uri !maxmeta env table current
     in
     maxmeta := newmeta;
-    if Equality.is_identity env newcurrent then None else Some newcurrent
+    if Equality.is_weak_identity newcurrent then None else Some newcurrent
   in
-  let rec demod current =
+  let demod current =
     if Utils.debug_metas then
       ignore (Indexing.check_target bag context current "demod0");
     let res = demodulate active_table current in
-      if Utils.debug_metas then
-        ignore ((function None -> () | Some x -> 
-                   ignore (Indexing.check_target bag context x "demod1");()) res);
+    if Utils.debug_metas then
+      ignore ((function None -> () | Some x -> 
+      ignore (Indexing.check_target bag context x "demod1");()) res);
     res
   in 
   let res = demod current in
@@ -489,7 +489,7 @@ let forward_simplify_new bag eq_uri env new_pos active =
   let new_pos_set =
     List.fold_left
       (fun s e ->
-         if not (Equality.is_identity env e) then
+         if not (Equality.is_weak_identity e) then
            EqualitySet.add e s
          else s)
       EqualitySet.empty new_pos
@@ -556,7 +556,7 @@ let backward_simplify_active
       (fun eq ((res,pruned), tbl) ->
          if List.mem eq res then
            (res, (id_of_eq eq)::pruned),tbl 
-         else if (Equality.is_identity env eq) || (find eq res) then (
+         else if (Equality.is_weak_identity eq) || (find eq res) then (
            (res, (id_of_eq eq)::pruned),tbl
          ) 
          else
@@ -564,7 +564,7 @@ let backward_simplify_active
       active_list (([],pruned), Indexing.empty),
     List.fold_right
       (fun eq p ->
-         if (Equality.is_identity env eq) then p
+         if (Equality.is_weak_identity eq) then p
          else eq::p)
       newa []
   in
@@ -746,7 +746,9 @@ let rec simpl bag eq_uri env e others others_simpl =
          if Equality.is_weak_identity e then t else Indexing.index t e) 
       Indexing.empty active
   in
-  let res = forward_simplify bag eq_uri env e (active, tbl) in
+  let res = 
+      forward_simplify bag eq_uri env e (active, tbl) 
+  in
     match others with
       | hd::tl -> (
           match res with
@@ -846,7 +848,7 @@ let check_if_goal_is_identity env = function
     (let _,context,_ = env in
     try 
      let s,m,_ = 
-       Inference.unification m m context left right CicUniv.empty_ugraph 
+       Founif.unification m m context left right CicUniv.empty_ugraph 
      in
       let reflproof = Equality.Exact (Equality.refl_proof uri eq_ty left) in
       let m = Subst.apply_subst_metasenv s m in
@@ -1077,6 +1079,7 @@ let given_clause
           ParamodulationSuccess p
       | None -> 
 *)
+
                   let active = 
                       let al, tbl = active in
                       al @ [current], Indexing.index tbl current
@@ -1084,6 +1087,7 @@ let given_clause
                   let goals = 
                     infer_goal_set_with_current bag env current goals active 
                   in
+
                   (* FORWARD AND BACKWARD SIMPLIFICATION *)
 (*                   prerr_endline "fwd/back simpl"; *)
                   let rec simplify new' active passive =
@@ -1103,6 +1107,7 @@ let given_clause
                   let active, passive, new' = 
                     simplify new' active passive
                   in
+
 (*                   prerr_endline "simpl goal with new"; *)
                   let goals = 
                     let a,b,_ = build_table new' in
@@ -1133,7 +1138,7 @@ let rec saturate_equations bag eq_uri env goal accept_fun passive active =
                              (Equality.string_of_equality ~env current)));
         let new' = infer bag eq_uri env current active in
         let active =
-          if Equality.is_identity env current then active
+          if Equality.is_weak_identity (*env*) current then active
           else
             let al, tbl = active in
             al @ [current], Indexing.index tbl current
@@ -1244,31 +1249,33 @@ let build_proof
           eq_uri goalproof initial type_of_goal side_effects
           context proof_menv
       in
-(*       prerr_endline ("PROOF: " ^ CicPp.pp goal_proof names); *)
+      (* prerr_endline ("PROOF: " ^ CicPp.pp goal_proof names); *)
       let goal_proof = Subst.apply_subst subsumption_subst goal_proof in
       let metas_still_open_in_proof = Utils.metas_of_term goal_proof in
-(*prerr_endline (CicPp.pp goal_proof names);*)
-      (* ?? *)
+      (* prerr_endline (CicPp.pp goal_proof names); *)
       let goal_proof = (* Subst.apply_subst subsumption_subst *) goal_proof in
       let side_effects_t = 
         List.map (Subst.apply_subst subsumption_subst) side_effects_t
       in
       (* replacing fake mets with real ones *)
-(*       prerr_endline "replacing metas..."; *)
+      (* prerr_endline "replacing metas..."; *)
       let irl=CicMkImplicit.identity_relocation_list_for_metavariable context in
       let goal_proof_menv, what, with_what,free_meta = 
         List.fold_left 
           (fun (acc1,acc2,acc3,uniq) (i,_,ty) -> 
              match uniq with
                | Some m -> 
-(*                    acc1, (Cic.Meta(i,[]))::acc2, m::acc3, uniq *)
-                   (i,context,ty)::acc1, (Cic.Meta(i,[]))::acc2, (Cic.Meta(i,irl))::acc3, uniq
+(*                     acc1, (Cic.Meta(i,[]))::acc2, m::acc3, uniq  *)
+                   (i,context,ty)::acc1, (Cic.Meta(i,[]))::acc2,
+                     (Cic.Meta(i,irl))::acc3, uniq
                | None ->
                    [i,context,ty], (Cic.Meta(i,[]))::acc2, 
                    (Cic.Meta(i,irl)) ::acc3,Some (Cic.Meta(i,irl))) 
           ([],[],[],None) 
           (List.filter 
-           (fun (i,_,_) -> List.mem i metas_still_open_in_proof) 
+           (fun (i,_,_) -> 
+             List.mem i metas_still_open_in_proof
+             (*&& not(List.mem i metas_still_open_in_goal)*)) 
            proof_menv)
       in
       let replace where = 
@@ -1288,8 +1295,9 @@ let build_proof
           (ProofEngineHelpers.compare_metasenvs 
             ~oldmetasenv:metasenv ~newmetasenv:goal_proof_menv)
       in
-(* prerr_endline ("freemetas: " ^ String.concat "," (List.map string_of_int
- * free_metas) ); *)
+      (* prerr_endline 
+       *   ("freemetas: " ^ 
+       *   String.concat "," (List.map string_of_int free_metas) ); *)
       (* check/refine/... build the new proof *)
       let replaced_goal = 
         ProofEngineReduction.replace
@@ -1335,13 +1343,20 @@ let build_proof
             prerr_endline "THE PROOF DOES NOT TYPECHECK!";
             raise exn
       in
+
+      let metas_of_proof = Utils.metas_of_term goal_proof in
+
       let proof, real_metasenv = 
         ProofEngineHelpers.subst_meta_and_metasenv_in_proof
           proof goalno (CicMetaSubst.apply_subst final_subst) real_menv
       in
       let open_goals = 
+        HExtlib.list_uniq (List.sort Pervasives.compare metas_of_proof) 
+      in
+(*
         match free_meta with Some(Cic.Meta(m,_)) when m<>goalno ->[m] | _ ->[] 
       in
+*)
 (*
       Printf.eprintf 
         "GOALS APERTI: %s\nMETASENV PRIMA:\n%s\nMETASENV DOPO:\n%s\n" 
@@ -1705,7 +1720,7 @@ let superposition_tac ~target ~table ~subterms_only ~demod_table status =
 
 let get_stats () = "" 
 (*
-  <:show<Saturation.>> ^ Indexing.get_stats () ^ Inference.get_stats () ^
+  <:show<Saturation.>> ^ Indexing.get_stats () ^ Founif.get_stats () ^
   Equality.get_stats ()
 ;;
 *)