X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Fcomponents%2Fng_refiner%2FnCicMetaSubst.ml;h=6deaaf572b7914f9ad3edba29b1a937b4bc1a711;hb=106db6ec639e23ab8af56a1d889b3670fa292d6f;hp=bdd0adfe014f3acba18eab6a1270c55527d012d5;hpb=2007402c996678701798d71124a1a255529061ee;p=helm.git diff --git a/helm/software/components/ng_refiner/nCicMetaSubst.ml b/helm/software/components/ng_refiner/nCicMetaSubst.ml index bdd0adfe0..6deaaf572 100644 --- a/helm/software/components/ng_refiner/nCicMetaSubst.ml +++ b/helm/software/components/ng_refiner/nCicMetaSubst.ml @@ -207,11 +207,18 @@ and restrict metasenv subst i restrictions = ;; let rec flexible_arg context subst = function - | NCic.Meta (i,_) | NCic.Appl (NCic.Meta (i,_) :: _)-> + | NCic.Meta (i,_) -> (try let _,_,t,_ = List.assoc i subst in flexible_arg context subst t with Not_found -> true) + | NCic.Appl (NCic.Meta (i,_) :: args)-> + (try + let _,_,t,_ = List.assoc i subst in + flexible_arg context subst + (NCicReduction.head_beta_reduce ~delta:max_int + (NCic.Appl (t :: args))) + with Not_found -> true) (* this is a cheap whd, it only performs zeta-reduction. * * it works when the **omissis** disambiguation algorithm @@ -454,26 +461,31 @@ let delift ~unify metasenv subst context n l t = raise (MetaSubstFailure msg) ;; -let mk_meta ?(attrs=[]) metasenv context ty = - let tyof = List.map (function `Name s -> `Name ("typeof_"^s) | x -> x) in - let rec mk_meta attrs n metasenv context = function - | `WithType ty -> - let len = List.length context in - let menv_entry = (n, (attrs, context, ty)) in - menv_entry :: metasenv, n, NCic.Meta (n, (0,NCic.Irl len)), ty - | `Sort -> - let ty = NCic.Implicit (`Typeof n) in - mk_meta (tyof attrs) n metasenv [] (`WithType ty) - | `Type -> - let metasenv, _, ty, _ = - mk_meta (tyof attrs) (newmeta ()) metasenv context `Sort in - mk_meta attrs n metasenv context (`WithType ty) - | `Term -> - let metasenv, _, ty, _ = - mk_meta (tyof attrs) (newmeta ()) metasenv context `Type in - mk_meta attrs n metasenv context (`WithType ty) - in - mk_meta attrs (newmeta ()) metasenv context ty +let mk_meta ?(attrs=[]) metasenv context ?with_type kind = + assert(kind <> `IsSort || context = []); + let n = newmeta () in + let ty= match with_type with None-> NCic.Implicit (`Typeof n)| Some x ->x in + let len = List.length context in + let attrs = NCicUntrusted.set_kind kind attrs in + let menv_entry = (n, (attrs, context, ty)) in + menv_entry :: metasenv, n, NCic.Meta (n, (0,NCic.Irl len)), ty +;; + +let extend_meta metasenv n = + try + let attrs,cc,ty = NCicUtils.lookup_meta n metasenv in + (match ty with + | NCic.Implicit (`Typeof _) -> + let mk_meta context kind = + let metasenv, _, ty, _ = mk_meta metasenv context kind in + (n, (attrs, cc, ty)) :: List.filter (fun x,_ -> x <> n) metasenv, ty + in + (match NCicUntrusted.kind_of_meta attrs with + | `IsSort + | `IsType -> mk_meta [] `IsSort + | `IsTerm -> mk_meta cc `IsType) + | ty -> metasenv, ty) + with NCicUtils.Meta_not_found _ -> assert false ;; let saturate ?(delta=0) metasenv subst context ty goal_arity = @@ -481,7 +493,7 @@ let saturate ?(delta=0) metasenv subst context ty goal_arity = let rec aux metasenv = function | NCic.Prod (name,s,t) as ty -> let metasenv1, _, arg,_ = - mk_meta ~attrs:[`Name name] metasenv context (`WithType s) in + mk_meta ~attrs:[`Name name] metasenv context ~with_type:s `IsTerm in let t, metasenv1, args, pno = aux metasenv1 (NCicSubstitution.subst arg t) in