Debian Codegraph @

vernac/canonical.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 open Libobject
11 open Structures
12
13 let open_canonical_structure (o,_) =
14 let env = Global.env () in
15 let sigma = Evd.from_env env in
16 Instance.register env sigma ~warn:false o
17
18 let cache_canonical_structure (o,_) =
19 let env = Global.env () in
20 let sigma = Evd.from_env env in
21 Instance.register ~warn:true env sigma o
22
23 let discharge_canonical_structure (x, local) =
24 let gref = Instance.repr x in
25 if local || (Globnames.isVarRef gref && Global.is_in_section gref) then None
26 else Some (x, local)
27
28 let canon_cat = create_category "canonicals"
29
30 let inCanonStruc : Instance.t * bool -> obj =
31 declare_object {(default_object "CANONICAL-STRUCTURE") with
32 open_function = simple_open ~cat:canon_cat open_canonical_structure;
33 cache_function = cache_canonical_structure;
34 subst_function = (fun (subst,(c,local)) -> Instance.subst subst c, local);
35 classify_function = (fun x -> Substitute);
36 discharge_function = discharge_canonical_structure }
37
38 let add_canonical_structure x = Lib.add_leaf (inCanonStruc x)
39
40 let declare_canonical_structure ?(local=false) ref =
41 let env = Global.env () in
42 let sigma = Evd.from_env env in
43 add_canonical_structure (Instance.make env sigma ref, local)