X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Fcomponents%2Facic_procedural%2FproceduralClassify.ml;h=4f9f99fcee76117056a100bd8f1a13dfb9fcfd24;hb=b4027b84fae91e907b6874060b91d89b6a1ad780;hp=d21c14601f5108502d27de3c34f1511e3b89c3ab;hpb=acc9067d3263ffced81c52539f918d47d418d5c7;p=helm.git diff --git a/helm/software/components/acic_procedural/proceduralClassify.ml b/helm/software/components/acic_procedural/proceduralClassify.ml index d21c14601..4f9f99fce 100644 --- a/helm/software/components/acic_procedural/proceduralClassify.ml +++ b/helm/software/components/acic_procedural/proceduralClassify.ml @@ -28,12 +28,16 @@ module D = Deannotate module I = CicInspect module PEH = ProofEngineHelpers +module H = ProceduralHelpers + +type dependence = I.S.t * bool + type conclusion = (int * int) option (* debugging ****************************************************************) -let string_of_entry inverse = - if I.S.mem 0 inverse then "C" else +let string_of_entry (inverse, b) = + if I.S.mem 0 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) = @@ -50,28 +54,43 @@ let out_table b = in Array.iteri map b; prerr_newline () - -(****************************************************************************) - -let id x = x -let classify_conclusion = function - | _, C.Rel i -> Some (i, 0) - | _, C.Appl (C.Rel i :: tl) -> Some (i, List.length tl) - | _ -> None +(* classification ***********************************************************) +let classify_conclusion vs = + let rec get_argsno = function + | c, C.Appl (t :: vs) -> + let hd, argsno = get_argsno (c, t) in + hd, argsno + List.length vs + | _, t -> t, 0 + in + 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 + begin match hd0, hd1 with + | C.Rel i, C.MutInd _ when inside i -> Some (i, argsno0) + | _ -> None + end + | _ -> None + let classify c t = try let vs, h = PEH.split_with_whd (c, t) in - let rc = classify_conclusion (List.hd vs) in - let map (b, h) (_, v) = (I.get_rels_from_premise h v, I.S.empty) :: b, succ h in + let rc = classify_conclusion vs in + let map (b, h) (c, v) = + let _, argsno = PEH.split_with_whd (c, v) in + let iu = H.is_unsafe h (List.hd vs) in + (I.get_rels_from_premise h v, I.S.empty, argsno > 0 && 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 (fst b.(j)) else id 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 = b.(i) in - b.(i) <- I.S.fold map direct direct, unused + let direct, unused, fa = b.(i) in + b.(i) <- I.S.fold map direct direct, unused, fa done; b in let b = mk_closure b h in @@ -79,13 +98,14 @@ try if I.S.is_empty direct then () else let j = I.S.choose direct in if j < h then - let unused, inverse = b.(j) in - b.(j) <- unused, I.S.add i inverse + let unused, inverse, fa = b.(j) in + b.(j) <- unused, I.S.add i inverse, fa else (); mk_inverse i (I.S.remove j direct) in - let map i (direct, _) = mk_inverse i direct in + let map i (direct, _, _) = mk_inverse i direct in Array.iteri map b; (* out_table b; *) - List.rev_map snd (List.tl (Array.to_list b)), rc + 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"