| 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 Constr |
| 13 | |
| 14 | (** {6 Data needed to abstract over the section variables and section universes } *) |
| 15 | |
| 16 | (** The instantiation to apply to generalized declarations so that |
| 17 | they behave as if not generalized: this is the a1..an instance to |
| 18 | apply to a declaration c in the following transformation: |
| 19 | [a1:T1..an:Tn, C:U(a1..an) ⊢ v(a1..an,C):V(a1..an,C) |
| 20 | ~~> |
| 21 | C:Πx1..xn.U(x1..xn), a1:T1..an:Tn ⊢ v(a1..an,Ca1..an):V(a1..an,Ca1..an)] |
| 22 | note that the data looks close to the one for substitution above |
| 23 | (because the substitution are represented by their domain) but |
| 24 | here, local definitions of the context have been dropped *) |
| 25 | |
| 26 | type abstr_inst_info |
| 27 | |
| 28 | type 'a entry_map = 'a Cmap_env.t * 'a Mindmap_env.t |
| 29 | type expand_info = abstr_inst_info entry_map |
| 30 | |
| 31 | (** The collection of instantiations to be done on generalized |
| 32 | declarations + the generalization to be done on a specific |
| 33 | judgment: |
| 34 | [a1:T1,a2:T2,C:U(a1) ⊢ v(a1,a2,C):V(a1,a2,C) |
| 35 | ~~> |
| 36 | c:Πx.U(x) ⊢ λx1x2.(v(a1,a2,cx1)[a1,a2:=x1,x2]):Πx1x2.(V(a1,a2,ca1)[a1,a2:=x1,x2])] |
| 37 | so, a cooking_info is the map [c ↦ x1..xn], |
| 38 | the context x:T,y:U to generalize, and the substitution [x,y] *) |
| 39 | |
| 40 | type cooking_info |
| 41 | |
| 42 | val empty_cooking_info : cooking_info |
| 43 | (** Nothing to abstract *) |
| 44 | |
| 45 | val make_cooking_info : recursive:MutInd.t option -> expand_info -> |
| 46 | named_context -> UVars.UContext.t -> cooking_info * abstr_inst_info |
| 47 | (** Abstract a context assumed to be de-Bruijn free for terms and universes *) |
| 48 | |
| 49 | val names_info : cooking_info -> Id.Set.t |
| 50 | |
| 51 | val universe_context_of_cooking_info : cooking_info -> UVars.AbstractContext.t |
| 52 | |
| 53 | val instance_of_cooking_info : cooking_info -> Constr.t array |
| 54 | |
| 55 | type cooking_cache |
| 56 | |
| 57 | val create_cache : cooking_info -> cooking_cache |
| 58 | val instance_of_cooking_cache : cooking_cache -> Constr.t array |
| 59 | val rel_context_of_cooking_cache : cooking_cache -> rel_context |
| 60 | |
| 61 | val abstract_as_type : cooking_cache -> types -> types |
| 62 | |
| 63 | val abstract_as_body : cooking_cache -> constr -> constr |
| 64 | |
| 65 | val abstract_as_sort : cooking_cache -> Sorts.t -> Sorts.t |
| 66 | |
| 67 | val lift_mono_univs : cooking_info -> Univ.ContextSet.t -> cooking_info * Univ.ContextSet.t |
| 68 | |
| 69 | (** The [int] is how many universes got discharged, ie size of |
| 70 | returned context - size of input context. *) |
| 71 | val lift_poly_univs : cooking_info -> UVars.AbstractContext.t -> cooking_info * (int * int) * UVars.AbstractContext.t |
| 72 | |
| 73 | val lift_private_mono_univs : cooking_info -> 'a -> 'a |
| 74 | |
| 75 | val lift_private_poly_univs : cooking_info -> Univ.ContextSet.t -> Univ.ContextSet.t |
| 76 | |
| 77 | val lift_quality : cooking_info -> Sorts.Quality.t -> Sorts.Quality.t |
| 78 | |
| 79 | val lift_relevance : cooking_info -> Sorts.relevance -> Sorts.relevance |
| 80 | |
| 81 | val discharge_proj_repr : cooking_info -> Names.Projection.Repr.t -> Names.Projection.Repr.t |