| 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 | open UVars |
| 13 | open Cooking |
| 14 | |
| 15 | (** Kernel implementation of sections. *) |
| 16 | |
| 17 | type 'a t |
| 18 | (** Type of sections with additional data ['a] *) |
| 19 | |
| 20 | val depth : 'a t -> int |
| 21 | (** Number of nested sections. *) |
| 22 | |
| 23 | val map_custom : ('a -> 'a) -> 'a t -> 'a t |
| 24 | (** Modify the custom data *) |
| 25 | |
| 26 | (** {6 Manipulating sections} *) |
| 27 | |
| 28 | type section_entry = |
| 29 | | SecDefinition of Constant.t |
| 30 | | SecInductive of MutInd.t |
| 31 | |
| 32 | val open_section : custom:'a -> 'a t option -> 'a t |
| 33 | (** Open a new section with the provided universe polymorphic status. Sections |
| 34 | can be nested, with the proviso that polymorphic sections cannot appear |
| 35 | inside a monomorphic one. A custom data can be attached to this section, |
| 36 | that will be returned by {!close_section}. *) |
| 37 | |
| 38 | val close_section : 'a t -> 'a t option * section_entry list * Univ.ContextSet.t * 'a |
| 39 | (** Close the current section and returns the entries defined inside, the set |
| 40 | of global monomorphic constraints added in this section, and the custom data |
| 41 | provided at the opening of the section. *) |
| 42 | |
| 43 | (** {6 Extending sections} *) |
| 44 | |
| 45 | val push_local : Constr.named_declaration -> 'a t -> 'a t |
| 46 | (** Extend the current section with a local definition (cf. push_named). *) |
| 47 | |
| 48 | val push_local_universe_context : UContext.t -> 'a t -> 'a t |
| 49 | (** Extend the current section with a local universe context. Assumes that the |
| 50 | last opened section is polymorphic. *) |
| 51 | |
| 52 | val push_level_constraints : Univ.ContextSet.t -> 'a t -> 'a t |
| 53 | (** Extend the current section with a global universe context. |
| 54 | Assumes that the last opened section is monomorphic. *) |
| 55 | |
| 56 | val push_global : Environ.env -> poly:bool -> section_entry -> 'a t -> 'a t |
| 57 | (** Push a global entry in this section. *) |
| 58 | |
| 59 | (** {6 Retrieving section data} *) |
| 60 | |
| 61 | val all_poly_univs : 'a t -> Instance.t |
| 62 | (** Returns all polymorphic universes, including those from previous |
| 63 | sections. Earlier sections are earlier in the array. |
| 64 | |
| 65 | NB: even if the array is empty there may be polymorphic |
| 66 | constraints about monomorphic universes, which prevent declaring |
| 67 | monomorphic globals. *) |
| 68 | |
| 69 | val segment_of_constant : Constant.t -> 'a t -> cooking_info |
| 70 | (** Section segment at the time of the constant declaration *) |
| 71 | |
| 72 | val segment_of_inductive : MutInd.t -> 'a t -> cooking_info |
| 73 | (** Section segment at the time of the inductive declaration *) |
| 74 | |
| 75 | val is_in_section : Environ.env -> GlobRef.t -> 'a t -> bool |