Debian Codegraph @

pretyping/constr_matching.mli

raw symbols SCIP
1 (************************************************************************)
2 (* * The Rocq Prover / The Rocq Development Team *)
3 (* v * Copyright INRIA, CNRS and contributors *)
4 (* <O___,, * (see version control and CREDITS file for authors & dates) *)
5 (* \VV/ **************************************************************)
6 (* // * This file is distributed under the terms of the *)
7 (* * GNU Lesser General Public License Version 2.1 *)
8 (* * (see LICENSE file for the text of the license) *)
9 (************************************************************************)
10
11 (** This module implements pattern-matching on terms *)
12
13 open Names
14 open Constr
15 open EConstr
16 open Environ
17 open Pattern
18 open Ltac_pretype
19
20 type binding_bound_vars = Id.Set.t
21
22 (** [PatternMatchingFailure] is the exception raised when pattern
23 matching fails *)
24 exception PatternMatchingFailure
25
26 (** [special_meta] is the default name of the meta holding the
27 surrounding context in subterm matching *)
28 val special_meta : metavariable
29
30 (** [bound_ident_map] represents the result of matching binding
31 identifiers of the pattern with the binding identifiers of the term
32 matched *)
33 type bound_ident_map = Id.t Id.Map.t
34
35 (** [matches pat c] matches [c] against [pat] and returns the resulting
36 assignment of metavariables; it raises [PatternMatchingFailure] if
37 not matchable; bindings are given in increasing order based on the
38 numbers given in the pattern *)
39 val matches : env -> Evd.evar_map -> constr_pattern -> constr -> patvar_map
40
41 (** [matches_head pat c] does the same as [matches pat c] but accepts
42 [pat] to match an applicative prefix of [c] *)
43 val matches_head : env -> Evd.evar_map -> constr_pattern -> constr -> patvar_map
44
45 (** [extended_matches pat c] also returns the names of bound variables
46 in [c] that matches the bound variables in [pat]; if several bound
47 variables or metavariables have the same name, the metavariable,
48 or else the rightmost bound variable, takes precedence *)
49 val extended_matches :
50 env -> Evd.evar_map -> binding_bound_vars * constr_pattern ->
51 constr -> bound_ident_map * extended_patvar_map
52
53 (** [is_matching pat c] just tells if [c] matches against [pat] *)
54 val is_matching : env -> Evd.evar_map -> constr_pattern -> constr -> bool
55
56 (** [is_matching_head pat c] just tells if [c] or an applicative
57 prefix of it matches against [pat] *)
58 val is_matching_head : env -> Evd.evar_map -> constr_pattern -> constr -> bool
59
60 type context
61
62 val empty_context : context
63 val repr_context : context -> EConstr.t
64 val instantiate_context : context -> EConstr.t -> EConstr.t
65
66 (** The type of subterm matching results: a substitution + a context
67 (whose hole is denoted here with [special_meta]) *)
68 type matching_result =
69 { m_sub : bound_ident_map * patvar_map;
70 m_ctx : context }
71
72 (** [match_subterm pat c] returns the substitution and the context
73 corresponding to each **closed** subterm of [c] matching [pat],
74 considering application contexts as well. *)
75 val match_subterm : env -> Evd.evar_map ->
76 binding_bound_vars * constr_pattern -> constr ->
77 matching_result IStream.t
78
79 (** [is_matching_appsubterm pat c] tells if a subterm of [c] matches
80 against [pat] taking partial subterms into consideration *)
81 val is_matching_appsubterm : ?closed:bool -> env -> Evd.evar_map -> constr_pattern -> constr -> bool