diff options
author | Pierre-Marie Pédrot <pierre-marie.pedrot@inria.fr> | 2016-11-20 01:35:54 +0100 |
---|---|---|
committer | Pierre-Marie Pédrot <pierre-marie.pedrot@inria.fr> | 2017-02-14 17:30:26 +0100 |
commit | e6a8ab0f428c26fff2bd7e636126974f167101bf (patch) | |
tree | b1be917ecc68504649aa9583aad77475e6f13157 /pretyping | |
parent | c72bf7330bb32970616be4dddc7571f3b91c1562 (diff) |
Tactic_matching API using EConstr.
Diffstat (limited to 'pretyping')
-rw-r--r-- | pretyping/constr_matching.ml | 11 | ||||
-rw-r--r-- | pretyping/constr_matching.mli | 2 | ||||
-rw-r--r-- | pretyping/detyping.ml | 1 | ||||
-rw-r--r-- | pretyping/patternops.ml | 4 | ||||
-rw-r--r-- | pretyping/pretyping.ml | 2 |
5 files changed, 11 insertions, 9 deletions
diff --git a/pretyping/constr_matching.ml b/pretyping/constr_matching.ml index 4d2500ccd..06daa5116 100644 --- a/pretyping/constr_matching.ml +++ b/pretyping/constr_matching.ml @@ -16,6 +16,7 @@ open Nameops open Termops open Reductionops open Term +open EConstr open Vars open Pattern open Patternops @@ -61,11 +62,11 @@ let constrain sigma n (ids, m) (names, terms as subst) = let open EConstr in try let (ids', m') = Id.Map.find n terms in - if List.equal Id.equal ids ids' && eq_constr sigma m (EConstr.of_constr m') then subst + if List.equal Id.equal ids ids' && eq_constr sigma m m' then subst else raise PatternMatchingFailure with Not_found -> let () = if Id.Map.mem n names then warn_meta_collision n in - (names, Id.Map.add n (ids, EConstr.Unsafe.to_constr m) terms) + (names, Id.Map.add n (ids, m) terms) let add_binders na1 na2 binding_vars (names, terms as subst) = match na1, na2 with @@ -152,7 +153,6 @@ let merge_binding sigma allow_bound_rels ctx n cT subst = | [] -> (* Optimization *) ([], cT) | _ -> - let open EConstr in let frels = free_rels sigma cT in if allow_bound_rels then let vars = extract_bound_vars frels ctx in @@ -344,7 +344,7 @@ type matching_result = { m_sub : bound_ident_map * patvar_map; m_ctx : constr; } -let mkresult s c n = IStream.Cons ( { m_sub=s; m_ctx=EConstr.Unsafe.to_constr c; } , (IStream.thunk n) ) +let mkresult s c n = IStream.Cons ( { m_sub=s; m_ctx=c; } , (IStream.thunk n) ) let isPMeta = function PMeta _ -> true | _ -> false @@ -362,10 +362,9 @@ let matches_head env sigma pat c = (* Tells if it is an authorized occurrence and if the instance is closed *) let authorized_occ env sigma partial_app closed pat c mk_ctx = - let open EConstr in try let subst = matches_core_closed env sigma false partial_app pat c in - if closed && Id.Map.exists (fun _ c -> not (closed0 c)) (snd subst) + if closed && Id.Map.exists (fun _ c -> not (closed0 sigma c)) (snd subst) then (fun next -> next ()) else (fun next -> mkresult subst (mk_ctx (mkMeta special_meta)) next) with PatternMatchingFailure -> (fun next -> next ()) diff --git a/pretyping/constr_matching.mli b/pretyping/constr_matching.mli index 32bb48c93..4734c90a8 100644 --- a/pretyping/constr_matching.mli +++ b/pretyping/constr_matching.mli @@ -64,7 +64,7 @@ val matches_conv : env -> Evd.evar_map -> constr_pattern -> constr -> patvar_map (whose hole is denoted here with [special_meta]) *) type matching_result = { m_sub : bound_ident_map * patvar_map; - m_ctx : Constr.t } + m_ctx : EConstr.t } (** [match_subterm n pat c] returns the substitution and the context corresponding to each **closed** subterm of [c] matching [pat]. *) diff --git a/pretyping/detyping.ml b/pretyping/detyping.ml index ec8945e85..c0611dcec 100644 --- a/pretyping/detyping.ml +++ b/pretyping/detyping.ml @@ -745,6 +745,7 @@ let detype_closed_glob ?lax isgoal avoid env sigma t = with Not_found -> try (* assumes [detype] does not raise [Not_found] exceptions *) let (b,c) = Id.Map.find id cl.typed in + let c = EConstr.Unsafe.to_constr c in (* spiwack: I'm not sure it is the right thing to do, but I'm computing the detyping environment like [Printer.pr_constr_under_binders_env] does. *) diff --git a/pretyping/patternops.ml b/pretyping/patternops.ml index ffd6e73fa..26e23be23 100644 --- a/pretyping/patternops.ml +++ b/pretyping/patternops.ml @@ -224,6 +224,8 @@ let error_instantiate_pattern id l = ++ strbrk " which " ++ str is ++ strbrk " not bound in the pattern.") let instantiate_pattern env sigma lvar c = + let open EConstr in + let open Vars in let rec aux vars = function | PVar id as x -> (try @@ -235,7 +237,7 @@ let instantiate_pattern env sigma lvar c = ctx in let c = substl inst c in - pattern_of_constr env sigma (EConstr.of_constr c) + pattern_of_constr env sigma c with Not_found (* List.index failed *) -> let vars = List.map_filter (function Name id -> Some id | _ -> None) vars in diff --git a/pretyping/pretyping.ml b/pretyping/pretyping.ml index 11d50926f..c792bf2ca 100644 --- a/pretyping/pretyping.ml +++ b/pretyping/pretyping.ml @@ -445,7 +445,7 @@ let pretype_id pretype k0 loc env evdref lvar id = try let (ids,c) = Id.Map.find id lvar.ltac_constrs in let subst = List.map (invert_ltac_bound_name lvar env id) ids in - let c = substl subst (EConstr.of_constr c) in + let c = substl subst c in { uj_val = c; uj_type = protected_get_type_of env sigma c } with Not_found -> try let {closure;term} = Id.Map.find id lvar.ltac_uconstrs in |