aboutsummaryrefslogtreecommitdiff
path: root/interp
diff options
context:
space:
mode:
authorPierre-Marie Pédrot2019-05-17 16:42:48 +0200
committerPierre-Marie Pédrot2019-05-26 00:08:58 +0200
commita21e1bb60f579baec910d4c3d8e8434501470b6d (patch)
treee60df4eff524bb7751ff4d8f9636f20eba177e79 /interp
parent51dc650f8b47a7381c19376793871817f2ef9578 (diff)
Move the Discharge module into the kernel.
Diffstat (limited to 'interp')
-rw-r--r--interp/declare.ml6
-rw-r--r--interp/discharge.ml118
-rw-r--r--interp/discharge.mli16
-rw-r--r--interp/interp.mllib1
4 files changed, 4 insertions, 137 deletions
diff --git a/interp/declare.ml b/interp/declare.ml
index 7ee7ecb5e8..fd1f7df9aa 100644
--- a/interp/declare.ml
+++ b/interp/declare.ml
@@ -91,7 +91,8 @@ let discharge_constant ((sp, kn), obj) =
let from = Global.lookup_constant con in
let modlist = replacement_context () in
let { abstr_ctx = hyps; abstr_subst = subst; abstr_uctx = uctx } = section_segment_of_constant con in
- let abstract = (named_of_variable_context hyps, subst, uctx) in
+ let named_ctx = List.map fst hyps in
+ let abstract = (named_ctx, subst, uctx) in
let new_decl = { from; info = { Opaqueproof.modlist; abstract } } in
(* This is a hack: when leaving a section, we lose the constant definition, so
we have to store it in the libobject to be able to retrieve it after. *)
@@ -314,7 +315,8 @@ let discharge_inductive ((sp,kn),mie) =
let mie = Global.lookup_mind mind in
let repl = replacement_context () in
let info = section_segment_of_mutual_inductive mind in
- Some (Discharge.process_inductive info repl mie)
+ let hyps = List.map fst info.abstr_ctx in
+ Some (Discharge.process_inductive hyps info.abstr_subst info.abstr_uctx repl mie)
let dummy_one_inductive_entry mie = {
mind_entry_typename = mie.mind_entry_typename;
diff --git a/interp/discharge.ml b/interp/discharge.ml
deleted file mode 100644
index 1efd13adb1..0000000000
--- a/interp/discharge.ml
+++ /dev/null
@@ -1,118 +0,0 @@
-(************************************************************************)
-(* * The Coq Proof Assistant / The Coq Development Team *)
-(* v * INRIA, CNRS and contributors - Copyright 1999-2018 *)
-(* <O___,, * (see CREDITS file for the list of authors) *)
-(* \VV/ **************************************************************)
-(* // * This file is distributed under the terms of the *)
-(* * GNU Lesser General Public License Version 2.1 *)
-(* * (see LICENSE file for the text of the license) *)
-(************************************************************************)
-
-open Util
-open Term
-open Constr
-open Vars
-open Declarations
-open Cooking
-open Entries
-
-(********************************)
-(* Discharging mutual inductive *)
-
-(* Replace
-
- Var(y1)..Var(yq):C1..Cq |- Ij:Bj
- Var(y1)..Var(yq):C1..Cq; I1..Ip:B1..Bp |- ci : Ti
-
- by
-
- |- Ij: (y1..yq:C1..Cq)Bj
- I1..Ip:(B1 y1..yq)..(Bp y1..yq) |- ci : (y1..yq:C1..Cq)Ti[Ij:=(Ij y1..yq)]
-*)
-
-let abstract_inductive decls nparamdecls inds =
- let ntyp = List.length inds in
- let ndecls = Context.Named.length decls in
- let args = Context.Named.to_instance mkVar (List.rev decls) in
- let args = Array.of_list args in
- let subs = List.init ntyp (fun k -> lift ndecls (mkApp(mkRel (k+1),args))) in
- let inds' =
- List.map
- (function (tname,arity,template,cnames,lc) ->
- let lc' = List.map (substl subs) lc in
- let lc'' = List.map (fun b -> Termops.it_mkNamedProd_wo_LetIn b decls) lc' in
- let arity' = Termops.it_mkNamedProd_wo_LetIn arity decls in
- (tname,arity',template,cnames,lc''))
- inds in
- let nparamdecls' = nparamdecls + Array.length args in
-(* To be sure to be the same as before, should probably be moved to process_inductive *)
- let params' = let (_,arity,_,_,_) = List.hd inds' in
- let (params,_) = decompose_prod_n_assum nparamdecls' arity in
- params
- in
- let ind'' =
- List.map
- (fun (a,arity,template,c,lc) ->
- let _, short_arity = decompose_prod_n_assum nparamdecls' arity in
- let shortlc =
- List.map (fun c -> snd (decompose_prod_n_assum nparamdecls' c)) lc in
- { mind_entry_typename = a;
- mind_entry_arity = short_arity;
- mind_entry_template = template;
- mind_entry_consnames = c;
- mind_entry_lc = shortlc })
- inds'
- in (params',ind'')
-
-let refresh_polymorphic_type_of_inductive (_,mip) =
- match mip.mind_arity with
- | RegularArity s -> s.mind_user_arity, false
- | TemplateArity ar ->
- let ctx = List.rev mip.mind_arity_ctxt in
- mkArity (List.rev ctx, Sorts.sort_of_univ ar.template_level), true
-
-let process_inductive info modlist mib =
- let section_decls = Lib.named_of_variable_context info.Lib.abstr_ctx in
- let nparamdecls = Context.Rel.length mib.mind_params_ctxt in
- let subst, ind_univs =
- match mib.mind_universes with
- | Monomorphic ctx -> Univ.empty_level_subst, Monomorphic_entry ctx
- | Polymorphic auctx ->
- let subst, auctx = Lib.discharge_abstract_universe_context info auctx in
- let nas = Univ.AUContext.names auctx in
- let auctx = Univ.AUContext.repr auctx in
- subst, Polymorphic_entry (nas, auctx)
- in
- let variance = match mib.mind_variance with
- | None -> None
- | Some _ -> Some (InferCumulativity.dummy_variance ind_univs)
- in
- let discharge c = Vars.subst_univs_level_constr subst (expmod_constr modlist c) in
- let inds =
- Array.map_to_list
- (fun mip ->
- let ty, template = refresh_polymorphic_type_of_inductive (mib,mip) in
- let arity = discharge ty in
- let lc = Array.map discharge mip.mind_user_lc in
- (mip.mind_typename,
- arity, template,
- Array.to_list mip.mind_consnames,
- Array.to_list lc))
- mib.mind_packets in
- let section_decls' = Context.Named.map discharge section_decls in
- let (params',inds') = abstract_inductive section_decls' nparamdecls inds in
- let record = match mib.mind_record with
- | PrimRecord info ->
- Some (Some (Array.map (fun (x,_,_,_) -> x) info))
- | FakeRecord -> Some None
- | NotRecord -> None
- in
- { mind_entry_record = record;
- mind_entry_finite = mib.mind_finite;
- mind_entry_params = params';
- mind_entry_inds = inds';
- mind_entry_private = mib.mind_private;
- mind_entry_variance = variance;
- mind_entry_universes = ind_univs
- }
-
diff --git a/interp/discharge.mli b/interp/discharge.mli
deleted file mode 100644
index f7408937cf..0000000000
--- a/interp/discharge.mli
+++ /dev/null
@@ -1,16 +0,0 @@
-(************************************************************************)
-(* * The Coq Proof Assistant / The Coq Development Team *)
-(* v * INRIA, CNRS and contributors - Copyright 1999-2018 *)
-(* <O___,, * (see CREDITS file for the list of authors) *)
-(* \VV/ **************************************************************)
-(* // * This file is distributed under the terms of the *)
-(* * GNU Lesser General Public License Version 2.1 *)
-(* * (see LICENSE file for the text of the license) *)
-(************************************************************************)
-
-open Declarations
-open Entries
-open Opaqueproof
-
-val process_inductive :
- Lib.abstr_info -> work_list -> mutual_inductive_body -> mutual_inductive_entry
diff --git a/interp/interp.mllib b/interp/interp.mllib
index 1262dbb181..b65a171ef9 100644
--- a/interp/interp.mllib
+++ b/interp/interp.mllib
@@ -16,5 +16,4 @@ Implicit_quantifiers
Constrintern
Modintern
Constrextern
-Discharge
Declare