X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Fcomponents%2Facic_procedural%2FproceduralClassify.ml;h=53c363a428372c447284c5c3f5654dbc2cd69f4b;hb=68dbcd02022874a025a9444aa1125b0458816fbb;hp=6c1e482c2ff4d86aee5ee01cb988e50ece825630;hpb=ac1f50b898154dc3d74aa8fa2fff212a7d3a235c;p=helm.git diff --git a/helm/software/components/acic_procedural/proceduralClassify.ml b/helm/software/components/acic_procedural/proceduralClassify.ml index 6c1e482c2..53c363a42 100644 --- a/helm/software/components/acic_procedural/proceduralClassify.ml +++ b/helm/software/components/acic_procedural/proceduralClassify.ml @@ -23,14 +23,17 @@ * http://cs.unibo.it/helm/. *) +module UM = UriManager module C = Cic module D = Deannotate module I = CicInspect module PEH = ProofEngineHelpers -type dependence = I.S.t * bool +module H = ProceduralHelpers -type conclusion = (int * int) option +type dependences = (I.S.t * bool) list + +type conclusion = (int * int * UM.uri * int) option (* debugging ****************************************************************) @@ -41,8 +44,8 @@ let string_of_entry (inverse, b) = let to_string (classes, rc) = let linearize = String.concat " " (List.map string_of_entry classes) in match rc with - | None -> linearize - | Some (i, j) -> Printf.sprintf "%s %u %u" linearize i j + | None -> linearize + | Some (i, j, _, _) -> Printf.sprintf "%s %u %u" linearize i j let out_table b = let map i (_, inverse) = @@ -52,12 +55,14 @@ let out_table b = in Array.iteri map b; prerr_newline () - -(****************************************************************************) -let identity x = x +(* dummy dependences ********************************************************) + +let make l = + let map _ = I.S.empty, false in + List.rev_map map l -let fst3 (x, _, _) = x +(* classification ***********************************************************) let classify_conclusion vs = let rec get_argsno = function @@ -69,11 +74,11 @@ let classify_conclusion vs = let inside i = i > 1 && i <= List.length vs in match vs with | v0 :: v1 :: _ -> - let hd0, argsno0 = get_argsno v0 in - let hd1, argsno1 = get_argsno v1 in + let hd0, a0 = get_argsno v0 in + let hd1, a1 = get_argsno v1 in begin match hd0, hd1 with - | C.Rel i, C.MutInd _ when inside i -> Some (i, argsno0) - | _ -> None + | C.Rel i, C.MutInd (u, n, _) when inside i -> Some (i, a0, u, n) + | _ -> None end | _ -> None @@ -83,12 +88,14 @@ try let rc = classify_conclusion vs in let map (b, h) (c, v) = let _, argsno = PEH.split_with_whd (c, v) in - (I.get_rels_from_premise h v, I.S.empty, argsno > 0) :: b, succ h + 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 let l, h = List.fold_left map ([], 0) vs in let b = Array.of_list (List.rev l) in let mk_closure b h = - let map j = if j < h then I.S.union (fst3 b.(j)) else identity in + let map j = if j < h then I.S.union (H.fst3 b.(j)) else H.identity in for i = pred h downto 0 do let direct, unused, fa = b.(i) in b.(i) <- I.S.fold map direct direct, unused, fa @@ -110,3 +117,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