]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/components/tactics/paramodulation/indexing.ml
added applyS
[helm.git] / helm / software / components / tactics / paramodulation / indexing.ml
index 524c06eff409542d664256094fc6977bff31d507..925aab6e05d3663ba3d01eabca3cf11e43b16ac8 100644 (file)
@@ -181,8 +181,17 @@ let check_target context target msg =
 let get_candidates ?env mode tree term =
   let s = 
     match mode with
-    | Matching -> Index.retrieve_generalizations tree term
-    | Unification -> Index.retrieve_unifiables tree term
+    | Matching -> 
+        let _ = <:start<retrieve_generalizations>> in
+        <:stop<retrieve_generalizations
+        Index.retrieve_generalizations tree term
+        >>
+    | Unification -> 
+        let _ = <:start<retrieve_unifiables>> in
+        <:stop<retrieve_unifiables
+        Index.retrieve_unifiables tree term
+        >>
+        
   in
   Index.PosEqSet.elements s
 ;;
@@ -386,7 +395,7 @@ let subsumption_aux use_unification env table target =
         find_all_matches ~unif_fun
           metasenv context ugraph 0 left ty leftc
   in
-  let rec ok what = function
+  let rec ok what leftorright = function
     | [] -> None
     | (_, subst, menv, ug, ((pos,equation),_))::tl ->
         let _, _, (_, l, r, o), m,_ = Equality.open_equality equation in
@@ -398,13 +407,13 @@ let subsumption_aux use_unification env table target =
             unif_fun metasenv m context what' other' ugraph
           in
           (match Subst.merge_subst_if_possible subst subst' with
-          | None -> ok what tl
-          | Some s -> Some (s, equation))
+          | None -> ok what leftorright tl
+          | Some s -> Some (s, equation, leftorright <> pos ))
         with 
         | Inference.MatchingFailure 
-        | CicUnification.UnificationFailure _ -> ok what tl
+        | CicUnification.UnificationFailure _ -> ok what leftorright tl
   in
-  match ok right leftr with
+  match ok right Utils.Left  leftr with
   | Some _ as res -> res
   | None -> 
       let rightr =
@@ -415,7 +424,7 @@ let subsumption_aux use_unification env table target =
                 find_all_matches ~unif_fun
                   metasenv context ugraph 0 right ty rightc
       in
-        ok left rightr
+        ok left Utils.Right rightr 
 ;;
 
 let subsumption x y z =
@@ -574,7 +583,7 @@ let rec demodulation_equality ?from newmeta env table sign target =
       let name = C.Name "x" in
       let bo' =
         let l, r = if is_left then t, S.lift 1 right else S.lift 1 left, t in
-          C.Appl [C.MutInd (LibraryObjects.eq_URI (), 0, []);
+          C.Appl [C.MutInd (Utils.eq_URI (), 0, []);
                   S.lift 1 eq_ty; l; r]
       in
       if sign = Utils.Positive then
@@ -719,6 +728,7 @@ let rec betaexpand_term
   let res, lifted_term = 
     match term with
     | C.Meta (i, l) ->
+        let l = [] in
         let l', lifted_l =
           List.fold_right
             (fun arg (res, lifted_tl) ->
@@ -891,7 +901,7 @@ let superposition_right
       let bo'' =
         let l, r =
           if ordering = U.Gt then bo, S.lift 1 right else S.lift 1 left, bo in
-        C.Appl [C.MutInd (LibraryObjects.eq_URI (), 0, []);
+        C.Appl [C.MutInd (Utils.eq_URI (), 0, []);
                 S.lift 1 eq_ty; l; r]
       in
       bo',
@@ -1048,11 +1058,23 @@ let superposition_left (metasenv, context, ugraph) table goal =
     Utils.compare_weights ~normalize:true
       (Utils.weight_of_term l) (Utils.weight_of_term r)
   in
-  let big,small,possmall = 
-    match c with Utils.Gt -> l,r,Utils.Right | _ -> r,l,Utils.Left
-  in
-  let expansions, _ = betaexpand_term menv context ugraph table 0 big in
-  List.map (build_newgoal context goal possmall Equality.SuperpositionLeft) expansions
+  
+  if c = Utils.Incomparable then
+    let expansionsl, _ = betaexpand_term menv context ugraph table 0 l in
+    let expansionsr, _ = betaexpand_term menv context ugraph table 0 r in
+    prerr_endline "ZZZ";
+    prerr_endline (string_of_int (List.length expansionsl));
+    prerr_endline (string_of_int (List.length expansionsr));
+    List.map (build_newgoal context goal Utils.Right Equality.SuperpositionLeft) expansionsl
+    @
+    List.map (build_newgoal context goal Utils.Left Equality.SuperpositionLeft) expansionsr
+
+  else
+    let big,small,possmall = 
+      match c with Utils.Gt -> l,r,Utils.Right | _ -> r,l,Utils.Left
+    in
+    let expansions, _ = betaexpand_term menv context ugraph table 0 big in
+    List.map (build_newgoal context goal possmall Equality.SuperpositionLeft) expansions
 ;;
 
 (** demodulation, when the target is a goal *)