Debian Codegraph @

tactics/declareScheme.ml

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 Names
12
13 let scheme_map = Summary.ref Indmap_env.empty ~name:"Schemes"
14
15 let cache_one_scheme kind (ind,const) =
16 scheme_map := Indmap_env.update ind (function
17 | None -> Some (CString.Map.singleton kind const)
18 | Some map -> Some (CString.Map.add kind const map))
19 !scheme_map
20
21 let cache_scheme (kind,l) =
22 cache_one_scheme kind l
23
24 let subst_one_scheme subst (ind,const) =
25 (* Remark: const is a def: the result of substitution is a constant *)
26 (Mod_subst.subst_ind subst ind, Globnames.subst_global_reference subst const)
27
28 let subst_scheme (subst,(kind,l)) =
29 (kind, subst_one_scheme subst l)
30
31 let inScheme : Libobject.locality * (string * (inductive * GlobRef.t)) -> Libobject.obj =
32 let open Libobject in
33 declare_object @@ object_with_locality "SCHEME"
34 ~cache:cache_scheme
35 ~subst:(Some subst_scheme)
36 ~discharge:(fun x -> x)
37
38 let declare_scheme local kind indcl =
39 Lib.add_leaf (inScheme (local,(kind,indcl)))
40
41 let lookup_scheme kind ind = CString.Map.find kind (Indmap_env.find ind !scheme_map)
42
43 let lookup_scheme_opt kind ind =
44 try Some (lookup_scheme kind ind) with Not_found -> None
45
46 let all_schemes () = !scheme_map