Debian Codegraph @

pretyping/find_subterm.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 open Locus
12 open Evd
13 open Pretype_errors
14 open Environ
15 open EConstr
16
17 (** Finding subterms, possibly up to some unification function,
18 possibly at some given occurrences *)
19
20 exception SubtermUnificationError of subterm_unification_error
21
22 (** A testing function is typically a unification function returning a
23 substitution or failing with Error, together with a function to merge
24 substitutions and an initial substitution;
25 last_found is used for error messages and it has to be initialized
26 with None. *)
27
28 type ('a, 'b) testing_function = {
29 match_fun : int -> 'a -> constr -> ('b, unit) Result.t;
30 merge_fun : 'b -> 'a -> ('a, unit) Result.t;
31 mutable testing_state : 'a;
32 mutable last_found : position_reporting option
33 }
34
35 (** This is the basic testing function, looking for exact matches of a
36 closed term *)
37 val make_eq_univs_test : env -> evar_map -> constr -> (evar_map, evar_map) testing_function
38
39 (** [replace_term_occ_modulo occl test mk c] looks in [c] for subterm
40 modulo a testing function [test] and replaces successfully
41 matching subterms at the indicated occurrences [occl] with [mk
42 ()]; it turns an Error value returned by the [merge_fun]
43 function into a SubtermUnificationError. *)
44 val replace_term_occ_modulo : env -> evar_map -> occurrences or_like_first ->
45 ('a, 'b) testing_function -> (unit -> constr) -> constr -> constr
46
47 (** [replace_term_occ_decl_modulo] is similar to
48 [replace_term_occ_modulo] but for a named_declaration. *)
49 val replace_term_occ_decl_modulo :
50 env -> evar_map ->
51 (occurrences * hyp_location_flag) or_like_first ->
52 ('a, 'b) testing_function -> (unit -> constr) ->
53 named_declaration -> named_declaration
54
55 (** [subst_closed_term_occ occl c d] replaces occurrences of
56 closed [c] at positions [occl] by [Rel 1] in [d] (see also Note OCC),
57 unifying universes which results in a set of constraints. *)
58 val subst_closed_term_occ : env -> evar_map -> occurrences or_like_first ->
59 constr -> constr -> constr * evar_map
60
61 (** [subst_closed_term_occ_decl evd occl c decl] replaces occurrences of
62 closed [c] at positions [occl] by [Rel 1] in [decl]. *)
63 val subst_closed_term_occ_decl : env -> evar_map ->
64 (occurrences * hyp_location_flag) or_like_first ->
65 constr -> named_declaration -> named_declaration * evar_map