X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;ds=sidebyside;f=helm%2Fsoftware%2Fcomponents%2Fng_refiner%2FnCicUnifHint.ml;h=7961be96a80a234afed831403bdfb11cb7586de1;hb=c75bfa659bee91e9b12a2a4f856673b94a29d2db;hp=c797b2eee6d752ca6a5e868384d0c26ba3465663;hpb=33d0fc706f337453ceb6967dd4fcdc5fe55e65de;p=helm.git diff --git a/helm/software/components/ng_refiner/nCicUnifHint.ml b/helm/software/components/ng_refiner/nCicUnifHint.ml index c797b2eee..7961be96a 100644 --- a/helm/software/components/ng_refiner/nCicUnifHint.ml +++ b/helm/software/components/ng_refiner/nCicUnifHint.ml @@ -57,16 +57,56 @@ let index_hint hdb context t1 t2 = let empty_db = DB.empty ;; let db () = - let _,_,_,x,_,_ = NCicEnvironment.get_checked_def - (NReference.reference_of_string "cic:/matita/tests/pullback/xxx.def(0)") + let combine f cmp l1 l2 = + List.flatten + (List.map + (fun u1 -> + HExtlib.filter_map + (fun u2 -> if cmp u1 u2 then None else Some (f u1 u2)) l2) + l1) in - let rec decontextualize ctx = function - | NCic.Prod (n,s,t) -> decontextualize ((n,NCic.Decl s)::ctx) t - | t -> ctx, t + let mk_hint (u1,_,_) (u2,_,_) = + let l = OCic2NCic.convert_obj u1 + (fst (CicEnvironment.get_obj CicUniv.oblivion_ugraph u1)) in + let r = OCic2NCic.convert_obj u2 + (fst (CicEnvironment.get_obj CicUniv.oblivion_ugraph u2)) in + match List.hd l,List.hd r with + | (_,_,_,_,NCic.Constant (_,_,Some l,_,_)), + (_,_,_,_,NCic.Constant (_,_,Some r,_,_)) -> + let rec aux ctx t1 t2 = + match t1, t2 with + | NCic.Lambda (n1,s1,b1), NCic.Lambda(_,s2,b2) -> + if NCicReduction.are_convertible ~subst:[] ~metasenv:[] ctx s1 s2 + then aux ((n1, NCic.Decl s1) :: ctx) b1 b2 + else None + | b1,b2 -> + if NCicReduction.are_convertible ~subst:[] ~metasenv:[] ctx b1 b2 + then begin +(* + prerr_endline ("hint: " ^ NCicPp.ppterm ~metasenv:[] ~subst:[] + ~context:ctx b1 ^ " === " ^ NCicPp.ppterm ~metasenv:[] + ~subst:[] ~context:ctx b2); +*) + Some (ctx,b1,b2) + end else None + in + aux [] l r + | _ -> None + in + let hints = + List.fold_left + (fun acc (_,_,l) -> + acc @ + if List.length l > 1 then + combine mk_hint (fun (u1,_,_) (u2,_,_) -> UriManager.eq u1 u2) l l + else []) + [] (CoercDb.to_list ()) in - match (decontextualize [] x) with - | ctx, NCic.Appl [_;_;a;b] -> index_hint empty_db ctx a b - | _ -> assert false + List.fold_left + (fun db -> function + |None -> db + | Some (ctx,b1,b2) -> index_hint db ctx b1 b2) + empty_db hints ;;