diff options
| -rw-r--r-- | pretyping/matching.ml | 4 | ||||
| -rw-r--r-- | pretyping/matching.mli | 9 |
2 files changed, 8 insertions, 5 deletions
diff --git a/pretyping/matching.ml b/pretyping/matching.ml index 645684a869..237ec0db82 100644 --- a/pretyping/matching.ml +++ b/pretyping/matching.ml @@ -242,6 +242,10 @@ and try_sub_match nocc pat lc = | NextOccurrence nocc -> try_sub_match_rec nocc pat (lacc@[c]) tl) in try_sub_match_rec nocc pat [] lc +let match_subterm nocc pat c = + try sub_match nocc pat c + with NextOccurrence _ -> raise PatternMatchingFailure + let is_matching pat n = try let _ = matches pat n in true with PatternMatchingFailure -> false diff --git a/pretyping/matching.mli b/pretyping/matching.mli index 886d87ae09..2b0b8f2404 100644 --- a/pretyping/matching.mli +++ b/pretyping/matching.mli @@ -39,11 +39,10 @@ val is_matching : constr_pattern -> constr -> bool val matches_conv :env -> Evd.evar_map -> constr_pattern -> constr -> patvar_map -(* To skip to the next occurrence *) -exception NextOccurrence of int - -(* Tries to match a _closed_ subterm of [c] with [pat] *) -val sub_match : int -> constr_pattern -> constr -> patvar_map * constr +(* [match_subterm n pat c] returns the substitution and the context + corresponding to the [n+1]th _closed_ subterm of [c] matching [pat]; + It raises PatternMatchingFailure if no such matching exists *) +val match_subterm : int -> constr_pattern -> constr -> patvar_map * constr (* [is_matching_conv env sigma pat c] tells if [c] matches against [pat] up to conversion for constants in patterns *) |
