X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Focaml%2Fcic%2FcicUtil.ml;h=ad01110c403f8b178ab91ddb7cdea3953d9b067e;hb=0c6a5aadb1a7746681a8e26fc0b009f847c10557;hp=55a70822ed6a95a9c04a95daebcfa3a4a105487c;hpb=a8f2c7ca6806a563808eba60fadd2e1dbaec49e4;p=helm.git diff --git a/helm/ocaml/cic/cicUtil.ml b/helm/ocaml/cic/cicUtil.ml index 55a70822e..ad01110c4 100644 --- a/helm/ocaml/cic/cicUtil.ml +++ b/helm/ocaml/cic/cicUtil.ml @@ -24,14 +24,42 @@ *) exception Meta_not_found of int +exception Subst_not_found of int + let lookup_meta index metasenv = try List.find (fun (index', _, _) -> index = index') metasenv with Not_found -> raise (Meta_not_found index) +let lookup_subst n subst = + try + List.assoc n subst + with Not_found -> raise (Subst_not_found n) + let exists_meta index = List.exists (fun (index', _, _) -> (index = index')) +(* clean_up_meta take a substitution, a metasenv a meta_inex and a local +context l and clean up l with respect to the hidden hipothesis in the +canonical context *) + +let clean_up_local_context subst metasenv n l = + let cc = + (try + let (cc,_) = lookup_subst n subst in cc + with Subst_not_found _ -> + try + let (_,cc,_) = lookup_meta n metasenv in cc + with Meta_not_found _ -> assert false) in + (try + List.map2 + (fun t1 t2 -> + match t1,t2 with + None , _ -> None + | _ , t -> t) cc l + with + Invalid_argument _ -> assert false) + let is_closed = let module C = Cic in let rec is_closed k =