]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/components/acic_procedural/proceduralClassify.ml
made executable again
[helm.git] / helm / software / components / acic_procedural / proceduralClassify.ml
index 489feb4b66aa54385f1e3f102ecdc5381cb1d9c8..6da59eed1cf643ba4d68f4039b2b0d89dfb42642 100644 (file)
@@ -31,18 +31,20 @@ module PEH = ProofEngineHelpers
 
 module H   = ProceduralHelpers
 
-type dependence = I.S.t * bool
+type dependences = (I.S.t * bool) list
 
 type conclusion = (int * int * UM.uri * int) option
 
 (* debugging ****************************************************************)
 
-let string_of_entry (inverse, b) =
-   if I.S.mem 0 inverse then begin if b then "CF" else "C" end else
+let string_of_entry synth (inverse, b) =
+   if I.overlaps synth inverse then begin if b then "CF" else "C" end else
    if I.S.is_empty inverse then "I" else "P"
 
-let to_string (classes, rc) =
-   let linearize = String.concat " " (List.map string_of_entry classes) in
+let to_string synth (classes, rc) =
+   let linearize = 
+      String.concat " " (List.map (string_of_entry synth) classes)
+   in
    match rc with
       | None              -> linearize
       | Some (i, j, _, _) -> Printf.sprintf "%s %u %u" linearize i j
@@ -56,6 +58,12 @@ let out_table b =
    Array.iteri map b;
    prerr_newline ()
 
+(* dummy dependences ********************************************************)
+
+let make l =
+   let map _ = I.S.empty, false in
+   List.rev_map map l
+
 (* classification ***********************************************************)
 
 let classify_conclusion vs = 
@@ -82,7 +90,7 @@ try
    let rc = classify_conclusion vs in
    let map (b, h) (c, v) = 
       let _, argsno = PEH.split_with_whd (c, v) in
-      let isf = argsno > 0 || H.is_sort v in
+      let isf = argsno > 0 (* || H.is_sort v *) in
       let iu = H.is_unsafe h (List.hd vs) in
       (I.get_rels_from_premise h v, I.S.empty, isf && iu) :: b, succ h
    in
@@ -111,3 +119,21 @@ try
    let extract (x, y, z) = y, z in
    List.rev_map extract (List.tl (Array.to_list b)), rc
 with Invalid_argument _ -> failwith "Classify.classify"
+
+(* adjusting the inferrable arguments that do not occur in the goal *********)
+
+let adjust c vs ?goal classes = 
+   let list_xmap2 map l1 l2 = 
+      let rec aux a = function
+         | hd1 :: tl1, hd2 :: tl2 -> aux (map hd1 hd2 :: a) (tl1,tl2)
+        | _, l2                  -> List.rev_append l2 a
+      in
+      List.rev (aux [] (l1, l2))
+   in
+   let map where what (i, b) = 
+      let what = H.cic what in
+      (i, b || not (H.occurs c ~what ~where))
+   in
+   match goal with
+      | None      -> classes
+      | Some goal -> list_xmap2 (map goal) vs classes