From 256ca51bafc7200c8c006981cad60e57014e0dbc Mon Sep 17 00:00:00 2001
From: Pierre-Marie Pédrot
Date: Sun, 26 Feb 2017 21:14:52 +0100
Subject: Do not recompute twice the whnf of terms in conversion.
This performance bug was introduced 9 years ago in a8b0345, where the
responsibility of normalizing the term went from ccnv to eqappr in Reduction.
As a result, all recursive calls to eqappr that were preemptively reducing the
term ended up calling whd_stack twice, once by themselves, and once in the
subsequent call to eqappr.
This caused an important slowdown for conversion-intensive proofs, as the
whd_stack calls CClosure.zip to perfom in-place term sharing, leading to
useless huge re-allocations and repetitive write barriers.
Now that eqappr always head-normalizes the term beforehand, we simply don't
call whd_stack anymore when jumping to eqappr.
---
kernel/reduction.ml | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/kernel/reduction.ml b/kernel/reduction.ml
index 1ae89347ad..fc379fb7d8 100644
--- a/kernel/reduction.ml
+++ b/kernel/reduction.ml
@@ -322,17 +322,17 @@ and eqappr cv_pb l2r infos (lft1,st1) (lft2,st2) cuniv =
let (app1,app2) =
if Conv_oracle.oracle_order Univ.out_punivs oracle l2r fl1 fl2 then
match unfold_reference infos fl1 with
- | Some def1 -> ((lft1, whd def1 v1), appr2)
+ | Some def1 -> ((lft1, (def1, v1)), appr2)
| None ->
(match unfold_reference infos fl2 with
- | Some def2 -> (appr1, (lft2, whd def2 v2))
+ | Some def2 -> (appr1, (lft2, (def2, v2)))
| None -> raise NotConvertible)
else
match unfold_reference infos fl2 with
- | Some def2 -> (appr1, (lft2, whd def2 v2))
+ | Some def2 -> (appr1, (lft2, (def2, v2)))
| None ->
(match unfold_reference infos fl1 with
- | Some def1 -> ((lft1, whd def1 v1), appr2)
+ | Some def1 -> ((lft1, (def1, v1)), appr2)
| None -> raise NotConvertible)
in
eqappr cv_pb l2r infos app1 app2 cuniv)
@@ -343,11 +343,11 @@ and eqappr cv_pb l2r infos (lft1,st1) (lft2,st2) cuniv =
form *)
(match unfold_projection infos p1 c1 with
| Some (def1,s1) ->
- eqappr cv_pb l2r infos (lft1, whd def1 (s1 :: v1)) appr2 cuniv
+ eqappr cv_pb l2r infos (lft1, (def1, s1 :: v1)) appr2 cuniv
| None ->
match unfold_projection infos p2 c2 with
| Some (def2,s2) ->
- eqappr cv_pb l2r infos appr1 (lft2, whd def2 (s2 :: v2)) cuniv
+ eqappr cv_pb l2r infos appr1 (lft2, (def2, s2 :: v2)) cuniv
| None ->
if Constant.equal (Projection.constant p1) (Projection.constant p2)
&& compare_stack_shape v1 v2 then
@@ -359,26 +359,26 @@ and eqappr cv_pb l2r infos (lft1,st1) (lft2,st2) cuniv =
| (FProj (p1,c1), t2) ->
(match unfold_projection infos p1 c1 with
| Some (def1,s1) ->
- eqappr cv_pb l2r infos (lft1, whd def1 (s1 :: v1)) appr2 cuniv
+ eqappr cv_pb l2r infos (lft1, (def1, s1 :: v1)) appr2 cuniv
| None ->
(match t2 with
| FFlex fl2 ->
(match unfold_reference infos fl2 with
| Some def2 ->
- eqappr cv_pb l2r infos appr1 (lft2, whd def2 v2) cuniv
+ eqappr cv_pb l2r infos appr1 (lft2, (def2, v2)) cuniv
| None -> raise NotConvertible)
| _ -> raise NotConvertible))
| (t1, FProj (p2,c2)) ->
(match unfold_projection infos p2 c2 with
| Some (def2,s2) ->
- eqappr cv_pb l2r infos appr1 (lft2, whd def2 (s2 :: v2)) cuniv
+ eqappr cv_pb l2r infos appr1 (lft2, (def2, s2 :: v2)) cuniv
| None ->
(match t1 with
| FFlex fl1 ->
(match unfold_reference infos fl1 with
| Some def1 ->
- eqappr cv_pb l2r infos (lft1, whd def1 v1) appr2 cuniv
+ eqappr cv_pb l2r infos (lft1, (def1, v1)) appr2 cuniv
| None -> raise NotConvertible)
| _ -> raise NotConvertible))
@@ -424,7 +424,7 @@ and eqappr cv_pb l2r infos (lft1,st1) (lft2,st2) cuniv =
| (FFlex fl1, c2) ->
(match unfold_reference infos fl1 with
| Some def1 ->
- eqappr cv_pb l2r infos (lft1, whd def1 v1) appr2 cuniv
+ eqappr cv_pb l2r infos (lft1, (def1, v1)) appr2 cuniv
| None ->
match c2 with
| FConstruct ((ind2,j2),u2) ->
@@ -438,7 +438,7 @@ and eqappr cv_pb l2r infos (lft1,st1) (lft2,st2) cuniv =
| (c1, FFlex fl2) ->
(match unfold_reference infos fl2 with
| Some def2 ->
- eqappr cv_pb l2r infos appr1 (lft2, whd def2 v2) cuniv
+ eqappr cv_pb l2r infos appr1 (lft2, (def2, v2)) cuniv
| None ->
match c1 with
| FConstruct ((ind1,j1),u1) ->
--
cgit v1.2.3
From b0e8bf149a9c620f2e2bd25f586fb41ee71aae0d Mon Sep 17 00:00:00 2001
From: Emilio Jesus Gallego Arias
Date: Sat, 3 Jun 2017 16:50:40 +0200
Subject: [tactics] Fix summary registration of global hint variable.
It looks like `Class_tactics` forgot to register a couple of global
variables with the summary, thus creating problems on backtracking.
Fixes https://coq.inria.fr/bugs/show_bug.cgi?id=5578
---
tactics/class_tactics.ml | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/tactics/class_tactics.ml b/tactics/class_tactics.ml
index 46d66b9d06..7ce6042c1a 100644
--- a/tactics/class_tactics.ml
+++ b/tactics/class_tactics.ml
@@ -643,8 +643,9 @@ module V85 = struct
Goal.V82.hyps gls.Evd.sigma (sig_it gls)
let make_autogoal_hints =
- let cache = ref (true, Environ.empty_named_context_val,
- Hint_db.empty full_transparent_state true)
+ let cache = Summary.ref ~name:"make_autogoal_hints_cache"
+ (true, Environ.empty_named_context_val,
+ Hint_db.empty full_transparent_state true)
in
fun only_classes ?(st=full_transparent_state) g ->
let sign = pf_filtered_hyps g in
@@ -973,8 +974,9 @@ module Search = struct
search_hints : hint_db; }
(** Local hints *)
- let autogoal_cache = ref (DirPath.empty, true, Context.Named.empty,
- Hint_db.empty full_transparent_state true)
+ let autogoal_cache = Summary.ref ~name:"autogoal_cache"
+ (DirPath.empty, true, Context.Named.empty,
+ Hint_db.empty full_transparent_state true)
let make_autogoal_hints only_classes ?(st=full_transparent_state) g =
let open Proofview in
--
cgit v1.2.3
From 9ea1cae62c5335eb7f1dcc14df1dc0b97dfb48e7 Mon Sep 17 00:00:00 2001
From: Emilio Jesus Gallego Arias
Date: Wed, 7 Jun 2017 15:17:30 +0200
Subject: [kernel] Improve proof using message, fixes bugzilla #3613
---
kernel/term_typing.ml | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/kernel/term_typing.ml b/kernel/term_typing.ml
index eeb9c421a1..bdfd00a8d3 100644
--- a/kernel/term_typing.ml
+++ b/kernel/term_typing.ml
@@ -344,11 +344,18 @@ let build_constant_declaration kn env (def,typ,proj,poly,univs,inline_code,ctx)
if not (Id.Set.subset inferred_set declared_set) then
let l = Id.Set.elements (Idset.diff inferred_set declared_set) in
let n = List.length l in
- user_err (Pp.(str "The following section " ++
- str (String.plural n "variable") ++
- str " " ++ str (String.conjugate_verb_to_be n) ++
- str " used but not declared:" ++
- fnl () ++ pr_sequence Id.print (List.rev l) ++ str ".")) in
+ let declared_vars = Pp.pr_sequence Id.print (Idset.elements declared_set) in
+ let inferred_vars = Pp.pr_sequence Id.print (Idset.elements inferred_set) in
+ let missing_vars = Pp.pr_sequence Id.print (List.rev l) in
+ user_err Pp.(prlist str
+ ["The following section "; (String.plural n "variable"); " ";
+ (String.conjugate_verb_to_be n); " used but not declared:"] ++ fnl () ++
+ missing_vars ++ str "." ++ fnl () ++ fnl () ++
+ str "You can either update your proof to not depend on " ++ missing_vars ++
+ str ", or you can update your Proof line from" ++ fnl () ++
+ str "Proof using " ++ declared_vars ++ fnl () ++
+ str "to" ++ fnl () ++
+ str "Proof using " ++ inferred_vars) in
let sort evn l =
List.filter (fun decl ->
let id = NamedDecl.get_id decl in
--
cgit v1.2.3
From b5e90d92fc52e568f1ed6e65a4b611bdab80e8f5 Mon Sep 17 00:00:00 2001
From: Matej Košík
Date: Wed, 7 Jun 2017 15:44:41 +0200
Subject: completing a sentence in a comment
---
lib/pp.mli | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/pp.mli b/lib/pp.mli
index 7a191b01a8..45834dade5 100644
--- a/lib/pp.mli
+++ b/lib/pp.mli
@@ -13,6 +13,7 @@
(* `Pp.t` or `Pp.std_ppcmds` is the main pretty printing document type *)
(* in the Coq system. Documents are composed laying out boxes, and *)
(* users can add arbitrary tag metadata that backends are free *)
+(* to interpret. *)
(* *)
(* The datatype has a public view to allow serialization or advanced *)
(* uses, however regular users are _strongly_ warned againt its use, *)
--
cgit v1.2.3
From 168c8db946494694c5c32b9f2345c9a2830f03da Mon Sep 17 00:00:00 2001
From: Emilio Jesus Gallego Arias
Date: Wed, 7 Jun 2017 21:31:40 +0200
Subject: [stm] More fixes for nested commands [bugzilla 5589]
---
stm/stm.ml | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/stm/stm.ml b/stm/stm.ml
index a79bf54267..11aca16272 100644
--- a/stm/stm.ml
+++ b/stm/stm.ml
@@ -2046,7 +2046,8 @@ let collect_proof keep cur hd brkind id =
| `ASync(_,pua,_,name,_) -> `Sync (name,pua,why) in
let check_policy rc = if async_policy () then rc else make_sync `Policy rc in
match cur, (VCS.visit id).step, brkind with
- | (parent, { expr = VernacExactProof _ }), `Fork _, _ ->
+ | (parent, { expr = VernacExactProof _ }), `Fork _, _
+ | (parent, { expr = VernacTime (_, VernacExactProof _) }), `Fork _, _ ->
`Sync (no_name,None,`Immediate)
| _, _, { VCS.kind = `Edit _ } -> check_policy (collect (Some cur) [] id)
| _ ->
--
cgit v1.2.3
From a526ef890f614e130a8afc032d427c81fd8e6442 Mon Sep 17 00:00:00 2001
From: Théo Zimmermann
Date: Thu, 8 Jun 2017 17:41:43 +0200
Subject: Fix bug 5026 (the stdlib shouldn't define inconsistent notations).
---
theories/QArith/Qcabs.v | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/theories/QArith/Qcabs.v b/theories/QArith/Qcabs.v
index c0ababfff5..e433ecffa1 100644
--- a/theories/QArith/Qcabs.v
+++ b/theories/QArith/Qcabs.v
@@ -22,7 +22,7 @@ Lemma Qcabs_canon (x : Q) : Qred x = x -> Qred (Qabs x) = Qabs x.
Proof. intros H; now rewrite (Qred_abs x), H. Qed.
Definition Qcabs (x:Qc) : Qc := {| canon := Qcabs_canon x (canon x) |}.
-Notation "[ q ]" := (Qcabs q) (q at next level, format "[ q ]") : Qc_scope.
+Notation "[ q ]" := (Qcabs q) : Qc_scope.
Ltac Qc_unfolds :=
unfold Qcabs, Qcminus, Qcopp, Qcplus, Qcmult, Qcle, Q2Qc, this.
--
cgit v1.2.3
From f713e6c195d1de177b43cab7c2902f5160f6af9f Mon Sep 17 00:00:00 2001
From: Hugo Herbelin
Date: Fri, 24 Mar 2017 02:18:53 +0100
Subject: A fix to #5414 (ident bound by ltac names now known for "match").
Also taking into account a name in the return clause and in the
indices.
Note the double meaning ``bound as a term to match'' and ``binding in
the "as" clause'' when the term to match is a variable for all of
"match", "if" and "let".
---
API/API.mli | 38 ++++++++---------
intf/glob_term.ml | 16 +++++++
plugins/funind/glob_termops.ml | 2 +-
plugins/ltac/evar_tactics.ml | 2 +-
plugins/ltac/tacexpr.mli | 2 +-
plugins/ltac/tacinterp.ml | 8 ++--
plugins/ltac/tactic_debug.ml | 2 +-
plugins/ssr/ssrcommon.ml | 4 +-
pretyping/cases.ml | 96 +++++++++++++++++++++++++++++-------------
pretyping/cases.mli | 13 ++++--
pretyping/glob_ops.ml | 24 +++++++++++
pretyping/glob_ops.mli | 3 ++
pretyping/pretyping.ml | 61 +++++++++------------------
pretyping/pretyping.mli | 18 --------
proofs/proof.ml | 2 +-
test-suite/bugs/closed/5414.v | 12 ++++++
test-suite/output/Cases.out | 46 ++++++++++++++++++++
test-suite/output/Cases.v | 63 +++++++++++++++++++++++++++
test-suite/success/Case19.v | 19 +++++++++
19 files changed, 309 insertions(+), 122 deletions(-)
create mode 100644 test-suite/bugs/closed/5414.v
diff --git a/API/API.mli b/API/API.mli
index d844e8bf52..2045fadaef 100644
--- a/API/API.mli
+++ b/API/API.mli
@@ -2510,6 +2510,20 @@ sig
and closed_glob_constr = Glob_term.closed_glob_constr = {
closure: closure;
term: glob_constr }
+
+ type var_map = Pattern.constr_under_binders Names.Id.Map.t
+ type uconstr_var_map = Glob_term.closed_glob_constr Names.Id.Map.t
+ type unbound_ltac_var_map = Geninterp.Val.t Names.Id.Map.t
+ type ltac_var_map = Glob_term.ltac_var_map = {
+ ltac_constrs : var_map;
+ (** Ltac variables bound to constrs *)
+ ltac_uconstrs : uconstr_var_map;
+ (** Ltac variables bound to untyped constrs *)
+ ltac_idents: Names.Id.t Names.Id.Map.t;
+ (** Ltac variables bound to identifiers *)
+ ltac_genargs : unbound_ltac_var_map;
+ (** Ltac variables bound to other kinds of arguments *)
+ }
end
module Libnames :
@@ -2875,10 +2889,6 @@ sig
| IsType
| WithoutTypeConstraint
- type var_map = Pattern.constr_under_binders Names.Id.Map.t
- type uconstr_var_map = Glob_term.closed_glob_constr Names.Id.Map.t
- type unbound_ltac_var_map = Geninterp.Val.t Names.Id.Map.t
-
type inference_hook = Environ.env -> Evd.evar_map -> Evar.t -> Evd.evar_map * EConstr.constr
type inference_flags = Pretyping.inference_flags = {
use_typeclasses : bool;
@@ -2888,22 +2898,11 @@ sig
expand_evars : bool
}
- type ltac_var_map = Pretyping.ltac_var_map = {
- ltac_constrs : var_map;
- (** Ltac variables bound to constrs *)
- ltac_uconstrs : uconstr_var_map;
- (** Ltac variables bound to untyped constrs *)
- ltac_idents: Names.Id.t Names.Id.Map.t;
- (** Ltac variables bound to identifiers *)
- ltac_genargs : unbound_ltac_var_map;
- (** Ltac variables bound to other kinds of arguments *)
- }
type pure_open_constr = Evd.evar_map * EConstr.constr
- type glob_constr_ltac_closure = ltac_var_map * Glob_term.glob_constr
+ type glob_constr_ltac_closure = Glob_term.ltac_var_map * Glob_term.glob_constr
- val empty_lvar : ltac_var_map
val understand_ltac : inference_flags ->
- Environ.env -> Evd.evar_map -> ltac_var_map ->
+ Environ.env -> Evd.evar_map -> Glob_term.ltac_var_map ->
typing_constraint -> Glob_term.glob_constr -> pure_open_constr
val understand_tcc : ?flags:inference_flags -> Environ.env -> Evd.evar_map ->
?expected_type:typing_constraint -> Glob_term.glob_constr -> Evd.evar_map * EConstr.constr
@@ -2917,11 +2916,11 @@ sig
val interp_elimination_sort : Misctypes.glob_sort -> Sorts.family
val register_constr_interp0 :
('r, 'g, 't) Genarg.genarg_type ->
- (unbound_ltac_var_map -> Environ.env -> Evd.evar_map -> EConstr.types -> 'g -> EConstr.constr * Evd.evar_map) -> unit
+ (Glob_term.unbound_ltac_var_map -> Environ.env -> Evd.evar_map -> EConstr.types -> 'g -> EConstr.constr * Evd.evar_map) -> unit
val all_and_fail_flags : inference_flags
val ise_pretype_gen :
inference_flags -> Environ.env -> Evd.evar_map ->
- ltac_var_map -> typing_constraint -> Glob_term.glob_constr -> Evd.evar_map * EConstr.constr
+ Glob_term.ltac_var_map -> typing_constraint -> Glob_term.glob_constr -> Evd.evar_map * EConstr.constr
end
module Evarconv :
@@ -3746,6 +3745,7 @@ sig
val cases_pattern_of_glob_constr : Names.Name.t -> Glob_term.glob_constr -> Glob_term.cases_pattern
val map_glob_constr :
(Glob_term.glob_constr -> Glob_term.glob_constr) -> Glob_term.glob_constr -> Glob_term.glob_constr
+ val empty_lvar : Glob_term.ltac_var_map
end
module Indrec :
diff --git a/intf/glob_term.ml b/intf/glob_term.ml
index 5da20c9d1c..a35dae4aae 100644
--- a/intf/glob_term.ml
+++ b/intf/glob_term.ml
@@ -95,3 +95,19 @@ type closure = {
and closed_glob_constr = {
closure: closure;
term: glob_constr }
+
+(** Ltac variable maps *)
+type var_map = Pattern.constr_under_binders Id.Map.t
+type uconstr_var_map = closed_glob_constr Id.Map.t
+type unbound_ltac_var_map = Geninterp.Val.t Id.Map.t
+
+type ltac_var_map = {
+ ltac_constrs : var_map;
+ (** Ltac variables bound to constrs *)
+ ltac_uconstrs : uconstr_var_map;
+ (** Ltac variables bound to untyped constrs *)
+ ltac_idents: Id.t Id.Map.t;
+ (** Ltac variables bound to identifiers *)
+ ltac_genargs : unbound_ltac_var_map;
+ (** Ltac variables bound to other kinds of arguments *)
+}
diff --git a/plugins/funind/glob_termops.ml b/plugins/funind/glob_termops.ml
index eae72d9e84..1f2a0a1b4d 100644
--- a/plugins/funind/glob_termops.ml
+++ b/plugins/funind/glob_termops.ml
@@ -722,7 +722,7 @@ let resolve_and_replace_implicits ?(flags=Pretyping.all_and_fail_flags) ?(expect
(* we first (pseudo) understand [rt] and get back the computed evar_map *)
(* FIXME : JF (30/03/2017) I'm not completely sure to have split understand as needed.
If someone knows how to prevent solved existantial removal in understand, please do not hesitate to change the computation of [ctx] here *)
- let ctx,_ = Pretyping.ise_pretype_gen flags env sigma Pretyping.empty_lvar expected_type rt in
+ let ctx,_ = Pretyping.ise_pretype_gen flags env sigma Glob_ops.empty_lvar expected_type rt in
let ctx, f = Evarutil.nf_evars_and_universes ctx in
(* then we map [rt] to replace the implicit holes by their values *)
diff --git a/plugins/ltac/evar_tactics.ml b/plugins/ltac/evar_tactics.ml
index 958f43bd79..4f6f244f82 100644
--- a/plugins/ltac/evar_tactics.ml
+++ b/plugins/ltac/evar_tactics.ml
@@ -28,7 +28,7 @@ let instantiate_evar evk (ist,rawc) sigma =
let filtered = Evd.evar_filtered_env evi in
let constrvars = Tacinterp.extract_ltac_constr_values ist filtered in
let lvar = {
- Pretyping.ltac_constrs = constrvars;
+ Glob_term.ltac_constrs = constrvars;
ltac_uconstrs = Names.Id.Map.empty;
ltac_idents = Names.Id.Map.empty;
ltac_genargs = ist.Geninterp.lfun;
diff --git a/plugins/ltac/tacexpr.mli b/plugins/ltac/tacexpr.mli
index 9b6ac8a9ae..67893bd11e 100644
--- a/plugins/ltac/tacexpr.mli
+++ b/plugins/ltac/tacexpr.mli
@@ -386,7 +386,7 @@ type ltac_call_kind =
| LtacNameCall of ltac_constant
| LtacAtomCall of glob_atomic_tactic_expr
| LtacVarCall of Id.t * glob_tactic_expr
- | LtacConstrInterp of Glob_term.glob_constr * Pretyping.ltac_var_map
+ | LtacConstrInterp of Glob_term.glob_constr * Glob_term.ltac_var_map
type ltac_trace = ltac_call_kind Loc.located list
diff --git a/plugins/ltac/tacinterp.ml b/plugins/ltac/tacinterp.ml
index 85d3944b18..18c9e839ad 100644
--- a/plugins/ltac/tacinterp.ml
+++ b/plugins/ltac/tacinterp.ml
@@ -605,10 +605,10 @@ let interp_gen kind ist pattern_mode flags env sigma c =
let { closure = constrvars ; term } =
interp_glob_closure ist env sigma ~kind:kind_for_intern ~pattern_mode c in
let vars = {
- Pretyping.ltac_constrs = constrvars.typed;
- Pretyping.ltac_uconstrs = constrvars.untyped;
- Pretyping.ltac_idents = constrvars.idents;
- Pretyping.ltac_genargs = ist.lfun;
+ Glob_term.ltac_constrs = constrvars.typed;
+ Glob_term.ltac_uconstrs = constrvars.untyped;
+ Glob_term.ltac_idents = constrvars.idents;
+ Glob_term.ltac_genargs = ist.lfun;
} in
(* Jason Gross: To avoid unnecessary modifications to tacinterp, as
suggested by Arnaud Spiwack, we run push_trace immediately. We do
diff --git a/plugins/ltac/tactic_debug.ml b/plugins/ltac/tactic_debug.ml
index 8126421c7d..d495eb8210 100644
--- a/plugins/ltac/tactic_debug.ml
+++ b/plugins/ltac/tactic_debug.ml
@@ -366,7 +366,7 @@ let explain_ltac_call_trace last trace loc =
| Tacexpr.LtacAtomCall te ->
quote (Pptactic.pr_glob_tactic (Global.env())
(Tacexpr.TacAtom (Loc.tag te)))
- | Tacexpr.LtacConstrInterp (c, { Pretyping.ltac_constrs = vars }) ->
+ | Tacexpr.LtacConstrInterp (c, { Glob_term.ltac_constrs = vars }) ->
quote (Printer.pr_glob_constr_env (Global.env()) c) ++
(if not (Id.Map.is_empty vars) then
strbrk " (with " ++
diff --git a/plugins/ssr/ssrcommon.ml b/plugins/ssr/ssrcommon.ml
index 38ee4be45d..d1b4eb8500 100644
--- a/plugins/ssr/ssrcommon.ml
+++ b/plugins/ssr/ssrcommon.ml
@@ -226,8 +226,8 @@ let isAppInd gl c =
let interp_refine ist gl rc =
let constrvars = Tacinterp.extract_ltac_constr_values ist (pf_env gl) in
- let vars = { Pretyping.empty_lvar with
- Pretyping.ltac_constrs = constrvars; ltac_genargs = ist.Tacinterp.lfun
+ let vars = { Glob_ops.empty_lvar with
+ Glob_term.ltac_constrs = constrvars; ltac_genargs = ist.Tacinterp.lfun
} in
let kind = Pretyping.OfType (pf_concl gl) in
let flags = {
diff --git a/pretyping/cases.ml b/pretyping/cases.ml
index c3f392980a..b88532e1b9 100644
--- a/pretyping/cases.ml
+++ b/pretyping/cases.ml
@@ -245,6 +245,7 @@ let push_history_pattern n pci cont =
type 'a pattern_matching_problem =
{ env : env;
+ lvar : Glob_term.ltac_var_map;
evdref : evar_map ref;
pred : constr;
tomatch : tomatch_stack;
@@ -346,25 +347,45 @@ let find_tomatch_tycon evdref env loc = function
| None ->
empty_tycon,None
-let coerce_row typing_fun evdref env pats (tomatch,(_,indopt)) =
+let make_return_predicate_ltac_lvar sigma na tm c lvar =
+ match na, tm.CAst.v with
+ | Name id, (GVar id' | GRef (Globnames.VarRef id', _)) when Id.equal id id' ->
+ if Id.Map.mem id lvar.ltac_genargs then
+ let ltac_genargs = Id.Map.remove id lvar.ltac_genargs in
+ let ltac_idents = match kind sigma c with
+ | Var id' -> Id.Map.add id id' lvar.ltac_idents
+ | _ -> lvar.ltac_idents in
+ { lvar with ltac_genargs; ltac_idents }
+ else lvar
+ | _ -> lvar
+
+let ltac_interp_realnames lvar = function
+ | t, IsInd (ty,ind,realnal) -> t, IsInd (ty,ind,List.map (ltac_interp_name lvar) realnal)
+ | _ as x -> x
+
+let coerce_row typing_fun evdref env lvar pats (tomatch,(na,indopt)) =
let loc = loc_of_glob_constr tomatch in
let tycon,realnames = find_tomatch_tycon evdref env loc indopt in
- let j = typing_fun tycon env evdref tomatch in
+ let j = typing_fun tycon env evdref !lvar tomatch in
let evd, j = Coercion.inh_coerce_to_base ?loc:(loc_of_glob_constr tomatch) env !evdref j in
evdref := evd;
let typ = nf_evar !evdref j.uj_type in
+ lvar := make_return_predicate_ltac_lvar !evdref na tomatch j.uj_val !lvar;
let t =
try try_find_ind env !evdref typ realnames
with Not_found ->
unify_tomatch_with_patterns evdref env loc typ pats realnames in
(j.uj_val,t)
-let coerce_to_indtype typing_fun evdref env matx tomatchl =
+let coerce_to_indtype typing_fun evdref env lvar matx tomatchl =
let pats = List.map (fun r -> r.patterns) matx in
let matx' = match matrix_transpose pats with
| [] -> List.map (fun _ -> []) tomatchl (* no patterns at all *)
| m -> m in
- List.map2 (coerce_row typing_fun evdref env) matx' tomatchl
+ let lvar = ref lvar in
+ let tms = List.map2 (coerce_row typing_fun evdref env lvar) matx' tomatchl in
+ let tms = List.map (ltac_interp_realnames !lvar) tms in
+ !lvar,tms
(************************************************************************)
(* Utils *)
@@ -1392,6 +1413,7 @@ and match_current pb (initial,tomatch) =
postprocess_dependencies !(pb.evdref) depstocheck
brvals pb.tomatch pb.pred deps cstrs in
let brvals = Array.map (fun (sign,body) ->
+ let sign = List.map (map_name (ltac_interp_name pb.lvar)) sign in
it_mkLambda_or_LetIn body sign) brvals in
let (pred,typ) =
find_predicate pb.caseloc pb.env pb.evdref
@@ -1824,6 +1846,7 @@ let build_inversion_problem loc env sigma tms t =
let evdref = ref sigma in
let pb =
{ env = pb_env;
+ lvar = empty_lvar;
evdref = evdref;
pred = (*ty *) mkSort s;
tomatch = sub_tms;
@@ -1847,15 +1870,15 @@ let build_initial_predicate arsign pred =
| _ -> assert false
in buildrec 0 pred [] (List.rev arsign)
-let extract_arity_signature ?(dolift=true) env0 tomatchl tmsign =
+let extract_arity_signature ?(dolift=true) env0 lvar tomatchl tmsign =
let lift = if dolift then lift else fun n t -> t in
let get_one_sign n tm (na,t) =
match tm with
| NotInd (bo,typ) ->
(match t with
- | None -> (match bo with
+ | None -> let sign = match bo with
| None -> [LocalAssum (na, lift n typ)]
- | Some b -> [LocalDef (na, lift n b, lift n typ)])
+ | Some b -> [LocalDef (na, lift n b, lift n typ)] in sign,sign
| Some (loc,_) ->
user_err ?loc
(str"Unexpected type annotation for a term of non inductive type."))
@@ -1865,22 +1888,31 @@ let extract_arity_signature ?(dolift=true) env0 tomatchl tmsign =
let nrealargs_ctxt = inductive_nrealdecls_env env0 ind in
let arsign = fst (get_arity env0 indf') in
let arsign = List.map (fun d -> map_rel_decl EConstr.of_constr d) arsign in
- let realnal =
+ let realnal, realnal' =
match t with
| Some (loc,(ind',realnal)) ->
if not (eq_ind ind ind') then
user_err ?loc (str "Wrong inductive type.");
if not (Int.equal nrealargs_ctxt (List.length realnal)) then
anomaly (Pp.str "Ill-formed 'in' clause in cases.");
- List.rev realnal
- | None -> List.make nrealargs_ctxt Anonymous in
- LocalAssum (na, EConstr.of_constr (build_dependent_inductive env0 indf'))
- ::(List.map2 RelDecl.set_name realnal arsign) in
+ let realnal = List.rev realnal in
+ let realnal' = List.map (ltac_interp_name lvar) realnal in
+ realnal,realnal'
+ | None ->
+ let realnal = List.make nrealargs_ctxt Anonymous in
+ realnal, realnal in
+ let na' = ltac_interp_name lvar na in
+ let t = EConstr.of_constr (build_dependent_inductive env0 indf') in
+ (* Context with names for typing *)
+ let arsign1 = LocalAssum (na, t) :: List.map2 RelDecl.set_name realnal arsign in
+ (* Context with names for building the term *)
+ let arsign2 = LocalAssum (na', t) :: List.map2 RelDecl.set_name realnal' arsign in
+ arsign1,arsign2 in
let rec buildrec n = function
| [],[] -> []
| (_,tm)::ltm, (_,x)::tmsign ->
let l = get_one_sign n tm x in
- l :: buildrec (n + List.length l) (ltm,tmsign)
+ l :: buildrec (n + List.length (fst l)) (ltm,tmsign)
| _ -> assert false
in List.rev (buildrec 0 (tomatchl,tmsign))
@@ -1970,7 +2002,7 @@ let noccur_with_meta sigma n m term =
in
try (occur_rec n term; true) with LocalOccur -> false
-let prepare_predicate ?loc typing_fun env sigma tomatchs arsign tycon pred =
+let prepare_predicate ?loc typing_fun env sigma lvar tomatchs arsign tycon pred =
let refresh_tycon sigma t =
(** If we put the typing constraint in the term, it has to be
refreshed to preserve the invariant that no algebraic universe
@@ -1978,6 +2010,7 @@ let prepare_predicate ?loc typing_fun env sigma tomatchs arsign tycon pred =
refresh_universes ~status:Evd.univ_flexible ~onlyalg:true (Some true)
env sigma t
in
+ let typing_arsign,building_arsign = List.split arsign in
let preds =
match pred, tycon with
(* No return clause *)
@@ -1987,7 +2020,7 @@ let prepare_predicate ?loc typing_fun env sigma tomatchs arsign tycon pred =
(* First strategy: we abstract the tycon wrt to the dependencies *)
let sigma, t = refresh_tycon sigma t in
let p1 =
- prepare_predicate_from_arsign_tycon env sigma loc tomatchs arsign t in
+ prepare_predicate_from_arsign_tycon env sigma loc tomatchs typing_arsign t in
(* Second strategy: we build an "inversion" predicate *)
let sigma2,pred2 = build_inversion_problem loc env sigma tomatchs t in
(match p1 with
@@ -2006,22 +2039,22 @@ let prepare_predicate ?loc typing_fun env sigma tomatchs arsign tycon pred =
(* First strategy: we build an "inversion" predicate *)
let sigma1,pred1 = build_inversion_problem loc env sigma tomatchs t in
(* Second strategy: we directly use the evar as a non dependent pred *)
- let pred2 = lift (List.length (List.flatten arsign)) t in
+ let pred2 = lift (List.length (List.flatten typing_arsign)) t in
[sigma1, pred1; sigma, pred2]
(* Some type annotation *)
| Some rtntyp, _ ->
(* We extract the signature of the arity *)
- let envar = List.fold_right push_rel_context arsign env in
+ let envar = List.fold_right push_rel_context typing_arsign env in
let sigma, newt = new_sort_variable univ_flexible_alg sigma in
let evdref = ref sigma in
- let predcclj = typing_fun (mk_tycon (mkSort newt)) envar evdref rtntyp in
+ let predcclj = typing_fun (mk_tycon (mkSort newt)) envar evdref lvar rtntyp in
let sigma = !evdref in
let predccl = nf_evar sigma predcclj.uj_val in
[sigma, predccl]
in
List.map
(fun (sigma,pred) ->
- let (nal,pred) = build_initial_predicate arsign pred in
+ let (nal,pred) = build_initial_predicate building_arsign pred in
sigma,nal,pred)
preds
@@ -2441,10 +2474,10 @@ let context_of_arsign l =
l ([], 0)
in x
-let compile_program_cases ?loc style (typing_function, evdref) tycon env
+let compile_program_cases ?loc style (typing_function, evdref) tycon env lvar
(predopt, tomatchl, eqns) =
let typing_fun tycon env = function
- | Some t -> typing_function tycon env evdref t
+ | Some t -> typing_function tycon env evdref lvar t
| None -> Evarutil.evd_comb0 use_unit_judge evdref in
(* We build the matrix of patterns and right-hand side *)
@@ -2452,14 +2485,15 @@ let compile_program_cases ?loc style (typing_function, evdref) tycon env
(* We build the vector of terms to match consistently with the *)
(* constructors found in patterns *)
- let tomatchs = coerce_to_indtype typing_function evdref env matx tomatchl in
+ let predlvar,tomatchs = coerce_to_indtype typing_function evdref env lvar matx tomatchl in
let tycon = valcon_of_tycon tycon in
let tomatchs, tomatchs_lets, tycon' = abstract_tomatch env !evdref tomatchs tycon in
let env = push_rel_context tomatchs_lets env in
let len = List.length eqns in
let sign, allnames, signlen, eqs, neqs, args =
(* The arity signature *)
- let arsign = extract_arity_signature ~dolift:false env tomatchs tomatchl in
+ let arsign = extract_arity_signature ~dolift:false env predlvar tomatchs tomatchl in
+ let arsign = List.map fst arsign in (* Because no difference between the arity for typing and the arity for building *)
(* Build the dependent arity signature, the equalities which makes
the first part of the predicate and their instantiations. *)
let avoid = [] in
@@ -2522,11 +2556,12 @@ let compile_program_cases ?loc style (typing_function, evdref) tycon env
let initial_pushed = List.map (fun x -> Pushed (true,x)) typs' in
let typing_function tycon env evdref = function
- | Some t -> typing_function tycon env evdref t
+ | Some t -> typing_function tycon env evdref lvar t
| None -> evd_comb0 use_unit_judge evdref in
let pb =
{ env = env;
+ lvar = lvar;
evdref = evdref;
pred = pred;
tomatch = initial_pushed;
@@ -2548,10 +2583,10 @@ let compile_program_cases ?loc style (typing_function, evdref) tycon env
(**************************************************************************)
(* Main entry of the matching compilation *)
-let compile_cases ?loc style (typing_fun, evdref) tycon env (predopt, tomatchl, eqns) =
+let compile_cases ?loc style (typing_fun, evdref) tycon env lvar (predopt, tomatchl, eqns) =
if predopt == None && Flags.is_program_mode () && Program.is_program_cases () then
compile_program_cases ?loc style (typing_fun, evdref)
- tycon env (predopt, tomatchl, eqns)
+ tycon env lvar (predopt, tomatchl, eqns)
else
(* We build the matrix of patterns and right-hand side *)
@@ -2559,15 +2594,15 @@ let compile_cases ?loc style (typing_fun, evdref) tycon env (predopt, tomatchl,
(* We build the vector of terms to match consistently with the *)
(* constructors found in patterns *)
- let tomatchs = coerce_to_indtype typing_fun evdref env matx tomatchl in
+ let predlvar,tomatchs = coerce_to_indtype typing_fun evdref env lvar matx tomatchl in
(* If an elimination predicate is provided, we check it is compatible
with the type of arguments to match; if none is provided, we
build alternative possible predicates *)
- let arsign = extract_arity_signature env tomatchs tomatchl in
- let preds = prepare_predicate ?loc typing_fun env !evdref tomatchs arsign tycon predopt in
+ let arsign = extract_arity_signature env predlvar tomatchs tomatchl in
+ let preds = prepare_predicate ?loc typing_fun env !evdref predlvar tomatchs arsign tycon predopt in
let compile_for_one_predicate (sigma,nal,pred) =
(* We push the initial terms to match and push their alias to rhs' envs *)
@@ -2598,13 +2633,14 @@ let compile_cases ?loc style (typing_fun, evdref) tycon env (predopt, tomatchl,
(* A typing function that provides with a canonical term for absurd cases*)
let typing_fun tycon env evdref = function
- | Some t -> typing_fun tycon env evdref t
+ | Some t -> typing_fun tycon env evdref lvar t
| None -> evd_comb0 use_unit_judge evdref in
let myevdref = ref sigma in
let pb =
{ env = env;
+ lvar = lvar;
evdref = myevdref;
pred = pred;
tomatch = initial_pushed;
diff --git a/pretyping/cases.mli b/pretyping/cases.mli
index b16342db4b..4b1fde25a8 100644
--- a/pretyping/cases.mli
+++ b/pretyping/cases.mli
@@ -39,9 +39,9 @@ val irrefutable : env -> cases_pattern -> bool
val compile_cases :
?loc:Loc.t -> case_style ->
- (type_constraint -> env -> evar_map ref -> glob_constr -> unsafe_judgment) * evar_map ref ->
+ (type_constraint -> env -> evar_map ref -> ltac_var_map -> glob_constr -> unsafe_judgment) * evar_map ref ->
type_constraint ->
- env -> glob_constr option * tomatch_tuples * cases_clauses ->
+ env -> ltac_var_map -> glob_constr option * tomatch_tuples * cases_clauses ->
unsafe_judgment
val constr_of_pat :
@@ -101,6 +101,7 @@ and pattern_continuation =
type 'a pattern_matching_problem =
{ env : env;
+ lvar : Glob_term.ltac_var_map;
evdref : evar_map ref;
pred : constr;
tomatch : tomatch_stack;
@@ -115,10 +116,14 @@ val compile : 'a pattern_matching_problem -> unsafe_judgment
val prepare_predicate : ?loc:Loc.t ->
(Evarutil.type_constraint ->
- Environ.env -> Evd.evar_map ref -> glob_constr -> unsafe_judgment) ->
+ Environ.env -> Evd.evar_map ref -> ltac_var_map -> glob_constr -> unsafe_judgment) ->
Environ.env ->
Evd.evar_map ->
+ Glob_term.ltac_var_map ->
(types * tomatch_type) list ->
- rel_context list ->
+ (rel_context * rel_context) list ->
constr option ->
glob_constr option -> (Evd.evar_map * Names.name list * constr) list
+
+val make_return_predicate_ltac_lvar : Evd.evar_map -> Names.name ->
+ Glob_term.glob_constr -> constr -> Glob_term.ltac_var_map -> Glob_term.ltac_var_map
diff --git a/pretyping/glob_ops.ml b/pretyping/glob_ops.ml
index 62ff9ac708..9c09396ccc 100644
--- a/pretyping/glob_ops.ml
+++ b/pretyping/glob_ops.ml
@@ -504,3 +504,27 @@ let glob_constr_of_closed_cases_pattern = function
na,glob_constr_of_closed_cases_pattern_aux (CAst.make ?loc @@ PatCstr (cstr,l,Anonymous))
| _ ->
raise Not_found
+
+(**********************************************************************)
+(* Interpreting ltac variables *)
+
+open Pp
+open CErrors
+
+let ltac_interp_name { ltac_idents ; ltac_genargs } = function
+ | Anonymous -> Anonymous
+ | Name id as n ->
+ try Name (Id.Map.find id ltac_idents)
+ with Not_found ->
+ if Id.Map.mem id ltac_genargs then
+ user_err (str"Ltac variable"++spc()++ pr_id id ++
+ spc()++str"is not bound to an identifier."++spc()++
+ str"It cannot be used in a binder.")
+ else n
+
+let empty_lvar : ltac_var_map = {
+ ltac_constrs = Id.Map.empty;
+ ltac_uconstrs = Id.Map.empty;
+ ltac_idents = Id.Map.empty;
+ ltac_genargs = Id.Map.empty;
+}
diff --git a/pretyping/glob_ops.mli b/pretyping/glob_ops.mli
index 75db04f77f..6bb421e732 100644
--- a/pretyping/glob_ops.mli
+++ b/pretyping/glob_ops.mli
@@ -83,3 +83,6 @@ val cases_pattern_of_glob_constr : Name.t -> glob_constr -> cases_pattern
val glob_constr_of_closed_cases_pattern : cases_pattern -> Name.t * glob_constr
val add_patterns_for_params_remove_local_defs : constructor -> cases_pattern list -> cases_pattern list
+
+val ltac_interp_name : Glob_term.ltac_var_map -> Names.name -> Names.name
+val empty_lvar : Glob_term.ltac_var_map
diff --git a/pretyping/pretyping.ml b/pretyping/pretyping.ml
index 92e728683d..7488f35bfe 100644
--- a/pretyping/pretyping.ml
+++ b/pretyping/pretyping.ml
@@ -42,21 +42,11 @@ open Pretype_errors
open Glob_term
open Glob_ops
open Evarconv
-open Pattern
open Misctypes
module NamedDecl = Context.Named.Declaration
type typing_constraint = OfType of types | IsType | WithoutTypeConstraint
-type var_map = constr_under_binders Id.Map.t
-type uconstr_var_map = Glob_term.closed_glob_constr Id.Map.t
-type unbound_ltac_var_map = Geninterp.Val.t Id.Map.t
-type ltac_var_map = {
- ltac_constrs : var_map;
- ltac_uconstrs : uconstr_var_map;
- ltac_idents: Id.t Id.Map.t;
- ltac_genargs : unbound_ltac_var_map;
-}
type glob_constr_ltac_closure = ltac_var_map * glob_constr
type pure_open_constr = evar_map * EConstr.constr
@@ -419,17 +409,6 @@ let orelse_name name name' = match name with
| Anonymous -> name'
| _ -> name
-let ltac_interp_name { ltac_idents ; ltac_genargs } = function
- | Anonymous -> Anonymous
- | Name id as n ->
- try Name (Id.Map.find id ltac_idents)
- with Not_found ->
- if Id.Map.mem id ltac_genargs then
- user_err (str"Ltac variable"++spc()++ pr_id id ++
- spc()++str"is not bound to an identifier."++spc()++
- str"It cannot be used in a binder.")
- else n
-
let ltac_interp_name_env k0 lvar env sigma =
(* envhd is the initial part of the env when pretype was called first *)
(* (in practice is is probably 0, but we have to grant the
@@ -943,16 +922,20 @@ let rec pretype k0 resolve_tc (tycon : type_constraint) (env : ExtraEnv.t) evdre
List.map (set_name Anonymous) arsgn
else arsgn
in
- let psign = LocalAssum (na, build_dependent_inductive env.ExtraEnv.env indf) :: arsgn in
+ let indt = build_dependent_inductive env.ExtraEnv.env indf in
+ let psign = LocalAssum (na, indt) :: arsgn in (* For locating names in [po] *)
+ let predlvar = Cases.make_return_predicate_ltac_lvar !evdref na c cj.uj_val lvar in
+ let psign' = LocalAssum (ltac_interp_name predlvar na, indt) :: arsgn in
+ let psign' = List.map (fun d -> map_rel_decl EConstr.of_constr d) psign' in
+ let psign' = Namegen.name_context env.ExtraEnv.env !evdref psign' in (* For naming abstractions in [po] *)
let psign = List.map (fun d -> map_rel_decl EConstr.of_constr d) psign in
let nar = List.length arsgn in
(match po with
| Some p ->
let env_p = push_rel_context !evdref psign env in
- let pj = pretype_type empty_valcon env_p evdref lvar p in
+ let pj = pretype_type empty_valcon env_p evdref predlvar p in
let ccl = nf_evar !evdref pj.utj_val in
- let psign = make_arity_signature env.ExtraEnv.env !evdref true indf in (* with names *)
- let p = it_mkLambda_or_LetIn ccl psign in
+ let p = it_mkLambda_or_LetIn ccl psign' in
let inst =
(Array.map_to_list EConstr.of_constr cs.cs_concl_realargs)
@[EConstr.of_constr (build_dependent_constructor cs)] in
@@ -968,7 +951,7 @@ let rec pretype k0 resolve_tc (tycon : type_constraint) (env : ExtraEnv.t) evdre
| None ->
let tycon = lift_tycon cs.cs_nargs tycon in
- let fj = pretype tycon env_f evdref lvar d in
+ let fj = pretype tycon env_f evdref predlvar d in
let ccl = nf_evar !evdref fj.uj_type in
let ccl =
if noccur_between !evdref 1 cs.cs_nargs ccl then
@@ -977,7 +960,7 @@ let rec pretype k0 resolve_tc (tycon : type_constraint) (env : ExtraEnv.t) evdre
error_cant_find_case_type ?loc env.ExtraEnv.env !evdref
cj.uj_val in
(* let ccl = refresh_universes ccl in *)
- let p = it_mkLambda_or_LetIn (lift (nar+1) ccl) psign in
+ let p = it_mkLambda_or_LetIn (lift (nar+1) ccl) psign' in
let v =
let ind,_ = dest_ind_family indf in
Typing.check_allowed_sort env.ExtraEnv.env !evdref ind cj.uj_val p;
@@ -1004,14 +987,19 @@ let rec pretype k0 resolve_tc (tycon : type_constraint) (env : ExtraEnv.t) evdre
else arsgn
in
let nar = List.length arsgn in
- let psign = LocalAssum (na, build_dependent_inductive env.ExtraEnv.env indf) :: arsgn in
+ let indt = build_dependent_inductive env.ExtraEnv.env indf in
+ let psign = LocalAssum (na, indt) :: arsgn in (* For locating names in [po] *)
+ let predlvar = Cases.make_return_predicate_ltac_lvar !evdref na c cj.uj_val lvar in
+ let psign' = LocalAssum (ltac_interp_name predlvar na, indt) :: arsgn in
+ let psign' = List.map (fun d -> map_rel_decl EConstr.of_constr d) psign' in
+ let psign' = Namegen.name_context env.ExtraEnv.env !evdref psign' in (* For naming abstractions in [po] *)
let psign = List.map (fun d -> map_rel_decl EConstr.of_constr d) psign in
let pred,p = match po with
| Some p ->
let env_p = push_rel_context !evdref psign env in
- let pj = pretype_type empty_valcon env_p evdref lvar p in
+ let pj = pretype_type empty_valcon env_p evdref predlvar p in
let ccl = nf_evar !evdref pj.utj_val in
- let pred = it_mkLambda_or_LetIn ccl psign in
+ let pred = it_mkLambda_or_LetIn ccl psign' in
let typ = lift (- nar) (beta_applist !evdref (pred,[cj.uj_val])) in
pred, typ
| None ->
@@ -1021,7 +1009,7 @@ let rec pretype k0 resolve_tc (tycon : type_constraint) (env : ExtraEnv.t) evdre
let env = ltac_interp_name_env k0 lvar env !evdref in
new_type_evar env evdref loc
in
- it_mkLambda_or_LetIn (lift (nar+1) p) psign, p in
+ it_mkLambda_or_LetIn (lift (nar+1) p) psign', p in
let pred = nf_evar !evdref pred in
let p = nf_evar !evdref p in
let f cs b =
@@ -1054,8 +1042,8 @@ let rec pretype k0 resolve_tc (tycon : type_constraint) (env : ExtraEnv.t) evdre
| GCases (sty,po,tml,eqns) ->
Cases.compile_cases ?loc sty
- ((fun vtyc env evdref -> pretype vtyc (make_env env !evdref) evdref lvar),evdref)
- tycon env.ExtraEnv.env (* loc *) (po,tml,eqns)
+ ((fun vtyc env evdref -> pretype vtyc (make_env env !evdref) evdref),evdref)
+ tycon env.ExtraEnv.env (* loc *) lvar (po,tml,eqns)
| GCast (c,k) ->
let cj =
@@ -1198,13 +1186,6 @@ let no_classes_no_fail_inference_flags = {
let all_and_fail_flags = default_inference_flags true
let all_no_fail_flags = default_inference_flags false
-let empty_lvar : ltac_var_map = {
- ltac_constrs = Id.Map.empty;
- ltac_uconstrs = Id.Map.empty;
- ltac_idents = Id.Map.empty;
- ltac_genargs = Id.Map.empty;
-}
-
let on_judgment sigma f j =
let c = mkCast(j.uj_val,DEFAULTcast, j.uj_type) in
let (c,_,t) = destCast sigma (f c) in
diff --git a/pretyping/pretyping.mli b/pretyping/pretyping.mli
index dcacd07209..e17468ef83 100644
--- a/pretyping/pretyping.mli
+++ b/pretyping/pretyping.mli
@@ -12,7 +12,6 @@
into elementary ones, insertion of coercions and resolution of
implicit arguments. *)
-open Names
open Term
open Environ
open Evd
@@ -28,23 +27,6 @@ val search_guard :
type typing_constraint = OfType of types | IsType | WithoutTypeConstraint
-type var_map = Pattern.constr_under_binders Id.Map.t
-type uconstr_var_map = Glob_term.closed_glob_constr Id.Map.t
-type unbound_ltac_var_map = Geninterp.Val.t Id.Map.t
-
-type ltac_var_map = {
- ltac_constrs : var_map;
- (** Ltac variables bound to constrs *)
- ltac_uconstrs : uconstr_var_map;
- (** Ltac variables bound to untyped constrs *)
- ltac_idents: Id.t Id.Map.t;
- (** Ltac variables bound to identifiers *)
- ltac_genargs : unbound_ltac_var_map;
- (** Ltac variables bound to other kinds of arguments *)
-}
-
-val empty_lvar : ltac_var_map
-
type glob_constr_ltac_closure = ltac_var_map * glob_constr
type pure_open_constr = evar_map * constr
diff --git a/proofs/proof.ml b/proofs/proof.ml
index 2aa620c1da..ef454299ea 100644
--- a/proofs/proof.ml
+++ b/proofs/proof.ml
@@ -428,7 +428,7 @@ module V82 = struct
in
let env = Evd.evar_filtered_env evi in
let rawc = Constrintern.intern_constr env com in
- let ltac_vars = Pretyping.empty_lvar in
+ let ltac_vars = Glob_ops.empty_lvar in
let sigma = Evar_refiner.w_refine (evk, evi) (ltac_vars, rawc) sigma in
Proofview.Unsafe.tclEVARS sigma
end in
diff --git a/test-suite/bugs/closed/5414.v b/test-suite/bugs/closed/5414.v
new file mode 100644
index 0000000000..2522a274fb
--- /dev/null
+++ b/test-suite/bugs/closed/5414.v
@@ -0,0 +1,12 @@
+(* Use of idents bound to ltac names in a "match" *)
+
+Definition foo : Type.
+Proof.
+ let x := fresh "a" in
+ refine (forall k : nat * nat, let '(x, _) := k in (_ : Type)).
+ exact (a = a).
+Defined.
+Goal foo.
+intros k. elim k. (* elim because elim keeps names *)
+intros.
+Check a. (* We check that the name is "a" *)
diff --git a/test-suite/output/Cases.out b/test-suite/output/Cases.out
index f064dfe763..97fa8e2542 100644
--- a/test-suite/output/Cases.out
+++ b/test-suite/output/Cases.out
@@ -80,3 +80,49 @@ fun '(D n m p q) => n + m + p + q
: J -> nat
The command has indeed failed with message:
The constructor D (in type J) expects 3 arguments.
+lem1 =
+fun dd : nat * nat => let (bb, cc) as aa return (aa = aa) := dd in eq_refl
+ : forall k : nat * nat, k = k
+lem2 =
+fun dd : bool => if dd as aa return (aa = aa) then eq_refl else eq_refl
+ : forall k : bool, k = k
+
+Argument scope is [bool_scope]
+lem3 =
+fun dd : nat * nat => let (bb, cc) as aa return (aa = aa) := dd in eq_refl
+ : forall k : nat * nat, k = k
+1 subgoal
+
+ x : nat
+ n, n0 := match x + 0 with
+ | 0 => 0
+ | S _ => 0
+ end : nat
+ e,
+ e0 := match x + 0 as y return (y = y) with
+ | 0 => eq_refl
+ | S n => eq_refl
+ end : x + 0 = x + 0
+ n1, n2 := match x with
+ | 0 => 0
+ | S _ => 0
+ end : nat
+ e1, e2 := match x return (x = x) with
+ | 0 => eq_refl
+ | S n => eq_refl
+ end : x = x
+ ============================
+ x + 0 = 0
+1 subgoal
+
+ p : nat
+ a,
+ a0 := match eq_refl as y in (_ = e) return (y = y /\ e = e) with
+ | eq_refl => conj eq_refl eq_refl
+ end : eq_refl = eq_refl /\ p = p
+ a1,
+ a2 := match eq_refl in (_ = e) return (p = p /\ e = e) with
+ | eq_refl => conj eq_refl eq_refl
+ end : p = p /\ p = p
+ ============================
+ eq_refl = eq_refl
diff --git a/test-suite/output/Cases.v b/test-suite/output/Cases.v
index 6a4fd007df..17fee3303d 100644
--- a/test-suite/output/Cases.v
+++ b/test-suite/output/Cases.v
@@ -121,3 +121,66 @@ Check fun x => let '(D n m p q) := x in n+m+p+q.
(* This used to succeed, being interpreted as "let '{{n, m, p}} := ..." *)
Fail Check fun x : J => let '{{n, m, _}} p := x in n + m + p.
+
+(* Test use of idents bound to ltac names in a "match" *)
+
+Lemma lem1 : forall k, k=k :>nat * nat.
+let x := fresh "aa" in
+let y := fresh "bb" in
+let z := fresh "cc" in
+let k := fresh "dd" in
+refine (fun k : nat * nat => match k as x return x = x with (y,z) => eq_refl end).
+Qed.
+Print lem1.
+
+Lemma lem2 : forall k, k=k :> bool.
+let x := fresh "aa" in
+let y := fresh "bb" in
+let z := fresh "cc" in
+let k := fresh "dd" in
+refine (fun k => if k as x return x = x then eq_refl else eq_refl).
+Qed.
+Print lem2.
+
+Lemma lem3 : forall k, k=k :>nat * nat.
+let x := fresh "aa" in
+let y := fresh "bb" in
+let z := fresh "cc" in
+let k := fresh "dd" in
+refine (fun k : nat * nat => let (y,z) as x return x = x := k in eq_refl).
+Qed.
+Print lem3.
+
+Lemma lem4 x : x+0=0.
+match goal with |- ?y = _ => pose (match y with 0 => 0 | S n => 0 end) end.
+match goal with |- ?y = _ => pose (match y as y with 0 => 0 | S n => 0 end) end.
+match goal with |- ?y = _ => pose (match y as y return y=y with 0 => eq_refl | S n => eq_refl end) end.
+match goal with |- ?y = _ => pose (match y return y=y with 0 => eq_refl | S n => eq_refl end) end.
+match goal with |- ?y + _ = _ => pose (match y with 0 => 0 | S n => 0 end) end.
+match goal with |- ?y + _ = _ => pose (match y as y with 0 => 0 | S n => 0 end) end.
+match goal with |- ?y + _ = _ => pose (match y as y return y=y with 0 => eq_refl | S n => eq_refl end) end.
+match goal with |- ?y + _ = _ => pose (match y return y=y with 0 => eq_refl | S n => eq_refl end) end.
+Show.
+
+Lemma lem5 (p:nat) : eq_refl p = eq_refl p.
+let y := fresh "n" in (* Checking that y is hidden *)
+ let z := fresh "e" in (* Checking that z is hidden *)
+ match goal with
+ |- ?y = _ => pose (match y as y in _ = z return y=y /\ z=z with eq_refl => conj eq_refl eq_refl end)
+ end.
+let y := fresh "n" in
+ let z := fresh "e" in
+ match goal with
+ |- ?y = _ => pose (match y in _ = z return y=y /\ z=z with eq_refl => conj eq_refl eq_refl end)
+ end.
+let y := fresh "n" in
+ let z := fresh "e" in
+ match goal with
+ |- eq_refl ?y = _ => pose (match eq_refl y in _ = z return y=y /\ z=z with eq_refl => conj eq_refl eq_refl end)
+ end.
+let p := fresh "p" in
+ let z := fresh "e" in
+ match goal with
+ |- eq_refl ?p = _ => pose (match eq_refl p in _ = z return p=p /\ z=z with eq_refl => conj eq_refl eq_refl end)
+ end.
+Show.
diff --git a/test-suite/success/Case19.v b/test-suite/success/Case19.v
index e59828defe..ce98879a5f 100644
--- a/test-suite/success/Case19.v
+++ b/test-suite/success/Case19.v
@@ -17,3 +17,22 @@ Fail exists (fun x =>
with
| eq_refl => eq_refl
end).
+Abort.
+
+(* Some tests with ltac matching on building "if" and "let" *)
+
+Goal forall b c d, (if negb b then c else d) = 0.
+intros.
+match goal with
+|- (if ?b then ?c else ?d) = 0 => transitivity (if b then d else c)
+end.
+Abort.
+
+Definition swap {A} {B} '((x,y):A*B) := (y,x).
+
+Goal forall p, (let '(x,y) := swap p in x + y) = 0.
+intros.
+match goal with
+|- (let '(x,y) := ?p in x + y) = 0 => transitivity (let (x,y) := p in x+y)
+end.
+Abort.
--
cgit v1.2.3
From b89c8f3846e8254651dbcba262f83d3d1fe3adb6 Mon Sep 17 00:00:00 2001
From: Emilio Jesus Gallego Arias
Date: Sat, 10 Jun 2017 03:22:24 +0200
Subject: [toplevel] Print error header on fatal batch error.
---
toplevel/vernac.ml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/toplevel/vernac.ml b/toplevel/vernac.ml
index a61ade7849..f0c77875a5 100644
--- a/toplevel/vernac.ml
+++ b/toplevel/vernac.ml
@@ -111,7 +111,7 @@ let pr_open_cur_subgoals () =
with Proof_global.NoCurrentProof -> Pp.str ""
let vernac_error msg =
- Format.fprintf !Topfmt.err_ft "@[%a@]%!" Pp.pp_with msg;
+ Topfmt.std_logger Feedback.Error msg;
flush_all ();
exit 1
--
cgit v1.2.3
From 6e0855b5dc0fbebafa1e73f42993c94b2a47ae1c Mon Sep 17 00:00:00 2001
From: Matej Košík
Date: Thu, 8 Jun 2017 23:25:31 +0200
Subject: don't leak unqualified identifiers from the macro
---
grammar/argextend.mlp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/grammar/argextend.mlp b/grammar/argextend.mlp
index 36b9d612a0..8aecf0e0c8 100644
--- a/grammar/argextend.mlp
+++ b/grammar/argextend.mlp
@@ -178,7 +178,7 @@ let declare_vernac_argument loc s pr cl =
let se = mlexpr_of_string s in
let wit = <:expr< $lid:"wit_"^s$ >> in
let pr_rules = match pr with
- | None -> <:expr< fun _ _ _ _ -> str $str:"[No printer for "^s^"]"$ >>
+ | None -> <:expr< fun _ _ _ _ -> Pp.str $str:"[No printer for "^s^"]"$ >>
| Some pr -> <:expr< fun _ _ _ -> $lid:pr$ >> in
declare_str_items loc
[ <:str_item<
--
cgit v1.2.3
From 9a14a95f96c77ff3850d694637738358c164f4b5 Mon Sep 17 00:00:00 2001
From: Théo Zimmermann
Date: Thu, 8 Jun 2017 11:17:22 +0200
Subject: Normalize deprecation notices of ./configure
Always output a warning on stderr when a deprecated option is used.
---
.travis.yml | 2 +-
configure.ml | 39 ++++++++++++++++++++++++---------------
dev/doc/setup.txt | 8 +++-----
3 files changed, 28 insertions(+), 21 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index e794981245..13bdd6fb2c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -155,7 +155,7 @@ script:
- set -e
- echo 'Configuring Coq...' && echo -en 'travis_fold:start:coq.config\\r'
-- ./configure -local -usecamlp5 -native-compiler ${NATIVE_COMP} ${EXTRA_CONF}
+- ./configure -local -native-compiler ${NATIVE_COMP} ${EXTRA_CONF}
- echo -en 'travis_fold:end:coq.config\\r'
- echo 'Building Coq...' && echo -en 'travis_fold:start:coq.build\\r'
diff --git a/configure.ml b/configure.ml
index a5204d5b57..b2c027522a 100644
--- a/configure.ml
+++ b/configure.ml
@@ -301,33 +301,37 @@ let args_options = Arg.align [
"-emacslib", arg_string_option Prefs.emacslib,
"
Where to install emacs files";
"-emacs", Arg.String (fun s ->
- printf "Warning: obsolete -emacs option\n";
+ prerr_endline "Warning: -emacs option is deprecated. Use -emacslib instead.";
Prefs.emacslib := Some s),
- " Obsolete: same as -emacslib";
+ " Deprecated: same as -emacslib";
"-coqdocdir", arg_string_option Prefs.coqdocdir,
" Where to install Coqdoc style files";
"-ocamlfind", arg_string_option Prefs.ocamlfindcmd,
" Specifies the ocamlfind command to use";
"-lablgtkdir", arg_string_option Prefs.lablgtkdir,
" Specifies the path to the Lablgtk library";
- "-usecamlp5", Arg.Unit (fun () -> ()),
- "Deprecated";
+ "-usecamlp5", Arg.Unit (fun () ->
+ prerr_endline "Warning: -usecamlp5 option is deprecated. Camlp5 is already a required dependency."),
+ " Deprecated: Camlp5 is a required dependency (Camlp4 is not supported anymore)";
"-camlp5dir",
Arg.String (fun s -> Prefs.camlp5dir:=Some s),
" Specifies where is the Camlp5 library and tells to use it";
"-arch", arg_string_option Prefs.arch,
" Specifies the architecture";
- "-opt", Arg.Unit (fun () -> printf "Warning: obsolete -opt option\n"),
- " Obsolete: native OCaml executables detected automatically";
+ "-opt", Arg.Unit (fun () ->
+ prerr_endline "Warning: -opt option is deprecated. Native OCaml executables are detected automatically."),
+ " Deprecated: native OCaml executables detected automatically";
"-natdynlink", arg_bool Prefs.natdynlink,
"(yes|no) Use dynamic loading of native code or not";
"-coqide", Arg.String (fun s -> Prefs.coqide := Some (get_ide s)),
- "(opt|byte|no) Specifies whether or not to compile Coqide";
+ "(opt|byte|no) Specifies whether or not to compile CoqIDE";
"-nomacintegration", Arg.Clear Prefs.macintegration,
- " Do not try to build coqide mac integration";
+ " Do not try to build CoqIDE MacOS integration";
"-browser", arg_string_option Prefs.browser,
" Use to open URL %s";
- "-nodoc", Arg.Clear Prefs.withdoc,
+ "-nodoc", Arg.Unit (fun () ->
+ prerr_endline "Warning: -nodoc option is deprecated. Use -with-doc no instead.";
+ Prefs.withdoc := false),
" Deprecated: use -with-doc no instead";
"-with-doc", arg_bool Prefs.withdoc,
"(yes|no) Compile the documentation or not";
@@ -335,18 +339,23 @@ let args_options = Arg.align [
"(yes|no) Use Geoproof binding or not";
"-byte-only", Arg.Set Prefs.byteonly,
" Compiles only bytecode version of Coq";
- "-byteonly", Arg.Set Prefs.byteonly,
- " Compiles only bytecode version of Coq";
- "-debug", Arg.Set Prefs.debug,
- " Deprecated";
+ "-byteonly", Arg.Unit (fun () ->
+ prerr_endline "Warning: -byteonly option is deprecated. Use -byte-only instead.";
+ Prefs.byteonly := true),
+ " Deprecated: use -byte-only instead";
+ "-debug", Arg.Unit (fun () ->
+ prerr_endline "Warning: -debug option is deprecated. Coq is compiled in debug mode by default.";
+ Prefs.debug := true),
+ " Deprecated: Coq is compiled in debug mode by default";
"-nodebug", Arg.Clear Prefs.debug,
" Do not add debugging information in the Coq executables";
"-profile", Arg.Set Prefs.profile,
" Add profiling information in the Coq executables";
"-annotate", Arg.Set Prefs.annotate,
" Dumps ml annotation files while compiling Coq";
- "-makecmd", Arg.String (fun _ -> printf "Warning: obsolete -makecmd option\n"),
- " Obsolete: name of GNU Make command";
+ "-makecmd", Arg.String (fun _ ->
+ prerr_endline "Warning: -makecmd option is deprecated and doesn't have any effect."),
+ " Deprecated";
"-native-compiler", arg_bool Prefs.nativecompiler,
"(yes|no) Compilation to native code for conversion and normalization";
"-coqwebsite", Arg.Set_string Prefs.coqwebsite,
diff --git a/dev/doc/setup.txt b/dev/doc/setup.txt
index 1b016a4e26..0c6d3ee80d 100644
--- a/dev/doc/setup.txt
+++ b/dev/doc/setup.txt
@@ -12,7 +12,7 @@ How to compile Coq
Getting build dependencies:
- sudo apt-get install make opam git mercurial darcs
+ sudo apt-get install make opam git
opam init --comp 4.02.3
# Then follow the advice displayed at the end as how to update your ~/.bashrc and ~/.ocamlinit files.
@@ -41,7 +41,7 @@ Building coqtop:
cd ~/git/coq
git checkout trunk
make distclean
- ./configure -annotate -with-doc no -local -debug -usecamlp5
+ ./configure -annotate -local
make clean
make -j4 coqide printers
@@ -49,8 +49,6 @@ The "-annotate" option is essential when one wants to use Merlin.
The "-local" option is useful if one wants to run the coqtop and coqide binaries without running make install
-The "-debug" option is essential if one wants to use ocamldebug with the coqtop binary.
-
Then check if
- bin/coqtop
- bin/coqide
@@ -60,7 +58,7 @@ behave as expected.
A note about rlwrap
-------------------
-Running "coqtop" under "rlwrap" is possible, but there is a catch. If you try:
+Running "coqtop" under "rlwrap" is possible, but (on Debian) there is a catch. If you try:
cd ~/git/coq
rlwrap bin/coqtop
--
cgit v1.2.3
From cdceb6ac279196b04d3276cccdbbfce88bec2e4c Mon Sep 17 00:00:00 2001
From: Hugo Herbelin
Date: Sun, 11 Jun 2017 11:27:01 +0200
Subject: Fixing base_include after loc is an option (30d3515).
---
dev/base_include | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dev/base_include b/dev/base_include
index defea713d8..f9af0696b1 100644
--- a/dev/base_include
+++ b/dev/base_include
@@ -233,7 +233,7 @@ let pf_e gl s =
let _ = Flags.in_debugger := false
let _ = Flags.in_toplevel := true
let _ = Constrextern.set_extern_reference
- (fun loc _ r -> Libnames.Qualid (loc,Nametab.shortest_qualid_of_global Idset.empty r));;
+ (fun ?loc _ r -> Libnames.Qualid (loc,Nametab.shortest_qualid_of_global Idset.empty r));;
open Coqloop
let go = loop
--
cgit v1.2.3
From 7e0f61eb7cd16b2f2e58ce7ca18992fde7ac9aea Mon Sep 17 00:00:00 2001
From: Hugo Herbelin
Date: Sun, 11 Jun 2017 11:34:11 +0200
Subject: A stronger test that #use"include";; works well.
---
test-suite/misc/printers.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test-suite/misc/printers.sh b/test-suite/misc/printers.sh
index c822d0eb37..28e7dc362f 100755
--- a/test-suite/misc/printers.sh
+++ b/test-suite/misc/printers.sh
@@ -1,3 +1,3 @@
-printf "Drop. #use\"include\";; #quit;;\n" | $coqtopbyte 2>&1 | grep Unbound
+printf "Drop. #use\"include\";; #quit;;\n" | $coqtopbyte 2>&1 | egrep "Error|Unbound"
if [ $? = 0 ]; then exit 1; else exit 0; fi
--
cgit v1.2.3
From f610068823b33bdc0af752a646df05b98489d7ce Mon Sep 17 00:00:00 2001
From: Emilio Jesus Gallego Arias
Date: Sun, 11 Jun 2017 06:08:02 +0200
Subject: [proof] Deprecate redundant wrappers.
As we would like to reduce the role of proof_global in future
versions, we start to deprecate old compatibility aliases in `Pfedit`
in favor of the real functions underlying the 8.5 proof engine.
We also deprecate a couple of alias types and explicitly mark the few
remaining uses of `Pfedit`.
---
API/API.mli | 13 ++-
plugins/funind/functional_principles_types.ml | 8 +-
plugins/funind/indfun_common.ml | 4 +-
plugins/funind/recdef.ml | 2 +-
plugins/ltac/tacinterp.ml | 7 +-
printing/printer.ml | 3 +-
proofs/pfedit.ml | 63 ++++++-----
proofs/pfedit.mli | 157 ++++++++++++++------------
stm/stm.ml | 2 +-
tactics/hints.ml | 3 +-
tactics/tactics.ml | 11 +-
toplevel/coqloop.ml | 2 +-
toplevel/vernac.ml | 2 +-
vernac/command.ml | 4 +-
vernac/command.mli | 3 +-
vernac/lemmas.ml | 10 +-
vernac/lemmas.mli | 17 ++-
vernac/obligations.ml | 2 +-
vernac/vernacentries.ml | 43 ++++---
19 files changed, 188 insertions(+), 168 deletions(-)
diff --git a/API/API.mli b/API/API.mli
index d844e8bf52..f25dcccb82 100644
--- a/API/API.mli
+++ b/API/API.mli
@@ -3417,6 +3417,8 @@ sig
(** @raise NoCurrentProof when outside proof mode. *)
val discard_all : unit -> unit
+ val discard_current : unit -> unit
+ val get_current_proof_name : unit -> Names.Id.t
end
module Nametab :
@@ -3889,11 +3891,18 @@ sig
val solve : ?with_end_tac:unit Proofview.tactic ->
Vernacexpr.goal_selector -> int option -> unit Proofview.tactic ->
Proof.proof -> Proof.proof * bool
- val delete_current_proof : unit -> unit
val cook_proof :
unit -> (Names.Id.t * (Safe_typing.private_constants Entries.definition_entry * Proof_global.proof_universes * Decl_kinds.goal_kind))
- val get_current_proof_name : unit -> Names.Id.t
+
val get_current_context : unit -> Evd.evar_map * Environ.env
+
+ (* Deprecated *)
+ val delete_current_proof : unit -> unit
+ [@@ocaml.deprecated "use Proof_global.discard_current"]
+
+ val get_current_proof_name : unit -> Names.Id.t
+ [@@ocaml.deprecated "use Proof_global.get_current_proof_name"]
+
end
module Tactics :
diff --git a/plugins/funind/functional_principles_types.ml b/plugins/funind/functional_principles_types.ml
index fd4b52b65c..de5a5685b5 100644
--- a/plugins/funind/functional_principles_types.ml
+++ b/plugins/funind/functional_principles_types.ml
@@ -371,12 +371,12 @@ let generate_functional_principle (evd: Evd.evar_map ref)
begin
begin
try
- let id = Pfedit.get_current_proof_name () in
+ let id = Proof_global.get_current_proof_name () in
let s = Id.to_string id in
let n = String.length "___________princ_________" in
if String.length s >= n
then if String.equal (String.sub s 0 n) "___________princ_________"
- then Pfedit.delete_current_proof ()
+ then Proof_global.discard_current ()
else ()
else ()
with e when CErrors.noncritical e -> ()
@@ -524,12 +524,12 @@ let make_scheme evd (fas : (pconstant*glob_sort) list) : Safe_typing.private_con
begin
begin
try
- let id = Pfedit.get_current_proof_name () in
+ let id = Proof_global.get_current_proof_name () in
let s = Id.to_string id in
let n = String.length "___________princ_________" in
if String.length s >= n
then if String.equal (String.sub s 0 n) "___________princ_________"
- then Pfedit.delete_current_proof ()
+ then Proof_global.discard_current ()
else ()
else ()
with e when CErrors.noncritical e -> ()
diff --git a/plugins/funind/indfun_common.ml b/plugins/funind/indfun_common.ml
index 8f62231aeb..b824c3e293 100644
--- a/plugins/funind/indfun_common.ml
+++ b/plugins/funind/indfun_common.ml
@@ -161,7 +161,7 @@ let save with_clean id const (locality,_,kind) hook =
let kn = declare_constant id ~local (DefinitionEntry const, k) in
(locality, ConstRef kn)
in
- if with_clean then Pfedit.delete_current_proof ();
+ if with_clean then Proof_global.discard_current ();
CEphemeron.iter_opt hook (fun f -> Lemmas.call_hook fix_exn f l r);
definition_message id
@@ -173,7 +173,7 @@ let cook_proof _ =
let get_proof_clean do_reduce =
let result = cook_proof do_reduce in
- Pfedit.delete_current_proof ();
+ Proof_global.discard_current ();
result
let with_full_print f a =
diff --git a/plugins/funind/recdef.ml b/plugins/funind/recdef.ml
index bd74d2cf64..b1c69812dc 100644
--- a/plugins/funind/recdef.ml
+++ b/plugins/funind/recdef.ml
@@ -1295,7 +1295,7 @@ let is_opaque_constant c =
let open_new_goal build_proof sigma using_lemmas ref_ goal_name (gls_type,decompose_and_tac,nb_goal) =
(* Pp.msgnl (str "gls_type := " ++ Printer.pr_lconstr gls_type); *)
- let current_proof_name = get_current_proof_name () in
+ let current_proof_name = Proof_global.get_current_proof_name () in
let name = match goal_name with
| Some s -> s
| None ->
diff --git a/plugins/ltac/tacinterp.ml b/plugins/ltac/tacinterp.ml
index 85d3944b18..0688d60d41 100644
--- a/plugins/ltac/tacinterp.ml
+++ b/plugins/ltac/tacinterp.ml
@@ -22,7 +22,6 @@ open Nameops
open Libnames
open Globnames
open Nametab
-open Pfedit
open Refiner
open Tacmach.New
open Tactic_debug
@@ -629,7 +628,7 @@ let interp_gen kind ist pattern_mode flags env sigma c =
let constr_flags () = {
use_typeclasses = true;
solve_unification_constraints = true;
- use_hook = solve_by_implicit_tactic ();
+ use_hook = Pfedit.solve_by_implicit_tactic ();
fail_evar = true;
expand_evars = true }
@@ -644,14 +643,14 @@ let interp_type = interp_constr_gen IsType
let open_constr_use_classes_flags () = {
use_typeclasses = true;
solve_unification_constraints = true;
- use_hook = solve_by_implicit_tactic ();
+ use_hook = Pfedit.solve_by_implicit_tactic ();
fail_evar = false;
expand_evars = true }
let open_constr_no_classes_flags () = {
use_typeclasses = false;
solve_unification_constraints = true;
- use_hook = solve_by_implicit_tactic ();
+ use_hook = Pfedit.solve_by_implicit_tactic ();
fail_evar = false;
expand_evars = true }
diff --git a/printing/printer.ml b/printing/printer.ml
index 3c31dd96bf..d6f0778f75 100644
--- a/printing/printer.ml
+++ b/printing/printer.ml
@@ -17,7 +17,6 @@ open Nametab
open Evd
open Proof_type
open Refiner
-open Pfedit
open Constrextern
open Ppconstr
open Declarations
@@ -812,7 +811,7 @@ let pr_open_subgoals ?(proof=Proof_global.give_me_the_proof ()) () =
end
let pr_nth_open_subgoal n =
- let pf = get_pftreestate () in
+ let pf = Proof_global.give_me_the_proof () in
let { it=gls ; sigma=sigma } = Proof.V82.subgoals pf in
pr_subgoal n sigma gls
diff --git a/proofs/pfedit.ml b/proofs/pfedit.ml
index 3fb66d1b87..b28234a504 100644
--- a/proofs/pfedit.ml
+++ b/proofs/pfedit.ml
@@ -24,19 +24,6 @@ let _ = Goptions.declare_bool_option {
let use_unification_heuristics () = !use_unification_heuristics_ref
-let refining = Proof_global.there_are_pending_proofs
-let check_no_pending_proofs = Proof_global.check_no_pending_proof
-
-let get_current_proof_name = Proof_global.get_current_proof_name
-let get_all_proof_names = Proof_global.get_all_proof_names
-
-type lemma_possible_guards = Proof_global.lemma_possible_guards
-type universe_binders = Proof_global.universe_binders
-
-let delete_proof = Proof_global.discard
-let delete_current_proof = Proof_global.discard_current
-let delete_all_proofs = Proof_global.discard_all
-
let start_proof (id : Id.t) ?pl str sigma hyps c ?init_tac terminator =
let goals = [ (Global.env_of_context hyps , c) ] in
Proof_global.start_proof sigma id ?pl str goals terminator;
@@ -55,32 +42,20 @@ let cook_this_proof p =
let cook_proof () =
cook_this_proof (fst
(Proof_global.close_proof ~keep_body_ucst_separate:false (fun x -> x)))
-let get_pftreestate () =
- Proof_global.give_me_the_proof ()
-
-let set_end_tac tac =
- Proof_global.set_endline_tactic tac
-
-let set_used_variables l =
- Proof_global.set_used_variables l
-let get_used_variables () =
- Proof_global.get_used_variables ()
-
-let get_universe_binders () =
- Proof_global.get_universe_binders ()
exception NoSuchGoal
let _ = CErrors.register_handler begin function
| NoSuchGoal -> CErrors.user_err Pp.(str "No such goal.")
| _ -> raise CErrors.Unhandled
end
+
let get_nth_V82_goal i =
let p = Proof_global.give_me_the_proof () in
let { it=goals ; sigma = sigma; } = Proof.V82.subgoals p in
try
{ it=(List.nth goals (i-1)) ; sigma=sigma; }
with Failure _ -> raise NoSuchGoal
-
+
let get_goal_context_gen i =
let { it=goal ; sigma=sigma; } = get_nth_V82_goal i in
(sigma, Refiner.pf_env { it=goal ; sigma=sigma; })
@@ -106,7 +81,7 @@ let get_current_context () =
(Evd.from_env env, env)
| NoSuchGoal ->
(* No more focused goals ? *)
- let p = get_pftreestate () in
+ let p = Proof_global.give_me_the_proof () in
let evd = Proof.in_proof p (fun x -> x) in
(evd, Global.env ())
@@ -165,11 +140,11 @@ let build_constant_by_tactic id ctx sign ?(goal_kind = Global, false, Proof Theo
try
let status = by tac in
let _,(const,univs,_) = cook_proof () in
- delete_current_proof ();
+ Proof_global.discard_current ();
const, status, fst univs
with reraise ->
let reraise = CErrors.push reraise in
- delete_current_proof ();
+ Proof_global.discard_current ();
iraise reraise
let build_by_tactic ?(side_eff=true) env sigma ?(poly=false) typ tac =
@@ -257,4 +232,32 @@ let solve_by_implicit_tactic () = match !implicit_tactic with
| None -> None
| Some tac -> Some (apply_implicit_tactic tac)
+(** Deprecated functions *)
+let refining = Proof_global.there_are_pending_proofs
+let check_no_pending_proofs = Proof_global.check_no_pending_proof
+
+let get_current_proof_name = Proof_global.get_current_proof_name
+let get_all_proof_names = Proof_global.get_all_proof_names
+
+type lemma_possible_guards = Proof_global.lemma_possible_guards
+type universe_binders = Proof_global.universe_binders
+
+let delete_proof = Proof_global.discard
+let delete_current_proof = Proof_global.discard_current
+let delete_all_proofs = Proof_global.discard_all
+
+let get_pftreestate () =
+ Proof_global.give_me_the_proof ()
+
+let set_end_tac tac =
+ Proof_global.set_endline_tactic tac
+
+let set_used_variables l =
+ Proof_global.set_used_variables l
+
+let get_used_variables () =
+ Proof_global.get_used_variables ()
+
+let get_universe_binders () =
+ Proof_global.get_universe_binders ()
diff --git a/proofs/pfedit.mli b/proofs/pfedit.mli
index 1bf65b8aed..f009593e98 100644
--- a/proofs/pfedit.mli
+++ b/proofs/pfedit.mli
@@ -14,39 +14,6 @@ open Term
open Environ
open Decl_kinds
-(** Several proofs can be opened simultaneously but at most one is
- focused at some time. The following functions work by side-effect
- on current set of open proofs. In this module, ``proofs'' means an
- open proof (something started by vernacular command [Goal], [Lemma]
- or [Theorem]), and ``goal'' means a subgoal of the current focused
- proof *)
-
-(** {6 ... } *)
-(** [refining ()] tells if there is some proof in progress, even if a not
- focused one *)
-
-val refining : unit -> bool
-
-(** [check_no_pending_proofs ()] fails if there is still some proof in
- progress *)
-
-val check_no_pending_proofs : unit -> unit
-
-(** {6 ... } *)
-(** [delete_proof name] deletes proof of name [name] or fails if no proof
- has this name *)
-
-val delete_proof : Id.t located -> unit
-
-(** [delete_current_proof ()] deletes current focused proof or fails if
- no proof is focused *)
-
-val delete_current_proof : unit -> unit
-
-(** [delete_all_proofs ()] deletes all open proofs if any *)
-
-val delete_all_proofs : unit -> unit
-
(** {6 ... } *)
(** [start_proof s str env t hook tac] starts a proof of name [s] and
conclusion [t]; [hook] is optionally a function to be applied at
@@ -55,12 +22,8 @@ val delete_all_proofs : unit -> unit
systematically apply at initialization time (e.g. to start the
proof of mutually dependent theorems) *)
-type lemma_possible_guards = Proof_global.lemma_possible_guards
-
-type universe_binders = Id.t Loc.located list
-
val start_proof :
- Id.t -> ?pl:universe_binders -> goal_kind -> Evd.evar_map -> named_context_val -> EConstr.constr ->
+ Id.t -> ?pl:Proof_global.universe_binders -> goal_kind -> Evd.evar_map -> named_context_val -> EConstr.constr ->
?init_tac:unit Proofview.tactic ->
Proof_global.proof_terminator -> unit
@@ -80,11 +43,6 @@ val cook_proof : unit ->
(Safe_typing.private_constants Entries.definition_entry * Proof_global.proof_universes * goal_kind))
(** {6 ... } *)
-(** [get_pftreestate ()] returns the current focused pending proof.
- @raise NoCurrentProof if there is no pending proof. *)
-
-val get_pftreestate : unit -> Proof.proof
-
(** [get_goal_context n] returns the context of the [n]th subgoal of
the current focused proof or raises a [UserError] if there is no
focused proof or if there is no more subgoals *)
@@ -108,34 +66,6 @@ val get_current_context : unit -> Evd.evar_map * env
val current_proof_statement :
unit -> Id.t * goal_kind * EConstr.types
-(** {6 ... } *)
-(** [get_current_proof_name ()] return the name of the current focused
- proof or failed if no proof is focused *)
-
-val get_current_proof_name : unit -> Id.t
-
-(** [get_all_proof_names ()] returns the list of all pending proof names.
- The first name is the current proof, the other names may come in
- any order. *)
-
-val get_all_proof_names : unit -> Id.t list
-
-(** {6 ... } *)
-(** [set_end_tac tac] applies tactic [tac] to all subgoal generate
- by [solve] *)
-
-val set_end_tac : Genarg.glob_generic_argument -> unit
-
-(** {6 ... } *)
-(** [set_used_variables l] declares that section variables [l] will be
- used in the proof *)
-val set_used_variables :
- Id.t list -> Context.Named.t * Names.Id.t Loc.located list
-val get_used_variables : unit -> Context.Named.t option
-
-(** {6 Universe binders } *)
-val get_universe_binders : unit -> universe_binders option
-
(** {6 ... } *)
(** [solve (SelectNth n) tac] applies tactic [tac] to the [n]th
subgoal of the current focused proof or raises a [UserError] if no
@@ -191,3 +121,88 @@ val clear_implicit_tactic : unit -> unit
(* Raise Exit if cannot solve *)
val solve_by_implicit_tactic : unit -> Pretyping.inference_hook option
+
+(** {5 Deprecated functions in favor of [Proof_global]} *)
+
+(** {6 ... } *)
+(** Several proofs can be opened simultaneously but at most one is
+ focused at some time. The following functions work by side-effect
+ on current set of open proofs. In this module, ``proofs'' means an
+ open proof (something started by vernacular command [Goal], [Lemma]
+ or [Theorem]), and ``goal'' means a subgoal of the current focused
+ proof *)
+
+(** [refining ()] tells if there is some proof in progress, even if a not
+ focused one *)
+
+val refining : unit -> bool
+[@@ocaml.deprecated "use Proof_global.there_are_pending_proofs"]
+
+(** [check_no_pending_proofs ()] fails if there is still some proof in
+ progress *)
+
+val check_no_pending_proofs : unit -> unit
+[@@ocaml.deprecated "use Proof_global.check_no_pending_proofs"]
+
+(** {6 ... } *)
+(** [delete_proof name] deletes proof of name [name] or fails if no proof
+ has this name *)
+
+val delete_proof : Id.t located -> unit
+[@@ocaml.deprecated "use Proof_global.discard"]
+
+(** [delete_current_proof ()] deletes current focused proof or fails if
+ no proof is focused *)
+
+val delete_current_proof : unit -> unit
+[@@ocaml.deprecated "use Proof_global.discard_current"]
+
+(** [delete_all_proofs ()] deletes all open proofs if any *)
+val delete_all_proofs : unit -> unit
+[@@ocaml.deprecated "use Proof_global.discard_all"]
+
+(** [get_pftreestate ()] returns the current focused pending proof.
+ @raise NoCurrentProof if there is no pending proof. *)
+
+val get_pftreestate : unit -> Proof.proof
+[@@ocaml.deprecated "use Proof_global.give_me_the_proof"]
+
+(** {6 ... } *)
+(** [set_end_tac tac] applies tactic [tac] to all subgoal generate
+ by [solve] *)
+
+val set_end_tac : Genarg.glob_generic_argument -> unit
+[@@ocaml.deprecated "use Proof_global.set_endline_tactic"]
+
+(** {6 ... } *)
+(** [set_used_variables l] declares that section variables [l] will be
+ used in the proof *)
+val set_used_variables :
+ Id.t list -> Context.Named.t * Names.Id.t Loc.located list
+[@@ocaml.deprecated "use Proof_global.set_used_variables"]
+
+val get_used_variables : unit -> Context.Named.t option
+[@@ocaml.deprecated "use Proof_global.get_used_variables"]
+
+(** {6 Universe binders } *)
+val get_universe_binders : unit -> Proof_global.universe_binders option
+[@@ocaml.deprecated "use Proof_global.get_universe_binders"]
+
+(** {6 ... } *)
+(** [get_current_proof_name ()] return the name of the current focused
+ proof or failed if no proof is focused *)
+val get_current_proof_name : unit -> Id.t
+[@@ocaml.deprecated "use Proof_global.get_current_proof_name"]
+
+(** [get_all_proof_names ()] returns the list of all pending proof names.
+ The first name is the current proof, the other names may come in
+ any order. *)
+val get_all_proof_names : unit -> Id.t list
+[@@ocaml.deprecated "use Proof_global.get_all_proof_names"]
+
+type lemma_possible_guards = Proof_global.lemma_possible_guards
+[@@ocaml.deprecated "use Proof_global.lemma_possible_guards"]
+
+type universe_binders = Proof_global.universe_binders
+[@@ocaml.deprecated "use Proof_global.universe_binders"]
+
diff --git a/stm/stm.ml b/stm/stm.ml
index a79bf54267..1580b451d0 100644
--- a/stm/stm.ml
+++ b/stm/stm.ml
@@ -931,7 +931,7 @@ let show_script ?proof () =
try
let prf =
try match proof with
- | None -> Some (Pfedit.get_current_proof_name ())
+ | None -> Some (Proof_global.get_current_proof_name ())
| Some (p,_) -> Some (p.Proof_global.id)
with Proof_global.NoCurrentProof -> None
in
diff --git a/tactics/hints.ml b/tactics/hints.ml
index 773abb9f0c..681db5d08e 100644
--- a/tactics/hints.ml
+++ b/tactics/hints.ml
@@ -29,7 +29,6 @@ open Decl_kinds
open Pattern
open Patternops
open Clenv
-open Pfedit
open Tacred
open Printer
open Vernacexpr
@@ -1462,7 +1461,7 @@ let pr_hint_term sigma cl =
(* print all hints that apply to the concl of the current goal *)
let pr_applicable_hint () =
- let pts = get_pftreestate () in
+ let pts = Proof_global.give_me_the_proof () in
let glss = Proof.V82.subgoals pts in
match glss.Evd.it with
| [] -> CErrors.user_err Pp.(str "No focused goal.")
diff --git a/tactics/tactics.ml b/tactics/tactics.ml
index b553f316c2..7e560b1762 100644
--- a/tactics/tactics.ml
+++ b/tactics/tactics.ml
@@ -25,7 +25,6 @@ open Inductiveops
open Reductionops
open Globnames
open Evd
-open Pfedit
open Tacred
open Genredexpr
open Tacmach.New
@@ -543,7 +542,7 @@ end
let fix ido n = match ido with
| None ->
Proofview.Goal.enter begin fun gl ->
- let name = Pfedit.get_current_proof_name () in
+ let name = Proof_global.get_current_proof_name () in
let id = new_fresh_id [] name gl in
mutual_fix id n [] 0
end
@@ -594,7 +593,7 @@ end
let cofix ido = match ido with
| None ->
Proofview.Goal.enter begin fun gl ->
- let name = Pfedit.get_current_proof_name () in
+ let name = Proof_global.get_current_proof_name () in
let id = new_fresh_id [] name gl in
mutual_cofix id [] 0
end
@@ -1140,7 +1139,7 @@ let rec intros_move = function
let tactic_infer_flags with_evar = {
Pretyping.use_typeclasses = true;
Pretyping.solve_unification_constraints = true;
- Pretyping.use_hook = solve_by_implicit_tactic ();
+ Pretyping.use_hook = Pfedit.solve_by_implicit_tactic ();
Pretyping.fail_evar = not with_evar;
Pretyping.expand_evars = true }
@@ -5032,11 +5031,11 @@ let name_op_to_name name_op object_kind suffix =
let default_gk = (Global, false, object_kind) in
match name_op with
| Some s ->
- (try let _, gk, _ = current_proof_statement () in s, gk
+ (try let _, gk, _ = Pfedit.current_proof_statement () in s, gk
with NoCurrentProof -> s, default_gk)
| None ->
let name, gk =
- try let name, gk, _ = current_proof_statement () in name, gk
+ try let name, gk, _ = Pfedit.current_proof_statement () in name, gk
with NoCurrentProof -> anon_id, default_gk in
add_suffix name suffix, gk
diff --git a/toplevel/coqloop.ml b/toplevel/coqloop.ml
index 908786565e..0b0ef67176 100644
--- a/toplevel/coqloop.ml
+++ b/toplevel/coqloop.ml
@@ -187,7 +187,7 @@ end
from cycling. *)
let make_prompt () =
try
- (Names.Id.to_string (Pfedit.get_current_proof_name ())) ^ " < "
+ (Names.Id.to_string (Proof_global.get_current_proof_name ())) ^ " < "
with Proof_global.NoCurrentProof ->
"Coq < "
diff --git a/toplevel/vernac.ml b/toplevel/vernac.ml
index a61ade7849..d4146ace11 100644
--- a/toplevel/vernac.ml
+++ b/toplevel/vernac.ml
@@ -285,7 +285,7 @@ let ensure_exists f =
(* Compile a vernac file *)
let compile verbosely f =
let check_pending_proofs () =
- let pfs = Pfedit.get_all_proof_names () in
+ let pfs = Proof_global.get_all_proof_names () in
if not (List.is_empty pfs) then vernac_error (str "There are pending proofs")
in
match !Flags.compilation_mode with
diff --git a/vernac/command.ml b/vernac/command.ml
index b1425d7034..998e7803e1 100644
--- a/vernac/command.ml
+++ b/vernac/command.ml
@@ -187,7 +187,7 @@ let declare_definition ident (local, p, k) ce pl imps hook =
let () = definition_message ident in
let gr = VarRef ident in
let () = maybe_declare_manual_implicits false gr imps in
- let () = if Pfedit.refining () then
+ let () = if Proof_global.there_are_pending_proofs () then
warn_definition_not_visible ident
in
gr
@@ -233,7 +233,7 @@ match local with
let _ = declare_variable ident decl in
let () = assumption_message ident in
let () =
- if not !Flags.quiet && Pfedit.refining () then
+ if not !Flags.quiet && Proof_global.there_are_pending_proofs () then
Feedback.msg_info (str"Variable" ++ spc () ++ pr_id ident ++
strbrk " is not visible from current goals")
in
diff --git a/vernac/command.mli b/vernac/command.mli
index 9bbc2fdac1..2a52d9bcb5 100644
--- a/vernac/command.mli
+++ b/vernac/command.mli
@@ -15,7 +15,6 @@ open Vernacexpr
open Constrexpr
open Decl_kinds
open Redexpr
-open Pfedit
(** This file is about the interpretation of raw commands into typed
ones and top-level declaration of the main Gallina objects *)
@@ -151,7 +150,7 @@ val declare_fixpoint :
locality -> polymorphic ->
recursive_preentry * lident list option * Evd.evar_universe_context *
(Context.Rel.t * Impargs.manual_implicits * int option) list ->
- lemma_possible_guards -> decl_notation list -> unit
+ Proof_global.lemma_possible_guards -> decl_notation list -> unit
val declare_cofixpoint : locality -> polymorphic ->
recursive_preentry * lident list option * Evd.evar_universe_context *
diff --git a/vernac/lemmas.ml b/vernac/lemmas.ml
index 77e356eb2c..5bf419caf5 100644
--- a/vernac/lemmas.ml
+++ b/vernac/lemmas.ml
@@ -209,7 +209,7 @@ let compute_proof_name locality = function
user_err ?loc (pr_id id ++ str " already exists.");
id, pl
| None ->
- next_global_ident_away default_thm_id (Pfedit.get_all_proof_names ()), None
+ next_global_ident_away default_thm_id (Proof_global.get_all_proof_names ()), None
let save_remaining_recthms (locality,p,kind) norm ctx body opaq i ((id,pl),(t_i,(_,imps))) =
let t_i = norm t_i in
@@ -487,7 +487,7 @@ let save_proof ?proof = function
let sec_vars = if !keep_admitted_vars then const_entry_secctx else None in
Admitted(id, k, (sec_vars, pi2 k, (typ, ctx), None), universes)
| None ->
- let pftree = Pfedit.get_pftreestate () in
+ let pftree = Proof_global.give_me_the_proof () in
let id, k, typ = Pfedit.current_proof_statement () in
let typ = EConstr.Unsafe.to_constr typ in
let universes = Proof.initial_euctx pftree in
@@ -496,7 +496,7 @@ let save_proof ?proof = function
Proof_global.return_proof ~allow_partial:true () in
let sec_vars =
if not !keep_admitted_vars then None
- else match Pfedit.get_used_variables(), pproofs with
+ else match Proof_global.get_used_variables(), pproofs with
| Some _ as x, _ -> x
| None, (pproof, _) :: _ ->
let env = Global.env () in
@@ -504,7 +504,7 @@ let save_proof ?proof = function
let ids_def = Environ.global_vars_set env pproof in
Some (Environ.keep_hyps env (Idset.union ids_typ ids_def))
| _ -> None in
- let names = Pfedit.get_universe_binders () in
+ let names = Proof_global.get_universe_binders () in
let evd = Evd.from_ctx universes in
let binders, ctx = Evd.universe_context ?names evd in
Admitted(id,k,(sec_vars, pi2 k, (typ, ctx), None),
@@ -519,7 +519,7 @@ let save_proof ?proof = function
| Some proof -> proof
in
(* if the proof is given explicitly, nothing has to be deleted *)
- if Option.is_empty proof then Pfedit.delete_current_proof ();
+ if Option.is_empty proof then Proof_global.discard_current ();
Proof_global.(apply_terminator terminator (Proved (is_opaque,idopt,proof_obj)))
(* Miscellaneous *)
diff --git a/vernac/lemmas.mli b/vernac/lemmas.mli
index d06b8fd14b..a9c0d99f30 100644
--- a/vernac/lemmas.mli
+++ b/vernac/lemmas.mli
@@ -9,7 +9,6 @@
open Names
open Term
open Decl_kinds
-open Pfedit
type 'a declaration_hook
val mk_hook :
@@ -21,16 +20,16 @@ val call_hook :
(** A hook start_proof calls on the type of the definition being started *)
val set_start_hook : (EConstr.types -> unit) -> unit
-val start_proof : Id.t -> ?pl:universe_binders -> goal_kind -> Evd.evar_map ->
- ?terminator:(lemma_possible_guards -> unit declaration_hook -> Proof_global.proof_terminator) ->
+val start_proof : Id.t -> ?pl:Proof_global.universe_binders -> goal_kind -> Evd.evar_map ->
+ ?terminator:(Proof_global.lemma_possible_guards -> unit declaration_hook -> Proof_global.proof_terminator) ->
?sign:Environ.named_context_val -> EConstr.types ->
- ?init_tac:unit Proofview.tactic -> ?compute_guard:lemma_possible_guards ->
+ ?init_tac:unit Proofview.tactic -> ?compute_guard:Proof_global.lemma_possible_guards ->
unit declaration_hook -> unit
-val start_proof_univs : Id.t -> ?pl:universe_binders -> goal_kind -> Evd.evar_map ->
- ?terminator:(lemma_possible_guards -> (Evd.evar_universe_context option -> unit declaration_hook) -> Proof_global.proof_terminator) ->
+val start_proof_univs : Id.t -> ?pl:Proof_global.universe_binders -> goal_kind -> Evd.evar_map ->
+ ?terminator:(Proof_global.lemma_possible_guards -> (Evd.evar_universe_context option -> unit declaration_hook) -> Proof_global.proof_terminator) ->
?sign:Environ.named_context_val -> EConstr.types ->
- ?init_tac:unit Proofview.tactic -> ?compute_guard:lemma_possible_guards ->
+ ?init_tac:unit Proofview.tactic -> ?compute_guard:Proof_global.lemma_possible_guards ->
(Evd.evar_universe_context option -> unit declaration_hook) -> unit
val start_proof_com :
@@ -40,8 +39,8 @@ val start_proof_com :
val start_proof_with_initialization :
goal_kind -> Evd.evar_map ->
- (bool * lemma_possible_guards * unit Proofview.tactic list option) option ->
- ((Id.t (* name of thm *) * universe_binders option) *
+ (bool * Proof_global.lemma_possible_guards * unit Proofview.tactic list option) option ->
+ ((Id.t (* name of thm *) * Proof_global.universe_binders option) *
(types (* type of thm *) * (Name.t list (* names to pre-introduce *) * Impargs.manual_explicitation list))) list
-> int list option -> unit declaration_hook -> unit
diff --git a/vernac/obligations.ml b/vernac/obligations.ml
index 6dee95bc54..e03e9b8039 100644
--- a/vernac/obligations.ml
+++ b/vernac/obligations.ml
@@ -947,7 +947,7 @@ let rec solve_obligation prg num tac =
let hook ctx = Lemmas.mk_hook (obligation_hook prg obl num auto ctx) in
let () = Lemmas.start_proof_univs ~sign:prg.prg_sign obl.obl_name kind evd (EConstr.of_constr obl.obl_type) ~terminator hook in
let _ = Pfedit.by !default_tactic in
- Option.iter (fun tac -> Pfedit.set_end_tac tac) tac
+ Option.iter (fun tac -> Proof_global.set_endline_tactic tac) tac
and obligation (user_num, name, typ) tac =
let num = pred user_num in
diff --git a/vernac/vernacentries.ml b/vernac/vernacentries.ml
index ef16df5b75..5d1def7a4b 100644
--- a/vernac/vernacentries.ml
+++ b/vernac/vernacentries.ml
@@ -15,7 +15,6 @@ open Flags
open Names
open Nameops
open Term
-open Pfedit
open Tacmach
open Constrintern
open Prettyp
@@ -70,13 +69,13 @@ let show_thesis () = CErrors.anomaly (Pp.str "Show Thesis: TODO.")
let show_top_evars () =
(* spiwack: new as of Feb. 2010: shows goal evars in addition to non-goal evars. *)
- let pfts = get_pftreestate () in
+ let pfts = Proof_global.give_me_the_proof () in
let gls = Proof.V82.subgoals pfts in
let sigma = gls.Evd.sigma in
Feedback.msg_notice (pr_evars_int sigma 1 (Evarutil.non_instantiated sigma))
let show_universes () =
- let pfts = get_pftreestate () in
+ let pfts = Proof_global.give_me_the_proof () in
let gls = Proof.V82.subgoals pfts in
let sigma = gls.Evd.sigma in
let ctx = Evd.universe_context_set (Evd.nf_constraints sigma) in
@@ -89,7 +88,7 @@ let show_prooftree () = ()
(* Simulate the Intro(s) tactic *)
let show_intro all =
let open EConstr in
- let pf = get_pftreestate() in
+ let pf = Proof_global.give_me_the_proof() in
let {Evd.it=gls ; sigma=sigma; } = Proof.V82.subgoals pf in
if not (List.is_empty gls) then begin
let gl = {Evd.it=List.hd gls ; sigma = sigma; } in
@@ -508,7 +507,7 @@ let vernac_start_proof locality p kind l lettop =
match id with
| Some (lid,_) -> Dumpglob.dump_definition lid false "prf"
| None -> ()) l;
- if not(refining ()) then
+ if not(Proof_global.there_are_pending_proofs ()) then
if lettop then
user_err ~hdr:"Vernacentries.StartProof"
(str "Let declarations can only be used in proof editing mode.");
@@ -521,7 +520,7 @@ let vernac_end_proof ?proof = function
let vernac_exact_proof c =
(* spiwack: for simplicity I do not enforce that "Proof proof_term" is
called only at the begining of a proof. *)
- let status = by (Tactics.exact_proof c) in
+ let status = Pfedit.by (Tactics.exact_proof c) in
save_proof (Vernacexpr.(Proved(Opaque None,None)));
if not status then Feedback.feedback Feedback.AddedAxiom
@@ -667,7 +666,7 @@ let vernac_define_module export (loc, id) binders_ast mty_ast_o mexpr_ast_l =
user_err Pp.(str "Modules and Module Types are not allowed inside sections.");
match mexpr_ast_l with
| [] ->
- check_no_pending_proofs ();
+ Proof_global.check_no_pending_proof ();
let binders_ast,argsexport =
List.fold_right
(fun (export,idl,ty) (args,argsexport) ->
@@ -713,7 +712,7 @@ let vernac_declare_module_type (loc,id) binders_ast mty_sign mty_ast_l =
match mty_ast_l with
| [] ->
- check_no_pending_proofs ();
+ Proof_global.check_no_pending_proof ();
let binders_ast,argsexport =
List.fold_right
(fun (export,idl,ty) (args,argsexport) ->
@@ -761,7 +760,7 @@ let vernac_include l =
(* Sections *)
let vernac_begin_section (_, id as lid) =
- check_no_pending_proofs ();
+ Proof_global.check_no_pending_proof ();
Dumpglob.dump_definition lid true "sec";
Lib.open_section id
@@ -775,7 +774,7 @@ let vernac_name_sec_hyp (_,id) set = Proof_using.name_set id set
(* Dispatcher of the "End" command *)
let vernac_end_segment (_,id as lid) =
- check_no_pending_proofs ();
+ Proof_global.check_no_pending_proof ();
match Lib.find_opening_node id with
| Lib.OpenedModule (false,export,_,_) -> vernac_end_module export lid
| Lib.OpenedModule (true,_,_,_) -> vernac_end_modtype lid
@@ -855,14 +854,14 @@ let focus_command_cond = Proof.no_cond command_focus
there are no more goals to solve. It cannot be a tactic since
all tactics fail if there are no further goals to prove. *)
-let vernac_solve_existential = instantiate_nth_evar_com
+let vernac_solve_existential = Pfedit.instantiate_nth_evar_com
let vernac_set_end_tac tac =
let env = Genintern.empty_glob_sign (Global.env ()) in
let _, tac = Genintern.generic_intern env tac in
- if not (refining ()) then
+ if not (Proof_global.there_are_pending_proofs ()) then
user_err Pp.(str "Unknown command of the non proof-editing mode.");
- set_end_tac tac
+ Proof_global.set_endline_tactic tac
(* TO DO verifier s'il faut pas mettre exist s | TacId s ici*)
let vernac_set_used_variables e =
@@ -877,13 +876,13 @@ let vernac_set_used_variables e =
user_err ~hdr:"vernac_set_used_variables"
(str "Unknown variable: " ++ pr_id id))
l;
- let _, to_clear = set_used_variables l in
+ let _, to_clear = Proof_global.set_used_variables l in
let to_clear = List.map snd to_clear in
Proof_global.with_current_proof begin fun _ p ->
if List.is_empty to_clear then (p, ())
else
let tac = Tactics.clear to_clear in
- fst (solve SelectAll None tac p), ()
+ fst (Pfedit.solve SelectAll None tac p), ()
end
(*****************************)
@@ -927,12 +926,12 @@ let vernac_chdir = function
(* State management *)
let vernac_write_state file =
- Pfedit.delete_all_proofs ();
+ Proof_global.discard_all ();
let file = CUnix.make_suffix file ".coq" in
States.extern_state file
let vernac_restore_state file =
- Pfedit.delete_all_proofs ();
+ Proof_global.discard_all ();
let file = Loadpath.locate_file (CUnix.make_suffix file ".coq") in
States.intern_state file
@@ -1526,7 +1525,7 @@ let vernac_print_option key =
with Not_found -> error_undeclared_key key
let get_current_context_of_args = function
- | Some n -> get_goal_context n
+ | Some n -> Pfedit.get_goal_context n
| None -> get_current_context ()
let query_command_selector ?loc = function
@@ -1588,7 +1587,7 @@ let vernac_global_check c =
let get_nth_goal n =
- let pf = get_pftreestate() in
+ let pf = Proof_global.give_me_the_proof() in
let {Evd.it=gls ; sigma=sigma; } = Proof.V82.subgoals pf in
let gl = {Evd.it=List.nth gls (n-1) ; sigma = sigma; } in
gl
@@ -1777,7 +1776,7 @@ let vernac_locate = let open Feedback in function
| LocateFile f -> msg_notice (locate_file f)
let vernac_register id r =
- if Pfedit.refining () then
+ if Proof_global.there_are_pending_proofs () then
user_err Pp.(str "Cannot register a primitive while in proof editing mode.");
let kn = Constrintern.global_reference (snd id) in
if not (isConstRef kn) then
@@ -1854,14 +1853,14 @@ let vernac_show = let open Feedback in function
| ShowUniverses -> show_universes ()
| ShowTree -> show_prooftree ()
| ShowProofNames ->
- msg_notice (pr_sequence pr_id (Pfedit.get_all_proof_names()))
+ msg_notice (pr_sequence pr_id (Proof_global.get_all_proof_names()))
| ShowIntros all -> show_intro all
| ShowMatch id -> show_match id
| ShowThesis -> show_thesis ()
let vernac_check_guard () =
- let pts = get_pftreestate () in
+ let pts = Proof_global.give_me_the_proof () in
let pfterm = List.hd (Proof.partial_proof pts) in
let message =
try
--
cgit v1.2.3
From faa064c746e20a12b3c8f792f69537b18e387be6 Mon Sep 17 00:00:00 2001
From: Théo Zimmermann
Date: Mon, 12 Jun 2017 11:02:13 +0200
Subject: Remove Show Goal "uid" command.
Introduced for Proof-General but unused at the current time,
undocumented and can raise anomalies.
---
parsing/g_proofs.ml4 | 3 ---
1 file changed, 3 deletions(-)
diff --git a/parsing/g_proofs.ml4 b/parsing/g_proofs.ml4
index a3f9793bbd..e2d0aed73a 100644
--- a/parsing/g_proofs.ml4
+++ b/parsing/g_proofs.ml4
@@ -64,9 +64,6 @@ GEXTEND Gram
| IDENT "Show" -> VernacShow (ShowGoal OpenSubgoals)
| IDENT "Show"; n = natural -> VernacShow (ShowGoal (NthGoal n))
| IDENT "Show"; id = ident -> VernacShow (ShowGoal (GoalId id))
- | IDENT "Show"; IDENT "Goal" -> VernacShow (ShowGoal (GoalId (Names.Id.of_string "Goal")))
- | IDENT "Show"; IDENT "Goal"; n = string ->
- VernacShow (ShowGoal (GoalUid n))
| IDENT "Show"; IDENT "Implicit"; IDENT "Arguments"; n = OPT natural ->
VernacShow (ShowGoalImplicitly n)
| IDENT "Show"; IDENT "Node" -> VernacShow ShowNode
--
cgit v1.2.3
From 2253d2eb4f892f932332358be8537fdb5552ef87 Mon Sep 17 00:00:00 2001
From: Théo Zimmermann
Date: Mon, 12 Jun 2017 11:08:12 +0200
Subject: Remove Show Implicit Arguments command.
The command has been broken for 15 years. It is basically dead code.
Its former behavior can be mimicked with Set Printing Implicit. Show.
---
intf/vernacexpr.ml | 1 -
parsing/g_proofs.ml4 | 2 --
printing/ppvernac.ml | 1 -
vernac/vernacentries.ml | 4 ----
4 files changed, 8 deletions(-)
diff --git a/intf/vernacexpr.ml b/intf/vernacexpr.ml
index ab440c6b71..c928e0bbbf 100644
--- a/intf/vernacexpr.ml
+++ b/intf/vernacexpr.ml
@@ -96,7 +96,6 @@ type locatable =
type showable =
| ShowGoal of goal_reference
- | ShowGoalImplicitly of int option
| ShowProof
| ShowNode
| ShowScript
diff --git a/parsing/g_proofs.ml4 b/parsing/g_proofs.ml4
index e2d0aed73a..8c270d8024 100644
--- a/parsing/g_proofs.ml4
+++ b/parsing/g_proofs.ml4
@@ -64,8 +64,6 @@ GEXTEND Gram
| IDENT "Show" -> VernacShow (ShowGoal OpenSubgoals)
| IDENT "Show"; n = natural -> VernacShow (ShowGoal (NthGoal n))
| IDENT "Show"; id = ident -> VernacShow (ShowGoal (GoalId id))
- | IDENT "Show"; IDENT "Implicit"; IDENT "Arguments"; n = OPT natural ->
- VernacShow (ShowGoalImplicitly n)
| IDENT "Show"; IDENT "Node" -> VernacShow ShowNode
| IDENT "Show"; IDENT "Script" -> VernacShow ShowScript
| IDENT "Show"; IDENT "Existentials" -> VernacShow ShowExistentials
diff --git a/printing/ppvernac.ml b/printing/ppvernac.ml
index 781af47892..2633cdd6b5 100644
--- a/printing/ppvernac.ml
+++ b/printing/ppvernac.ml
@@ -561,7 +561,6 @@ open Decl_kinds
| GoalUid n -> spc () ++ str n in
let pr_showable = function
| ShowGoal n -> keyword "Show" ++ pr_goal_reference n
- | ShowGoalImplicitly n -> keyword "Show Implicit Arguments" ++ pr_opt int n
| ShowProof -> keyword "Show Proof"
| ShowNode -> keyword "Show Node"
| ShowScript -> keyword "Show Script"
diff --git a/vernac/vernacentries.ml b/vernac/vernacentries.ml
index ef16df5b75..c0272f2108 100644
--- a/vernac/vernacentries.ml
+++ b/vernac/vernacentries.ml
@@ -1844,10 +1844,6 @@ let vernac_show = let open Feedback in function
| GoalUid id -> pr_goal_by_uid id
in
msg_notice info
- | ShowGoalImplicitly None ->
- Constrextern.with_implicits msg_notice (pr_open_subgoals ())
- | ShowGoalImplicitly (Some n) ->
- Constrextern.with_implicits msg_notice (pr_nth_open_subgoal n)
| ShowProof -> show_proof ()
| ShowNode -> show_node ()
| ShowExistentials -> show_top_evars ()
--
cgit v1.2.3
From 76f97eac9e0b6eee76469b2a00a9c157caa3da8a Mon Sep 17 00:00:00 2001
From: Théo Zimmermann
Date: Mon, 12 Jun 2017 11:14:54 +0200
Subject: Remove more dead code (follow-up of previous commit).
---
interp/constrextern.ml | 3 ---
interp/constrextern.mli | 10 ----------
2 files changed, 13 deletions(-)
diff --git a/interp/constrextern.ml b/interp/constrextern.ml
index d254520e0e..668a2e6acd 100644
--- a/interp/constrextern.ml
+++ b/interp/constrextern.ml
@@ -74,9 +74,6 @@ let print_projections = ref false
let print_meta_as_hole = ref false
-let with_arguments f = Flags.with_option print_arguments f
-let with_implicits f = Flags.with_option print_implicits f
-let with_coercions f = Flags.with_option print_coercions f
let with_universes f = Flags.with_option print_universes f
let with_meta_as_hole f = Flags.with_option print_meta_as_hole f
let without_symbols f = Flags.with_option print_no_symbol f
diff --git a/interp/constrextern.mli b/interp/constrextern.mli
index ea627cff11..071898e16b 100644
--- a/interp/constrextern.mli
+++ b/interp/constrextern.mli
@@ -59,16 +59,6 @@ val set_extern_reference :
val get_extern_reference :
unit -> (?loc:Loc.t -> Id.Set.t -> global_reference -> reference)
-(** This governs printing of implicit arguments. If [with_implicits] is
- on and not [with_arguments] then implicit args are printed prefixed
- by "!"; if [with_implicits] and [with_arguments] are both on the
- function and not the arguments is prefixed by "!" *)
-val with_implicits : ('a -> 'b) -> 'a -> 'b
-val with_arguments : ('a -> 'b) -> 'a -> 'b
-
-(** This forces printing of coercions *)
-val with_coercions : ('a -> 'b) -> 'a -> 'b
-
(** This forces printing universe names of Type\{.\} *)
val with_universes : ('a -> 'b) -> 'a -> 'b
--
cgit v1.2.3
From 6cd14bf253f681d0465f8dce1d84a54a4f104d9c Mon Sep 17 00:00:00 2001
From: Théo Zimmermann
Date: Mon, 12 Jun 2017 11:22:38 +0200
Subject: Remove non-working Show Tree and Show Node commands.
---
intf/vernacexpr.ml | 2 --
parsing/g_proofs.ml4 | 2 --
printing/ppvernac.ml | 2 --
vernac/vernacentries.ml | 10 ----------
4 files changed, 16 deletions(-)
diff --git a/intf/vernacexpr.ml b/intf/vernacexpr.ml
index c928e0bbbf..b3b3327272 100644
--- a/intf/vernacexpr.ml
+++ b/intf/vernacexpr.ml
@@ -97,11 +97,9 @@ type locatable =
type showable =
| ShowGoal of goal_reference
| ShowProof
- | ShowNode
| ShowScript
| ShowExistentials
| ShowUniverses
- | ShowTree
| ShowProofNames
| ShowIntros of bool
| ShowMatch of reference
diff --git a/parsing/g_proofs.ml4 b/parsing/g_proofs.ml4
index 8c270d8024..b5eb2a1813 100644
--- a/parsing/g_proofs.ml4
+++ b/parsing/g_proofs.ml4
@@ -64,11 +64,9 @@ GEXTEND Gram
| IDENT "Show" -> VernacShow (ShowGoal OpenSubgoals)
| IDENT "Show"; n = natural -> VernacShow (ShowGoal (NthGoal n))
| IDENT "Show"; id = ident -> VernacShow (ShowGoal (GoalId id))
- | IDENT "Show"; IDENT "Node" -> VernacShow ShowNode
| IDENT "Show"; IDENT "Script" -> VernacShow ShowScript
| IDENT "Show"; IDENT "Existentials" -> VernacShow ShowExistentials
| IDENT "Show"; IDENT "Universes" -> VernacShow ShowUniverses
- | IDENT "Show"; IDENT "Tree" -> VernacShow ShowTree
| IDENT "Show"; IDENT "Conjectures" -> VernacShow ShowProofNames
| IDENT "Show"; IDENT "Proof" -> VernacShow ShowProof
| IDENT "Show"; IDENT "Intro" -> VernacShow (ShowIntros false)
diff --git a/printing/ppvernac.ml b/printing/ppvernac.ml
index 2633cdd6b5..81f41cba13 100644
--- a/printing/ppvernac.ml
+++ b/printing/ppvernac.ml
@@ -562,11 +562,9 @@ open Decl_kinds
let pr_showable = function
| ShowGoal n -> keyword "Show" ++ pr_goal_reference n
| ShowProof -> keyword "Show Proof"
- | ShowNode -> keyword "Show Node"
| ShowScript -> keyword "Show Script"
| ShowExistentials -> keyword "Show Existentials"
| ShowUniverses -> keyword "Show Universes"
- | ShowTree -> keyword "Show Tree"
| ShowProofNames -> keyword "Show Conjectures"
| ShowIntros b -> keyword "Show " ++ (if b then keyword "Intros" else keyword "Intro")
| ShowMatch id -> keyword "Show Match " ++ pr_reference id
diff --git a/vernac/vernacentries.ml b/vernac/vernacentries.ml
index c0272f2108..e0eeaf563b 100644
--- a/vernac/vernacentries.ml
+++ b/vernac/vernacentries.ml
@@ -61,11 +61,6 @@ let show_proof () =
let pprf = Proof.partial_proof p in
Feedback.msg_notice (Pp.prlist_with_sep Pp.fnl Printer.pr_econstr pprf)
-let show_node () =
- (* spiwack: I'm have little clue what this function used to do. I deactivated it,
- could, possibly, be cleaned away. (Feb. 2010) *)
- ()
-
let show_thesis () = CErrors.anomaly (Pp.str "Show Thesis: TODO.")
let show_top_evars () =
@@ -83,9 +78,6 @@ let show_universes () =
Feedback.msg_notice (Termops.pr_evar_universe_context (Evd.evar_universe_context sigma));
Feedback.msg_notice (str"Normalized constraints: " ++ Univ.pr_universe_context_set (Termops.pr_evd_level sigma) ctx)
-(* Spiwack: proof tree is currently not working *)
-let show_prooftree () = ()
-
(* Simulate the Intro(s) tactic *)
let show_intro all =
let open EConstr in
@@ -1845,10 +1837,8 @@ let vernac_show = let open Feedback in function
in
msg_notice info
| ShowProof -> show_proof ()
- | ShowNode -> show_node ()
| ShowExistentials -> show_top_evars ()
| ShowUniverses -> show_universes ()
- | ShowTree -> show_prooftree ()
| ShowProofNames ->
msg_notice (pr_sequence pr_id (Pfedit.get_all_proof_names()))
| ShowIntros all -> show_intro all
--
cgit v1.2.3
From 3813ba5229cf42597cd30a08e842e0832e5253cb Mon Sep 17 00:00:00 2001
From: Théo Zimmermann
Date: Mon, 12 Jun 2017 11:25:26 +0200
Subject: Remove Show Thesis command which was never implemented.
---
intf/vernacexpr.ml | 1 -
parsing/g_proofs.ml4 | 1 -
printing/ppvernac.ml | 1 -
vernac/vernacentries.ml | 4 ----
4 files changed, 7 deletions(-)
diff --git a/intf/vernacexpr.ml b/intf/vernacexpr.ml
index b3b3327272..cabd06735f 100644
--- a/intf/vernacexpr.ml
+++ b/intf/vernacexpr.ml
@@ -103,7 +103,6 @@ type showable =
| ShowProofNames
| ShowIntros of bool
| ShowMatch of reference
- | ShowThesis
type comment =
| CommentConstr of constr_expr
diff --git a/parsing/g_proofs.ml4 b/parsing/g_proofs.ml4
index b5eb2a1813..e96a68bc69 100644
--- a/parsing/g_proofs.ml4
+++ b/parsing/g_proofs.ml4
@@ -72,7 +72,6 @@ GEXTEND Gram
| IDENT "Show"; IDENT "Intro" -> VernacShow (ShowIntros false)
| IDENT "Show"; IDENT "Intros" -> VernacShow (ShowIntros true)
| IDENT "Show"; IDENT "Match"; id = reference -> VernacShow (ShowMatch id)
- | IDENT "Show"; IDENT "Thesis" -> VernacShow ShowThesis
| IDENT "Guarded" -> VernacCheckGuard
(* Hints for Auto and EAuto *)
| IDENT "Create"; IDENT "HintDb" ;
diff --git a/printing/ppvernac.ml b/printing/ppvernac.ml
index 81f41cba13..9d28bc4f84 100644
--- a/printing/ppvernac.ml
+++ b/printing/ppvernac.ml
@@ -568,7 +568,6 @@ open Decl_kinds
| ShowProofNames -> keyword "Show Conjectures"
| ShowIntros b -> keyword "Show " ++ (if b then keyword "Intros" else keyword "Intro")
| ShowMatch id -> keyword "Show Match " ++ pr_reference id
- | ShowThesis -> keyword "Show Thesis"
in
return (pr_showable s)
| VernacCheckGuard ->
diff --git a/vernac/vernacentries.ml b/vernac/vernacentries.ml
index e0eeaf563b..6830a5da1a 100644
--- a/vernac/vernacentries.ml
+++ b/vernac/vernacentries.ml
@@ -61,8 +61,6 @@ let show_proof () =
let pprf = Proof.partial_proof p in
Feedback.msg_notice (Pp.prlist_with_sep Pp.fnl Printer.pr_econstr pprf)
-let show_thesis () = CErrors.anomaly (Pp.str "Show Thesis: TODO.")
-
let show_top_evars () =
(* spiwack: new as of Feb. 2010: shows goal evars in addition to non-goal evars. *)
let pfts = get_pftreestate () in
@@ -1843,8 +1841,6 @@ let vernac_show = let open Feedback in function
msg_notice (pr_sequence pr_id (Pfedit.get_all_proof_names()))
| ShowIntros all -> show_intro all
| ShowMatch id -> show_match id
- | ShowThesis -> show_thesis ()
-
let vernac_check_guard () =
let pts = get_pftreestate () in
--
cgit v1.2.3
From b36448114c3853311e31f533657a4d4e78b2820c Mon Sep 17 00:00:00 2001
From: Théo Zimmermann
Date: Mon, 12 Jun 2017 12:38:05 +0200
Subject: Remove commented documentation for Show Tree.
---
doc/refman/RefMan-pro.tex | 16 ----------------
1 file changed, 16 deletions(-)
diff --git a/doc/refman/RefMan-pro.tex b/doc/refman/RefMan-pro.tex
index 0760d716e3..b66659dc8c 100644
--- a/doc/refman/RefMan-pro.tex
+++ b/doc/refman/RefMan-pro.tex
@@ -427,22 +427,6 @@ This command displays the current goals.
This tactics script may contain some holes (subgoals not yet proved).
They are printed under the form \verb!!.
-%% \item {\tt Show Tree.}\comindex{Show Tree}\\
-%% This command can be seen as a more structured way of
-%% displaying the state of the proof than that
-%% provided by {\tt Show Script}. Instead of just giving
-%% the list of tactics that have been applied, it
-%% shows the derivation tree constructed by then.
-%% Each node of the tree contains the conclusion
-%% of the corresponding sub-derivation (i.e. a
-%% goal with its corresponding local context) and
-%% the tactic that has generated all the
-%% sub-derivations. The leaves of this tree are
-%% the goals which still remain to be proved.
-
-%\item {\tt Show Node}\comindex{Show Node}\\
-% Not yet documented
-
\item {\tt Show Proof.}\comindex{Show Proof}\\
It displays the proof term generated by the
tactics that have been applied.
--
cgit v1.2.3
From 63896b2443e71e47c016fc9d0709cc22cf24f288 Mon Sep 17 00:00:00 2001
From: Emilio Jesus Gallego Arias
Date: Mon, 12 Jun 2017 12:37:55 +0200
Subject: [lib] Remove obsolete state-management function add_frozen_state
AFAICS this function predates modern state-handling; nowadays
summaries are stored by the STM and nobody were using this
information.
---
API/API.mli | 1 -
library/declaremods.ml | 7 +------
library/lib.ml | 13 ++-----------
library/lib.mli | 5 -----
library/library.ml | 2 +-
printing/prettyp.ml | 2 --
vernac/vernacentries.ml | 3 +--
7 files changed, 5 insertions(+), 28 deletions(-)
diff --git a/API/API.mli b/API/API.mli
index d844e8bf52..0b5183947b 100644
--- a/API/API.mli
+++ b/API/API.mli
@@ -2634,7 +2634,6 @@ module Lib : sig
| ClosedModule of library_segment
| OpenedSection of Libnames.object_prefix * Summary.frozen
| ClosedSection of library_segment
- | FrozenState of Summary.frozen
and library_segment = (Libnames.object_name * node) list
diff --git a/library/declaremods.ml b/library/declaremods.ml
index c98d4a7f31..187b749b87 100644
--- a/library/declaremods.ml
+++ b/library/declaremods.ml
@@ -589,7 +589,6 @@ let start_module interp_modast export id args res fs =
openmod_info := { cur_typ = res_entry_o; cur_typs = subtyps };
let prefix = Lib.start_module export id mp fs in
Nametab.push_dir (Nametab.Until 1) (fst prefix) (DirOpenModule prefix);
- Lib.add_frozen_state ();
if_xml (Hook.get f_xml_start_module) mp;
mp
@@ -629,7 +628,6 @@ let end_module () =
assert (eq_full_path (fst newoname) (fst oldoname));
assert (ModPath.equal (mp_of_kn (snd newoname)) mp);
- Lib.add_frozen_state () (* to prevent recaching *);
if_xml (Hook.get f_xml_end_module) mp;
mp
@@ -701,7 +699,6 @@ let start_modtype interp_modast id args mtys fs =
openmodtype_info := sub_mty_l;
let prefix = Lib.start_modtype id mp fs in
Nametab.push_dir (Nametab.Until 1) (fst prefix) (DirOpenModtype prefix);
- Lib.add_frozen_state ();
if_xml (Hook.get f_xml_start_module_type) mp;
mp
@@ -719,7 +716,6 @@ let end_modtype () =
assert (eq_full_path (fst oname) (fst oldoname));
assert (ModPath.equal (mp_of_kn (snd oname)) mp);
- Lib.add_frozen_state ()(* to prevent recaching *);
if_xml (Hook.get f_xml_end_module_type) mp;
mp
@@ -894,8 +890,7 @@ let get_library_native_symbols dir =
let start_library dir =
let mp = Global.start_library dir in
openmod_info := default_module_info;
- Lib.start_compilation dir mp;
- Lib.add_frozen_state ()
+ Lib.start_compilation dir mp
let end_library_hook = ref ignore
let append_end_library_hook f =
diff --git a/library/lib.ml b/library/lib.ml
index 9d71a854f0..f22f53eadf 100644
--- a/library/lib.ml
+++ b/library/lib.ml
@@ -27,7 +27,6 @@ type node =
| ClosedModule of library_segment
| OpenedSection of object_prefix * Summary.frozen
| ClosedSection of library_segment
- | FrozenState of Summary.frozen
and library_entry = object_name * node
@@ -80,7 +79,6 @@ let classify_segment seg =
| (_,OpenedModule (ty,_,_,_)) :: _ ->
user_err ~hdr:"Lib.classify_segment"
(str "there are still opened " ++ str (module_kind ty) ++ str "s")
- | (_,FrozenState _) :: stk -> clean acc stk
in
clean ([],[],[]) (List.rev seg)
@@ -254,10 +252,6 @@ let add_anonymous_leaf ?(cache_first = true) obj =
cache_object (oname,obj)
end
-let add_frozen_state () =
- add_anonymous_entry
- (FrozenState (Summary.freeze_summaries ~marshallable:`No))
-
(* Modules. *)
let is_opening_node = function
@@ -544,7 +538,6 @@ let discharge_item ((sp,_ as oname),e) =
match e with
| Leaf lobj ->
Option.map (fun o -> (basename sp,o)) (discharge_object (oname,lobj))
- | FrozenState _ -> None
| ClosedSection _ | ClosedModule _ -> None
| OpenedSection _ | OpenedModule _ | CompilingLibrary _ ->
anomaly (Pp.str "discharge_item.")
@@ -585,8 +578,7 @@ let freeze ~marshallable =
| n, ClosedModule _ -> Some (n,ClosedModule [])
| n, OpenedSection (op, _) ->
Some(n,OpenedSection(op,Summary.empty_frozen))
- | n, ClosedSection _ -> Some (n,ClosedSection [])
- | _, FrozenState _ -> None)
+ | n, ClosedSection _ -> Some (n,ClosedSection []))
!lib_state.lib_stk in
{ !lib_state with lib_stk }
| _ ->
@@ -596,8 +588,7 @@ let unfreeze st = lib_state := st
let init () =
unfreeze initial_lib_state;
- Summary.init_summaries ();
- add_frozen_state () (* Stores e.g. the keywords declared in g_*.ml4 *)
+ Summary.init_summaries ()
(* Misc *)
diff --git a/library/lib.mli b/library/lib.mli
index 9f9d8c7e5f..f47d6e1a58 100644
--- a/library/lib.mli
+++ b/library/lib.mli
@@ -23,7 +23,6 @@ type node =
| ClosedModule of library_segment
| OpenedSection of Libnames.object_prefix * Summary.frozen
| ClosedSection of library_segment
- | FrozenState of Summary.frozen
and library_segment = (Libnames.object_name * node) list
@@ -61,8 +60,6 @@ val pull_to_head : Libnames.object_name -> unit
for each of them *)
val add_leaves : Names.Id.t -> Libobject.obj list -> Libnames.object_name
-val add_frozen_state : unit -> unit
-
(** {6 ... } *)
(** The function [contents] gives access to the current entire segment *)
@@ -123,8 +120,6 @@ val end_modtype :
Libnames.object_name * Libnames.object_prefix *
Summary.frozen * library_segment
-(** [Lib.add_frozen_state] must be called after each of the above functions *)
-
(** {6 Compilation units } *)
val start_compilation : Names.DirPath.t -> Names.module_path -> unit
diff --git a/library/library.ml b/library/library.ml
index 5a5f99cc51..db05ad2b7b 100644
--- a/library/library.ml
+++ b/library/library.ml
@@ -575,7 +575,7 @@ let require_library_from_dirpath modrefl export =
else
add_anonymous_leaf (in_require (needed,modrefl,export));
if !Flags.xml_export then List.iter (Hook.get f_xml_require) modrefl;
- add_frozen_state ()
+ ()
(* the function called by Vernacentries.vernac_import *)
diff --git a/printing/prettyp.ml b/printing/prettyp.ml
index 2b21b3f9e8..3ae7da8fc1 100644
--- a/printing/prettyp.ml
+++ b/printing/prettyp.ml
@@ -587,8 +587,6 @@ let gallina_print_library_entry with_values ent =
Some (str " >>>>>>> Module " ++ pr_name oname)
| (oname,Lib.ClosedModule _) ->
Some (str " >>>>>>> Closed Module " ++ pr_name oname)
- | (_,Lib.FrozenState _) ->
- None
let gallina_print_context with_values =
let rec prec n = function
diff --git a/vernac/vernacentries.ml b/vernac/vernacentries.ml
index ef16df5b75..338e7c06e3 100644
--- a/vernac/vernacentries.ml
+++ b/vernac/vernacentries.ml
@@ -639,8 +639,7 @@ let vernac_constraint loc poly l =
(* Modules *)
let vernac_import export refl =
- Library.import_module export (List.map qualid_of_reference refl);
- Lib.add_frozen_state ()
+ Library.import_module export (List.map qualid_of_reference refl)
let vernac_declare_module export (loc, id) binders_ast mty_ast =
(* We check the state of the system (in section, in module type)
--
cgit v1.2.3
From 83a3abfa7de680f1a3279710e8f84721c32b7668 Mon Sep 17 00:00:00 2001
From: Pierre Letouzey
Date: Tue, 23 May 2017 16:33:14 +0200
Subject: zify: confusion between Pos2Z.inj_sub and Pos2Z.inj_sub_max (fix
#5336)
---
plugins/omega/PreOmega.v | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/plugins/omega/PreOmega.v b/plugins/omega/PreOmega.v
index 6c0e2d776d..d301217fa6 100644
--- a/plugins/omega/PreOmega.v
+++ b/plugins/omega/PreOmega.v
@@ -264,8 +264,8 @@ Ltac zify_positive_op :=
| |- context [ Zpos (Pos.max ?a ?b) ] => rewrite (Pos2Z.inj_max a b)
(* Pos.sub -> Z.max 1 (Z.sub ... ...) *)
- | H : context [ Zpos (Pos.sub ?a ?b) ] |- _ => rewrite (Pos2Z.inj_sub a b) in H
- | |- context [ Zpos (Pos.sub ?a ?b) ] => rewrite (Pos2Z.inj_sub a b)
+ | H : context [ Zpos (Pos.sub ?a ?b) ] |- _ => rewrite (Pos2Z.inj_sub_max a b) in H
+ | |- context [ Zpos (Pos.sub ?a ?b) ] => rewrite (Pos2Z.inj_sub_max a b)
(* Pos.succ -> Z.succ *)
| H : context [ Zpos (Pos.succ ?a) ] |- _ => rewrite (Pos2Z.inj_succ a) in H
--
cgit v1.2.3
From 1fe90249916bcce13aa39f36aa39f90b0f98bf50 Mon Sep 17 00:00:00 2001
From: Pierre Letouzey
Date: Wed, 24 May 2017 10:31:30 +0200
Subject: zify: force reduction of (Z.max 0 0) and similar (fix #5439)
Turn some "simpl" into "compute". Also do the same for the few
"simpl (Z.of_nat ...)". This way, definition like Z.max are properly
reduced, and moreover zify isn't sensible anymore to the
"Arguments Z.of_nat : simpl never" that some user want (see also #5039).
Unfortunately, the compute we're using now still honor the "Opaque"
declarations, so a "Opaque Z.max" will block things again (see also #5374).
---
plugins/omega/PreOmega.v | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/plugins/omega/PreOmega.v b/plugins/omega/PreOmega.v
index d301217fa6..2780be4aaa 100644
--- a/plugins/omega/PreOmega.v
+++ b/plugins/omega/PreOmega.v
@@ -48,10 +48,13 @@ Ltac zify_unop_var_or_term t thm a :=
(remember a as za; zify_unop_core t thm za).
Ltac zify_unop t thm a :=
- (* if a is a scalar, we can simply reduce the unop *)
+ (* If a is a scalar, we can simply reduce the unop. *)
+ (* Note that simpl wasn't enough to reduce [Z.max 0 0] (#5439) *)
let isz := isZcst a in
match isz with
- | true => simpl (t a) in *
+ | true =>
+ let u := eval compute in (t a) in
+ change (t a) with u in *
| _ => zify_unop_var_or_term t thm a
end.
@@ -165,14 +168,16 @@ Ltac zify_nat_op :=
rewrite (Nat2Z.inj_mul a b) in *
(* O -> Z0 *)
- | H : context [ Z.of_nat O ] |- _ => simpl (Z.of_nat O) in H
- | |- context [ Z.of_nat O ] => simpl (Z.of_nat O)
+ | H : context [ Z.of_nat O ] |- _ => change (Z.of_nat O) with Z0 in H
+ | |- context [ Z.of_nat O ] => change (Z.of_nat O) with Z0
(* S -> number or Z.succ *)
| H : context [ Z.of_nat (S ?a) ] |- _ =>
let isnat := isnatcst a in
match isnat with
- | true => simpl (Z.of_nat (S a)) in H
+ | true =>
+ let t := eval compute in (Z.of_nat (S a)) in
+ change (Z.of_nat (S a)) with t in H
| _ => rewrite (Nat2Z.inj_succ a) in H
| _ => (* if the [rewrite] fails (most likely a dependent occurence of [Z.of_nat (S a)]),
hide [Z.of_nat (S a)] in this one hypothesis *)
@@ -181,7 +186,9 @@ Ltac zify_nat_op :=
| |- context [ Z.of_nat (S ?a) ] =>
let isnat := isnatcst a in
match isnat with
- | true => simpl (Z.of_nat (S a))
+ | true =>
+ let t := eval compute in (Z.of_nat (S a)) in
+ change (Z.of_nat (S a)) with t
| _ => rewrite (Nat2Z.inj_succ a)
| _ => (* if the [rewrite] fails (most likely a dependent occurence of [Z.of_nat (S a)]),
hide [Z.of_nat (S a)] in the goal *)
--
cgit v1.2.3
From 649cc52200303abe4559d4c501c8aca06eed7591 Mon Sep 17 00:00:00 2001
From: Jason Gross
Date: Mon, 12 Jun 2017 12:07:34 -0400
Subject: [travis overlay] Partially Revert 013c0232953f1f58
I've pushed commits which add `-bypass-API` to bedrock in the proper way, so these overlays are no longer needed---
dev/ci/ci-basic-overlay.sh | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/dev/ci/ci-basic-overlay.sh b/dev/ci/ci-basic-overlay.sh
index 7a9df93c45..03cf0a9d14 100644
--- a/dev/ci/ci-basic-overlay.sh
+++ b/dev/ci/ci-basic-overlay.sh
@@ -97,14 +97,14 @@
########################################################################
# bedrock_src
########################################################################
-: ${bedrock_src_CI_BRANCH:=trunk__API}
-: ${bedrock_src_CI_GITURL:=https://github.com/matejkosik/bedrock.git}
+: ${bedrock_src_CI_BRANCH:=master}
+: ${bedrock_src_CI_GITURL:=https://github.com/mit-plv/bedrock.git}
########################################################################
# bedrock_facade
########################################################################
-: ${bedrock_facade_CI_BRANCH:=trunk__API}
-: ${bedrock_facade_CI_GITURL:=https://github.com/matejkosik/bedrock.git}
+: ${bedrock_facade_CI_BRANCH:=master}
+: ${bedrock_facade_CI_GITURL:=https://github.com/mit-plv/bedrock.git}
########################################################################
# formal-topology
--
cgit v1.2.3
From 6332f43dfee3efc890c5f8fdc1b5b54942c16307 Mon Sep 17 00:00:00 2001
From: Pierre-Marie Pédrot
Date: Tue, 9 May 2017 09:55:40 +0200
Subject: Explicit the unsafe flag of all calls to Refine.refine.
---
plugins/cc/cctac.ml | 2 +-
plugins/omega/coq_omega.ml | 4 ++--
tactics/inv.ml | 2 +-
tactics/tactics.ml | 16 ++++++++--------
vernac/classes.ml | 2 +-
5 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/plugins/cc/cctac.ml b/plugins/cc/cctac.ml
index 1ce1660b32..4f4e9a8518 100644
--- a/plugins/cc/cctac.ml
+++ b/plugins/cc/cctac.ml
@@ -255,7 +255,7 @@ let app_global_with_holes f args n =
Tacticals.New.pf_constr_of_global (Lazy.force f) >>= fun fc ->
let env = Proofview.Goal.env gl in
let concl = Proofview.Goal.concl gl in
- Refine.refine begin fun sigma ->
+ Refine.refine ~unsafe:true begin fun sigma ->
let t = Tacmach.New.pf_get_type_of gl fc in
let t = Termops.prod_applist sigma t (Array.to_list args) in
let ans = mkApp (fc, args) in
diff --git a/plugins/omega/coq_omega.ml b/plugins/omega/coq_omega.ml
index 9cb94b68df..fb03948ba1 100644
--- a/plugins/omega/coq_omega.ml
+++ b/plugins/omega/coq_omega.ml
@@ -652,7 +652,7 @@ let clever_rewrite_base_poly typ p result theorem =
let full = pf_concl gl in
let env = pf_env gl in
let (abstracted,occ) = abstract_path (project gl) typ (List.rev p) full in
- Refine.refine begin fun sigma ->
+ Refine.refine ~unsafe:true begin fun sigma ->
let t =
applist
(mkLambda
@@ -688,7 +688,7 @@ let clever_rewrite_gen_nat p result (t,args) =
(** Solve using the term the term [t _] *)
let refine_app gl t =
let open Tacmach.New in
- Refine.refine begin fun sigma ->
+ Refine.refine ~unsafe:true begin fun sigma ->
let env = pf_env gl in
let ht = match EConstr.kind sigma (pf_get_type_of gl t) with
| Prod (_, t, _) -> t
diff --git a/tactics/inv.ml b/tactics/inv.ml
index ec038f638e..425b88ee7e 100644
--- a/tactics/inv.ml
+++ b/tactics/inv.ml
@@ -460,7 +460,7 @@ let raw_inversion inv_kind id status names =
in
let refined id =
let prf = mkApp (mkVar id, args) in
- Refine.refine (fun h -> (h, prf))
+ Refine.refine ~unsafe:true (fun h -> (h, prf))
in
let neqns = List.length realargs in
let as_mode = names != None in
diff --git a/tactics/tactics.ml b/tactics/tactics.ml
index b553f316c2..9f03191cff 100644
--- a/tactics/tactics.ml
+++ b/tactics/tactics.ml
@@ -527,7 +527,7 @@ let mutual_fix f n rest j = Proofview.Goal.enter begin fun gl ->
mk_sign (push_named_context_val (LocalAssum (f, ar)) sign) oth
in
let nenv = reset_with_named_context (mk_sign (named_context_val env) all) env in
- Refine.refine begin fun sigma ->
+ Refine.refine ~unsafe:true begin fun sigma ->
let (sigma, evs) = mk_holes nenv sigma (List.map pi3 all) in
let ids = List.map pi1 all in
let evs = List.map (Vars.subst_vars (List.rev ids)) evs in
@@ -579,7 +579,7 @@ let mutual_cofix f others j = Proofview.Goal.enter begin fun gl ->
mk_sign (push_named_context_val (LocalAssum (f, ar)) sign) oth
in
let nenv = reset_with_named_context (mk_sign (named_context_val env) all) env in
- Refine.refine begin fun sigma ->
+ Refine.refine ~unsafe:true begin fun sigma ->
let (ids, types) = List.split all in
let (sigma, evs) = mk_holes nenv sigma types in
let evs = List.map (Vars.subst_vars (List.rev ids)) evs in
@@ -1914,7 +1914,7 @@ let cut_and_apply c =
| Prod (_,c1,c2) when Vars.noccurn sigma 1 c2 ->
let concl = Proofview.Goal.concl gl in
let env = Tacmach.New.pf_env gl in
- Refine.refine begin fun sigma ->
+ Refine.refine ~unsafe:true begin fun sigma ->
let typ = mkProd (Anonymous, c2, concl) in
let (sigma, f) = Evarutil.new_evar env sigma typ in
let (sigma, x) = Evarutil.new_evar env sigma c1 in
@@ -1959,7 +1959,7 @@ let native_cast_no_check c = cast_no_check Term.NATIVEcast c
let exact_proof c =
let open Tacmach.New in
Proofview.Goal.enter begin fun gl ->
- Refine.refine begin fun sigma ->
+ Refine.refine ~unsafe:true begin fun sigma ->
let (c, ctx) = Constrintern.interp_casted_constr (pf_env gl) sigma c (pf_concl gl) in
let c = EConstr.of_constr c in
let sigma = Evd.merge_universe_context sigma ctx in
@@ -2128,7 +2128,7 @@ let apply_type newcl args =
Proofview.Goal.enter begin fun gl ->
let env = Proofview.Goal.env gl in
let store = Proofview.Goal.extra gl in
- Refine.refine begin fun sigma ->
+ Refine.refine ~unsafe:true begin fun sigma ->
let newcl = nf_betaiota sigma newcl (* As in former Logic.refine *) in
let (sigma, ev) =
Evarutil.new_evar env sigma ~principal:true ~store newcl in
@@ -2149,7 +2149,7 @@ let bring_hyps hyps =
let concl = Tacmach.New.pf_concl gl in
let newcl = List.fold_right mkNamedProd_or_LetIn hyps concl in
let args = Array.of_list (Context.Named.to_instance mkVar hyps) in
- Refine.refine begin fun sigma ->
+ Refine.refine ~unsafe:true begin fun sigma ->
let (sigma, ev) =
Evarutil.new_evar env sigma ~principal:true ~store newcl in
(sigma, mkApp (ev, args))
@@ -2888,7 +2888,7 @@ let new_generalize_gen_let lconstr =
0 lconstr (concl, sigma, [])
in
Proofview.tclTHEN (Proofview.Unsafe.tclEVARS sigma)
- (Refine.refine begin fun sigma ->
+ (Refine.refine ~unsafe:true begin fun sigma ->
let (sigma, ev) = Evarutil.new_evar env sigma ~principal:true newcl in
(sigma, applist (ev, args))
end)
@@ -3598,7 +3598,7 @@ let mk_term_eq homogeneous env sigma ty t ty' t' =
let make_abstract_generalize env id typ concl dep ctx body c eqs args refls =
let open Context.Rel.Declaration in
- Refine.refine begin fun sigma ->
+ Refine.refine ~unsafe:true begin fun sigma ->
let eqslen = List.length eqs in
(* Abstract by the "generalized" hypothesis equality proof if necessary. *)
let sigma, abshypeq, abshypt =
diff --git a/vernac/classes.ml b/vernac/classes.ml
index 8e6a0f6a72..3cd0a8de85 100644
--- a/vernac/classes.ml
+++ b/vernac/classes.ml
@@ -341,7 +341,7 @@ let new_instance ?(abstract=false) ?(global=false) ?(refine= !refine_instance) p
if not (Option.is_empty term) then
let init_refine =
Tacticals.New.tclTHENLIST [
- Refine.refine (fun evm -> (evm,EConstr.of_constr (Option.get term)));
+ Refine.refine ~unsafe:true (fun evm -> (evm,EConstr.of_constr (Option.get term)));
Proofview.Unsafe.tclNEWGOALS gls;
Tactics.New.reduce_after_refine;
]
--
cgit v1.2.3
From 22ca6b0d70bb8b49aaa420f844c75592e5781c21 Mon Sep 17 00:00:00 2001
From: Pierre-Marie Pédrot
Date: Tue, 9 May 2017 10:03:37 +0200
Subject: Turn the default behaviour of the refine primitive into the safe one.
---
proofs/refine.ml | 6 +++---
proofs/refine.mli | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/proofs/refine.ml b/proofs/refine.ml
index caa6b9fb30..eab053f3a3 100644
--- a/proofs/refine.ml
+++ b/proofs/refine.ml
@@ -69,7 +69,7 @@ let add_side_effect env = function
let add_side_effects env effects =
List.fold_left (fun env eff -> add_side_effect env eff) env effects
-let generic_refine ?(unsafe = true) f gl =
+let generic_refine ?(unsafe = false) f gl =
let gl = Proofview.Goal.assume gl in
let sigma = Proofview.Goal.sigma gl in
let env = Proofview.Goal.env gl in
@@ -134,10 +134,10 @@ let lift c =
let make_refine_enter ?unsafe f gl = generic_refine ?unsafe (lift f) gl
-let refine_one ?(unsafe = true) f =
+let refine_one ?(unsafe = false) f =
Proofview.Goal.enter_one (make_refine_enter ~unsafe f)
-let refine ?(unsafe = true) f =
+let refine ?(unsafe = false) f =
let f evd =
let (evd,c) = f evd in (evd,((), c))
in
diff --git a/proofs/refine.mli b/proofs/refine.mli
index f1439f9a13..cede9d4581 100644
--- a/proofs/refine.mli
+++ b/proofs/refine.mli
@@ -27,7 +27,7 @@ val refine : ?unsafe:bool -> (Evd.evar_map -> Evd.evar_map * EConstr.t) -> unit
for the current goal (refine is a goal-dependent tactic), the
new holes created by [t] become the new subgoals. Exceptions
raised during the interpretation of [t] are caught and result in
- tactic failures. If [unsafe] is [false] (default is [true]) [t] is
+ tactic failures. If [unsafe] is [false] (which is the default) [t] is
type-checked beforehand. *)
val refine_one : ?unsafe:bool -> (Evd.evar_map -> Evd.evar_map * ('a * EConstr.t)) -> 'a tactic
--
cgit v1.2.3
From 3cfb38cb0e5491d13a6ef5cda81dfec7f979cced Mon Sep 17 00:00:00 2001
From: Pierre-Marie Pédrot
Date: Tue, 9 May 2017 17:28:23 +0200
Subject: Documenting the change of default flag value of Refine.refine.
---
dev/doc/changes.txt | 3 +++
1 file changed, 3 insertions(+)
diff --git a/dev/doc/changes.txt b/dev/doc/changes.txt
index bcda4ff50a..8456195e6b 100644
--- a/dev/doc/changes.txt
+++ b/dev/doc/changes.txt
@@ -144,6 +144,9 @@ In Coqlib / reference location:
- The tclWEAK_PROGRESS and tclNOTSAMEGOAL tacticals were removed. Their usecase
was very specific. Use tclPROGRESS instead.
+- The Refine.refine function and its variants now have the unsafe flag turned
+ down by default.
+
** Ltac API **
Many Ltac specific API has been moved in its own ltac/ folder. Amongst other
--
cgit v1.2.3
From 0fad09306982a88ff8d633d36abdc440dd542ab3 Mon Sep 17 00:00:00 2001
From: Pierre-Marie Pédrot
Date: Tue, 13 Jun 2017 10:33:56 +0200
Subject: Dualize the unsafe flag of refine into typecheck and make it
mandatory.
---
API/API.mli | 4 ++--
dev/doc/changes.txt | 4 ++--
dev/doc/proof-engine.md | 7 +++----
plugins/cc/cctac.ml | 2 +-
plugins/ltac/extratactics.ml4 | 2 +-
plugins/ltac/rewrite.ml | 6 +++---
plugins/omega/coq_omega.ml | 4 ++--
plugins/ssr/ssripats.ml | 2 +-
proofs/refine.ml | 20 ++++++++++----------
proofs/refine.mli | 13 ++++++-------
tactics/class_tactics.ml | 2 +-
tactics/eqdecide.ml | 2 +-
tactics/inv.ml | 2 +-
tactics/tactics.ml | 44 +++++++++++++++++++++----------------------
tactics/tactics.mli | 4 ++--
vernac/classes.ml | 2 +-
16 files changed, 59 insertions(+), 61 deletions(-)
diff --git a/API/API.mli b/API/API.mli
index 20a637c1fa..5a833d08ad 100644
--- a/API/API.mli
+++ b/API/API.mli
@@ -4100,7 +4100,7 @@ sig
module New :
sig
- val refine : ?unsafe:bool -> (Evd.evar_map -> Evd.evar_map * EConstr.constr) -> unit Proofview.tactic
+ val refine : typecheck:bool -> (Evd.evar_map -> Evd.evar_map * EConstr.constr) -> unit Proofview.tactic
val reduce_after_refine : unit Proofview.tactic
end
module Simple :
@@ -4490,7 +4490,7 @@ end
module Refine :
sig
- val refine : ?unsafe:bool -> (Evd.evar_map -> Evd.evar_map * EConstr.t) -> unit Proofview.tactic
+ val refine : typecheck:bool -> (Evd.evar_map -> Evd.evar_map * EConstr.t) -> unit Proofview.tactic
val solve_constraints : unit Proofview.tactic
end
diff --git a/dev/doc/changes.txt b/dev/doc/changes.txt
index 8456195e6b..63c064d843 100644
--- a/dev/doc/changes.txt
+++ b/dev/doc/changes.txt
@@ -144,8 +144,8 @@ In Coqlib / reference location:
- The tclWEAK_PROGRESS and tclNOTSAMEGOAL tacticals were removed. Their usecase
was very specific. Use tclPROGRESS instead.
-- The Refine.refine function and its variants now have the unsafe flag turned
- down by default.
+- The unsafe flag of the Refine.refine function and its variants has been
+ renamed and dualized into typecheck and has been made mandatory.
** Ltac API **
diff --git a/dev/doc/proof-engine.md b/dev/doc/proof-engine.md
index db69b08a20..8f96ac223f 100644
--- a/dev/doc/proof-engine.md
+++ b/dev/doc/proof-engine.md
@@ -42,14 +42,13 @@ goal holes thanks to the `Refine` module, and in particular to the
`Refine.refine` primitive.
```ocaml
-val refine : ?unsafe:bool -> Constr.t Sigma.run -> unit tactic
-(** In [refine ?unsafe t], [t] is a term with holes under some
+val refine : typecheck:bool -> Constr.t Sigma.run -> unit tactic
+(** In [refine typecheck t], [t] is a term with holes under some
[evar_map] context. The term [t] is used as a partial solution
for the current goal (refine is a goal-dependent tactic), the
new holes created by [t] become the new subgoals. Exceptions
raised during the interpretation of [t] are caught and result in
- tactic failures. If [unsafe] is [false] (default is [true]) [t] is
- type-checked beforehand. *)
+ tactic failures. If [typecheck] is [true] [t] is type-checked beforehand. *)
```
In a first approximation, we can think of `'a Sigma.run` as
diff --git a/plugins/cc/cctac.ml b/plugins/cc/cctac.ml
index 4f4e9a8518..0f5b806644 100644
--- a/plugins/cc/cctac.ml
+++ b/plugins/cc/cctac.ml
@@ -255,7 +255,7 @@ let app_global_with_holes f args n =
Tacticals.New.pf_constr_of_global (Lazy.force f) >>= fun fc ->
let env = Proofview.Goal.env gl in
let concl = Proofview.Goal.concl gl in
- Refine.refine ~unsafe:true begin fun sigma ->
+ Refine.refine ~typecheck:false begin fun sigma ->
let t = Tacmach.New.pf_get_type_of gl fc in
let t = Termops.prod_applist sigma t (Array.to_list args) in
let ans = mkApp (fc, args) in
diff --git a/plugins/ltac/extratactics.ml4 b/plugins/ltac/extratactics.ml4
index 18d7b818cd..7259faecd0 100644
--- a/plugins/ltac/extratactics.ml4
+++ b/plugins/ltac/extratactics.ml4
@@ -365,7 +365,7 @@ let refine_tac ist simple with_classes c =
let update = begin fun sigma ->
c env sigma
end in
- let refine = Refine.refine ~unsafe:true update in
+ let refine = Refine.refine ~typecheck:false update in
if simple then refine
else refine <*>
Tactics.New.reduce_after_refine <*>
diff --git a/plugins/ltac/rewrite.ml b/plugins/ltac/rewrite.ml
index 3927ca7ce1..fad181c897 100644
--- a/plugins/ltac/rewrite.ml
+++ b/plugins/ltac/rewrite.ml
@@ -1539,7 +1539,7 @@ let assert_replacing id newt tac =
| d :: rem -> insert_dependent env sigma (LocalAssum (NamedDecl.get_id d, newt)) [] after @ rem
in
let env' = Environ.reset_with_named_context (val_of_named_context nc) env in
- Refine.refine ~unsafe:false begin fun sigma ->
+ Refine.refine ~typecheck:true begin fun sigma ->
let (sigma, ev) = Evarutil.new_evar env' sigma concl in
let (sigma, ev') = Evarutil.new_evar env sigma newt in
let map d =
@@ -1573,7 +1573,7 @@ let cl_rewrite_clause_newtac ?abs ?origsigma ~progress strat clause =
match clause, prf with
| Some id, Some p ->
let tac = tclTHENLIST [
- Refine.refine ~unsafe:false (fun h -> (h,p));
+ Refine.refine ~typecheck:true (fun h -> (h,p));
Proofview.Unsafe.tclNEWGOALS gls;
] in
Proofview.Unsafe.tclEVARS undef <*>
@@ -1590,7 +1590,7 @@ let cl_rewrite_clause_newtac ?abs ?origsigma ~progress strat clause =
let (sigma, ev) = Evarutil.new_evar env sigma newt in
(sigma, mkApp (p, [| ev |]))
end in
- Refine.refine ~unsafe:false make <*> Proofview.Unsafe.tclNEWGOALS gls
+ Refine.refine ~typecheck:true make <*> Proofview.Unsafe.tclNEWGOALS gls
end
| None, None ->
Proofview.Unsafe.tclEVARS undef <*>
diff --git a/plugins/omega/coq_omega.ml b/plugins/omega/coq_omega.ml
index fb03948ba1..440a10bfb9 100644
--- a/plugins/omega/coq_omega.ml
+++ b/plugins/omega/coq_omega.ml
@@ -652,7 +652,7 @@ let clever_rewrite_base_poly typ p result theorem =
let full = pf_concl gl in
let env = pf_env gl in
let (abstracted,occ) = abstract_path (project gl) typ (List.rev p) full in
- Refine.refine ~unsafe:true begin fun sigma ->
+ Refine.refine ~typecheck:false begin fun sigma ->
let t =
applist
(mkLambda
@@ -688,7 +688,7 @@ let clever_rewrite_gen_nat p result (t,args) =
(** Solve using the term the term [t _] *)
let refine_app gl t =
let open Tacmach.New in
- Refine.refine ~unsafe:true begin fun sigma ->
+ Refine.refine ~typecheck:false begin fun sigma ->
let env = pf_env gl in
let ht = match EConstr.kind sigma (pf_get_type_of gl t) with
| Prod (_, t, _) -> t
diff --git a/plugins/ssr/ssripats.ml b/plugins/ssr/ssripats.ml
index 4a9dddd2ba..7ae9e38248 100644
--- a/plugins/ssr/ssripats.ml
+++ b/plugins/ssr/ssripats.ml
@@ -95,7 +95,7 @@ let ssrmkabs id gl =
end in
Proofview.V82.of_tactic
(Proofview.tclTHEN
- (Tactics.New.refine step)
+ (Tactics.New.refine ~typecheck:false step)
(Proofview.tclFOCUS 1 3 Proofview.shelve)) gl
let ssrmkabstac ids =
diff --git a/proofs/refine.ml b/proofs/refine.ml
index eab053f3a3..796b4b8377 100644
--- a/proofs/refine.ml
+++ b/proofs/refine.ml
@@ -69,7 +69,7 @@ let add_side_effect env = function
let add_side_effects env effects =
List.fold_left (fun env eff -> add_side_effect env eff) env effects
-let generic_refine ?(unsafe = false) f gl =
+let generic_refine ~typecheck f gl =
let gl = Proofview.Goal.assume gl in
let sigma = Proofview.Goal.sigma gl in
let env = Proofview.Goal.env gl in
@@ -91,9 +91,9 @@ let generic_refine ?(unsafe = false) f gl =
let env = add_side_effects env sideff in
(** Check that the introduced evars are well-typed *)
let fold accu ev = typecheck_evar ev env accu in
- let sigma = if unsafe then sigma else CList.fold_left fold sigma evs in
+ let sigma = if typecheck then CList.fold_left fold sigma evs else sigma in
(** Check that the refined term is typesafe *)
- let sigma = if unsafe then sigma else typecheck_proof c concl env sigma in
+ let sigma = if typecheck then typecheck_proof c concl env sigma else sigma in
(** Check that the goal itself does not appear in the refined term *)
let self = Proofview.Goal.goal gl in
let _ =
@@ -132,16 +132,16 @@ let lift c =
Proofview.tclUNIT c
end
-let make_refine_enter ?unsafe f gl = generic_refine ?unsafe (lift f) gl
+let make_refine_enter ~typecheck f gl = generic_refine ~typecheck (lift f) gl
-let refine_one ?(unsafe = false) f =
- Proofview.Goal.enter_one (make_refine_enter ~unsafe f)
+let refine_one ~typecheck f =
+ Proofview.Goal.enter_one (make_refine_enter ~typecheck f)
-let refine ?(unsafe = false) f =
+let refine ~typecheck f =
let f evd =
let (evd,c) = f evd in (evd,((), c))
in
- Proofview.Goal.enter (make_refine_enter ~unsafe f)
+ Proofview.Goal.enter (make_refine_enter ~typecheck f)
(** Useful definitions *)
@@ -153,7 +153,7 @@ let with_type env evd c t =
in
evd , j'.Environ.uj_val
-let refine_casted ?unsafe f = Proofview.Goal.enter begin fun gl ->
+let refine_casted ~typecheck f = Proofview.Goal.enter begin fun gl ->
let gl = Proofview.Goal.assume gl in
let concl = Proofview.Goal.concl gl in
let env = Proofview.Goal.env gl in
@@ -161,7 +161,7 @@ let refine_casted ?unsafe f = Proofview.Goal.enter begin fun gl ->
let (h, c) = f h in
with_type env h c concl
in
- refine ?unsafe f
+ refine ~typecheck f
end
(** {7 solve_constraints}
diff --git a/proofs/refine.mli b/proofs/refine.mli
index cede9d4581..c1c57ecb8e 100644
--- a/proofs/refine.mli
+++ b/proofs/refine.mli
@@ -21,19 +21,18 @@ val pr_constr :
(** {7 Refinement primitives} *)
-val refine : ?unsafe:bool -> (Evd.evar_map -> Evd.evar_map * EConstr.t) -> unit tactic
-(** In [refine ?unsafe t], [t] is a term with holes under some
+val refine : typecheck:bool -> (Evd.evar_map -> Evd.evar_map * EConstr.t) -> unit tactic
+(** In [refine ~typecheck t], [t] is a term with holes under some
[evar_map] context. The term [t] is used as a partial solution
for the current goal (refine is a goal-dependent tactic), the
new holes created by [t] become the new subgoals. Exceptions
raised during the interpretation of [t] are caught and result in
- tactic failures. If [unsafe] is [false] (which is the default) [t] is
- type-checked beforehand. *)
+ tactic failures. If [typecheck] is [true] [t] is type-checked beforehand. *)
-val refine_one : ?unsafe:bool -> (Evd.evar_map -> Evd.evar_map * ('a * EConstr.t)) -> 'a tactic
+val refine_one : typecheck:bool -> (Evd.evar_map -> Evd.evar_map * ('a * EConstr.t)) -> 'a tactic
(** A variant of [refine] which assumes exactly one goal under focus *)
-val generic_refine : ?unsafe:bool -> ('a * EConstr.t) tactic ->
+val generic_refine : typecheck:bool -> ('a * EConstr.t) tactic ->
[ `NF ] Proofview.Goal.t -> 'a tactic
(** The general version of refine. *)
@@ -44,7 +43,7 @@ val with_type : Environ.env -> Evd.evar_map ->
(** [with_type env sigma c t] ensures that [c] is of type [t]
inserting a coercion if needed. *)
-val refine_casted : ?unsafe:bool -> (Evd.evar_map -> Evd.evar_map * EConstr.t) -> unit tactic
+val refine_casted : typecheck:bool -> (Evd.evar_map -> Evd.evar_map * EConstr.t) -> unit tactic
(** Like {!refine} except the refined term is coerced to the conclusion of the
current goal. *)
diff --git a/tactics/class_tactics.ml b/tactics/class_tactics.ml
index 4bde427b15..2faf1e0ecb 100644
--- a/tactics/class_tactics.ml
+++ b/tactics/class_tactics.ml
@@ -250,7 +250,7 @@ let unify_resolve_refine poly flags gls ((c, t, ctx),n,clenv) =
let open Clenv in
let env = Proofview.Goal.env gls in
let concl = Proofview.Goal.concl gls in
- Refine.refine ~unsafe:true begin fun sigma ->
+ Refine.refine ~typecheck:false begin fun sigma ->
let sigma, term, ty =
if poly then
let (subst, ctx) = Universes.fresh_universe_context_set_instance ctx in
diff --git a/tactics/eqdecide.ml b/tactics/eqdecide.ml
index 0cee4b6edb..10bc6e3e24 100644
--- a/tactics/eqdecide.ml
+++ b/tactics/eqdecide.ml
@@ -72,7 +72,7 @@ let generalize_right mk typ c1 c2 =
Proofview.Goal.enter begin fun gl ->
let env = Proofview.Goal.env gl in
let store = Proofview.Goal.extra gl in
- Refine.refine ~unsafe:true begin fun sigma ->
+ Refine.refine ~typecheck:false begin fun sigma ->
let na = Name (next_name_away_with_default "x" Anonymous (Termops.ids_of_context env)) in
let newconcl = mkProd (na, typ, mk typ c1 (mkRel 1)) in
let (sigma, x) = Evarutil.new_evar env sigma ~principal:true ~store newconcl in
diff --git a/tactics/inv.ml b/tactics/inv.ml
index 425b88ee7e..2bc9d9f788 100644
--- a/tactics/inv.ml
+++ b/tactics/inv.ml
@@ -460,7 +460,7 @@ let raw_inversion inv_kind id status names =
in
let refined id =
let prf = mkApp (mkVar id, args) in
- Refine.refine ~unsafe:true (fun h -> (h, prf))
+ Refine.refine ~typecheck:false (fun h -> (h, prf))
in
let neqns = List.length realargs in
let as_mode = names != None in
diff --git a/tactics/tactics.ml b/tactics/tactics.ml
index 9f03191cff..cde891290b 100644
--- a/tactics/tactics.ml
+++ b/tactics/tactics.ml
@@ -163,7 +163,7 @@ let _ =
(** This tactic creates a partial proof realizing the introduction rule, but
does not check anything. *)
let unsafe_intro env store decl b =
- Refine.refine ~unsafe:true begin fun sigma ->
+ Refine.refine ~typecheck:false begin fun sigma ->
let ctx = named_context_val env in
let nctx = push_named_context_val decl ctx in
let inst = List.map (NamedDecl.get_id %> mkVar) (named_context env) in
@@ -200,7 +200,7 @@ let convert_concl ?(check=true) ty k =
let env = Proofview.Goal.env gl in
let store = Proofview.Goal.extra gl in
let conclty = Proofview.Goal.concl gl in
- Refine.refine ~unsafe:true begin fun sigma ->
+ Refine.refine ~typecheck:false begin fun sigma ->
let sigma =
if check then begin
ignore (Typing.unsafe_type_of env sigma ty);
@@ -222,7 +222,7 @@ let convert_hyp ?(check=true) d =
let store = Proofview.Goal.extra gl in
let sign = convert_hyp check (named_context_val env) sigma d in
let env = reset_with_named_context sign env in
- Refine.refine ~unsafe:true begin fun sigma ->
+ Refine.refine ~typecheck:false begin fun sigma ->
Evarutil.new_evar env sigma ~principal:true ~store ty
end
end
@@ -293,7 +293,7 @@ let clear_gen fail = function
in
let env = reset_with_named_context hyps env in
Proofview.tclTHEN (Proofview.Unsafe.tclEVARS !evdref)
- (Refine.refine ~unsafe:true begin fun sigma ->
+ (Refine.refine ~typecheck:false begin fun sigma ->
Evarutil.new_evar env sigma ~principal:true concl
end)
end
@@ -323,7 +323,7 @@ let move_hyp id dest =
let sign = named_context_val env in
let sign' = move_hyp_in_named_context sigma id dest sign in
let env = reset_with_named_context sign' env in
- Refine.refine ~unsafe:true begin fun sigma ->
+ Refine.refine ~typecheck:false begin fun sigma ->
Evarutil.new_evar env sigma ~principal:true ~store ty
end
end
@@ -377,7 +377,7 @@ let rename_hyp repl =
let nconcl = subst concl in
let nctx = val_of_named_context nhyps in
let instance = List.map (NamedDecl.get_id %> mkVar) hyps in
- Refine.refine ~unsafe:true begin fun sigma ->
+ Refine.refine ~typecheck:false begin fun sigma ->
Evarutil.new_evar_instance nctx sigma nconcl ~principal:true ~store instance
end
end
@@ -527,7 +527,7 @@ let mutual_fix f n rest j = Proofview.Goal.enter begin fun gl ->
mk_sign (push_named_context_val (LocalAssum (f, ar)) sign) oth
in
let nenv = reset_with_named_context (mk_sign (named_context_val env) all) env in
- Refine.refine ~unsafe:true begin fun sigma ->
+ Refine.refine ~typecheck:false begin fun sigma ->
let (sigma, evs) = mk_holes nenv sigma (List.map pi3 all) in
let ids = List.map pi1 all in
let evs = List.map (Vars.subst_vars (List.rev ids)) evs in
@@ -579,7 +579,7 @@ let mutual_cofix f others j = Proofview.Goal.enter begin fun gl ->
mk_sign (push_named_context_val (LocalAssum (f, ar)) sign) oth
in
let nenv = reset_with_named_context (mk_sign (named_context_val env) all) env in
- Refine.refine ~unsafe:true begin fun sigma ->
+ Refine.refine ~typecheck:false begin fun sigma ->
let (ids, types) = List.split all in
let (sigma, evs) = mk_holes nenv sigma types in
let evs = List.map (Vars.subst_vars (List.rev ids)) evs in
@@ -1225,7 +1225,7 @@ let cut c =
let id = next_name_away_with_default "H" Anonymous (Tacmach.New.pf_ids_of_hyps gl) in
(** Backward compat: normalize [c]. *)
let c = if normalize_cut then local_strong whd_betaiota sigma c else c in
- Refine.refine ~unsafe:true begin fun h ->
+ Refine.refine ~typecheck:false begin fun h ->
let (h, f) = Evarutil.new_evar ~principal:true env h (mkArrow c (Vars.lift 1 concl)) in
let (h, x) = Evarutil.new_evar env h c in
let f = mkLetIn (Name id, x, c, mkApp (Vars.lift 1 f, [|mkRel 1|])) in
@@ -1666,7 +1666,7 @@ let solve_remaining_apply_goals =
if Typeclasses.is_class_type evd concl then
let evd', c' = Typeclasses.resolve_one_typeclass env evd concl in
Proofview.tclTHEN (Proofview.Unsafe.tclEVARS evd')
- (Refine.refine ~unsafe:true (fun h -> (h,c')))
+ (Refine.refine ~typecheck:false (fun h -> (h,c')))
else Proofview.tclUNIT ()
with Not_found -> Proofview.tclUNIT ()
else Proofview.tclUNIT ()
@@ -1914,7 +1914,7 @@ let cut_and_apply c =
| Prod (_,c1,c2) when Vars.noccurn sigma 1 c2 ->
let concl = Proofview.Goal.concl gl in
let env = Tacmach.New.pf_env gl in
- Refine.refine ~unsafe:true begin fun sigma ->
+ Refine.refine ~typecheck:false begin fun sigma ->
let typ = mkProd (Anonymous, c2, concl) in
let (sigma, f) = Evarutil.new_evar env sigma typ in
let (sigma, x) = Evarutil.new_evar env sigma c1 in
@@ -1934,7 +1934,7 @@ let cut_and_apply c =
(* let refine_no_check = Profile.profile2 refine_no_checkkey refine_no_check *)
let exact_no_check c =
- Refine.refine ~unsafe:true (fun h -> (h,c))
+ Refine.refine ~typecheck:false (fun h -> (h,c))
let exact_check c =
Proofview.Goal.enter begin fun gl ->
@@ -1959,7 +1959,7 @@ let native_cast_no_check c = cast_no_check Term.NATIVEcast c
let exact_proof c =
let open Tacmach.New in
Proofview.Goal.enter begin fun gl ->
- Refine.refine ~unsafe:true begin fun sigma ->
+ Refine.refine ~typecheck:false begin fun sigma ->
let (c, ctx) = Constrintern.interp_casted_constr (pf_env gl) sigma c (pf_concl gl) in
let c = EConstr.of_constr c in
let sigma = Evd.merge_universe_context sigma ctx in
@@ -2076,7 +2076,7 @@ let clear_body ids =
Tacticals.New.tclZEROMSG msg
in
check <*>
- Refine.refine ~unsafe:true begin fun sigma ->
+ Refine.refine ~typecheck:false begin fun sigma ->
Evarutil.new_evar env sigma ~principal:true concl
end
end
@@ -2128,7 +2128,7 @@ let apply_type newcl args =
Proofview.Goal.enter begin fun gl ->
let env = Proofview.Goal.env gl in
let store = Proofview.Goal.extra gl in
- Refine.refine ~unsafe:true begin fun sigma ->
+ Refine.refine ~typecheck:false begin fun sigma ->
let newcl = nf_betaiota sigma newcl (* As in former Logic.refine *) in
let (sigma, ev) =
Evarutil.new_evar env sigma ~principal:true ~store newcl in
@@ -2149,7 +2149,7 @@ let bring_hyps hyps =
let concl = Tacmach.New.pf_concl gl in
let newcl = List.fold_right mkNamedProd_or_LetIn hyps concl in
let args = Array.of_list (Context.Named.to_instance mkVar hyps) in
- Refine.refine ~unsafe:true begin fun sigma ->
+ Refine.refine ~typecheck:false begin fun sigma ->
let (sigma, ev) =
Evarutil.new_evar env sigma ~principal:true ~store newcl in
(sigma, mkApp (ev, args))
@@ -2888,7 +2888,7 @@ let new_generalize_gen_let lconstr =
0 lconstr (concl, sigma, [])
in
Proofview.tclTHEN (Proofview.Unsafe.tclEVARS sigma)
- (Refine.refine ~unsafe:true begin fun sigma ->
+ (Refine.refine ~typecheck:false begin fun sigma ->
let (sigma, ev) = Evarutil.new_evar env sigma ~principal:true newcl in
(sigma, applist (ev, args))
end)
@@ -3598,7 +3598,7 @@ let mk_term_eq homogeneous env sigma ty t ty' t' =
let make_abstract_generalize env id typ concl dep ctx body c eqs args refls =
let open Context.Rel.Declaration in
- Refine.refine ~unsafe:true begin fun sigma ->
+ Refine.refine ~typecheck:false begin fun sigma ->
let eqslen = List.length eqs in
(* Abstract by the "generalized" hypothesis equality proof if necessary. *)
let sigma, abshypeq, abshypt =
@@ -4418,7 +4418,7 @@ let pose_induction_arg_then isrec with_evars (is_arg_pure_hyp,from_prefix) elim
(* and destruct has side conditions first *)
Tacticals.New.tclTHENLAST)
(Tacticals.New.tclTHENLIST [
- Refine.refine ~unsafe:true begin fun sigma ->
+ Refine.refine ~typecheck:false begin fun sigma ->
let b = not with_evars && with_eq != None in
let (sigma, c) = use_bindings env sigma elim b (c0,lbind) t0 in
let t = Retyping.get_type_of env sigma c in
@@ -4441,7 +4441,7 @@ let pose_induction_arg_then isrec with_evars (is_arg_pure_hyp,from_prefix) elim
let env = reset_with_named_context sign env in
let tac =
Tacticals.New.tclTHENLIST [
- Refine.refine ~unsafe:true begin fun sigma ->
+ Refine.refine ~typecheck:false begin fun sigma ->
mkletin_goal env sigma store with_eq true (id,lastlhyp,ccl,c) None
end;
tac
@@ -5101,7 +5101,7 @@ module New = struct
rZeta=false;rDelta=false;rConst=[]})
{onhyps; concl_occs=AllOccurrences }
- let refine ?unsafe c =
- Refine.refine ?unsafe c <*>
+ let refine ~typecheck c =
+ Refine.refine ~typecheck c <*>
reduce_after_refine
end
diff --git a/tactics/tactics.mli b/tactics/tactics.mli
index ec8fe11456..2e17b8dd5c 100644
--- a/tactics/tactics.mli
+++ b/tactics/tactics.mli
@@ -435,8 +435,8 @@ end
module New : sig
- val refine : ?unsafe:bool -> (evar_map -> evar_map * constr) -> unit Proofview.tactic
- (** [refine ?unsafe c] is [Refine.refine ?unsafe c]
+ val refine : typecheck:bool -> (evar_map -> evar_map * constr) -> unit Proofview.tactic
+ (** [refine ~typecheck c] is [Refine.refine ~typecheck c]
followed by beta-iota-reduction of the conclusion. *)
val reduce_after_refine : unit Proofview.tactic
diff --git a/vernac/classes.ml b/vernac/classes.ml
index 3cd0a8de85..aba61146c7 100644
--- a/vernac/classes.ml
+++ b/vernac/classes.ml
@@ -341,7 +341,7 @@ let new_instance ?(abstract=false) ?(global=false) ?(refine= !refine_instance) p
if not (Option.is_empty term) then
let init_refine =
Tacticals.New.tclTHENLIST [
- Refine.refine ~unsafe:true (fun evm -> (evm,EConstr.of_constr (Option.get term)));
+ Refine.refine ~typecheck:false (fun evm -> (evm,EConstr.of_constr (Option.get term)));
Proofview.Unsafe.tclNEWGOALS gls;
Tactics.New.reduce_after_refine;
]
--
cgit v1.2.3
From 4db32ffb3a157077be771f753ba8b5e4a8efc631 Mon Sep 17 00:00:00 2001
From: Hugo Herbelin
Date: Tue, 13 Jun 2017 17:05:27 +0200
Subject: Improving documentation of tactic "move" (report #4561).
---
doc/refman/RefMan-tac.tex | 41 ++++++++++++++++++++++++++++++++++-------
proofs/logic.ml | 2 +-
2 files changed, 35 insertions(+), 8 deletions(-)
diff --git a/doc/refman/RefMan-tac.tex b/doc/refman/RefMan-tac.tex
index 253eb7f01b..673071c58a 100644
--- a/doc/refman/RefMan-tac.tex
+++ b/doc/refman/RefMan-tac.tex
@@ -1053,21 +1053,31 @@ dependencies. This tactic is the inverse of {\tt intro}.
\label{move}
This moves the hypothesis named {\ident$_1$} in the local context
-after the hypothesis named {\ident$_2$}. The proof term is not changed.
+after the hypothesis named {\ident$_2$}, where ``after'' is in
+reference to the direction of the move. The proof term is not changed.
-If {\ident$_1$} comes before {\ident$_2$} in the order of dependencies,
-then all the hypotheses between {\ident$_1$} and {\ident$_2$} that
-(possibly indirectly) depend on {\ident$_1$} are moved too.
+If {\ident$_1$} comes before {\ident$_2$} in the order of
+dependencies, then all the hypotheses between {\ident$_1$} and
+{\ident$_2$} that (possibly indirectly) depend on {\ident$_1$} are
+moved too, and all of them are thus moved after {\ident$_2$} in the
+order of dependencies.
If {\ident$_1$} comes after {\ident$_2$} in the order of dependencies,
then all the hypotheses between {\ident$_1$} and {\ident$_2$} that
-(possibly indirectly) occur in {\ident$_1$} are moved too.
+(possibly indirectly) occur in the type of {\ident$_1$} are moved
+too, and all of them are thus moved before {\ident$_2$} in the order
+of dependencies.
\begin{Variants}
\item {\tt move {\ident$_1$} before {\ident$_2$}}
-This moves {\ident$_1$} towards and just before the hypothesis named {\ident$_2$}.
+This moves {\ident$_1$} towards and just before the hypothesis named
+{\ident$_2$}. As for {\tt move {\ident$_1$} after {\ident$_2$}},
+dependencies over {\ident$_1$} (when {\ident$_1$} comes before
+{\ident$_2$} in the order of dependencies) or in the type of
+{\ident$_1$} (when {\ident$_1$} comes after {\ident$_2$} in the order
+of dependencies) are moved too.
\item {\tt move {\ident} at top}
@@ -1084,13 +1094,30 @@ This moves {\ident} at the bottom of the local context (at the end of the contex
\item \errindex{No such hypothesis}
\item \errindex{Cannot move {\ident$_1$} after {\ident$_2$}:
- it occurs in {\ident$_2$}}
+ it occurs in the type of {\ident$_2$}}
\item \errindex{Cannot move {\ident$_1$} after {\ident$_2$}:
it depends on {\ident$_2$}}
\end{ErrMsgs}
+\Example
+
+\begin{coq_example}
+Goal forall x :nat, x = 0 -> forall z y:nat, y=y-> 0=x.
+intros x H z y H0.
+move x after H0.
+Undo.
+move x before H0.
+Undo.
+move H0 after H.
+Undo.
+move H0 before H.
+\end{coq_example}
+\begin{coq_eval}
+Abort.
+\end{coq_eval}
+
\subsection{\tt rename {\ident$_1$} into {\ident$_2$}}
\tacindex{rename}
diff --git a/proofs/logic.ml b/proofs/logic.ml
index c329bdf4aa..6af1b2d837 100644
--- a/proofs/logic.ml
+++ b/proofs/logic.ml
@@ -253,7 +253,7 @@ let move_hyp sigma toleft (left,declfrom,right) hto =
else
user_err ~hdr:"move_hyp" (str "Cannot move " ++ pr_id (NamedDecl.get_id declfrom) ++
Miscprint.pr_move_location pr_id hto ++
- str (if toleft then ": it occurs in " else ": it depends on ")
+ str (if toleft then ": it occurs in the type of " else ": it depends on ")
++ pr_id hyp ++ str ".")
else
(d::first, middle)
--
cgit v1.2.3
From e36d139f6cb73d1e5021a77d38925b2879efda62 Mon Sep 17 00:00:00 2001
From: Théo Zimmermann
Date: Tue, 13 Jun 2017 17:24:43 +0200
Subject: Revert "[travis] temporary UniMath overlay"
This reverts commit 7ca4e36af8a12236a618bd3a8d045439df40dd43.
Not necessary anymore since UniMath/UniMath#715 has been merged.
---
dev/ci/ci-basic-overlay.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dev/ci/ci-basic-overlay.sh b/dev/ci/ci-basic-overlay.sh
index 3adc319355..d7714274e7 100644
--- a/dev/ci/ci-basic-overlay.sh
+++ b/dev/ci/ci-basic-overlay.sh
@@ -13,8 +13,8 @@
########################################################################
# UniMath
########################################################################
-: ${UniMath_CI_BRANCH:=coq_makefile2-fix}
-: ${UniMath_CI_GITURL:=https://github.com/maximedenes/UniMath.git}
+: ${UniMath_CI_BRANCH:=master}
+: ${UniMath_CI_GITURL:=https://github.com/UniMath/UniMath.git}
########################################################################
# Unicoq + Metacoq
--
cgit v1.2.3
From 80dfe0cb64285f58dfe2eebd7319c747c70d3d6b Mon Sep 17 00:00:00 2001
From: Guillaume Melquiond
Date: Fri, 7 Apr 2017 09:49:21 +0200
Subject: Add a version to be used when parsing compatibility notations
mentioning old versions.
---
lib/flags.ml | 38 +++++++++++++++++++++-----------------
lib/flags.mli | 2 +-
toplevel/coqinit.ml | 3 ++-
toplevel/coqinit.mli | 2 +-
toplevel/coqtop.ml | 4 +++-
5 files changed, 28 insertions(+), 21 deletions(-)
diff --git a/lib/flags.ml b/lib/flags.ml
index 6a3b7a4261..682e2e4df1 100644
--- a/lib/flags.ml
+++ b/lib/flags.ml
@@ -106,32 +106,36 @@ let we_are_parsing = ref false
(* Current means no particular compatibility consideration.
For correct comparisons, this constructor should remain the last one. *)
-type compat_version = V8_2 | V8_3 | V8_4 | V8_5 | V8_6 | Current
+type compat_version = VOld | V8_2 | V8_3 | V8_4 | V8_5 | V8_6 | Current
let compat_version = ref Current
let version_compare v1 v2 = match v1, v2 with
-| V8_2, V8_2 -> 0
-| V8_2, (V8_3 | V8_4 | V8_5 | V8_6 | Current) -> -1
-| V8_3, V8_2 -> 1
-| V8_3, V8_3 -> 0
-| V8_3, (V8_4 | V8_5 | V8_6 | Current) -> -1
-| V8_4, (V8_2 | V8_3) -> 1
-| V8_4, V8_4 -> 0
-| V8_4, (V8_5 | V8_6 | Current) -> -1
-| V8_5, (V8_2 | V8_3 | V8_4) -> 1
-| V8_5, V8_5 -> 0
-| V8_5, (V8_6 | Current) -> -1
-| V8_6, (V8_2 | V8_3 | V8_4 | V8_5) -> 1
-| V8_6, V8_6 -> 0
-| V8_6, Current -> -1
-| Current, Current -> 0
-| Current, (V8_2 | V8_3 | V8_4 | V8_5 | V8_6) -> 1
+ | VOld, VOld -> 0
+ | VOld, _ -> -1
+ | _, VOld -> 1
+ | V8_2, V8_2 -> 0
+ | V8_2, _ -> -1
+ | _, V8_2 -> 1
+ | V8_3, V8_3 -> 0
+ | V8_3, _ -> -1
+ | _, V8_3 -> 1
+ | V8_4, V8_4 -> 0
+ | V8_4, _ -> -1
+ | _, V8_4 -> 1
+ | V8_5, V8_5 -> 0
+ | V8_5, _ -> -1
+ | _, V8_5 -> 1
+ | V8_6, V8_6 -> 0
+ | V8_6, _ -> -1
+ | _, V8_6 -> 1
+ | Current, Current -> 0
let version_strictly_greater v = version_compare !compat_version v > 0
let version_less_or_equal v = not (version_strictly_greater v)
let pr_version = function
+ | VOld -> "old"
| V8_2 -> "8.2"
| V8_3 -> "8.3"
| V8_4 -> "8.4"
diff --git a/lib/flags.mli b/lib/flags.mli
index e2cf09474e..c0aca9c99b 100644
--- a/lib/flags.mli
+++ b/lib/flags.mli
@@ -77,7 +77,7 @@ val raw_print : bool ref
(* Univ print flag, never set anywere. Maybe should belong to Univ? *)
val univ_print : bool ref
-type compat_version = V8_2 | V8_3 | V8_4 | V8_5 | V8_6 | Current
+type compat_version = VOld | V8_2 | V8_3 | V8_4 | V8_5 | V8_6 | Current
val compat_version : compat_version ref
val version_compare : compat_version -> compat_version -> int
val version_strictly_greater : compat_version -> bool
diff --git a/toplevel/coqinit.ml b/toplevel/coqinit.ml
index 16fe405551..33b0327049 100644
--- a/toplevel/coqinit.ml
+++ b/toplevel/coqinit.ml
@@ -126,7 +126,7 @@ let init_ocaml_path () =
Mltop.add_ml_dir (Envars.coqlib ());
List.iter add_subdir Coq_config.all_src_dirs
-let get_compat_version = function
+let get_compat_version ?(allow_old = true) = function
| "8.7" -> Flags.Current
| "8.6" -> Flags.V8_6
| "8.5" -> Flags.V8_5
@@ -134,6 +134,7 @@ let get_compat_version = function
| "8.3" -> Flags.V8_3
| "8.2" -> Flags.V8_2
| ("8.1" | "8.0") as s ->
+ if allow_old then Flags.VOld else
CErrors.user_err ~hdr:"get_compat_version"
(str "Compatibility with version " ++ str s ++ str " not supported.")
| s -> CErrors.user_err ~hdr:"get_compat_version"
diff --git a/toplevel/coqinit.mli b/toplevel/coqinit.mli
index 3b42289eec..787dfb61a9 100644
--- a/toplevel/coqinit.mli
+++ b/toplevel/coqinit.mli
@@ -25,4 +25,4 @@ val init_library_roots : unit -> unit
val init_ocaml_path : unit -> unit
-val get_compat_version : string -> Flags.compat_version
+val get_compat_version : ?allow_old:bool -> string -> Flags.compat_version
diff --git a/toplevel/coqtop.ml b/toplevel/coqtop.ml
index 31450ebd51..7a487f809e 100644
--- a/toplevel/coqtop.ml
+++ b/toplevel/coqtop.ml
@@ -514,7 +514,9 @@ let parse_args arglist =
|"-async-proofs-delegation-threshold" ->
Flags.async_proofs_delegation_threshold:= get_float opt (next ())
|"-worker-id" -> set_worker_id opt (next ())
- |"-compat" -> let v = get_compat_version (next ()) in Flags.compat_version := v; add_compat_require v
+ |"-compat" ->
+ let v = get_compat_version ~allow_old:false (next ()) in
+ Flags.compat_version := v; add_compat_require v
|"-compile" -> add_compile false (next ())
|"-compile-verbose" -> add_compile true (next ())
|"-dump-glob" -> Dumpglob.dump_into_file (next ()); glob_opt := true
--
cgit v1.2.3
From 571c319ed536cb2757176d3ae4007a75f5d3b04d Mon Sep 17 00:00:00 2001
From: Guillaume Melquiond
Date: Tue, 22 Nov 2016 17:08:14 +0100
Subject: Remove support for Coq 8.2.
---
interp/constrintern.ml | 2 +-
lib/flags.ml | 8 ++------
lib/flags.mli | 2 +-
plugins/ltac/tauto.ml | 2 +-
pretyping/classops.ml | 8 ++------
pretyping/unification.ml | 1 -
tactics/equality.ml | 13 ++++---------
tactics/tactics.ml | 1 -
toplevel/coqinit.ml | 3 +--
vernac/indschemes.ml | 2 +-
10 files changed, 13 insertions(+), 29 deletions(-)
diff --git a/interp/constrintern.ml b/interp/constrintern.ml
index 3d484a02da..67fee62028 100644
--- a/interp/constrintern.ml
+++ b/interp/constrintern.ml
@@ -786,7 +786,7 @@ let find_appl_head_data c =
let scopes = find_arguments_scope ref in
c, impls, scopes, []
| GApp ({ v = GRef (ref,_) },l)
- when l != [] && Flags.version_strictly_greater Flags.V8_2 ->
+ when l != [] ->
let n = List.length l in
let impls = implicits_of_global ref in
let scopes = find_arguments_scope ref in
diff --git a/lib/flags.ml b/lib/flags.ml
index 682e2e4df1..c4a97bd12e 100644
--- a/lib/flags.ml
+++ b/lib/flags.ml
@@ -106,7 +106,7 @@ let we_are_parsing = ref false
(* Current means no particular compatibility consideration.
For correct comparisons, this constructor should remain the last one. *)
-type compat_version = VOld | V8_2 | V8_3 | V8_4 | V8_5 | V8_6 | Current
+type compat_version = VOld | V8_3 | V8_4 | V8_5 | V8_6 | Current
let compat_version = ref Current
@@ -114,9 +114,6 @@ let version_compare v1 v2 = match v1, v2 with
| VOld, VOld -> 0
| VOld, _ -> -1
| _, VOld -> 1
- | V8_2, V8_2 -> 0
- | V8_2, _ -> -1
- | _, V8_2 -> 1
| V8_3, V8_3 -> 0
| V8_3, _ -> -1
| _, V8_3 -> 1
@@ -136,7 +133,6 @@ let version_less_or_equal v = not (version_strictly_greater v)
let pr_version = function
| VOld -> "old"
- | V8_2 -> "8.2"
| V8_3 -> "8.3"
| V8_4 -> "8.4"
| V8_5 -> "8.5"
@@ -161,7 +157,7 @@ let is_verbose () = not !quiet
let auto_intros = ref true
let make_auto_intros flag = auto_intros := flag
-let is_auto_intros () = version_strictly_greater V8_2 && !auto_intros
+let is_auto_intros () = !auto_intros
let universe_polymorphism = ref false
let make_universe_polymorphism b = universe_polymorphism := b
diff --git a/lib/flags.mli b/lib/flags.mli
index c0aca9c99b..6e9362681f 100644
--- a/lib/flags.mli
+++ b/lib/flags.mli
@@ -77,7 +77,7 @@ val raw_print : bool ref
(* Univ print flag, never set anywere. Maybe should belong to Univ? *)
val univ_print : bool ref
-type compat_version = VOld | V8_2 | V8_3 | V8_4 | V8_5 | V8_6 | Current
+type compat_version = VOld | V8_3 | V8_4 | V8_5 | V8_6 | Current
val compat_version : compat_version ref
val version_compare : compat_version -> compat_version -> int
val version_strictly_greater : compat_version -> bool
diff --git a/plugins/ltac/tauto.ml b/plugins/ltac/tauto.ml
index 5eacb1a95e..c6cc955b0f 100644
--- a/plugins/ltac/tauto.ml
+++ b/plugins/ltac/tauto.ml
@@ -66,7 +66,7 @@ let negation_unfolding = ref true
(* Whether inner iff are unfolded *)
let iff_unfolding = ref false
-let unfold_iff () = !iff_unfolding || Flags.version_less_or_equal Flags.V8_2
+let unfold_iff () = !iff_unfolding
open Goptions
let _ =
diff --git a/pretyping/classops.ml b/pretyping/classops.ml
index 9a973cff55..627a9c9cc7 100644
--- a/pretyping/classops.ml
+++ b/pretyping/classops.ml
@@ -454,15 +454,11 @@ let cache_coercion (_, c) =
add_coercion_in_graph (xf,is,it)
let load_coercion _ o =
- if
- !automatically_import_coercions || Flags.version_less_or_equal Flags.V8_2
- then
+ if !automatically_import_coercions then
cache_coercion o
let open_coercion i o =
- if Int.equal i 1 && not
- (!automatically_import_coercions || Flags.version_less_or_equal Flags.V8_2)
- then
+ if Int.equal i 1 && not !automatically_import_coercions then
cache_coercion o
let subst_coercion (subst, c) =
diff --git a/pretyping/unification.ml b/pretyping/unification.ml
index 0fb48ed8cf..3e0eb9d91b 100644
--- a/pretyping/unification.ml
+++ b/pretyping/unification.ml
@@ -481,7 +481,6 @@ let set_flags_for_type flags = { flags with
let use_evars_pattern_unification flags =
!global_pattern_unification_flag && flags.use_pattern_unification
- && Flags.version_strictly_greater Flags.V8_2
let use_metas_pattern_unification sigma flags nb l =
!global_pattern_unification_flag && flags.use_pattern_unification
diff --git a/tactics/equality.ml b/tactics/equality.ml
index 05c5cd5ec1..46c042b8be 100644
--- a/tactics/equality.ml
+++ b/tactics/equality.ml
@@ -50,8 +50,7 @@ module NamedDecl = Context.Named.Declaration
let discriminate_introduction = ref true
-let discr_do_intro () =
- !discriminate_introduction && Flags.version_strictly_greater Flags.V8_2
+let discr_do_intro () = !discriminate_introduction
open Goptions
let _ =
@@ -356,7 +355,6 @@ let find_elim hdcncl lft2rgt dep cls ot gl =
if (is_global Coqlib.glob_eq hdcncl ||
(is_global Coqlib.glob_jmeq hdcncl &&
jmeq_same_dom gl ot)) && not dep
- || Flags.version_less_or_equal Flags.V8_2
then
let c =
match EConstr.kind sigma hdcncl with
@@ -1769,13 +1767,10 @@ type subst_tactic_flags = {
rewrite_dependent_proof : bool
}
-let default_subst_tactic_flags () =
- if Flags.version_strictly_greater Flags.V8_2 then
- { only_leibniz = false; rewrite_dependent_proof = true }
- else
- { only_leibniz = true; rewrite_dependent_proof = false }
+let default_subst_tactic_flags =
+ { only_leibniz = false; rewrite_dependent_proof = true }
-let subst_all ?(flags=default_subst_tactic_flags ()) () =
+let subst_all ?(flags=default_subst_tactic_flags) () =
if !regular_subst_tactic then
diff --git a/tactics/tactics.ml b/tactics/tactics.ml
index b553f316c2..ebfaab5bfe 100644
--- a/tactics/tactics.ml
+++ b/tactics/tactics.ml
@@ -64,7 +64,6 @@ let dependent_propositions_elimination = ref true
let use_dependent_propositions_elimination () =
!dependent_propositions_elimination
- && Flags.version_strictly_greater Flags.V8_2
let _ =
declare_bool_option
diff --git a/toplevel/coqinit.ml b/toplevel/coqinit.ml
index 33b0327049..af0c18fa26 100644
--- a/toplevel/coqinit.ml
+++ b/toplevel/coqinit.ml
@@ -132,8 +132,7 @@ let get_compat_version ?(allow_old = true) = function
| "8.5" -> Flags.V8_5
| "8.4" -> Flags.V8_4
| "8.3" -> Flags.V8_3
- | "8.2" -> Flags.V8_2
- | ("8.1" | "8.0") as s ->
+ | ("8.2" | "8.1" | "8.0") as s ->
if allow_old then Flags.VOld else
CErrors.user_err ~hdr:"get_compat_version"
(str "Compatibility with version " ++ str s ++ str " not supported.")
diff --git a/vernac/indschemes.ml b/vernac/indschemes.ml
index c2c27eb78e..e90c259263 100644
--- a/vernac/indschemes.ml
+++ b/vernac/indschemes.ml
@@ -92,7 +92,7 @@ let _ = (* compatibility *)
optread = (fun () -> !eq_flag) ;
optwrite = (fun b -> eq_flag := b) }
-let is_eq_flag () = !eq_flag && Flags.version_strictly_greater Flags.V8_2
+let is_eq_flag () = !eq_flag
let eq_dec_flag = ref false
let _ =
--
cgit v1.2.3
From daf5335b18c926d7130cd28e50f00cc49c4011f6 Mon Sep 17 00:00:00 2001
From: Guillaume Melquiond
Date: Tue, 22 Nov 2016 17:12:58 +0100
Subject: Remove support for Coq 8.3.
---
lib/flags.ml | 6 +-----
lib/flags.mli | 2 +-
pretyping/unification.ml | 8 ++------
tactics/equality.ml | 2 +-
toplevel/coqinit.ml | 3 +--
5 files changed, 6 insertions(+), 15 deletions(-)
diff --git a/lib/flags.ml b/lib/flags.ml
index c4a97bd12e..d738e3df18 100644
--- a/lib/flags.ml
+++ b/lib/flags.ml
@@ -106,7 +106,7 @@ let we_are_parsing = ref false
(* Current means no particular compatibility consideration.
For correct comparisons, this constructor should remain the last one. *)
-type compat_version = VOld | V8_3 | V8_4 | V8_5 | V8_6 | Current
+type compat_version = VOld | V8_4 | V8_5 | V8_6 | Current
let compat_version = ref Current
@@ -114,9 +114,6 @@ let version_compare v1 v2 = match v1, v2 with
| VOld, VOld -> 0
| VOld, _ -> -1
| _, VOld -> 1
- | V8_3, V8_3 -> 0
- | V8_3, _ -> -1
- | _, V8_3 -> 1
| V8_4, V8_4 -> 0
| V8_4, _ -> -1
| _, V8_4 -> 1
@@ -133,7 +130,6 @@ let version_less_or_equal v = not (version_strictly_greater v)
let pr_version = function
| VOld -> "old"
- | V8_3 -> "8.3"
| V8_4 -> "8.4"
| V8_5 -> "8.5"
| V8_6 -> "8.6"
diff --git a/lib/flags.mli b/lib/flags.mli
index 6e9362681f..d6a0eac444 100644
--- a/lib/flags.mli
+++ b/lib/flags.mli
@@ -77,7 +77,7 @@ val raw_print : bool ref
(* Univ print flag, never set anywere. Maybe should belong to Univ? *)
val univ_print : bool ref
-type compat_version = VOld | V8_3 | V8_4 | V8_5 | V8_6 | Current
+type compat_version = VOld | V8_4 | V8_5 | V8_6 | Current
val compat_version : compat_version ref
val version_compare : compat_version -> compat_version -> int
val version_strictly_greater : compat_version -> bool
diff --git a/pretyping/unification.ml b/pretyping/unification.ml
index 3e0eb9d91b..ef4f7f7545 100644
--- a/pretyping/unification.ml
+++ b/pretyping/unification.ml
@@ -484,8 +484,7 @@ let use_evars_pattern_unification flags =
let use_metas_pattern_unification sigma flags nb l =
!global_pattern_unification_flag && flags.use_pattern_unification
- || (Flags.version_less_or_equal Flags.V8_3 ||
- flags.use_meta_bound_pattern_unification) &&
+ || flags.use_meta_bound_pattern_unification &&
Array.for_all (fun c -> isRel sigma c && destRel sigma c <= nb) l
type key =
@@ -608,9 +607,6 @@ let do_reduce ts (env, nb) sigma c =
Stack.zip sigma (fst (whd_betaiota_deltazeta_for_iota_state
ts env sigma Cst_stack.empty (c, Stack.empty)))
-let use_full_betaiota flags =
- flags.modulo_betaiota && Flags.version_strictly_greater Flags.V8_3
-
let isAllowedEvar sigma flags c = match EConstr.kind sigma c with
| Evar (evk,_) -> not (Evar.Set.mem evk flags.frozen_evars)
| _ -> false
@@ -948,7 +944,7 @@ let rec unify_0_with_initial_metas (sigma,ms,es as subst : subst0) conv_at_top e
expand curenvnb pb opt substn cM f1 l1 cN f2 l2
and reduce curenvnb pb opt (sigma, metas, evars as substn) cM cN =
- if use_full_betaiota flags && not (subterm_restriction opt flags) then
+ if flags.modulo_betaiota && not (subterm_restriction opt flags) then
let cM' = do_reduce flags.modulo_delta curenvnb sigma cM in
if not (EConstr.eq_constr sigma cM cM') then
unirec_rec curenvnb pb opt substn cM' cN
diff --git a/tactics/equality.ml b/tactics/equality.ml
index 46c042b8be..5c23702536 100644
--- a/tactics/equality.ml
+++ b/tactics/equality.ml
@@ -1416,7 +1416,7 @@ let injEqThen tac l2r (eq,_,(t,t1,t2) as u) eq_clause =
"" else
" You can try to use option Set Keep Proof Equalities." in
tclZEROMSG (strbrk("No information can be deduced from this equality and the injectivity of constructors. This may be because the terms are convertible, or due to pattern matching restrictions in the sort Prop." ^ suggestion))
- | Inr [([],_,_)] when Flags.version_strictly_greater Flags.V8_3 ->
+ | Inr [([],_,_)] ->
tclZEROMSG (str"Nothing to inject.")
| Inr posns ->
inject_at_positions env sigma l2r u eq_clause posns
diff --git a/toplevel/coqinit.ml b/toplevel/coqinit.ml
index af0c18fa26..4a17a5ee14 100644
--- a/toplevel/coqinit.ml
+++ b/toplevel/coqinit.ml
@@ -131,8 +131,7 @@ let get_compat_version ?(allow_old = true) = function
| "8.6" -> Flags.V8_6
| "8.5" -> Flags.V8_5
| "8.4" -> Flags.V8_4
- | "8.3" -> Flags.V8_3
- | ("8.2" | "8.1" | "8.0") as s ->
+ | ("8.3" | "8.2" | "8.1" | "8.0") as s ->
if allow_old then Flags.VOld else
CErrors.user_err ~hdr:"get_compat_version"
(str "Compatibility with version " ++ str s ++ str " not supported.")
--
cgit v1.2.3
From bcaf9af83363f3e1a1c588271e5038984ee1760b Mon Sep 17 00:00:00 2001
From: Guillaume Melquiond
Date: Sat, 8 Apr 2017 07:04:56 +0200
Subject: Remove support for Coq 8.4.
---
doc/stdlib/index-list.html.template | 1 -
engine/namegen.ml | 3 +-
lib/flags.ml | 6 +--
lib/flags.mli | 2 +-
tactics/equality.ml | 4 +-
tactics/tactics.ml | 1 -
test-suite/bugs/closed/4394.v | 19 ---------
test-suite/bugs/closed/4400.v | 19 ---------
test-suite/bugs/closed/4656.v | 4 --
test-suite/bugs/closed/4727.v | 10 -----
test-suite/bugs/closed/4733.v | 52 ------------------------
test-suite/bugs/opened/4803.v | 48 ----------------------
test-suite/success/Compat84.v | 19 ---------
theories/Compat/Coq84.v | 79 -------------------------------------
toplevel/coqinit.ml | 3 +-
toplevel/coqtop.ml | 1 -
16 files changed, 5 insertions(+), 266 deletions(-)
delete mode 100644 test-suite/bugs/closed/4394.v
delete mode 100644 test-suite/bugs/closed/4400.v
delete mode 100644 test-suite/bugs/closed/4656.v
delete mode 100644 test-suite/bugs/closed/4727.v
delete mode 100644 test-suite/bugs/closed/4733.v
delete mode 100644 test-suite/bugs/opened/4803.v
delete mode 100644 test-suite/success/Compat84.v
delete mode 100644 theories/Compat/Coq84.v
diff --git a/doc/stdlib/index-list.html.template b/doc/stdlib/index-list.html.template
index 1b847414f2..48f82f2d92 100644
--- a/doc/stdlib/index-list.html.template
+++ b/doc/stdlib/index-list.html.template
@@ -589,7 +589,6 @@ through the Require Import command.
theories/Compat/AdmitAxiom.v
- theories/Compat/Coq84.v
theories/Compat/Coq85.v
theories/Compat/Coq86.v
diff --git a/engine/namegen.ml b/engine/namegen.ml
index 5bd62273c8..e635dc163a 100644
--- a/engine/namegen.ml
+++ b/engine/namegen.ml
@@ -412,8 +412,7 @@ let rename_bound_vars_as_displayed sigma avoid env c =
let h_based_elimination_names = ref false
-let use_h_based_elimination_names () =
- !h_based_elimination_names && Flags.version_strictly_greater Flags.V8_4
+let use_h_based_elimination_names () = !h_based_elimination_names
open Goptions
diff --git a/lib/flags.ml b/lib/flags.ml
index d738e3df18..13539bced3 100644
--- a/lib/flags.ml
+++ b/lib/flags.ml
@@ -106,7 +106,7 @@ let we_are_parsing = ref false
(* Current means no particular compatibility consideration.
For correct comparisons, this constructor should remain the last one. *)
-type compat_version = VOld | V8_4 | V8_5 | V8_6 | Current
+type compat_version = VOld | V8_5 | V8_6 | Current
let compat_version = ref Current
@@ -114,9 +114,6 @@ let version_compare v1 v2 = match v1, v2 with
| VOld, VOld -> 0
| VOld, _ -> -1
| _, VOld -> 1
- | V8_4, V8_4 -> 0
- | V8_4, _ -> -1
- | _, V8_4 -> 1
| V8_5, V8_5 -> 0
| V8_5, _ -> -1
| _, V8_5 -> 1
@@ -130,7 +127,6 @@ let version_less_or_equal v = not (version_strictly_greater v)
let pr_version = function
| VOld -> "old"
- | V8_4 -> "8.4"
| V8_5 -> "8.5"
| V8_6 -> "8.6"
| Current -> "current"
diff --git a/lib/flags.mli b/lib/flags.mli
index d6a0eac444..0026aba2e3 100644
--- a/lib/flags.mli
+++ b/lib/flags.mli
@@ -77,7 +77,7 @@ val raw_print : bool ref
(* Univ print flag, never set anywere. Maybe should belong to Univ? *)
val univ_print : bool ref
-type compat_version = VOld | V8_4 | V8_5 | V8_6 | Current
+type compat_version = VOld | V8_5 | V8_6 | Current
val compat_version : compat_version ref
val version_compare : compat_version -> compat_version -> int
val version_strictly_greater : compat_version -> bool
diff --git a/tactics/equality.ml b/tactics/equality.ml
index 5c23702536..d7ec527629 100644
--- a/tactics/equality.ml
+++ b/tactics/equality.ml
@@ -63,9 +63,7 @@ let _ =
let injection_pattern_l2r_order = ref true
-let use_injection_pattern_l2r_order () =
- !injection_pattern_l2r_order
- && Flags.version_strictly_greater Flags.V8_4
+let use_injection_pattern_l2r_order () = !injection_pattern_l2r_order
let _ =
declare_bool_option
diff --git a/tactics/tactics.ml b/tactics/tactics.ml
index ebfaab5bfe..96e7be763d 100644
--- a/tactics/tactics.ml
+++ b/tactics/tactics.ml
@@ -141,7 +141,6 @@ let bracketing_last_or_and_intro_pattern = ref true
let use_bracketing_last_or_and_intro_pattern () =
!bracketing_last_or_and_intro_pattern
- && Flags.version_strictly_greater Flags.V8_4
let _ =
declare_bool_option
diff --git a/test-suite/bugs/closed/4394.v b/test-suite/bugs/closed/4394.v
deleted file mode 100644
index 1ad81345db..0000000000
--- a/test-suite/bugs/closed/4394.v
+++ /dev/null
@@ -1,19 +0,0 @@
-(* -*- coq-prog-args: ("-compat" "8.4") -*- *)
-
-Require Import Equality List.
-Inductive Foo (I : Type -> Type) (A : Type) : Type :=
-| foo (B : Type) : A -> I B -> Foo I A.
-Definition Family := Type -> Type.
-Definition FooToo : Family -> Family := Foo.
-Definition optionize (I : Type -> Type) (A : Type) := option (I A).
-Definition bar (I : Type -> Type) (A : Type) : A -> option (I A) -> Foo (optionize I) A := foo (optionize I) A A.
-Record Rec (I : Type -> Type) := { rec : forall A : Type, A -> I A -> Foo I A }.
-Definition barRec : Rec (optionize id) := {| rec := bar id |}.
-Inductive Empty {T} : T -> Prop := .
-Theorem empty (family : Family) (a : fold_right prod unit (map (Foo family) nil)) (b : unit) :
- Empty (a, b) -> False.
-Proof.
- intro e.
- dependent induction e.
-Qed.
-
diff --git a/test-suite/bugs/closed/4400.v b/test-suite/bugs/closed/4400.v
deleted file mode 100644
index a89cf0cbc3..0000000000
--- a/test-suite/bugs/closed/4400.v
+++ /dev/null
@@ -1,19 +0,0 @@
-(* -*- coq-prog-args: ("-require" "Coq.Compat.Coq84" "-compat" "8.4") -*- *)
-Require Import Coq.Lists.List Coq.Logic.JMeq Program.Equality.
-Set Printing Universes.
-Inductive Foo (I : Type -> Type) (A : Type) : Type :=
-| foo (B : Type) : A -> I B -> Foo I A.
-Definition Family := Type -> Type.
-Definition FooToo : Family -> Family := Foo.
-Definition optionize (I : Type -> Type) (A : Type) := option (I A).
-Definition bar (I : Type -> Type) (A : Type) : A -> option (I A) -> Foo(optionize I) A := foo (optionize I) A A.
-Record Rec (I : Type -> Type) := { rec : forall A : Type, A -> I A -> Foo I A }.
-Definition barRec : Rec (optionize id) := {| rec := bar id |}.
-Inductive Empty {T} : T -> Prop := .
-Theorem empty (family : Family) (a : fold_right prod unit (map (Foo family)
-nil)) (b : unit) :
- Empty (a, b) -> False.
-Proof.
- intro e.
- dependent induction e.
-Qed.
diff --git a/test-suite/bugs/closed/4656.v b/test-suite/bugs/closed/4656.v
deleted file mode 100644
index a59eed2c86..0000000000
--- a/test-suite/bugs/closed/4656.v
+++ /dev/null
@@ -1,4 +0,0 @@
-(* -*- coq-prog-args: ("-compat" "8.4") -*- *)
-Goal True.
- constructor 1.
-Qed.
diff --git a/test-suite/bugs/closed/4727.v b/test-suite/bugs/closed/4727.v
deleted file mode 100644
index cfb4548d2c..0000000000
--- a/test-suite/bugs/closed/4727.v
+++ /dev/null
@@ -1,10 +0,0 @@
-(* -*- coq-prog-args: ("-compat" "8.4") -*- *)
-Goal forall (P : Set) (l : P) (P0 : Set) (w w0 : P0) (T : Type) (a : P * T) (o : P -> option P0),
- (forall (l1 l2 : P) (w1 : P0), o l1 = Some w1 -> o l2 = Some w1 -> l1 = l2) ->
- o l = Some w -> o (fst a) = Some w0 -> {w = w0} + {w <> w0} -> False.
-Proof.
- clear; intros ???????? inj H0 H1 H2.
- destruct H2; intuition subst.
- eapply inj in H1; [ | eauto ].
- progress subst. (* should succeed, used to not succeed *)
-Abort.
diff --git a/test-suite/bugs/closed/4733.v b/test-suite/bugs/closed/4733.v
deleted file mode 100644
index a90abd71cf..0000000000
--- a/test-suite/bugs/closed/4733.v
+++ /dev/null
@@ -1,52 +0,0 @@
-(* -*- coq-prog-args: ("-compat" "8.4") -*- *)
-(*Suppose a user wants to declare a new list-like notation with support for singletons in both 8.4 and 8.5. If they use*)
-Require Import Coq.Lists.List.
-Require Import Coq.Vectors.Vector.
-Import ListNotations.
-Import VectorNotations.
-Set Implicit Arguments.
-Inductive mylist T := mynil | mycons (_ : T) (_ : mylist T).
-Arguments mynil {_}, _.
-
-Delimit Scope mylist_scope with mylist.
-Bind Scope mylist_scope with mylist.
-Delimit Scope vector_scope with vector.
-
-Notation " [ ] " := mynil (format "[ ]") : mylist_scope.
-Notation " [ x ] " := (mycons x mynil) : mylist_scope.
-Notation " [ x ; .. ; y ] " := (mycons x .. (mycons y mynil) ..) : mylist_scope.
-
-(** All of these should work fine in -compat 8.4 mode, just as they do in Coq 8.4. There needs to be a way to specify notations above so that all of these [Check]s go through in both 8.4 and 8.5 *)
-Check [ ]%mylist : mylist _.
-Check [ ]%list : list _.
-Check []%vector : Vector.t _ _.
-Check [ _ ]%mylist : mylist _.
-Check [ _ ]%list : list _.
-Check [ _ ]%vector : Vector.t _ _.
-Check [ _ ; _ ]%list : list _.
-Check [ _ ; _ ]%vector : Vector.t _ _.
-Check [ _ ; _ ]%mylist : mylist _.
-Check [ _ ; _ ; _ ]%list : list _.
-Check [ _ ; _ ; _ ]%vector : Vector.t _ _.
-Check [ _ ; _ ; _ ]%mylist : mylist _.
-Check [ _ ; _ ; _ ; _ ]%list : list _.
-Check [ _ ; _ ; _ ; _ ]%vector : Vector.t _ _.
-Check [ _ ; _ ; _ ; _ ]%mylist : mylist _.
-
-Notation " [ x ; y ; .. ; z ] " := (mycons x (mycons y .. (mycons z mynil) ..)) : mylist_scope.
-(* Now these all work, but not so in 8.4. If we get the ability to remove notations, this section can also just be removed. *)
-Check [ ]%mylist : mylist _.
-Check [ ]%list : list _.
-Check []%vector : Vector.t _ _.
-Check [ _ ]%mylist : mylist _.
-Check [ _ ]%list : list _.
-Check [ _ ]%vector : Vector.t _ _.
-Check [ _ ; _ ]%list : list _.
-Check [ _ ; _ ]%vector : Vector.t _ _.
-Check [ _ ; _ ]%mylist : mylist _.
-Check [ _ ; _ ; _ ]%list : list _.
-Check [ _ ; _ ; _ ]%vector : Vector.t _ _.
-Check [ _ ; _ ; _ ]%mylist : mylist _.
-Check [ _ ; _ ; _ ; _ ]%list : list _.
-Check [ _ ; _ ; _ ; _ ]%vector : Vector.t _ _.
-Check [ _ ; _ ; _ ; _ ]%mylist : mylist _.
diff --git a/test-suite/bugs/opened/4803.v b/test-suite/bugs/opened/4803.v
deleted file mode 100644
index 4541f13d01..0000000000
--- a/test-suite/bugs/opened/4803.v
+++ /dev/null
@@ -1,48 +0,0 @@
-(* -*- coq-prog-args: ("-compat" "8.4") -*- *)
-(*Suppose a user wants to declare a new list-like notation with support for singletons in both 8.4 and 8.5. If they use*)
-Require Import Coq.Lists.List.
-Require Import Coq.Vectors.Vector.
-Import ListNotations.
-Import VectorNotations.
-Set Implicit Arguments.
-Inductive mylist T := mynil | mycons (_ : T) (_ : mylist T).
-Arguments mynil {_}, _.
-
-Delimit Scope mylist_scope with mylist.
-Bind Scope mylist_scope with mylist.
-Delimit Scope vector_scope with vector.
-
-Notation " [ ] " := mynil (format "[ ]") : mylist_scope.
-Notation " [ x ] " := (mycons x mynil) : mylist_scope.
-Notation " [ x ; .. ; y ] " := (mycons x .. (mycons y mynil) ..) : mylist_scope.
-
-(** All of these should work fine in -compat 8.4 mode, just as they do in Coq 8.4. There needs to be a way to specify notations above so that all of these [Check]s go through in both 8.4 and 8.5 *)
-Check [ ]%mylist : mylist _.
-Check [ ]%list : list _.
-Check []%vector : Vector.t _ _.
-Check [ _ ]%mylist : mylist _.
-Check [ _ ]%list : list _.
-Check [ _ ]%vector : Vector.t _ _.
-Check [ _ ; _ ]%list : list _.
-Check [ _ ; _ ]%vector : Vector.t _ _.
-Check [ _ ; _ ]%mylist : mylist _.
-Check [ _ ; _ ; _ ]%list : list _.
-Check [ _ ; _ ; _ ]%vector : Vector.t _ _.
-Check [ _ ; _ ; _ ]%mylist : mylist _.
-Check [ _ ; _ ; _ ; _ ]%list : list _.
-Check [ _ ; _ ; _ ; _ ]%vector : Vector.t _ _.
-Check [ _ ; _ ; _ ; _ ]%mylist : mylist _.
-
-(** Now check that we can add and then remove notations from the parser *)
-(* We should be able to stick some vernacular here to remove [] from the parser *)
-Fail Remove Notation "[]".
-Goal True.
- (* This should not be a syntax error; before moving this file to closed, uncomment this line. *)
- (* idtac; []. *)
- constructor.
-Qed.
-
-Check { _ : _ & _ }.
-Reserved Infix "&" (at level 0).
-Fail Remove Infix "&".
-(* Check { _ : _ & _ }. *)
diff --git a/test-suite/success/Compat84.v b/test-suite/success/Compat84.v
deleted file mode 100644
index 732a024fc1..0000000000
--- a/test-suite/success/Compat84.v
+++ /dev/null
@@ -1,19 +0,0 @@
-(* -*- coq-prog-args: ("-compat" "8.4") -*- *)
-
-Goal True.
- solve [ constructor 1 ]. Undo.
- solve [ econstructor 1 ]. Undo.
- solve [ constructor ]. Undo.
- solve [ econstructor ]. Undo.
- solve [ constructor (fail) ]. Undo.
- solve [ econstructor (fail) ]. Undo.
- split.
-Qed.
-
-Goal False \/ True.
- solve [ constructor (constructor) ]. Undo.
- solve [ econstructor (econstructor) ]. Undo.
- solve [ constructor 2; constructor ]. Undo.
- solve [ econstructor 2; econstructor ]. Undo.
- right; esplit.
-Qed.
diff --git a/theories/Compat/Coq84.v b/theories/Compat/Coq84.v
deleted file mode 100644
index a3e23f91c9..0000000000
--- a/theories/Compat/Coq84.v
+++ /dev/null
@@ -1,79 +0,0 @@
-(************************************************************************)
-(* v * The Coq Proof Assistant / The Coq Development Team *)
-(* -> sig.
-Coercion sigT_of_sigT2 : sigT2 >-> sigT.
-Coercion sigT_of_sig : sig >-> sigT.
-Coercion sig_of_sigT : sigT >-> sig.
-Coercion sigT2_of_sig2 : sig2 >-> sigT2.
-Coercion sig2_of_sigT2 : sigT2 >-> sig2.
-
-(** In 8.4, the statement of admitted lemmas did not depend on the section
- variables. *)
-Unset Keep Admitted Variables.
diff --git a/toplevel/coqinit.ml b/toplevel/coqinit.ml
index 4a17a5ee14..f36d0c348e 100644
--- a/toplevel/coqinit.ml
+++ b/toplevel/coqinit.ml
@@ -130,8 +130,7 @@ let get_compat_version ?(allow_old = true) = function
| "8.7" -> Flags.Current
| "8.6" -> Flags.V8_6
| "8.5" -> Flags.V8_5
- | "8.4" -> Flags.V8_4
- | ("8.3" | "8.2" | "8.1" | "8.0") as s ->
+ | ("8.4" | "8.3" | "8.2" | "8.1" | "8.0") as s ->
if allow_old then Flags.VOld else
CErrors.user_err ~hdr:"get_compat_version"
(str "Compatibility with version " ++ str s ++ str " not supported.")
diff --git a/toplevel/coqtop.ml b/toplevel/coqtop.ml
index 7a487f809e..3e43656056 100644
--- a/toplevel/coqtop.ml
+++ b/toplevel/coqtop.ml
@@ -205,7 +205,6 @@ let require () =
let add_compat_require v =
match v with
- | Flags.V8_4 -> add_require "Coq.Compat.Coq84"
| Flags.V8_5 -> add_require "Coq.Compat.Coq85"
| _ -> ()
--
cgit v1.2.3
From 165e3000844c1e84cc5c9d1b579a0a7dab8a3684 Mon Sep 17 00:00:00 2001
From: Guillaume Melquiond
Date: Fri, 7 Apr 2017 10:05:12 +0200
Subject: Add support for Coq 8.6.
---
toplevel/coqtop.ml | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/toplevel/coqtop.ml b/toplevel/coqtop.ml
index 3e43656056..5f0716fd9f 100644
--- a/toplevel/coqtop.ml
+++ b/toplevel/coqtop.ml
@@ -206,7 +206,8 @@ let require () =
let add_compat_require v =
match v with
| Flags.V8_5 -> add_require "Coq.Compat.Coq85"
- | _ -> ()
+ | Flags.V8_6 -> add_require "Coq.Compat.Coq86"
+ | Flags.VOld | Flags.Current -> ()
let compile_list = ref ([] : (bool * string) list)
--
cgit v1.2.3
From 376da97be60957b25e59afb5791fae665127b17b Mon Sep 17 00:00:00 2001
From: Guillaume Melquiond
Date: Tue, 22 Nov 2016 17:48:14 +0100
Subject: Remove options deprecated since 8.4.
---
pretyping/unification.ml | 13 +------------
vernac/indschemes.ml | 7 -------
vernac/vernacentries.ml | 11 -----------
3 files changed, 1 insertion(+), 30 deletions(-)
diff --git a/pretyping/unification.ml b/pretyping/unification.ml
index ef4f7f7545..b4964c1f36 100644
--- a/pretyping/unification.ml
+++ b/pretyping/unification.ml
@@ -248,20 +248,9 @@ let sort_eqns = unify_r2l
let global_pattern_unification_flag = ref true
-(* Compatibility option introduced and activated in Coq 8.3 whose
- syntax is now deprecated. *)
-
open Goptions
-let _ =
- declare_bool_option
- { optdepr = true;
- optname = "pattern-unification for existential variables in tactics";
- optkey = ["Tactic";"Evars";"Pattern";"Unification"];
- optread = (fun () -> !global_pattern_unification_flag);
- optwrite = (:=) global_pattern_unification_flag }
-(* Compatibility option superseding the previous one, introduced and
- activated in Coq 8.4 *)
+(* Compatibility option introduced and activated in Coq 8.4 *)
let _ =
declare_bool_option
diff --git a/vernac/indschemes.ml b/vernac/indschemes.ml
index e90c259263..44d6f37cc6 100644
--- a/vernac/indschemes.ml
+++ b/vernac/indschemes.ml
@@ -84,13 +84,6 @@ let _ =
optkey = ["Boolean";"Equality";"Schemes"];
optread = (fun () -> !eq_flag) ;
optwrite = (fun b -> eq_flag := b) }
-let _ = (* compatibility *)
- declare_bool_option
- { optdepr = true;
- optname = "automatic declaration of boolean equality";
- optkey = ["Equality";"Scheme"];
- optread = (fun () -> !eq_flag) ;
- optwrite = (fun b -> eq_flag := b) }
let is_eq_flag () = !eq_flag
diff --git a/vernac/vernacentries.ml b/vernac/vernacentries.ml
index ef16df5b75..9978848ff3 100644
--- a/vernac/vernacentries.ml
+++ b/vernac/vernacentries.ml
@@ -1394,17 +1394,6 @@ let _ =
optread = (fun () -> !CClosure.share);
optwrite = (fun b -> CClosure.share := b) }
-(* No more undo limit in the new proof engine.
- The command still exists for compatibility (e.g. with ProofGeneral) *)
-
-let _ =
- declare_int_option
- { optdepr = true;
- optname = "the undo limit (OBSOLETE)";
- optkey = ["Undo"];
- optread = (fun _ -> None);
- optwrite = (fun _ -> ()) }
-
let _ =
declare_bool_option
{ optdepr = false;
--
cgit v1.2.3
From 5e93f1e95853c3614df813845b94051a45f1a749 Mon Sep 17 00:00:00 2001
From: Guillaume Melquiond
Date: Tue, 22 Nov 2016 17:51:32 +0100
Subject: Deprecate options that were introduced for compatibility with 8.2.
---
plugins/ltac/tauto.ml | 2 +-
pretyping/classops.ml | 2 +-
pretyping/unification.ml | 2 +-
tactics/equality.ml | 2 +-
tactics/tactics.ml | 2 +-
vernac/vernacentries.ml | 2 +-
6 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/plugins/ltac/tauto.ml b/plugins/ltac/tauto.ml
index c6cc955b0f..2a8ed72387 100644
--- a/plugins/ltac/tauto.ml
+++ b/plugins/ltac/tauto.ml
@@ -79,7 +79,7 @@ let _ =
let _ =
declare_bool_option
- { optdepr = false;
+ { optdepr = true; (* remove in 8.8 *)
optname = "unfolding of iff in intuition";
optkey = ["Intuition";"Iff";"Unfolding"];
optread = (fun () -> !iff_unfolding);
diff --git a/pretyping/classops.ml b/pretyping/classops.ml
index 627a9c9cc7..8d87f6e99c 100644
--- a/pretyping/classops.ml
+++ b/pretyping/classops.ml
@@ -428,7 +428,7 @@ let automatically_import_coercions = ref false
open Goptions
let _ =
declare_bool_option
- { optdepr = false;
+ { optdepr = true; (* remove in 8.8 *)
optname = "automatic import of coercions";
optkey = ["Automatic";"Coercions";"Import"];
optread = (fun () -> !automatically_import_coercions);
diff --git a/pretyping/unification.ml b/pretyping/unification.ml
index b4964c1f36..67c8b07e78 100644
--- a/pretyping/unification.ml
+++ b/pretyping/unification.ml
@@ -254,7 +254,7 @@ open Goptions
let _ =
declare_bool_option
- { optdepr = false;
+ { optdepr = true; (* remove in 8.8 *)
optname = "pattern-unification for existential variables in tactics";
optkey = ["Tactic";"Pattern";"Unification"];
optread = (fun () -> !global_pattern_unification_flag);
diff --git a/tactics/equality.ml b/tactics/equality.ml
index d7ec527629..d810e862af 100644
--- a/tactics/equality.ml
+++ b/tactics/equality.ml
@@ -55,7 +55,7 @@ let discr_do_intro () = !discriminate_introduction
open Goptions
let _ =
declare_bool_option
- { optdepr = false;
+ { optdepr = true; (* remove in 8.8 *)
optname = "automatic introduction of hypotheses by discriminate";
optkey = ["Discriminate";"Introduction"];
optread = (fun () -> !discriminate_introduction);
diff --git a/tactics/tactics.ml b/tactics/tactics.ml
index 96e7be763d..dbb613c40e 100644
--- a/tactics/tactics.ml
+++ b/tactics/tactics.ml
@@ -67,7 +67,7 @@ let use_dependent_propositions_elimination () =
let _ =
declare_bool_option
- { optdepr = false;
+ { optdepr = true; (* remove in 8.8 *)
optname = "dependent-propositions-elimination tactic";
optkey = ["Dependent";"Propositions";"Elimination"];
optread = (fun () -> !dependent_propositions_elimination) ;
diff --git a/vernac/vernacentries.ml b/vernac/vernacentries.ml
index 9978848ff3..ba1da655a8 100644
--- a/vernac/vernacentries.ml
+++ b/vernac/vernacentries.ml
@@ -1298,7 +1298,7 @@ let _ =
let _ =
declare_bool_option
- { optdepr = false;
+ { optdepr = true; (* remove in 8.8 *)
optname = "automatic introduction of variables";
optkey = ["Automatic";"Introduction"];
optread = Flags.is_auto_intros;
--
cgit v1.2.3
From 180b3739bb6601ff9aaf951e4b87e0bb45341b77 Mon Sep 17 00:00:00 2001
From: Guillaume Melquiond
Date: Tue, 22 Nov 2016 17:54:14 +0100
Subject: Deprecate options that were introduced for compatibility with 8.4.
---
engine/namegen.ml | 2 +-
tactics/equality.ml | 2 +-
tactics/tactics.ml | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/engine/namegen.ml b/engine/namegen.ml
index e635dc163a..783085654e 100644
--- a/engine/namegen.ml
+++ b/engine/namegen.ml
@@ -417,7 +417,7 @@ let use_h_based_elimination_names () = !h_based_elimination_names
open Goptions
let _ = declare_bool_option
- { optdepr = false;
+ { optdepr = true; (* remove in 8.8 *)
optname = "use of \"H\"-based proposition names in elimination tactics";
optkey = ["Standard";"Proposition";"Elimination";"Names"];
optread = (fun () -> !h_based_elimination_names);
diff --git a/tactics/equality.ml b/tactics/equality.ml
index d810e862af..6e56dc48e5 100644
--- a/tactics/equality.ml
+++ b/tactics/equality.ml
@@ -67,7 +67,7 @@ let use_injection_pattern_l2r_order () = !injection_pattern_l2r_order
let _ =
declare_bool_option
- { optdepr = false;
+ { optdepr = true; (* remove in 8.8 *)
optname = "injection left-to-right pattern order and clear by default when with introduction pattern";
optkey = ["Injection";"L2R";"Pattern";"Order"];
optread = (fun () -> !injection_pattern_l2r_order) ;
diff --git a/tactics/tactics.ml b/tactics/tactics.ml
index dbb613c40e..f56a913cbe 100644
--- a/tactics/tactics.ml
+++ b/tactics/tactics.ml
@@ -144,7 +144,7 @@ let use_bracketing_last_or_and_intro_pattern () =
let _ =
declare_bool_option
- { optdepr = false;
+ { optdepr = true; (* remove in 8.8 *)
optname = "bracketing last or-and introduction pattern";
optkey = ["Bracketing";"Last";"Introduction";"Pattern"];
optread = (fun () -> !bracketing_last_or_and_intro_pattern);
--
cgit v1.2.3
From 7668037a8daaef7bc8f1fc3225c2e6cc26cac0aa Mon Sep 17 00:00:00 2001
From: Guillaume Melquiond
Date: Tue, 23 May 2017 10:40:51 +0200
Subject: Remove deprecated options from the standard library.
---
theories/Classes/CRelationClasses.v | 4 +---
theories/Classes/RelationClasses.v | 4 +---
theories/Reals/SeqProp.v | 2 +-
3 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/theories/Classes/CRelationClasses.v b/theories/Classes/CRelationClasses.v
index 3d7ef01fb1..cfe0e08edb 100644
--- a/theories/Classes/CRelationClasses.v
+++ b/theories/Classes/CRelationClasses.v
@@ -305,9 +305,7 @@ Section Binary.
fun x y => sum (R x y) (R' x y).
(** Relation equivalence is an equivalence, and subrelation defines a partial order. *)
-
- Set Automatic Introduction.
-
+
Global Instance relation_equivalence_equivalence :
Equivalence relation_equivalence.
Proof. split; red; unfold relation_equivalence, iffT. firstorder.
diff --git a/theories/Classes/RelationClasses.v b/theories/Classes/RelationClasses.v
index 11c204dae5..57728d305d 100644
--- a/theories/Classes/RelationClasses.v
+++ b/theories/Classes/RelationClasses.v
@@ -433,9 +433,7 @@ Section Binary.
@predicate_union (A::A::Tnil) R R'.
(** Relation equivalence is an equivalence, and subrelation defines a partial order. *)
-
- Set Automatic Introduction.
-
+
Global Instance relation_equivalence_equivalence :
Equivalence relation_equivalence.
Proof. exact (@predicate_equivalence_equivalence (A::A::Tnil)). Qed.
diff --git a/theories/Reals/SeqProp.v b/theories/Reals/SeqProp.v
index 3697999f70..6a5233b643 100644
--- a/theories/Reals/SeqProp.v
+++ b/theories/Reals/SeqProp.v
@@ -150,7 +150,7 @@ Definition sequence_lb (Un:nat -> R) (pr:has_lb Un)
(* Compatibility *)
Notation sequence_majorant := sequence_ub (only parsing).
Notation sequence_minorant := sequence_lb (only parsing).
-Unset Standard Proposition Elimination Names.
+
Lemma Wn_decreasing :
forall (Un:nat -> R) (pr:has_ub Un), Un_decreasing (sequence_ub Un pr).
Proof.
--
cgit v1.2.3
From d038839a32978548051573286e22462d68d42ee6 Mon Sep 17 00:00:00 2001
From: Pierre Letouzey
Date: Tue, 26 Apr 2016 17:30:30 +0200
Subject: Constrexpr.Numeral stays uninterpreted (string+sign instead of
BigInt.t)
This string contains the base-10 representation of the number (big endian)
Note that some inner parsing stuff still uses bigints, see egramcoq.ml
---
API/API.mli | 4 +++-
interp/constrexpr_ops.ml | 5 ++++-
interp/constrextern.ml | 26 +++++++++++++++++---------
interp/constrintern.ml | 17 +++++++++++------
interp/notation.ml | 20 ++++++++++++++------
intf/constrexpr.ml | 10 +++++++++-
parsing/egramcoq.ml | 8 ++++++--
parsing/g_constr.ml4 | 10 +++++-----
plugins/ltac/g_tactic.ml4 | 6 ++++--
plugins/ssr/ssrparser.ml4 | 3 ++-
printing/ppconstr.ml | 4 ++--
test-suite/bugs/closed/3036.v | 6 +++---
12 files changed, 80 insertions(+), 39 deletions(-)
diff --git a/API/API.mli b/API/API.mli
index 20a637c1fa..ba0e00a020 100644
--- a/API/API.mli
+++ b/API/API.mli
@@ -2055,8 +2055,10 @@ sig
type explicitation = Constrexpr.explicitation =
| ExplByPos of int * Names.Id.t option
| ExplByName of Names.Id.t
+ type sign = bool
+ type raw_natural_number = string
type prim_token = Constrexpr.prim_token =
- | Numeral of Bigint.bigint
+ | Numeral of raw_natural_number * sign
| String of string
type notation = string
type instance_expr = Misctypes.glob_level list
diff --git a/interp/constrexpr_ops.ml b/interp/constrexpr_ops.ml
index 79e0e61646..396dde0465 100644
--- a/interp/constrexpr_ops.ml
+++ b/interp/constrexpr_ops.ml
@@ -45,8 +45,11 @@ let names_of_local_binders bl =
(**********************************************************************)
(* Functions on constr_expr *)
+(* Note: redundant Numeral representations such as -0 and +0 (or different
+ numbers of leading zeros) are considered different here. *)
+
let prim_token_eq t1 t2 = match t1, t2 with
-| Numeral i1, Numeral i2 -> Bigint.equal i1 i2
+| Numeral (n1,s1), Numeral (n2,s2) -> String.equal n1 n2 && s1 == s2
| String s1, String s2 -> String.equal s1 s2
| _ -> false
diff --git a/interp/constrextern.ml b/interp/constrextern.ml
index d254520e0e..fb0efb6ad7 100644
--- a/interp/constrextern.ml
+++ b/interp/constrextern.ml
@@ -239,23 +239,31 @@ let expand_curly_brackets loc mknot ntn l =
let destPrim = function { CAst.v = CPrim t } -> Some t | _ -> None
let destPatPrim = function { CAst.v = CPatPrim t } -> Some t | _ -> None
+let is_number s =
+ let rec aux i =
+ Int.equal (String.length s) i ||
+ match s.[i] with '0'..'9' -> aux (i+1) | _ -> false
+ in aux 0
+
+let is_zero s =
+ let rec aux i =
+ Int.equal (String.length s) i || (s.[i] == '0' && aux (i+1))
+ in aux 0
+
let make_notation_gen loc ntn mknot mkprim destprim l =
if has_curly_brackets ntn
then expand_curly_brackets loc mknot ntn l
else match ntn,List.map destprim l with
(* Special case to avoid writing "- 3" for e.g. (Z.opp 3) *)
- | "- _", [Some (Numeral p)] when Bigint.is_strictly_pos p ->
+ | "- _", [Some (Numeral (p,true))] when not (is_zero p) ->
mknot (loc,ntn,([mknot (loc,"( _ )",l)]))
| _ ->
match decompose_notation_key ntn, l with
- | [Terminal "-"; Terminal x], [] ->
- (try mkprim (loc, Numeral (Bigint.neg (Bigint.of_string x)))
- with Failure _ -> mknot (loc,ntn,[]))
- | [Terminal x], [] ->
- (try mkprim (loc, Numeral (Bigint.of_string x))
- with Failure _ -> mknot (loc,ntn,[]))
- | _ ->
- mknot (loc,ntn,l)
+ | [Terminal "-"; Terminal x], [] when is_number x ->
+ mkprim (loc, Numeral (x,false))
+ | [Terminal x], [] when is_number x ->
+ mkprim (loc, Numeral (x,true))
+ | _ -> mknot (loc,ntn,l)
let make_notation loc ntn (terms,termlists,binders as subst) =
if not (List.is_empty termlists) || not (List.is_empty binders) then
diff --git a/interp/constrintern.ml b/interp/constrintern.ml
index 3d484a02da..7bc4b81b20 100644
--- a/interp/constrintern.ml
+++ b/interp/constrintern.ml
@@ -1219,6 +1219,11 @@ let alias_of als = match als.alias_ids with
*)
+let is_zero s =
+ let rec aux i =
+ Int.equal (String.length s) i || (s.[i] == '0' && aux (i+1))
+ in aux 0
+
let merge_subst s1 s2 = Id.Map.fold Id.Map.add s1 s2
let product_of_cases_patterns aliases idspl =
@@ -1331,9 +1336,9 @@ let drop_notations_pattern looked_for genv =
(* but not scopes in expl_pl *)
let (argscs1,_) = find_remaining_scopes expl_pl pl g in
CAst.make ?loc @@ RCPatCstr (g, List.map2 (in_pat_sc scopes) argscs1 expl_pl @ List.map (in_pat false scopes) pl, [])
- | CPatNotation ("- _",([{ CAst.v = CPatPrim(Numeral p) }],[]),[])
- when Bigint.is_strictly_pos p ->
- let pat, _df = Notation.interp_prim_token_cases_pattern_expr ?loc (ensure_kind false loc) (Numeral (Bigint.neg p)) scopes in
+ | CPatNotation ("- _",([{ CAst.v = CPatPrim(Numeral (p,true)) }],[]),[])
+ when not (is_zero p) ->
+ let pat, _df = Notation.interp_prim_token_cases_pattern_expr ?loc (ensure_kind false loc) (Numeral (p,false)) scopes in
rcp_of_glob pat
| CPatNotation ("( _ )",([a],[]),[]) ->
in_pat top scopes a
@@ -1639,9 +1644,9 @@ let internalize globalenv env pattern_mode (_, ntnvars as lvar) c =
CAst.make ?loc @@
GLetIn (snd na, inc1, int,
intern (push_name_env ntnvars (impls_term_list inc1) env na) c2)
- | CNotation ("- _",([{ CAst.v = CPrim (Numeral p) }],[],[]))
- when Bigint.is_strictly_pos p ->
- intern env (CAst.make ?loc @@ CPrim (Numeral (Bigint.neg p)))
+ | CNotation ("- _",([{ CAst.v = CPrim (Numeral (p,true)) }],[],[]))
+ when not (is_zero p) ->
+ intern env (CAst.make ?loc @@ CPrim (Numeral (p,false)))
| CNotation ("( _ )",([a],[],[])) -> intern env a
| CNotation (ntn,args) ->
intern_notation intern env ntnvars loc ntn args
diff --git a/interp/notation.ml b/interp/notation.ml
index 23332f7c45..f74e1d43b7 100644
--- a/interp/notation.ml
+++ b/interp/notation.ml
@@ -10,7 +10,6 @@
open CErrors
open Util
open Pp
-open Bigint
open Names
open Term
open Libnames
@@ -319,7 +318,13 @@ let declare_prim_token_interpreter sc interp (patl,uninterp,b) =
(glob_prim_constr_key pat) (sc,uninterp,b) !prim_token_key_table)
patl
-let mkNumeral n = Numeral n
+let mkNumeral n =
+ if Bigint.is_pos_or_zero n then Numeral (Bigint.to_string n, true)
+ else Numeral (Bigint.to_string (Bigint.neg n), false)
+
+let ofNumeral n s =
+ if s then Bigint.of_string n else Bigint.neg (Bigint.of_string n)
+
let mkString = function
| None -> None
| Some s -> if Unicode.is_utf8 s then Some (String s) else None
@@ -327,8 +332,10 @@ let mkString = function
let delay dir int ?loc x = (dir, (fun () -> int ?loc x))
let declare_numeral_interpreter sc dir interp (patl,uninterp,inpat) =
+ let interp' ?loc (n,s) = interp ?loc (ofNumeral n s) in
declare_prim_token_interpreter sc
- (fun cont ?loc -> function Numeral n-> delay dir interp ?loc n | p -> cont ?loc p)
+ (fun cont ?loc -> function Numeral (n,s) -> delay dir interp' ?loc (n,s)
+ | p -> cont ?loc p)
(patl, (fun r -> Option.map mkNumeral (uninterp r)), inpat)
let declare_string_interpreter sc dir interp (patl,uninterp,inpat) =
@@ -440,8 +447,8 @@ let find_notation ntn sc =
(n.not_interp, n.not_location)
let notation_of_prim_token = function
- | Numeral n when is_pos_or_zero n -> to_string n
- | Numeral n -> "- "^(to_string (neg n))
+ | Numeral (n,true) -> n
+ | Numeral (n,false) -> "- "^n
| String _ -> raise Not_found
let find_prim_token check_allowed ?loc p sc =
@@ -466,7 +473,8 @@ let interp_prim_token_gen ?loc g p local_scopes =
with Not_found ->
user_err ?loc ~hdr:"interp_prim_token"
((match p with
- | Numeral n -> str "No interpretation for numeral " ++ str (to_string n)
+ | Numeral _ ->
+ str "No interpretation for numeral " ++ str (notation_of_prim_token p)
| String s -> str "No interpretation for string " ++ qs s) ++ str ".")
let interp_prim_token ?loc =
diff --git a/intf/constrexpr.ml b/intf/constrexpr.ml
index 614c097b5a..593b190a6b 100644
--- a/intf/constrexpr.ml
+++ b/intf/constrexpr.ml
@@ -31,8 +31,16 @@ type abstraction_kind = AbsLambda | AbsPi
type proj_flag = int option (** [Some n] = proj of the n-th visible argument *)
+(** Representation of integer literals that appear in Coq scripts.
+ We now use raw strings of digits in base 10 (big-endian), and a separate
+ sign flag. Note that this representation is not unique, due to possible
+ multiple leading zeros, and -0 = +0 *)
+
+type sign = bool
+type raw_natural_number = string
+
type prim_token =
- | Numeral of Bigint.bigint (** representation of integer literals that appear in Coq scripts. *)
+ | Numeral of raw_natural_number * sign
| String of string
type instance_expr = Misctypes.glob_level list
diff --git a/parsing/egramcoq.ml b/parsing/egramcoq.ml
index 890ce2deca..f2ec6e8b7c 100644
--- a/parsing/egramcoq.ml
+++ b/parsing/egramcoq.ml
@@ -324,6 +324,10 @@ type 'r env = {
let push_constr subst v = { subst with constrs = v :: subst.constrs }
+let mkNumeral n =
+ if Bigint.is_pos_or_zero n then Numeral (Bigint.to_string n, true)
+ else Numeral (Bigint.to_string (Bigint.neg n), false)
+
let push_item : type s r. s target -> (s, r) entry -> s env -> r -> s env = fun forpat e subst v ->
match e with
| TTConstr _ -> push_constr subst v
@@ -337,8 +341,8 @@ match e with
| TTBinderListF _ -> { subst with binders = (List.flatten v, false) :: subst.binders }
| TTBigint ->
begin match forpat with
- | ForConstr -> push_constr subst (CAst.make @@ CPrim (Numeral v))
- | ForPattern -> push_constr subst (CAst.make @@ CPatPrim (Numeral v))
+ | ForConstr -> push_constr subst (CAst.make @@ CPrim (mkNumeral v))
+ | ForPattern -> push_constr subst (CAst.make @@ CPatPrim (mkNumeral v))
end
| TTReference ->
begin match forpat with
diff --git a/parsing/g_constr.ml4 b/parsing/g_constr.ml4
index 54bac253d0..de76118026 100644
--- a/parsing/g_constr.ml4
+++ b/parsing/g_constr.ml4
@@ -203,7 +203,7 @@ GEXTEND Gram
| c=match_constr -> c
| "("; c = operconstr LEVEL "200"; ")" ->
(match c.CAst.v with
- CPrim (Numeral z) when Bigint.is_pos_or_zero z ->
+ | CPrim (Numeral (n,true)) ->
CAst.make ~loc:(!@loc) @@ CNotation("( _ )",([c],[],[]))
| _ -> c)
| "{|"; c = record_declaration; "|}" -> c
@@ -280,7 +280,7 @@ GEXTEND Gram
atomic_constr:
[ [ g=global; i=instance -> CAst.make ~loc:!@loc @@ CRef (g,i)
| s=sort -> CAst.make ~loc:!@loc @@ CSort s
- | n=INT -> CAst.make ~loc:!@loc @@ CPrim (Numeral (Bigint.of_string n))
+ | n=INT -> CAst.make ~loc:!@loc @@ CPrim (Numeral (n,true))
| s=string -> CAst.make ~loc:!@loc @@ CPrim (String s)
| "_" -> CAst.make ~loc:!@loc @@ CHole (None, IntroAnonymous, None)
| "?"; "["; id=ident; "]" -> CAst.make ~loc:!@loc @@ CHole (None, IntroIdentifier id, None)
@@ -395,18 +395,18 @@ GEXTEND Gram
| "_" -> CAst.make ~loc:!@loc @@ CPatAtom None
| "("; p = pattern LEVEL "200"; ")" ->
(match p.CAst.v with
- | CPatPrim (Numeral z) when Bigint.is_pos_or_zero z ->
+ | CPatPrim (Numeral (n,true)) ->
CAst.make ~loc:!@loc @@ CPatNotation("( _ )",([p],[]),[])
| _ -> p)
| "("; p = pattern LEVEL "200"; ":"; ty = lconstr; ")" ->
let p =
match p with
- | { CAst.v = CPatPrim (Numeral z) } when Bigint.is_pos_or_zero z ->
+ | { CAst.v = CPatPrim (Numeral (n,true)) } ->
CAst.make ~loc:!@loc @@ CPatNotation("( _ )",([p],[]),[])
| _ -> p
in
CAst.make ~loc:!@loc @@ CPatCast (p, ty)
- | n = INT -> CAst.make ~loc:!@loc @@ CPatPrim (Numeral (Bigint.of_string n))
+ | n = INT -> CAst.make ~loc:!@loc @@ CPatPrim (Numeral (n,true))
| s = string -> CAst.make ~loc:!@loc @@ CPatPrim (String s) ] ]
;
impl_ident_tail:
diff --git a/plugins/ltac/g_tactic.ml4 b/plugins/ltac/g_tactic.ml4
index a971fc79f6..804f734504 100644
--- a/plugins/ltac/g_tactic.ml4
+++ b/plugins/ltac/g_tactic.ml4
@@ -139,14 +139,16 @@ let destruction_arg_of_constr (c,lbind as clbind) = match lbind with
end
| _ -> ElimOnConstr clbind
+let mkNumeral n = Numeral (string_of_int (abs n), 0<=n)
+
let mkTacCase with_evar = function
| [(clear,ElimOnConstr cl),(None,None),None],None ->
TacCase (with_evar,(clear,cl))
(* Reinterpret numbers as a notation for terms *)
| [(clear,ElimOnAnonHyp n),(None,None),None],None ->
TacCase (with_evar,
- (clear,(CAst.make @@ CPrim (Numeral (Bigint.of_int n)),
- NoBindings)))
+ (clear,(CAst.make @@ CPrim (mkNumeral n),
+ NoBindings)))
(* Reinterpret ident as notations for variables in the context *)
(* because we don't know if they are quantified or not *)
| [(clear,ElimOnIdent id),(None,None),None],None ->
diff --git a/plugins/ssr/ssrparser.ml4 b/plugins/ssr/ssrparser.ml4
index 3ea8c24314..09917339a7 100644
--- a/plugins/ssr/ssrparser.ml4
+++ b/plugins/ssr/ssrparser.ml4
@@ -346,7 +346,8 @@ let interp_index ist gl idx =
| Some c ->
let rc = Detyping.detype false [] (pf_env gl) (project gl) c in
begin match Notation.uninterp_prim_token rc with
- | _, Constrexpr.Numeral bigi -> int_of_string (Bigint.to_string bigi)
+ | _, Constrexpr.Numeral (s,b) ->
+ let n = int_of_string s in if b then n else -n
| _ -> raise Not_found
end
| None -> raise Not_found
diff --git a/printing/ppconstr.ml b/printing/ppconstr.ml
index 626464b96f..49eedb767b 100644
--- a/printing/ppconstr.ml
+++ b/printing/ppconstr.ml
@@ -80,7 +80,7 @@ let tag_var = tag Tag.variable
| Any -> true
let prec_of_prim_token = function
- | Numeral p -> if Bigint.is_pos_or_zero p then lposint else lnegint
+ | Numeral (_,b) -> if b then lposint else lnegint
| String _ -> latom
open Notation
@@ -231,7 +231,7 @@ let tag_var = tag Tag.variable
| ArgVar (loc,s) -> pr_lident (loc,s)
let pr_prim_token = function
- | Numeral n -> str (Bigint.to_string n)
+ | Numeral (n,s) -> str (if s then n else "-"^n)
| String s -> qs s
let pr_evar pr id l =
diff --git a/test-suite/bugs/closed/3036.v b/test-suite/bugs/closed/3036.v
index 451bec9b20..3b57310d6e 100644
--- a/test-suite/bugs/closed/3036.v
+++ b/test-suite/bugs/closed/3036.v
@@ -15,11 +15,11 @@ Definition perm := Qc.
Locate Qle_bool.
Definition compatibleb (p1 p2 : perm) : bool :=
-let p1pos := Qle_bool 00 p1 in
- let p2pos := Qle_bool 00 p2 in
+let p1pos := Qle_bool 0 p1 in
+ let p2pos := Qle_bool 0 p2 in
negb (
(p1pos && p2pos)
- || ((p1pos || p2pos) && (negb (Qle_bool 00 ((p1 + p2)%Qc)))))%Qc.
+ || ((p1pos || p2pos) && (negb (Qle_bool 0 ((p1 + p2)%Qc)))))%Qc.
Definition compatible (p1 p2 : perm) := compatibleb p1 p2 = true.
--
cgit v1.2.3
From 2bc76bf063da72d1db38c3c0d29c747b0fe23f78 Mon Sep 17 00:00:00 2001
From: Pierre Letouzey
Date: Wed, 22 Feb 2017 18:32:23 +0100
Subject: G_prim: the bigint entry keeps numbers in raw strings
---
API/grammar_API.mli | 2 +-
parsing/egramcoq.ml | 10 +++-------
parsing/g_prim.ml4 | 4 ++--
parsing/pcoq.mli | 2 +-
4 files changed, 7 insertions(+), 11 deletions(-)
diff --git a/API/grammar_API.mli b/API/grammar_API.mli
index 44aae771f6..b39ee30b53 100644
--- a/API/grammar_API.mli
+++ b/API/grammar_API.mli
@@ -116,7 +116,7 @@ sig
val pattern_identref : Names.Id.t located Gram.Entry.e
val base_ident : Names.Id.t Gram.Entry.e
val natural : int Gram.Entry.e
- val bigint : Bigint.bigint Gram.Entry.e
+ val bigint : Constrexpr.raw_natural_number Gram.Entry.e
val integer : int Gram.Entry.e
val string : string Gram.Entry.e
val qualid : API.Libnames.qualid located Gram.Entry.e
diff --git a/parsing/egramcoq.ml b/parsing/egramcoq.ml
index f2ec6e8b7c..35ffa20d08 100644
--- a/parsing/egramcoq.ml
+++ b/parsing/egramcoq.ml
@@ -227,7 +227,7 @@ type prod_info = production_level * production_position
type (_, _) entry =
| TTName : ('self, Name.t Loc.located) entry
| TTReference : ('self, reference) entry
-| TTBigint : ('self, Bigint.bigint) entry
+| TTBigint : ('self, Constrexpr.raw_natural_number) entry
| TTBinder : ('self, local_binder_expr list) entry
| TTConstr : prod_info * 'r target -> ('r, 'r) entry
| TTConstrList : prod_info * Tok.t list * 'r target -> ('r, 'r list) entry
@@ -324,10 +324,6 @@ type 'r env = {
let push_constr subst v = { subst with constrs = v :: subst.constrs }
-let mkNumeral n =
- if Bigint.is_pos_or_zero n then Numeral (Bigint.to_string n, true)
- else Numeral (Bigint.to_string (Bigint.neg n), false)
-
let push_item : type s r. s target -> (s, r) entry -> s env -> r -> s env = fun forpat e subst v ->
match e with
| TTConstr _ -> push_constr subst v
@@ -341,8 +337,8 @@ match e with
| TTBinderListF _ -> { subst with binders = (List.flatten v, false) :: subst.binders }
| TTBigint ->
begin match forpat with
- | ForConstr -> push_constr subst (CAst.make @@ CPrim (mkNumeral v))
- | ForPattern -> push_constr subst (CAst.make @@ CPatPrim (mkNumeral v))
+ | ForConstr -> push_constr subst (CAst.make @@ CPrim (Numeral (v,true)))
+ | ForPattern -> push_constr subst (CAst.make @@ CPatPrim (Numeral (v,true)))
end
| TTReference ->
begin match forpat with
diff --git a/parsing/g_prim.ml4 b/parsing/g_prim.ml4
index 78f75a73cb..c77d6e204e 100644
--- a/parsing/g_prim.ml4
+++ b/parsing/g_prim.ml4
@@ -114,7 +114,7 @@ GEXTEND Gram
natural:
[ [ i = INT -> my_int_of_string (!@loc) i ] ]
;
- bigint: (* Negative numbers are dealt with specially *)
- [ [ i = INT -> (Bigint.of_string i) ] ]
+ bigint: (* Negative numbers are dealt with elsewhere *)
+ [ [ i = INT -> i ] ]
;
END
diff --git a/parsing/pcoq.mli b/parsing/pcoq.mli
index 959e8ddf52..9fb3daabaf 100644
--- a/parsing/pcoq.mli
+++ b/parsing/pcoq.mli
@@ -199,7 +199,7 @@ module Prim :
val pattern_identref : Id.t located Gram.entry
val base_ident : Id.t Gram.entry
val natural : int Gram.entry
- val bigint : Bigint.bigint Gram.entry
+ val bigint : Constrexpr.raw_natural_number Gram.entry
val integer : int Gram.entry
val string : string Gram.entry
val lstring : string located Gram.entry
--
cgit v1.2.3
From 0b5ef21f936acbb89fa5b272efdcf3cf03de58cc Mon Sep 17 00:00:00 2001
From: Pierre Letouzey
Date: Wed, 31 May 2017 21:48:26 +0200
Subject: Notation.declare_rawnumeral_interpreter
This new function is similar to declare_numeral_interpreter,
but works on a lower level : instead of bigint, numbers are
represented as string of their decimal digits (plus a boolean sign)
---
interp/notation.ml | 10 ++++++++++
interp/notation.mli | 5 +++++
2 files changed, 15 insertions(+)
diff --git a/interp/notation.ml b/interp/notation.ml
index f74e1d43b7..300f6b1dd0 100644
--- a/interp/notation.ml
+++ b/interp/notation.ml
@@ -331,6 +331,16 @@ let mkString = function
let delay dir int ?loc x = (dir, (fun () -> int ?loc x))
+type rawnum = Constrexpr.raw_natural_number * Constrexpr.sign
+
+let declare_rawnumeral_interpreter sc dir interp (patl,uninterp,inpat) =
+ declare_prim_token_interpreter sc
+ (fun cont ?loc -> function Numeral (n,s) -> delay dir interp ?loc (n,s)
+ | p -> cont ?loc p)
+ (patl, (fun r -> match uninterp r with
+ | None -> None
+ | Some (n,s) -> Some (Numeral (n,s))), inpat)
+
let declare_numeral_interpreter sc dir interp (patl,uninterp,inpat) =
let interp' ?loc (n,s) = interp ?loc (ofNumeral n s) in
declare_prim_token_interpreter sc
diff --git a/interp/notation.mli b/interp/notation.mli
index d271a88fe7..c739ec12fd 100644
--- a/interp/notation.mli
+++ b/interp/notation.mli
@@ -74,6 +74,11 @@ type 'a prim_token_interpreter =
type 'a prim_token_uninterpreter =
glob_constr list * (glob_constr -> 'a option) * cases_pattern_status
+type rawnum = Constrexpr.raw_natural_number * Constrexpr.sign
+
+val declare_rawnumeral_interpreter : scope_name -> required_module ->
+ rawnum prim_token_interpreter -> rawnum prim_token_uninterpreter -> unit
+
val declare_numeral_interpreter : scope_name -> required_module ->
bigint prim_token_interpreter -> bigint prim_token_uninterpreter -> unit
--
cgit v1.2.3
From da0459552dd4ac253e45bb519d99a5a718105313 Mon Sep 17 00:00:00 2001
From: Gaëtan Gilbert
Date: Tue, 13 Jun 2017 21:38:59 +0200
Subject: API additions for coq-dpdgraph
---
API/API.mli | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/API/API.mli b/API/API.mli
index 20a637c1fa..a662517406 100644
--- a/API/API.mli
+++ b/API/API.mli
@@ -72,6 +72,7 @@ sig
val pr : (Level.t -> Pp.std_ppcmds) -> t -> Pp.std_ppcmds
end
type 'a puniverses = 'a * Instance.t
+ val out_punivs : 'a puniverses -> 'a
module Constraint : module type of struct include Univ.Constraint end
@@ -1034,7 +1035,16 @@ sig
| Undef of inline
| Def of Term.constr Mod_subst.substituted
| OpaqueDef of Opaqueproof.opaque
- type constant_type = Declarations.constant_type
+ type template_arity = Declarations.template_arity = {
+ template_param_levels : Univ.Level.t option list;
+ template_level : Univ.Universe.t;
+ }
+
+ type ('a, 'b) declaration_arity = ('a, 'b) Declarations.declaration_arity =
+ | RegularArity of 'a
+ | TemplateArity of 'b
+
+ type constant_type = (Prelude.types, Context.Rel.t * template_arity) declaration_arity
type constant_universes = Declarations.constant_universes
type projection_body = Declarations.projection_body = {
proj_ind : Names.MutInd.t;
@@ -1131,6 +1141,11 @@ sig
uj_val : 'constr;
uj_type : 'types
}
+ type 'types punsafe_type_judgment = 'types Environ.punsafe_type_judgment = {
+ utj_val : 'types;
+ utj_type : Sorts.t }
+
+ type unsafe_type_judgment = Term.types punsafe_type_judgment
val empty_env : env
val lookup_mind : Names.MutInd.t -> env -> Declarations.mutual_inductive_body
val push_rel : Context.Rel.Declaration.t -> env -> env
@@ -1156,6 +1171,7 @@ sig
val fold_named_context_reverse :
('a -> Context.Named.Declaration.t -> 'a) -> init:'a -> env -> 'a
val evaluable_named : Names.Id.t -> Environ.env -> bool
+ val push_context_set : ?strict:bool -> Univ.ContextSet.t -> env -> env
end
module UGraph :
@@ -1219,6 +1235,7 @@ end
module Typeops :
sig
+ val infer_type : Environ.env -> Term.types -> Environ.unsafe_type_judgment
val type_of_constant_type : Environ.env -> Declarations.constant_type -> Term.types
val type_of_constant_in : Environ.env -> Term.pconstant -> Term.types
end
@@ -2631,6 +2648,7 @@ sig
type universe_opt_subst = Universes.universe_opt_subst
val fresh_inductive_instance : Environ.env -> Names.inductive -> Term.pinductive Univ.in_universe_context_set
val new_Type : Names.DirPath.t -> Term.types
+ val type_of_global : Globnames.global_reference -> Term.types Univ.in_universe_context_set
val unsafe_type_of_global : Globnames.global_reference -> Term.types
val constr_of_global : Prelude.global_reference -> Term.constr
val universes_of_constr : Term.constr -> Univ.LSet.t
@@ -3473,6 +3491,7 @@ sig
type ltac_constant = Names.KerName.t
+ val global : Libnames.reference -> Globnames.global_reference
val global_of_path : Libnames.full_path -> Globnames.global_reference
val shortest_qualid_of_global : Names.Id.Set.t -> Globnames.global_reference -> Libnames.qualid
val path_of_global : Globnames.global_reference -> Libnames.full_path
--
cgit v1.2.3
From b240771a3661883ca0cc0497efee5b48519bddea Mon Sep 17 00:00:00 2001
From: Pierre Letouzey
Date: Wed, 14 Jun 2017 11:46:40 +0200
Subject: Makefile.build : cleanup now that micromega.ml isn't generated + sync
check of this file
There is now a warning if the content of micromega.ml isn't what MExtraction.v would
produce.
---
.gitignore | 1 +
Makefile | 1 +
Makefile.build | 43 +++++++++++++++++++----------------------
plugins/micromega/MExtraction.v | 5 ++++-
4 files changed, 26 insertions(+), 24 deletions(-)
diff --git a/.gitignore b/.gitignore
index db12a9de25..58e1d346cf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -52,6 +52,7 @@ config/Info-*.plist
dev/ocamldebug-coq
dev/camlp4.dbg
plugins/micromega/csdpcert
+plugins/micromega/.micromega.ml.generated
kernel/byterun/dllcoqrun.so
coqdoc.sty
.csdp.cache
diff --git a/Makefile b/Makefile
index 66721a3ad0..a6a73d2499 100644
--- a/Makefile
+++ b/Makefile
@@ -190,6 +190,7 @@ indepclean:
rm -f test-suite/check.log
rm -f glob.dump
rm -f config/revision.ml revision
+ rm -f plugins/micromega/.micromega.ml.generated
$(MAKE) -C test-suite clean
docclean:
diff --git a/Makefile.build b/Makefile.build
index 99541243a3..484673e174 100644
--- a/Makefile.build
+++ b/Makefile.build
@@ -77,27 +77,6 @@ include Makefile.ide ## provides the 'coqide' rule
include Makefile.install
include Makefile.dev ## provides the 'printers' and 'revision' rules
-###########################################################################
-# Adding missing pieces of information not discovered by ocamldep
-# due to the fact that:
-# - plugins/micromega/micromega_plugin.ml
-# - plugins/micromega/micromega_plugin.mli
-# are generated (and not yet present when we run "ocamldep").
-###########################################################################
-
-plugins/micromega/micromega_plugin.cmo : plugins/micromega/micromega.cmo
-plugins/micromega/micromega_plugin.cmx : plugins/micromega/micromega.cmx
-
-plugins/micromega/certificate.cmo plugins/micromega/coq_micromega.cmo plugins/micromega/csdpcert.cmo plugins/micromega/mfourier.cmo plugins/micromega/mutils.cmo plugins/micromega/polynomial.cmo : plugins/micromega/micromega.cmo
-
-plugins/micromega/certificate.cmx plugins/micromega/coq_micromega.cmx plugins/micromega/csdpcert.cmx plugins/micromega/mfourier.cmx plugins/micromega/mutils.cmx plugins/micromega/polynomial.cmx : plugins/micromega/micromega.cmx
-
-plugins/micromega/micromega.cmx plugins/micromega/micromega.cmo : plugins/micromega/micromega.cmi
-plugins/micromega/micromega.cmi : plugins/micromega/micromega.mli
-
-plugins/micromega/generated_micromega.mli plugins/micromega/generated_micromega.ml : plugins/micromega/MExtraction.vo
- @:
-
###########################################################################
# This include below will lauch the build of all .d.
@@ -110,8 +89,6 @@ DEPENDENCIES := \
-include $(DEPENDENCIES)
-plugins/micromega/micromega_FORPACK:= -for-pack Micromega_plugin
-
# All dependency includes must be declared secondary, otherwise make will
# delete them if it decided to build them by dependency instead of because
# of include, and they will then be automatically deleted, leading to an
@@ -617,6 +594,26 @@ theories/Init/%.vo theories/Init/%.glob: theories/Init/%.v $(VO_TOOLS_DEP)
$(HIDE)rm -f theories/Init/$*.glob
$(HIDE)$(BOOTCOQC) $< $(COQ_XML) -noinit -R theories Coq
+# MExtraction.v generates the ml core file of the micromega tactic.
+# We check that this generated code is still in sync with the version
+# of micromega.ml in the archive.
+
+# Note: we now dump to stdout there via "Recursive Extraction" for better
+# control on the name of the generated file, and avoid a .ml that
+# would end in our $(MLFILES). The "sed" below is to kill the final
+# blank line printed by Recursive Extraction (unlike Extraction "foo").
+
+MICROMEGAV:=plugins/micromega/MExtraction.v
+MICROMEGAML:=plugins/micromega/micromega.ml
+MICROMEGAGEN:=plugins/micromega/.micromega.ml.generated
+
+$(MICROMEGAV:.v=.vo) $(MICROMEGAV:.v=.glob) : $(MICROMEGAV) theories/Init/Prelude.vo $(VO_TOOLS_DEP)
+ $(SHOW)'COQC $<'
+ $(HIDE)rm -f $*.glob
+ $(HIDE)$(BOOTCOQC) $< | sed -e '$$d' > $(MICROMEGAGEN)
+ $(HIDE)cmp -s $(MICROMEGAML) $(MICROMEGAGEN) || \
+ echo "Warning: $(MICROMEGAML) and the code generated by $(MICROMEGAV) differ !"
+
# The general rule for building .vo files :
%.vo %.glob: %.v theories/Init/Prelude.vo $(VO_TOOLS_DEP)
diff --git a/plugins/micromega/MExtraction.v b/plugins/micromega/MExtraction.v
index 2451aeada7..135a715203 100644
--- a/plugins/micromega/MExtraction.v
+++ b/plugins/micromega/MExtraction.v
@@ -48,7 +48,10 @@ Extract Constant Rmult => "( * )".
Extract Constant Ropp => "fun x -> - x".
Extract Constant Rinv => "fun x -> 1 / x".
-Extraction "plugins/micromega/generated_micromega.ml"
+(** We now extract to stdout, see comment in Makefile.build *)
+
+(*Extraction "plugins/micromega/micromega.ml" *)
+Recursive Extraction
List.map simpl_cone (*map_cone indexes*)
denorm Qpower vm_add
n_of_Z N.of_nat ZTautoChecker ZWeakChecker QTautoChecker RTautoChecker find.
--
cgit v1.2.3
From 27c8e30fad95d887b698b0e3fa563644c293b033 Mon Sep 17 00:00:00 2001
From: Pierre Letouzey
Date: Thu, 23 Jun 2016 15:07:02 +0200
Subject: Prelude : no more autoload of plugins extraction and recdef
The user now has to manually load them, respectively via:
Require Extraction
Require Import FunInd
The "Import" in the case of FunInd is to ensure that the
tactics functional induction and functional inversion are indeed
in scope.
Note that the Recdef.v file is still there as well (it contains
complements used when doing Function with measures), and it also
triggers a load of FunInd.v.
This change is correctly documented in the refman, and the test-suite
has been adapted.
---
Makefile.dev | 2 +-
doc/refman/Extraction.tex | 7 +++++++
doc/refman/RefMan-ext.tex | 10 ++++++----
doc/refman/RefMan-sch.tex | 7 +++++--
doc/refman/RefMan-tac.tex | 5 ++++-
plugins/extraction/ExtrHaskellBasic.v | 2 ++
plugins/extraction/ExtrHaskellNatInt.v | 2 ++
plugins/extraction/ExtrHaskellNatInteger.v | 2 ++
plugins/extraction/ExtrHaskellNatNum.v | 2 ++
plugins/extraction/ExtrHaskellString.v | 2 ++
plugins/extraction/ExtrHaskellZInt.v | 2 ++
plugins/extraction/ExtrHaskellZInteger.v | 2 ++
plugins/extraction/ExtrHaskellZNum.v | 2 ++
plugins/extraction/ExtrOcamlBasic.v | 2 ++
plugins/extraction/ExtrOcamlBigIntConv.v | 2 ++
plugins/extraction/ExtrOcamlIntConv.v | 2 ++
plugins/extraction/ExtrOcamlNatBigInt.v | 2 ++
plugins/extraction/ExtrOcamlNatInt.v | 2 ++
plugins/extraction/ExtrOcamlString.v | 2 ++
plugins/extraction/ExtrOcamlZBigInt.v | 2 ++
plugins/extraction/ExtrOcamlZInt.v | 2 ++
plugins/extraction/Extraction.v | 9 +++++++++
plugins/funind/FunInd.v | 10 ++++++++++
plugins/funind/Recdef.v | 2 +-
plugins/micromega/MExtraction.v | 1 +
test-suite/bugs/closed/2141.v | 1 +
test-suite/bugs/closed/3287.v | 2 ++
test-suite/bugs/closed/3923.v | 2 ++
test-suite/bugs/closed/4616.v | 2 ++
test-suite/bugs/closed/4710.v | 2 ++
test-suite/bugs/closed/5372.v | 1 +
test-suite/ide/blocking-futures.fake | 1 +
test-suite/output/Extraction_matchs_2413.v | 2 ++
test-suite/success/Funind.v | 2 ++
test-suite/success/RecTutorial.v | 1 +
test-suite/success/extraction.v | 1 +
test-suite/success/extraction_dep.v | 2 ++
test-suite/success/extraction_impl.v | 2 ++
test-suite/success/extraction_polyprop.v | 2 ++
test-suite/success/primitiveproj.v | 2 ++
theories/Compat/Coq85.v | 3 +++
theories/FSets/FMapAVL.v | 2 +-
theories/FSets/FMapFullAVL.v | 2 +-
theories/FSets/FMapList.v | 2 +-
theories/FSets/FMapWeakList.v | 2 +-
theories/Init/Prelude.v | 2 --
theories/MSets/MSetAVL.v | 2 +-
theories/MSets/MSetGenTree.v | 2 +-
theories/Program/Wf.v | 1 +
49 files changed, 111 insertions(+), 17 deletions(-)
create mode 100644 plugins/extraction/Extraction.v
create mode 100644 plugins/funind/FunInd.v
diff --git a/Makefile.dev b/Makefile.dev
index 0105df972a..b0299bd160 100644
--- a/Makefile.dev
+++ b/Makefile.dev
@@ -186,7 +186,7 @@ omega: $(OMEGAVO) $(OMEGACMO) $(ROMEGAVO) $(ROMEGACMO)
micromega: $(MICROMEGAVO) $(MICROMEGACMO) $(CSDPCERT)
setoid_ring: $(RINGVO) $(RINGCMO)
nsatz: $(NSATZVO) $(NSATZCMO)
-extraction: $(EXTRACTIONCMO)
+extraction: $(EXTRACTIONCMO) $(EXTRACTIONVO)
fourier: $(FOURIERVO) $(FOURIERCMO)
funind: $(FUNINDCMO) $(FUNINDVO)
cc: $(CCVO) $(CCCMO)
diff --git a/doc/refman/Extraction.tex b/doc/refman/Extraction.tex
index 01dbcfb1cb..fa3d61b1cd 100644
--- a/doc/refman/Extraction.tex
+++ b/doc/refman/Extraction.tex
@@ -19,6 +19,12 @@ be used (abusively) to refer to any of the three.
%% the one in previous versions of \Coq: there is no more
%% an explicit toplevel for the language (formerly called \textsc{Fml}).
+Before using any of the commands or options described in this chapter,
+the extraction framework should first be loaded explicitly
+via {\tt Require Extraction}. Note that in earlier versions of Coq, these
+commands and options were directly available without any preliminary
+{\tt Require}.
+
\asection{Generating ML code}
\comindex{Extraction}
\comindex{Recursive Extraction}
@@ -501,6 +507,7 @@ We can now extract this program to \ocaml:
Reset Initial.
\end{coq_eval}
\begin{coq_example}
+Require Extraction.
Require Import Euclid Wf_nat.
Extraction Inline gt_wf_rec lt_wf_rec induction_ltof2.
Recursive Extraction eucl_dev.
diff --git a/doc/refman/RefMan-ext.tex b/doc/refman/RefMan-ext.tex
index 6dd0ddf81d..939fc87a6e 100644
--- a/doc/refman/RefMan-ext.tex
+++ b/doc/refman/RefMan-ext.tex
@@ -721,18 +721,20 @@ a given type. See Section~\ref{Show}.
\section{Advanced recursive functions}
-The \emph{experimental} command
+The following \emph{experimental} command is available
+when the {\tt FunInd} library has been loaded via {\tt Require Import FunInd}:
\begin{center}
\texttt{Function {\ident} {\binder$_1$}\ldots{\binder$_n$}
\{decrease\_annot\} : type$_0$ := \term$_0$}
\comindex{Function}
\label{Function}
\end{center}
-can be seen as a generalization of {\tt Fixpoint}. It is actually a
-wrapper for several ways of defining a function \emph{and other useful
+This command can be seen as a generalization of {\tt Fixpoint}. It is actually
+a wrapper for several ways of defining a function \emph{and other useful
related objects}, namely: an induction principle that reflects the
recursive structure of the function (see \ref{FunInduction}), and its
-fixpoint equality. The meaning of this
+fixpoint equality.
+ The meaning of this
declaration is to define a function {\it ident}, similarly to {\tt
Fixpoint}. Like in {\tt Fixpoint}, the decreasing argument must be
given (unless the function is not recursive), but it must not
diff --git a/doc/refman/RefMan-sch.tex b/doc/refman/RefMan-sch.tex
index 53aa6b86ab..d3719bed46 100644
--- a/doc/refman/RefMan-sch.tex
+++ b/doc/refman/RefMan-sch.tex
@@ -196,8 +196,10 @@ Check tree_forest_mutind.
The {\tt Functional Scheme} command is a high-level experimental
tool for generating automatically induction principles
-corresponding to (possibly mutually recursive) functions. Its
-syntax follows the schema:
+corresponding to (possibly mutually recursive) functions.
+First, it must be made available via {\tt Require Import FunInd}.
+ Its
+syntax then follows the schema:
\begin{quote}
{\tt Functional Scheme {\ident$_1$} := Induction for \ident'$_1$ Sort {\sort$_1$} \\
with\\
@@ -319,6 +321,7 @@ of a tree or a forest. Note that we use \texttt{Function} which
generally produces better principles.
\begin{coq_example*}
+Require Import FunInd.
Function tree_size (t:tree) : nat :=
match t with
| node A f => S (forest_size f)
diff --git a/doc/refman/RefMan-tac.tex b/doc/refman/RefMan-tac.tex
index 253eb7f01b..2bab04e90a 100644
--- a/doc/refman/RefMan-tac.tex
+++ b/doc/refman/RefMan-tac.tex
@@ -2113,13 +2113,15 @@ The tactic \texttt{functional induction} performs
case analysis and induction following the definition of a function. It
makes use of a principle generated by \texttt{Function}
(see Section~\ref{Function}) or \texttt{Functional Scheme}
-(see Section~\ref{FunScheme}).
+(see Section~\ref{FunScheme}). Note that this tactic is only available
+after a {\tt Require Import FunInd}.
\begin{coq_eval}
Reset Initial.
Import Nat.
\end{coq_eval}
\begin{coq_example}
+Require Import FunInd.
Functional Scheme minus_ind := Induction for minus Sort Prop.
Check minus_ind.
Lemma le_minus (n m:nat) : n - m <= n.
@@ -4797,6 +4799,7 @@ that performs inversion on hypothesis {\ident} of the form
\texttt{\qualid\ \term$_1$\dots\term$_n$\ = \term} or \texttt{\term\ =
\qualid\ \term$_1$\dots\term$_n$} where \qualid\ must have been
defined using \texttt{Function} (see Section~\ref{Function}).
+Note that this tactic is only available after a {\tt Require Import FunInd}.
\begin{ErrMsgs}
\item \errindex{Hypothesis {\ident} must contain at least one Function}
diff --git a/plugins/extraction/ExtrHaskellBasic.v b/plugins/extraction/ExtrHaskellBasic.v
index 294d61023b..d08a81da64 100644
--- a/plugins/extraction/ExtrHaskellBasic.v
+++ b/plugins/extraction/ExtrHaskellBasic.v
@@ -1,5 +1,7 @@
(** Extraction to Haskell : use of basic Haskell types *)
+Require Coq.extraction.Extraction.
+
Extract Inductive bool => "Prelude.Bool" [ "Prelude.True" "Prelude.False" ].
Extract Inductive option => "Prelude.Maybe" [ "Prelude.Just" "Prelude.Nothing" ].
Extract Inductive unit => "()" [ "()" ].
diff --git a/plugins/extraction/ExtrHaskellNatInt.v b/plugins/extraction/ExtrHaskellNatInt.v
index e94e7d42bd..267322d9ed 100644
--- a/plugins/extraction/ExtrHaskellNatInt.v
+++ b/plugins/extraction/ExtrHaskellNatInt.v
@@ -1,5 +1,7 @@
(** Extraction of [nat] into Haskell's [Int] *)
+Require Coq.extraction.Extraction.
+
Require Import Arith.
Require Import ExtrHaskellNatNum.
diff --git a/plugins/extraction/ExtrHaskellNatInteger.v b/plugins/extraction/ExtrHaskellNatInteger.v
index 038f0ed817..4c5c71f58a 100644
--- a/plugins/extraction/ExtrHaskellNatInteger.v
+++ b/plugins/extraction/ExtrHaskellNatInteger.v
@@ -1,5 +1,7 @@
(** Extraction of [nat] into Haskell's [Integer] *)
+Require Coq.extraction.Extraction.
+
Require Import Arith.
Require Import ExtrHaskellNatNum.
diff --git a/plugins/extraction/ExtrHaskellNatNum.v b/plugins/extraction/ExtrHaskellNatNum.v
index 244eb85fc2..fabe9a4c67 100644
--- a/plugins/extraction/ExtrHaskellNatNum.v
+++ b/plugins/extraction/ExtrHaskellNatNum.v
@@ -6,6 +6,8 @@
* implements [Num].
*)
+Require Coq.extraction.Extraction.
+
Require Import Arith.
Require Import EqNat.
diff --git a/plugins/extraction/ExtrHaskellString.v b/plugins/extraction/ExtrHaskellString.v
index 3558f4f254..ac1f6f9130 100644
--- a/plugins/extraction/ExtrHaskellString.v
+++ b/plugins/extraction/ExtrHaskellString.v
@@ -2,6 +2,8 @@
* Special handling of ascii and strings for extraction to Haskell.
*)
+Require Coq.extraction.Extraction.
+
Require Import Ascii.
Require Import String.
diff --git a/plugins/extraction/ExtrHaskellZInt.v b/plugins/extraction/ExtrHaskellZInt.v
index 66690851a7..0345ffc4e8 100644
--- a/plugins/extraction/ExtrHaskellZInt.v
+++ b/plugins/extraction/ExtrHaskellZInt.v
@@ -1,5 +1,7 @@
(** Extraction of [Z] into Haskell's [Int] *)
+Require Coq.extraction.Extraction.
+
Require Import ZArith.
Require Import ExtrHaskellZNum.
diff --git a/plugins/extraction/ExtrHaskellZInteger.v b/plugins/extraction/ExtrHaskellZInteger.v
index f192f16ee8..f7f9e2f80d 100644
--- a/plugins/extraction/ExtrHaskellZInteger.v
+++ b/plugins/extraction/ExtrHaskellZInteger.v
@@ -1,5 +1,7 @@
(** Extraction of [Z] into Haskell's [Integer] *)
+Require Coq.extraction.Extraction.
+
Require Import ZArith.
Require Import ExtrHaskellZNum.
diff --git a/plugins/extraction/ExtrHaskellZNum.v b/plugins/extraction/ExtrHaskellZNum.v
index cbbfda75e5..4141bd203f 100644
--- a/plugins/extraction/ExtrHaskellZNum.v
+++ b/plugins/extraction/ExtrHaskellZNum.v
@@ -6,6 +6,8 @@
* implements [Num].
*)
+Require Coq.extraction.Extraction.
+
Require Import ZArith.
Require Import EqNat.
diff --git a/plugins/extraction/ExtrOcamlBasic.v b/plugins/extraction/ExtrOcamlBasic.v
index d9b000c2af..dfdc498638 100644
--- a/plugins/extraction/ExtrOcamlBasic.v
+++ b/plugins/extraction/ExtrOcamlBasic.v
@@ -6,6 +6,8 @@
(* * GNU Lesser General Public License Version 2.1 *)
(************************************************************************)
+Require Coq.extraction.Extraction.
+
(** Extraction to Ocaml : use of basic Ocaml types *)
Extract Inductive bool => bool [ true false ].
diff --git a/plugins/extraction/ExtrOcamlBigIntConv.v b/plugins/extraction/ExtrOcamlBigIntConv.v
index c42938c8ec..78ee460856 100644
--- a/plugins/extraction/ExtrOcamlBigIntConv.v
+++ b/plugins/extraction/ExtrOcamlBigIntConv.v
@@ -13,6 +13,8 @@
simplifies the use of [Big_int] (it can be found in the sources
of Coq). *)
+Require Coq.extraction.Extraction.
+
Require Import Arith ZArith.
Parameter bigint : Type.
diff --git a/plugins/extraction/ExtrOcamlIntConv.v b/plugins/extraction/ExtrOcamlIntConv.v
index 515fa52dfa..fcfea352a7 100644
--- a/plugins/extraction/ExtrOcamlIntConv.v
+++ b/plugins/extraction/ExtrOcamlIntConv.v
@@ -10,6 +10,8 @@
Nota: no check that [int] values aren't generating overflows *)
+Require Coq.extraction.Extraction.
+
Require Import Arith ZArith.
Parameter int : Type.
diff --git a/plugins/extraction/ExtrOcamlNatBigInt.v b/plugins/extraction/ExtrOcamlNatBigInt.v
index 3149e70298..e0837be621 100644
--- a/plugins/extraction/ExtrOcamlNatBigInt.v
+++ b/plugins/extraction/ExtrOcamlNatBigInt.v
@@ -8,6 +8,8 @@
(** Extraction of [nat] into Ocaml's [big_int] *)
+Require Coq.extraction.Extraction.
+
Require Import Arith Even Div2 EqNat Euclid.
Require Import ExtrOcamlBasic.
diff --git a/plugins/extraction/ExtrOcamlNatInt.v b/plugins/extraction/ExtrOcamlNatInt.v
index 7c607f7ae6..80da72d43f 100644
--- a/plugins/extraction/ExtrOcamlNatInt.v
+++ b/plugins/extraction/ExtrOcamlNatInt.v
@@ -8,6 +8,8 @@
(** Extraction of [nat] into Ocaml's [int] *)
+Require Coq.extraction.Extraction.
+
Require Import Arith Even Div2 EqNat Euclid.
Require Import ExtrOcamlBasic.
diff --git a/plugins/extraction/ExtrOcamlString.v b/plugins/extraction/ExtrOcamlString.v
index 6af591eed3..64ca6c85d0 100644
--- a/plugins/extraction/ExtrOcamlString.v
+++ b/plugins/extraction/ExtrOcamlString.v
@@ -8,6 +8,8 @@
(* Extraction to Ocaml : special handling of ascii and strings *)
+Require Coq.extraction.Extraction.
+
Require Import Ascii String.
Extract Inductive ascii => char
diff --git a/plugins/extraction/ExtrOcamlZBigInt.v b/plugins/extraction/ExtrOcamlZBigInt.v
index c9e8eac0c5..66f188c84e 100644
--- a/plugins/extraction/ExtrOcamlZBigInt.v
+++ b/plugins/extraction/ExtrOcamlZBigInt.v
@@ -8,6 +8,8 @@
(** Extraction of [positive], [N] and [Z] into Ocaml's [big_int] *)
+Require Coq.extraction.Extraction.
+
Require Import ZArith NArith.
Require Import ExtrOcamlBasic.
diff --git a/plugins/extraction/ExtrOcamlZInt.v b/plugins/extraction/ExtrOcamlZInt.v
index 4d33174b35..c93cfb9d46 100644
--- a/plugins/extraction/ExtrOcamlZInt.v
+++ b/plugins/extraction/ExtrOcamlZInt.v
@@ -8,6 +8,8 @@
(** Extraction of [positive], [N] and [Z] into Ocaml's [int] *)
+Require Coq.extraction.Extraction.
+
Require Import ZArith NArith.
Require Import ExtrOcamlBasic.
diff --git a/plugins/extraction/Extraction.v b/plugins/extraction/Extraction.v
new file mode 100644
index 0000000000..ab1416b1d6
--- /dev/null
+++ b/plugins/extraction/Extraction.v
@@ -0,0 +1,9 @@
+(************************************************************************)
+(* v * The Coq Proof Assistant / The Coq Development Team *)
+(* false
diff --git a/test-suite/ide/blocking-futures.fake b/test-suite/ide/blocking-futures.fake
index b63f09bcfc..541fb798c0 100644
--- a/test-suite/ide/blocking-futures.fake
+++ b/test-suite/ide/blocking-futures.fake
@@ -4,6 +4,7 @@
# Extraction will force the future computation, assert it is blocking
# Example courtesy of Jonathan (jonikelee)
#
+ADD { Require Coq.extraction.Extraction. }
ADD { Require Import List. }
ADD { Import ListNotations. }
ADD { Definition myrev{A}(l : list A) : {rl : list A | rl = rev l}. }
diff --git a/test-suite/output/Extraction_matchs_2413.v b/test-suite/output/Extraction_matchs_2413.v
index 6c514b16ee..1ecd9771eb 100644
--- a/test-suite/output/Extraction_matchs_2413.v
+++ b/test-suite/output/Extraction_matchs_2413.v
@@ -1,5 +1,7 @@
(** Extraction : tests of optimizations of pattern matching *)
+Require Coq.extraction.Extraction.
+
(** First, a few basic tests *)
Definition test1 b :=
diff --git a/test-suite/success/Funind.v b/test-suite/success/Funind.v
index 3bf97c1312..f87f2e2a9d 100644
--- a/test-suite/success/Funind.v
+++ b/test-suite/success/Funind.v
@@ -1,4 +1,6 @@
+Require Import Coq.funind.FunInd.
+
Definition iszero (n : nat) : bool :=
match n with
| O => true
diff --git a/test-suite/success/RecTutorial.v b/test-suite/success/RecTutorial.v
index d8f8042465..8419404925 100644
--- a/test-suite/success/RecTutorial.v
+++ b/test-suite/success/RecTutorial.v
@@ -147,6 +147,7 @@ Proof.
intros; absurd (p < p); eauto with arith.
Qed.
+Require Coq.extraction.Extraction.
Extraction max.
diff --git a/test-suite/success/extraction.v b/test-suite/success/extraction.v
index 0086e090bd..89be144152 100644
--- a/test-suite/success/extraction.v
+++ b/test-suite/success/extraction.v
@@ -6,6 +6,7 @@
(* * GNU Lesser General Public License Version 2.1 *)
(************************************************************************)
+Require Coq.extraction.Extraction.
Require Import Arith.
Require Import List.
diff --git a/test-suite/success/extraction_dep.v b/test-suite/success/extraction_dep.v
index 11bb25fda0..e770cf779a 100644
--- a/test-suite/success/extraction_dep.v
+++ b/test-suite/success/extraction_dep.v
@@ -1,6 +1,8 @@
(** Examples of code elimination inside modules during extraction *)
+Require Coq.extraction.Extraction.
+
(** NB: we should someday check the produced code instead of
simply running the commands. *)
diff --git a/test-suite/success/extraction_impl.v b/test-suite/success/extraction_impl.v
index dfdeff82ff..5bf807b1c6 100644
--- a/test-suite/success/extraction_impl.v
+++ b/test-suite/success/extraction_impl.v
@@ -4,6 +4,8 @@
(** NB: we should someday check the produced code instead of
simply running the commands. *)
+Require Coq.extraction.Extraction.
+
(** Bug #4243, part 1 *)
Inductive dnat : nat -> Type :=
diff --git a/test-suite/success/extraction_polyprop.v b/test-suite/success/extraction_polyprop.v
index 7215bd9905..936d838c50 100644
--- a/test-suite/success/extraction_polyprop.v
+++ b/test-suite/success/extraction_polyprop.v
@@ -3,6 +3,8 @@
code that segfaults. See Table.error_singleton_become_prop
or S. Glondu's thesis for more details. *)
+Require Coq.extraction.Extraction.
+
Definition f {X} (p : (nat -> X) * True) : X * nat :=
(fst p 0, 0).
diff --git a/test-suite/success/primitiveproj.v b/test-suite/success/primitiveproj.v
index 2fa7704941..789854b2d6 100644
--- a/test-suite/success/primitiveproj.v
+++ b/test-suite/success/primitiveproj.v
@@ -181,6 +181,8 @@ Record wrap (A : Type) := { unwrap : A; unwrap2 : A }.
Definition term (x : wrap nat) := x.(unwrap).
Definition term' (x : wrap nat) := let f := (@unwrap2 nat) in f x.
+
+Require Coq.extraction.Extraction.
Recursive Extraction term term'.
(*Unset Printing Primitive Projection Parameters.*)
diff --git a/theories/Compat/Coq85.v b/theories/Compat/Coq85.v
index 64ba6b1e30..b30ad1af88 100644
--- a/theories/Compat/Coq85.v
+++ b/theories/Compat/Coq85.v
@@ -34,3 +34,6 @@ Global Unset Typeclasses Filtered Unification.
(** Allow silently letting unification constraints float after a "." *)
Global Unset Solve Unification Constraints.
+
+Require Export Coq.extraction.Extraction.
+Require Export Coq.funind.FunInd.
diff --git a/theories/FSets/FMapAVL.v b/theories/FSets/FMapAVL.v
index c9e5b8dd20..4a790296bb 100644
--- a/theories/FSets/FMapAVL.v
+++ b/theories/FSets/FMapAVL.v
@@ -16,7 +16,7 @@
See the comments at the beginning of FSetAVL for more details.
*)
-Require Import FMapInterface FMapList ZArith Int.
+Require Import FunInd FMapInterface FMapList ZArith Int.
Set Implicit Arguments.
Unset Strict Implicit.
diff --git a/theories/FSets/FMapFullAVL.v b/theories/FSets/FMapFullAVL.v
index a7be32328d..b8e362f159 100644
--- a/theories/FSets/FMapFullAVL.v
+++ b/theories/FSets/FMapFullAVL.v
@@ -25,7 +25,7 @@
*)
-Require Import Recdef FMapInterface FMapList ZArith Int FMapAVL ROmega.
+Require Import FunInd Recdef FMapInterface FMapList ZArith Int FMapAVL ROmega.
Set Implicit Arguments.
Unset Strict Implicit.
diff --git a/theories/FSets/FMapList.v b/theories/FSets/FMapList.v
index 5acdb7eb7e..aadef476d7 100644
--- a/theories/FSets/FMapList.v
+++ b/theories/FSets/FMapList.v
@@ -12,7 +12,7 @@
[FMapInterface.S] using lists of pairs ordered (increasing) with respect to
left projection. *)
-Require Import FMapInterface.
+Require Import FunInd FMapInterface.
Set Implicit Arguments.
Unset Strict Implicit.
diff --git a/theories/FSets/FMapWeakList.v b/theories/FSets/FMapWeakList.v
index 130cbee871..8124097020 100644
--- a/theories/FSets/FMapWeakList.v
+++ b/theories/FSets/FMapWeakList.v
@@ -11,7 +11,7 @@
(** This file proposes an implementation of the non-dependent interface
[FMapInterface.WS] using lists of pairs, unordered but without redundancy. *)
-Require Import FMapInterface.
+Require Import FunInd FMapInterface.
Set Implicit Arguments.
Unset Strict Implicit.
diff --git a/theories/Init/Prelude.v b/theories/Init/Prelude.v
index e71a8774ed..28049e9ee5 100644
--- a/theories/Init/Prelude.v
+++ b/theories/Init/Prelude.v
@@ -18,9 +18,7 @@ Require Export Coq.Init.Tactics.
Require Export Coq.Init.Tauto.
(* Initially available plugins
(+ nat_syntax_plugin loaded in Datatypes) *)
-Declare ML Module "extraction_plugin".
Declare ML Module "cc_plugin".
Declare ML Module "ground_plugin".
-Declare ML Module "recdef_plugin".
(* Default substrings not considered by queries like SearchAbout *)
Add Search Blacklist "_subproof" "_subterm" "Private_".
diff --git a/theories/MSets/MSetAVL.v b/theories/MSets/MSetAVL.v
index a3c265a21f..b30cb6b565 100644
--- a/theories/MSets/MSetAVL.v
+++ b/theories/MSets/MSetAVL.v
@@ -31,7 +31,7 @@
code after extraction.
*)
-Require Import MSetInterface MSetGenTree BinInt Int.
+Require Import FunInd MSetInterface MSetGenTree BinInt Int.
Set Implicit Arguments.
Unset Strict Implicit.
diff --git a/theories/MSets/MSetGenTree.v b/theories/MSets/MSetGenTree.v
index 154c2384c8..036ff1aa4b 100644
--- a/theories/MSets/MSetGenTree.v
+++ b/theories/MSets/MSetGenTree.v
@@ -27,7 +27,7 @@
- min_elt max_elt choose
*)
-Require Import Orders OrdersFacts MSetInterface PeanoNat.
+Require Import FunInd Orders OrdersFacts MSetInterface PeanoNat.
Local Open Scope list_scope.
Local Open Scope lazy_bool_scope.
diff --git a/theories/Program/Wf.v b/theories/Program/Wf.v
index c490ea5166..6e51f61873 100644
--- a/theories/Program/Wf.v
+++ b/theories/Program/Wf.v
@@ -69,6 +69,7 @@ Section Well_founded.
End Well_founded.
+Require Coq.extraction.Extraction.
Extraction Inline Fix_F_sub Fix_sub.
Set Implicit Arguments.
--
cgit v1.2.3
From 706b16c3c714f91bfff33ce340aec6f2d24fe246 Mon Sep 17 00:00:00 2001
From: Pierre Letouzey
Date: Sat, 10 Jun 2017 15:54:31 +0200
Subject: API: exports Mltop.module_is_known to both API.mli and
grammar_API.mli
---
API/API.mli | 1 +
API/grammar_API.mli | 1 +
2 files changed, 2 insertions(+)
diff --git a/API/API.mli b/API/API.mli
index 20a637c1fa..9714f52b91 100644
--- a/API/API.mli
+++ b/API/API.mli
@@ -3307,6 +3307,7 @@ sig
val declare_cache_obj : (unit -> unit) -> string -> unit
val add_known_plugin : (unit -> unit) -> string -> unit
val add_known_module : string -> unit
+ val module_is_known : string -> bool
end
(* All items in the Proof_type module are deprecated. *)
diff --git a/API/grammar_API.mli b/API/grammar_API.mli
index 44aae771f6..4da5b380fe 100644
--- a/API/grammar_API.mli
+++ b/API/grammar_API.mli
@@ -211,6 +211,7 @@ end
module Mltop :
sig
val add_known_module : string -> unit
+ val module_is_known : string -> bool
val declare_cache_obj : (unit -> unit) -> string -> unit
end
module Vernacinterp :
--
cgit v1.2.3
From a4faac6d24d28ae49ff38477f92f85aef6759075 Mon Sep 17 00:00:00 2001
From: Pierre Letouzey
Date: Thu, 23 Jun 2016 15:11:16 +0200
Subject: Grammar hacks to get nice errors about non-loaded plugins
(extr,recdef)
Since previous commit, some plugins are not loaded initially anymore :
extraction, funind. To ease this transition toward a mandatory Require,
we hack here the vernac grammar in order to get customized error messages
telling what to Require instead of the dreadful "Illegal begin of vernac".
Normally, these fake grammar entries are overloaded later by the grammar
extensions in these plugins. This code is meant to be removed in a few releases,
when this transition is considered finished.
NB : In a first attempt, a similar trick was tried in g_tactics.ml4 to
provide customized error message for "functional induction" and "functional
inversion", but this was leading to anomalies.
---
parsing/g_vernac.ml4 | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/parsing/g_vernac.ml4 b/parsing/g_vernac.ml4
index 893605499c..b605a44c87 100644
--- a/parsing/g_vernac.ml4
+++ b/parsing/g_vernac.ml4
@@ -51,6 +51,20 @@ let make_bullet s =
| '*' -> Star n
| _ -> assert false
+let extraction_err ~loc =
+ if not (Mltop.module_is_known "extraction_plugin") then
+ CErrors.user_err ~loc (str "Please do first a Require Extraction.")
+ else
+ (* The right grammar entries should have been loaded.
+ We could only end here in case of syntax error. *)
+ raise (Stream.Error "unexpected end of command")
+
+let funind_err ~loc =
+ if not (Mltop.module_is_known "recdef_plugin") then
+ CErrors.user_err ~loc (str "Please do first a Require Import FunInd.")
+ else
+ raise (Stream.Error "unexpected end of command") (* Same as above... *)
+
GEXTEND Gram
GLOBAL: vernac gallina_ext noedit_mode subprf;
vernac: FIRST
@@ -841,6 +855,22 @@ GEXTEND Gram
| IDENT "DelPath"; dir = ne_string ->
VernacRemoveLoadPath dir
+ (* Some plugins are not loaded initially anymore : extraction,
+ and funind. To ease this transition toward a mandatory Require,
+ we hack here the vernac grammar in order to get customized
+ error messages telling what to Require instead of the dreadful
+ "Illegal begin of vernac". Normally, these fake grammar entries
+ are overloaded later by the grammar extensions in these plugins.
+ This code is meant to be removed in a few releases, when this
+ transition is considered finished. *)
+
+ | IDENT "Extraction" -> extraction_err ~loc:!@loc
+ | IDENT "Extract" -> extraction_err ~loc:!@loc
+ | IDENT "Recursive"; IDENT "Extraction" -> extraction_err ~loc:!@loc
+ | IDENT "Separate"; IDENT "Extraction" -> extraction_err ~loc:!@loc
+ | IDENT "Function" -> funind_err ~loc:!@loc
+ | IDENT "Functional" -> funind_err ~loc:!@loc
+
(* Type-Checking (pas dans le refman) *)
| "Type"; c = lconstr -> VernacGlobalCheck c
--
cgit v1.2.3
From 930662915d75af750db7da1043f9feda321095b3 Mon Sep 17 00:00:00 2001
From: Pierre Letouzey
Date: Tue, 13 Jun 2017 12:04:34 +0200
Subject: Recdef do now a Require Export FunInd (better compat)
---
plugins/funind/Recdef.v | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plugins/funind/Recdef.v b/plugins/funind/Recdef.v
index c6fcd647ff..64f43b8335 100644
--- a/plugins/funind/Recdef.v
+++ b/plugins/funind/Recdef.v
@@ -6,7 +6,7 @@
(* * GNU Lesser General Public License Version 2.1 *)
(************************************************************************)
-Require Import Coq.funind.FunInd.
+Require Export Coq.funind.FunInd.
Require Import PeanoNat.
Require Compare_dec.
Require Wf_nat.
--
cgit v1.2.3
From c70a21a1c522639138dbcfac53fb2ed96d731d98 Mon Sep 17 00:00:00 2001
From: Pierre Letouzey
Date: Tue, 13 Jun 2017 12:05:04 +0200
Subject: [travis] fix CoLoR by inserting some Require Import FunInd
---
dev/ci/ci-color.sh | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/dev/ci/ci-color.sh b/dev/ci/ci-color.sh
index 57f569858b..a0a4e0749d 100755
--- a/dev/ci/ci-color.sh
+++ b/dev/ci/ci-color.sh
@@ -18,4 +18,18 @@ sed -i -e "s/From Coq Require Export BigN/From Bignums Require Export BigN/" ${C
sed -i -e "s/From Coq Require Import BigZ/From Bignums Require Import BigZ/" ${Color_CI_DIR}/Util/*/*.v
sed -i -e "s/From Coq Require Export BigZ/From Bignums Require Export BigZ/" ${Color_CI_DIR}/Util/*/*.v
+# Adapt to PR #220 (FunInd not loaded in Prelude anymore)
+sed -i -e "15i From Coq Require Import FunInd." ${Color_CI_DIR}/Coccinelle/basis/ordered_set.v
+sed -i -e "8i From Coq Require Import FunInd." ${Color_CI_DIR}/Coccinelle/examples/cime_trace/equational_extension.v
+sed -i -e "6i From Coq Require Import FunInd." ${Color_CI_DIR}/Coccinelle/examples/cime_trace/more_list_extention.v
+sed -i -e "6i From Coq Require Import FunInd." ${Color_CI_DIR}/Coccinelle/examples/cime_trace/ring_extention.v
+sed -i -e "27i From Coq Require Import FunInd." ${Color_CI_DIR}/Coccinelle/list_extensions/dickson.v
+sed -i -e "26i From Coq Require Import FunInd." ${Color_CI_DIR}/Coccinelle/list_extensions/list_permut.v
+sed -i -e "23i From Coq Require Import FunInd." ${Color_CI_DIR}/Coccinelle/list_extensions/list_set.v
+sed -i -e "25i From Coq Require Import FunInd." ${Color_CI_DIR}/Coccinelle/list_extensions/list_sort.v
+sed -i -e "21i From Coq Require Import FunInd." ${Color_CI_DIR}/Coccinelle/list_extensions/more_list.v
+sed -i -e "21i From Coq Require Import FunInd." ${Color_CI_DIR}/Util/List/ListUtil.v
+sed -i -e "17i From Coq Require Import FunInd." ${Color_CI_DIR}/Util/Multiset/MultisetOrder.v
+sed -i -e "13i From Coq Require Import FunInd." ${Color_CI_DIR}/Util/Set/SetUtil.v
+
( cd ${Color_CI_DIR} && make -j ${NJOBS} )
--
cgit v1.2.3
From bba2186f781695db9d0987758119fde061499fbc Mon Sep 17 00:00:00 2001
From: Pierre Letouzey
Date: Tue, 13 Jun 2017 12:44:01 +0200
Subject: [travis] fix Software Foundation (one added Require Extraction)
---
dev/ci/ci-sf.sh | 2 ++
1 file changed, 2 insertions(+)
diff --git a/dev/ci/ci-sf.sh b/dev/ci/ci-sf.sh
index 7d23ccad97..23ef41d2dd 100755
--- a/dev/ci/ci-sf.sh
+++ b/dev/ci/ci-sf.sh
@@ -7,6 +7,8 @@ source ${ci_dir}/ci-common.sh
wget ${sf_CI_TARURL}
tar xvfz sf.tgz
+sed -i.bak '15i From Coq Require Extraction.' sf/Extraction.v
+
( cd sf && sed -i.bak 's/(K,N)/((K,N))/' LibTactics.v && make clean && make -j ${NJOBS} )
--
cgit v1.2.3
From 2470182ac4bded5c433c8f6bc77eb7b96576dc8d Mon Sep 17 00:00:00 2001
From: Pierre Letouzey
Date: Tue, 13 Jun 2017 14:48:22 +0200
Subject: [travis] overlays for CompCert and VST (an extra Require Export
FunInd)
---
dev/ci/ci-user-overlay.sh | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/dev/ci/ci-user-overlay.sh b/dev/ci/ci-user-overlay.sh
index 200d431bcb..62c245b4fe 100644
--- a/dev/ci/ci-user-overlay.sh
+++ b/dev/ci/ci-user-overlay.sh
@@ -47,3 +47,10 @@ if [ $TRAVIS_PULL_REQUEST == "498" ] || [ $TRAVIS_BRANCH == "outsource-bignums"
Corn_CI_BRANCH=external-bignums
Corn_CI_GITURL=https://github.com/letouzey/corn.git
fi
+
+if [ $TRAVIS_PULL_REQUEST == "220" ] || [ $TRAVIS_BRANCH == "less_init_plugins" ]; then
+ CompCert_CI_BRANCH=less_init_plugins
+ CompCert_CI_GITURL=https://github.com/letouzey/CompCert.git
+ VST_CI_BRANCH=less_init_plugins
+ VST_CI_GITURL=https://github.com/letouzey/VST.git
+fi
--
cgit v1.2.3
From bb6dbba6a76f83c7cbac7a1f8d6eaa14da2d3d40 Mon Sep 17 00:00:00 2001
From: Pierre Letouzey
Date: Tue, 13 Jun 2017 15:47:56 +0200
Subject: [travis] overlay for fiat-crypto (a Require Import FunInd)
---
dev/ci/ci-user-overlay.sh | 2 ++
1 file changed, 2 insertions(+)
diff --git a/dev/ci/ci-user-overlay.sh b/dev/ci/ci-user-overlay.sh
index 62c245b4fe..2ecd40416f 100644
--- a/dev/ci/ci-user-overlay.sh
+++ b/dev/ci/ci-user-overlay.sh
@@ -53,4 +53,6 @@ if [ $TRAVIS_PULL_REQUEST == "220" ] || [ $TRAVIS_BRANCH == "less_init_plugins"
CompCert_CI_GITURL=https://github.com/letouzey/CompCert.git
VST_CI_BRANCH=less_init_plugins
VST_CI_GITURL=https://github.com/letouzey/VST.git
+ fiat_crypto_CI_BRANCH=less_init_plugins
+ fiat_crypto_CI_GITURL=https://github.com/letouzey/fiat-crypto.git
fi
--
cgit v1.2.3
From f4cec75fe74ff3f66f401efab357cae79124d984 Mon Sep 17 00:00:00 2001
From: Maxime Dénès
Date: Wed, 14 Jun 2017 10:32:17 +0200
Subject: Temporary overlays because fewer plugins are loaded at startup.
---
dev/ci/ci-basic-overlay.sh | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/dev/ci/ci-basic-overlay.sh b/dev/ci/ci-basic-overlay.sh
index 54db58c01f..b582921ecb 100644
--- a/dev/ci/ci-basic-overlay.sh
+++ b/dev/ci/ci-basic-overlay.sh
@@ -73,14 +73,14 @@
########################################################################
# CompCert
########################################################################
-: ${CompCert_CI_BRANCH:=master}
-: ${CompCert_CI_GITURL:=https://github.com/AbsInt/CompCert.git}
+: ${CompCert_CI_BRANCH:=less_init_plugins}
+: ${CompCert_CI_GITURL:=https://github.com/letouzey/CompCert.git}
########################################################################
# VST
########################################################################
-: ${VST_CI_BRANCH:=master}
-: ${VST_CI_GITURL:=https://github.com/PrincetonUniversity/VST.git}
+: ${VST_CI_BRANCH:=less_init_plugins}
+: ${VST_CI_GITURL:=https://github.com/letouzey/VST.git}
########################################################################
# fiat_parsers
@@ -91,8 +91,8 @@
########################################################################
# fiat_crypto
########################################################################
-: ${fiat_crypto_CI_BRANCH:=master}
-: ${fiat_crypto_CI_GITURL:=https://github.com/mit-plv/fiat-crypto.git}
+: ${fiat_crypto_CI_BRANCH:=less_init_plugins}
+: ${fiat_crypto_CI_GITURL:=https://github.com/letouzey/fiat-crypto.git}
########################################################################
# bedrock_src
--
cgit v1.2.3
From d50923b778684a2ffcc211beb5341a54304c97a4 Mon Sep 17 00:00:00 2001
From: Emilio Jesus Gallego Arias
Date: Sun, 4 Jun 2017 18:06:26 +0200
Subject: [print] Allow Selective Printing of Notations
We add new API to the printer to allows toggling the printing of
individual notations and scopes:
```ocaml
val toggle_scope_printing :
scope:Notation_term.scope_name -> activate:bool -> unit
val toggle_notation_printing :
?scope:Notation_term.scope_name -> notation:Constrexpr.notation -> activate:bool -> unit
```
This API is meant to be used by ML plugins.
[this commit includes some refactoring by EJGA]
---
interp/constrextern.ml | 135 +++++++++++++++++++++++++++++++++++++++++++++---
interp/constrextern.mli | 10 ++++
2 files changed, 137 insertions(+), 8 deletions(-)
diff --git a/interp/constrextern.ml b/interp/constrextern.ml
index d254520e0e..f405100b1d 100644
--- a/interp/constrextern.ml
+++ b/interp/constrextern.ml
@@ -66,8 +66,115 @@ let print_universes = Detyping.print_universes
(* This suppresses printing of primitive tokens (e.g. numeral) and notations *)
let print_no_symbol = ref false
-(* This tells which notations still not to used if print_no_symbol is true *)
-let print_non_active_notations = ref ([] : interp_rule list)
+(**********************************************************************)
+(* Turning notations and scopes on and off for printing *)
+module IRuleSet = Set.Make(struct
+ type t = interp_rule
+ let compare x y = Pervasives.compare x y
+ end)
+
+let inactive_notations_table =
+ Summary.ref ~name:"inactive_notations_table" (IRuleSet.empty)
+let inactive_scopes_table =
+ Summary.ref ~name:"inactive_scopes_table" CString.Set.empty
+
+let show_scope scopt =
+ match scopt with
+ | None -> str ""
+ | Some sc -> spc () ++ str "in scope" ++ spc () ++ str sc
+
+let _show_inactive_notations () =
+ begin
+ if CString.Set.is_empty !inactive_scopes_table
+ then
+ Feedback.msg_notice (str "No inactive notation scopes.")
+ else
+ let _ = Feedback.msg_notice (str "Inactive notation scopes:") in
+ CString.Set.iter (fun sc -> Feedback.msg_notice (str " " ++ str sc))
+ !inactive_scopes_table
+ end;
+ if IRuleSet.is_empty !inactive_notations_table
+ then
+ Feedback.msg_notice (str "No individual inactive notations.")
+ else
+ let _ = Feedback.msg_notice (str "Inactive notations:") in
+ IRuleSet.iter
+ (function
+ | NotationRule (scopt, ntn) ->
+ Feedback.msg_notice (str ntn ++ show_scope scopt)
+ | SynDefRule kn -> Feedback.msg_notice (str (Names.KerName.to_string kn)))
+ !inactive_notations_table
+
+let deactivate_notation nr =
+ match nr with
+ | SynDefRule kn ->
+ (* shouldn't we check wether it is well defined? *)
+ inactive_notations_table := IRuleSet.add nr !inactive_notations_table
+ | NotationRule (scopt, ntn) ->
+ match availability_of_notation (scopt, ntn) (scopt, []) with
+ | None -> user_err ~hdr:"Notation"
+ (str ntn ++ spc () ++ str "does not exist"
+ ++ (match scopt with
+ | None -> spc () ++ str "in the empty scope."
+ | Some _ -> show_scope scopt ++ str "."))
+ | Some _ ->
+ if IRuleSet.mem nr !inactive_notations_table then
+ Feedback.msg_warning
+ (str "Notation" ++ spc () ++ str ntn ++ spc ()
+ ++ str "is already inactive" ++ show_scope scopt ++ str ".")
+ else inactive_notations_table := IRuleSet.add nr !inactive_notations_table
+
+let reactivate_notation nr =
+ try
+ inactive_notations_table :=
+ IRuleSet.remove nr !inactive_notations_table
+ with Not_found ->
+ match nr with
+ | NotationRule (scopt, ntn) ->
+ Feedback.msg_warning (str "Notation" ++ spc () ++ str ntn ++ spc ()
+ ++ str "is already active" ++ show_scope scopt ++
+ str ".")
+ | SynDefRule kn ->
+ Feedback.msg_warning
+ (str "Notation" ++ spc () ++ str (Names.KerName.to_string kn)
+ ++ spc () ++ str "is already active.")
+
+
+let deactivate_scope sc =
+ ignore (find_scope sc); (* ensures that the scope exists *)
+ if CString.Set.mem sc !inactive_scopes_table
+ then
+ Feedback.msg_warning (str "Notation Scope" ++ spc () ++ str sc ++ spc ()
+ ++ str "is already inactive.")
+ else
+ inactive_scopes_table := CString.Set.add sc !inactive_scopes_table
+
+let reactivate_scope sc =
+ try
+ inactive_scopes_table := CString.Set.remove sc !inactive_scopes_table
+ with Not_found ->
+ Feedback.msg_warning (str "Notation Scope" ++ spc () ++ str sc ++ spc ()
+ ++ str "is already active.")
+
+let is_inactive_rule nr =
+ IRuleSet.mem nr !inactive_notations_table ||
+ match nr with
+ | NotationRule (Some sc, ntn) -> CString.Set.mem sc !inactive_scopes_table
+ | NotationRule (None, ntn) -> false
+ | SynDefRule _ -> false
+
+(* args: notation, scope, activate/deactivate *)
+let toggle_scope_printing ~scope ~activate =
+ if activate then
+ reactivate_scope scope
+ else
+ deactivate_scope scope
+
+let toggle_notation_printing ?scope ~notation ~activate =
+ if activate then
+ reactivate_notation (NotationRule (scope, notation))
+ else
+ deactivate_notation (NotationRule (scope, notation))
(* This governs printing of projections using the dot notation symbols *)
let print_projections = ref false
@@ -80,8 +187,20 @@ let with_coercions f = Flags.with_option print_coercions f
let with_universes f = Flags.with_option print_universes f
let with_meta_as_hole f = Flags.with_option print_meta_as_hole f
let without_symbols f = Flags.with_option print_no_symbol f
-let without_specific_symbols l f =
- Flags.with_extra_values print_non_active_notations l f
+
+(* XXX: Where to put this in the library? Util maybe? *)
+let protect_ref r nf f x =
+ let old_ref = !r in
+ r := nf !r;
+ try let res = f x in r := old_ref; res
+ with reraise ->
+ let reraise = Backtrace.add_backtrace reraise in
+ r := old_ref;
+ Exninfo.iraise reraise
+
+let without_specific_symbols l =
+ protect_ref inactive_notations_table
+ (fun tbl -> IRuleSet.(union (of_list l) tbl))
(**********************************************************************)
(* Control printing of records *)
@@ -390,7 +509,7 @@ and extern_notation_pattern (tmp_scope,scopes as allscopes) vars t = function
| [] -> raise No_match
| (keyrule,pat,n as _rule)::rules ->
try
- if List.mem keyrule !print_non_active_notations then raise No_match;
+ if is_inactive_rule keyrule then raise No_match;
let loc = t.loc in
match t.v with
| PatCstr (cstr,_,na) ->
@@ -406,8 +525,8 @@ let rec extern_notation_ind_pattern allscopes vars ind args = function
| [] -> raise No_match
| (keyrule,pat,n as _rule)::rules ->
try
- if List.mem keyrule !print_non_active_notations then raise No_match;
- apply_notation_to_pattern (IndRef ind)
+ if is_inactive_rule keyrule then raise No_match;
+ apply_notation_to_pattern (IndRef ind)
(match_notation_constr_ind_pattern ind args pat) allscopes vars keyrule
with
No_match -> extern_notation_ind_pattern allscopes vars ind args rules
@@ -877,7 +996,7 @@ and extern_notation (tmp_scope,scopes as allscopes) vars t = function
| (keyrule,pat,n as _rule)::rules ->
let loc = Glob_ops.loc_of_glob_constr t in
try
- if List.mem keyrule !print_non_active_notations then raise No_match;
+ if is_inactive_rule keyrule then raise No_match;
(* Adjusts to the number of arguments expected by the notation *)
let (t,args,argsscopes,argsimpls) = match t.v ,n with
| GApp (f,args), Some n
diff --git a/interp/constrextern.mli b/interp/constrextern.mli
index ea627cff11..d771ee86fb 100644
--- a/interp/constrextern.mli
+++ b/interp/constrextern.mli
@@ -80,3 +80,13 @@ val without_specific_symbols : interp_rule list -> ('a -> 'b) -> 'a -> 'b
(** This prints metas as anonymous holes *)
val with_meta_as_hole : ('a -> 'b) -> 'a -> 'b
+
+(** Fine-grained activation and deactivation of notation printing.
+ *)
+val toggle_scope_printing :
+ scope:Notation_term.scope_name -> activate:bool -> unit
+
+val toggle_notation_printing :
+ ?scope:Notation_term.scope_name -> notation:Constrexpr.notation -> activate:bool -> unit
+
+
--
cgit v1.2.3
From 6c6c045a42dc591a0c35730e0abff80be0c8b9bb Mon Sep 17 00:00:00 2001
From: Matthieu Sozeau
Date: Wed, 14 Jun 2017 15:37:14 +0200
Subject: [typeclasses eauto] Fix bug #3943: non-termination in topological
sorting for the dependency order option.
---
tactics/class_tactics.ml | 2 +-
test-suite/bugs/closed/3943.v | 50 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 51 insertions(+), 1 deletion(-)
create mode 100644 test-suite/bugs/closed/3943.v
diff --git a/tactics/class_tactics.ml b/tactics/class_tactics.ml
index 4bde427b15..cb0f66730a 100644
--- a/tactics/class_tactics.ml
+++ b/tactics/class_tactics.ml
@@ -527,10 +527,10 @@ let top_sort evm undefs =
let tosee = ref undefs in
let rec visit ev evi =
let evs = Evarutil.undefined_evars_of_evar_info evm evi in
+ tosee := Evar.Map.remove ev !tosee;
Evar.Set.iter (fun ev ->
if Evar.Map.mem ev !tosee then
visit ev (Evar.Map.find ev !tosee)) evs;
- tosee := Evar.Map.remove ev !tosee;
l' := ev :: !l';
in
while not (Evar.Map.is_empty !tosee) do
diff --git a/test-suite/bugs/closed/3943.v b/test-suite/bugs/closed/3943.v
new file mode 100644
index 0000000000..5e5ba816f9
--- /dev/null
+++ b/test-suite/bugs/closed/3943.v
@@ -0,0 +1,50 @@
+(* File reduced by coq-bug-finder from original input, then from 9492 lines to 119 lines *)
+(* coqc version 8.5beta1 (January 2015) compiled on Jan 18 2015 7:27:36 with OCaml 3.12.1
+ coqtop version 8.5beta1 (January 2015) *)
+
+Set Typeclasses Dependency Order.
+
+Inductive paths {A : Type} (a : A) : A -> Type :=
+ idpath : paths a a.
+Arguments idpath {A a} , [A] a.
+Notation "x = y" := (@paths _ x y) : type_scope.
+Definition ap {A B:Type} (f:A -> B) {x y:A} (p:x = y) : f x = f y
+ := match p with idpath => idpath end.
+
+Set Implicit Arguments.
+Delimit Scope morphism_scope with morphism.
+Delimit Scope category_scope with category.
+Delimit Scope object_scope with object.
+
+Record PreCategory := Build_PreCategory' {
+ object :> Type;
+ morphism : object -> object -> Type;
+ identity : forall x, morphism x x;
+ compose : forall s d d',
+ morphism d d'
+ -> morphism s d
+ -> morphism s d' }.
+Arguments identity {!C%category} / x%object : rename.
+Arguments compose {!C%category} / {s d d'}%object (m1 m2)%morphism : rename.
+
+Class IsIsomorphism {C : PreCategory} {s d} (m : morphism C s d) := {
+ morphism_inverse : morphism C d s;
+ left_inverse : compose morphism_inverse m = identity _;
+ right_inverse : compose m morphism_inverse = identity _ }.
+Arguments morphism_inverse {C s d} m {_}.
+Local Notation "m ^-1" := (morphism_inverse m) (at level 3, format "m '^-1'") : morphism_scope.
+
+Class Isomorphic {C : PreCategory} s d := {
+ morphism_isomorphic :> morphism C s d;
+ isisomorphism_isomorphic :> IsIsomorphism morphism_isomorphic }.
+Coercion morphism_isomorphic : Isomorphic >-> morphism.
+
+Variable C : PreCategory.
+Variables s d : C.
+
+Definition path_isomorphic (i j : Isomorphic s d)
+: @morphism_isomorphic _ _ _ i = @morphism_isomorphic _ _ _ j -> i = j.
+Admitted.
+
+Definition ap_morphism_inverse_path_isomorphic (i j : Isomorphic s d) p q
+: ap (fun e : Isomorphic s d => e^-1)%morphism (path_isomorphic i j p) = q.
\ No newline at end of file
--
cgit v1.2.3
From 10a16e4673230fc5c41856fa987f46f904fffcbe Mon Sep 17 00:00:00 2001
From: Théo Zimmermann
Date: Wed, 14 Jun 2017 16:18:20 +0200
Subject: Direct link to Travis branch builds.
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 91f9c560e8..93ab435411 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# Coq
-[](https://travis-ci.org/coq/coq) [](https://gitter.im/coq/coq)
+[](https://travis-ci.org/coq/coq/builds) [](https://gitter.im/coq/coq)
Coq is a formal proof management system. It provides a formal language to write
mathematical definitions, executable algorithms and theorems together with an
--
cgit v1.2.3
From c79db93e50b56e0abbc5a36b58a1db61a7d512bd Mon Sep 17 00:00:00 2001
From: Hugo Herbelin
Date: Wed, 14 Jun 2017 22:21:35 +0200
Subject: Fixing restrict regarding evar_store.
---
engine/evd.ml | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/engine/evd.ml b/engine/evd.ml
index 08d26f40d4..bf1e052b63 100644
--- a/engine/evd.ml
+++ b/engine/evd.ml
@@ -659,8 +659,7 @@ let restrict evk filter ?candidates ?src evd =
let evar_info' =
{ evar_info with evar_filter = filter;
evar_candidates = candidates;
- evar_source = (match src with None -> evar_info.evar_source | Some src -> src);
- evar_extra = Store.empty } in
+ evar_source = (match src with None -> evar_info.evar_source | Some src -> src) } in
let last_mods = match evd.conv_pbs with
| [] -> evd.last_mods
| _ -> Evar.Set.add evk evd.last_mods in
--
cgit v1.2.3
From 48219205d121ea3093287ac1b887fc81067fac6a Mon Sep 17 00:00:00 2001
From: Pierre Letouzey
Date: Thu, 15 Jun 2017 10:13:37 +0200
Subject: coqdep: correct support of Local Declare ML Module
---
tools/coqdep_lexer.mll | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/tools/coqdep_lexer.mll b/tools/coqdep_lexer.mll
index c68c34bbbd..9224cdafe8 100644
--- a/tools/coqdep_lexer.mll
+++ b/tools/coqdep_lexer.mll
@@ -74,7 +74,9 @@ let dot = '.' ( space+ | eof)
rule coq_action = parse
| "Require" space+
{ require_modifiers None lexbuf }
- | "Local"? "Declare" space+ "ML" space+ "Module" space+
+ | "Local" space+ "Declare" space+ "ML" space+ "Module" space+
+ { modules [] lexbuf }
+ | "Declare" space+ "ML" space+ "Module" space+
{ modules [] lexbuf }
| "Load" space+
{ load_file lexbuf }
--
cgit v1.2.3
From 929dc481c91dc860b69b08dd65fb6f65d5650e23 Mon Sep 17 00:00:00 2001
From: Maxime Dénès
Date: Thu, 15 Jun 2017 11:32:56 +0200
Subject: Remove dependency on -compat flag in coq_makefile test suite.
---
test-suite/coq-makefile/arg/_CoqProject | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test-suite/coq-makefile/arg/_CoqProject b/test-suite/coq-makefile/arg/_CoqProject
index afdb32e7cf..53dc963997 100644
--- a/test-suite/coq-makefile/arg/_CoqProject
+++ b/test-suite/coq-makefile/arg/_CoqProject
@@ -1,7 +1,7 @@
-R theories test
-R src test
-I src
--arg "-compat 8.4"
+-arg "-w default"
src/test_plugin.mlpack
src/test.ml4
--
cgit v1.2.3
From c5dabed1c1f33005fe942882ea0fcf008d52784a Mon Sep 17 00:00:00 2001
From: Maxime Dénès
Date: Thu, 15 Jun 2017 11:45:45 +0200
Subject: Remove bedrock from test suite.
Bedrock relies on the 8.4 compat flag that we are removing, and we heard
from MIT that they did not plan to port bedrock to more recent versions
of Coq.
---
.gitlab-ci.yml | 6 ------
.travis.yml | 2 --
Makefile.ci | 2 --
dev/ci/ci-basic-overlay.sh | 12 ------------
dev/ci/ci-bedrock-facade.sh | 10 ----------
dev/ci/ci-bedrock-src.sh | 10 ----------
dev/ci/ci-user-overlay.sh | 4 ----
7 files changed, 46 deletions(-)
delete mode 100755 dev/ci/ci-bedrock-facade.sh
delete mode 100755 dev/ci/ci-bedrock-src.sh
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index d5351f5738..1de9e7f7c8 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -244,12 +244,6 @@ validate:32bit:
ci-bignums:
<<: *ci-template
-ci-bedrock-src:
- <<: *ci-template
-
-ci-bedrock-facade:
- <<: *ci-template
-
ci-color:
<<: *ci-template
variables:
diff --git a/.travis.yml b/.travis.yml
index 01680583f0..224dfe2f57 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -38,8 +38,6 @@ env:
- TEST_TARGET="validate" TW="travis_wait"
- TEST_TARGET="validate" COMPILER="4.02.3+32bit" TW="travis_wait"
- TEST_TARGET="ci-bignums"
- - TEST_TARGET="ci-bedrock-src"
- - TEST_TARGET="ci-bedrock-facade"
- TEST_TARGET="ci-color"
- TEST_TARGET="ci-compcert"
- TEST_TARGET="ci-coq-dpdgraph" EXTRA_OPAM="ocamlgraph"
diff --git a/Makefile.ci b/Makefile.ci
index 2f7fcd48a5..3be90c0a31 100644
--- a/Makefile.ci
+++ b/Makefile.ci
@@ -1,7 +1,5 @@
CI_TARGETS=ci-all \
ci-bignums \
- ci-bedrock-facade \
- ci-bedrock-src \
ci-color \
ci-compcert \
ci-coq-dpdgraph \
diff --git a/dev/ci/ci-basic-overlay.sh b/dev/ci/ci-basic-overlay.sh
index 7f66dfb3b0..0099e815f4 100644
--- a/dev/ci/ci-basic-overlay.sh
+++ b/dev/ci/ci-basic-overlay.sh
@@ -94,18 +94,6 @@
: ${fiat_crypto_CI_BRANCH:=less_init_plugins}
: ${fiat_crypto_CI_GITURL:=https://github.com/letouzey/fiat-crypto.git}
-########################################################################
-# bedrock_src
-########################################################################
-: ${bedrock_src_CI_BRANCH:=master}
-: ${bedrock_src_CI_GITURL:=https://github.com/mit-plv/bedrock.git}
-
-########################################################################
-# bedrock_facade
-########################################################################
-: ${bedrock_facade_CI_BRANCH:=master}
-: ${bedrock_facade_CI_GITURL:=https://github.com/mit-plv/bedrock.git}
-
########################################################################
# formal-topology
########################################################################
diff --git a/dev/ci/ci-bedrock-facade.sh b/dev/ci/ci-bedrock-facade.sh
deleted file mode 100755
index 95cfa3073f..0000000000
--- a/dev/ci/ci-bedrock-facade.sh
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/usr/bin/env bash
-
-ci_dir="$(dirname "$0")"
-source ${ci_dir}/ci-common.sh
-
-bedrock_facade_CI_DIR=${CI_BUILD_DIR}/bedrock-facade
-
-git_checkout ${bedrock_facade_CI_BRANCH} ${bedrock_facade_CI_GITURL} ${bedrock_facade_CI_DIR}
-
-( cd ${bedrock_facade_CI_DIR} && make -j ${NJOBS} facade )
diff --git a/dev/ci/ci-bedrock-src.sh b/dev/ci/ci-bedrock-src.sh
deleted file mode 100755
index 532611d4b3..0000000000
--- a/dev/ci/ci-bedrock-src.sh
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/usr/bin/env bash
-
-ci_dir="$(dirname "$0")"
-source ${ci_dir}/ci-common.sh
-
-bedrock_src_CI_DIR=${CI_BUILD_DIR}/bedrock-src
-
-git_checkout ${bedrock_src_CI_BRANCH} ${bedrock_src_CI_GITURL} ${bedrock_src_CI_DIR}
-
-( cd ${bedrock_src_CI_DIR} && make -j ${NJOBS} src )
diff --git a/dev/ci/ci-user-overlay.sh b/dev/ci/ci-user-overlay.sh
index 2ecd40416f..b242ce3bd9 100644
--- a/dev/ci/ci-user-overlay.sh
+++ b/dev/ci/ci-user-overlay.sh
@@ -33,10 +33,6 @@ fi
echo "DEBUG: ci-user-overlay.sh 0"
if [ $TRAVIS_PULL_REQUEST = "707" ] || [ $TRAVIS_BRANCH == "trunk__API__coq_makefile" ]; then
echo "DEBUG: ci-user-overlay.sh 1"
- bedrock_src_CI_BRANCH=trunk__API
- bedrock_src_CI_GITURL=https://github.com/matejkosik/bedrock.git
- bedrock_facade_CI_BRANCH=trunk__API
- bedrock_facade_CI_GITURL=https://github.com/matejkosik/bedrock.git
fiat_parsers_CI_BRANCH=trunk__API
fiat_parsers_CI_GITURL=https://github.com/matejkosik/fiat.git
fi
--
cgit v1.2.3
From e710306910afc61c9a874e6020bbf35b77ffe4af Mon Sep 17 00:00:00 2001
From: Maxime Dénès
Date: Thu, 15 Jun 2017 11:51:11 +0200
Subject: Move Fiat to allowed failures.
For now, Fiat still relies on 8.4 compatibility.
---
.travis.yml | 1 +
1 file changed, 1 insertion(+)
diff --git a/.travis.yml b/.travis.yml
index 224dfe2f57..e7082a9eeb 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -64,6 +64,7 @@ matrix:
allow_failures:
- env: TEST_TARGET="ci-coq-dpdgraph" EXTRA_OPAM="ocamlgraph"
- env: TEST_TARGET="ci-geocoq"
+ - env: TEST_TARGET="ci-fiat-parsers"
include:
# Full Coq test-suite with two compilers
--
cgit v1.2.3
From db601b06b0880f573b6d1fa83de471679ce87ee7 Mon Sep 17 00:00:00 2001
From: Pierre Letouzey
Date: Wed, 14 Jun 2017 18:18:37 +0200
Subject: plugins/ltac : avoid spurious .cmxs files
In the previous setting, all plugins/ltac/*.cmxs except ltac_plugin.cmxs
(for instance coretactics.cmxs, g_auto.cmxs, ...) were utterly bogus :
- wrong -for-pack used for their inner .cmx
- dependency over modules not provided (for instance Tacenv, that ends
up being a submodule of the pack ltac_plugin).
But we were lucky, those files were actually never loaded, thanks to the
several DECLARE PLUGIN inside coretactics and co, that end up in ltac_plugin,
and hence tell Coq that these modules are already known, preventing
any attempt to load them.
Anyway, this commit cleans up this mess (thanks PMP for the help)
---
Makefile.common | 2 +-
plugins/ltac/coretactics.ml4 | 8 ++++----
plugins/ltac/extratactics.ml4 | 2 +-
plugins/ltac/g_auto.ml4 | 2 +-
plugins/ltac/g_class.ml4 | 2 +-
plugins/ltac/g_eqdecide.ml4 | 2 +-
plugins/ltac/g_rewrite.ml4 | 2 +-
plugins/ltac/ltac_plugin.mlpack | 1 -
plugins/ltac/tauto.ml | 3 ++-
plugins/ltac/tauto_plugin.mlpack | 1 +
test-suite/bugs/closed/3612.v | 1 -
test-suite/bugs/closed/3649.v | 2 --
theories/Init/Notations.v | 6 ------
theories/Init/Tauto.v | 2 +-
14 files changed, 14 insertions(+), 22 deletions(-)
create mode 100644 plugins/ltac/tauto_plugin.mlpack
diff --git a/Makefile.common b/Makefile.common
index ec5e6ac855..100698321a 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -134,7 +134,7 @@ OTHERSYNTAXCMO:=$(addprefix plugins/syntax/, \
ascii_syntax_plugin.cmo \
string_syntax_plugin.cmo )
DERIVECMO:=plugins/derive/derive_plugin.cmo
-LTACCMO:=plugins/ltac/ltac_plugin.cmo
+LTACCMO:=plugins/ltac/ltac_plugin.cmo plugins/ltac/tauto_plugin.cmo
SSRMATCHINGCMO:=plugins/ssrmatching/ssrmatching_plugin.cmo
SSRCMO:=plugins/ssr/ssreflect_plugin.cmo
diff --git a/plugins/ltac/coretactics.ml4 b/plugins/ltac/coretactics.ml4
index 07b8746fb2..50013f5583 100644
--- a/plugins/ltac/coretactics.ml4
+++ b/plugins/ltac/coretactics.ml4
@@ -17,7 +17,7 @@ open Stdarg
open Extraargs
open Names
-DECLARE PLUGIN "coretactics"
+DECLARE PLUGIN "ltac_plugin"
(** Basic tactics *)
@@ -324,11 +324,11 @@ let initial_atomic () =
"fresh", TacArg(Loc.tag @@ TacFreshId [])
]
-let () = Mltop.declare_cache_obj initial_atomic "coretactics"
+let () = Mltop.declare_cache_obj initial_atomic "ltac_plugin"
(* First-class Ltac access to primitive blocks *)
-let initial_name s = { mltac_plugin = "coretactics"; mltac_tactic = s; }
+let initial_name s = { mltac_plugin = "ltac_plugin"; mltac_tactic = s; }
let initial_entry s = { mltac_name = initial_name s; mltac_index = 0; }
let register_list_tactical name f =
@@ -356,4 +356,4 @@ let initial_tacticals () =
"solve", TacFun ([Name (idn 0)], TacML (None, (initial_entry "solve", [varn 0])));
]
-let () = Mltop.declare_cache_obj initial_tacticals "coretactics"
+let () = Mltop.declare_cache_obj initial_tacticals "ltac_plugin"
diff --git a/plugins/ltac/extratactics.ml4 b/plugins/ltac/extratactics.ml4
index 7259faecd0..36df25cc77 100644
--- a/plugins/ltac/extratactics.ml4
+++ b/plugins/ltac/extratactics.ml4
@@ -28,7 +28,7 @@ open Equality
open Misctypes
open Proofview.Notations
-DECLARE PLUGIN "extratactics"
+DECLARE PLUGIN "ltac_plugin"
(**********************************************************************)
(* replace, discriminate, injection, simplify_eq *)
diff --git a/plugins/ltac/g_auto.ml4 b/plugins/ltac/g_auto.ml4
index dfd8e88a91..6145e373b1 100644
--- a/plugins/ltac/g_auto.ml4
+++ b/plugins/ltac/g_auto.ml4
@@ -18,7 +18,7 @@ open Pcoq.Constr
open Pltac
open Hints
-DECLARE PLUGIN "g_auto"
+DECLARE PLUGIN "ltac_plugin"
(* Hint bases *)
diff --git a/plugins/ltac/g_class.ml4 b/plugins/ltac/g_class.ml4
index 905cfd02a6..63451210ca 100644
--- a/plugins/ltac/g_class.ml4
+++ b/plugins/ltac/g_class.ml4
@@ -13,7 +13,7 @@ open Class_tactics
open Stdarg
open Tacarg
-DECLARE PLUGIN "g_class"
+DECLARE PLUGIN "ltac_plugin"
(** Options: depth, debug and transparency settings. *)
diff --git a/plugins/ltac/g_eqdecide.ml4 b/plugins/ltac/g_eqdecide.ml4
index 570cd4e694..dceefeaa13 100644
--- a/plugins/ltac/g_eqdecide.ml4
+++ b/plugins/ltac/g_eqdecide.ml4
@@ -17,7 +17,7 @@
open API
open Eqdecide
-DECLARE PLUGIN "g_eqdecide"
+DECLARE PLUGIN "ltac_plugin"
TACTIC EXTEND decide_equality
| [ "decide" "equality" ] -> [ decideEqualityGoal ]
diff --git a/plugins/ltac/g_rewrite.ml4 b/plugins/ltac/g_rewrite.ml4
index e6ddc5cc1b..3e6f420065 100644
--- a/plugins/ltac/g_rewrite.ml4
+++ b/plugins/ltac/g_rewrite.ml4
@@ -27,7 +27,7 @@ open Pcoq.Prim
open Pcoq.Constr
open Pltac
-DECLARE PLUGIN "g_rewrite"
+DECLARE PLUGIN "ltac_plugin"
type constr_expr_with_bindings = constr_expr with_bindings
type glob_constr_with_bindings = Tacexpr.glob_constr_and_expr with_bindings
diff --git a/plugins/ltac/ltac_plugin.mlpack b/plugins/ltac/ltac_plugin.mlpack
index af1c7149da..12b4c81fc4 100644
--- a/plugins/ltac/ltac_plugin.mlpack
+++ b/plugins/ltac/ltac_plugin.mlpack
@@ -21,7 +21,6 @@ G_auto
G_class
Rewrite
G_rewrite
-Tauto
G_eqdecide
G_tactic
G_ltac
diff --git a/plugins/ltac/tauto.ml b/plugins/ltac/tauto.ml
index 5eacb1a95e..bb56fd78ac 100644
--- a/plugins/ltac/tauto.ml
+++ b/plugins/ltac/tauto.ml
@@ -13,13 +13,14 @@ open Hipattern
open Names
open Geninterp
open Misctypes
+open Ltac_plugin
open Tacexpr
open Tacinterp
open Util
open Tacticals.New
open Proofview.Notations
-let tauto_plugin = "tauto"
+let tauto_plugin = "tauto_plugin"
let () = Mltop.add_known_module tauto_plugin
let assoc_var s ist =
diff --git a/plugins/ltac/tauto_plugin.mlpack b/plugins/ltac/tauto_plugin.mlpack
new file mode 100644
index 0000000000..b3618018ea
--- /dev/null
+++ b/plugins/ltac/tauto_plugin.mlpack
@@ -0,0 +1 @@
+Tauto
diff --git a/test-suite/bugs/closed/3612.v b/test-suite/bugs/closed/3612.v
index 73709268a4..33e5d532ad 100644
--- a/test-suite/bugs/closed/3612.v
+++ b/test-suite/bugs/closed/3612.v
@@ -39,7 +39,6 @@ Axiom path_path_sigma : forall {A : Type} (P : A -> Type) (u v : sigT P)
p = q.
Declare ML Module "ltac_plugin".
-Declare ML Module "coretactics".
Set Default Proof Mode "Classic".
diff --git a/test-suite/bugs/closed/3649.v b/test-suite/bugs/closed/3649.v
index 179f81e668..a664a1ef1d 100644
--- a/test-suite/bugs/closed/3649.v
+++ b/test-suite/bugs/closed/3649.v
@@ -3,7 +3,6 @@
(* coqc version trunk (September 2014) compiled on Sep 18 2014 21:0:5 with OCaml 4.01.0
coqtop version cagnode16:/afs/csail.mit.edu/u/j/jgross/coq-trunk,trunk (07e4438bd758c2ced8caf09a6961ccd77d84e42b) *)
Declare ML Module "ltac_plugin".
-Declare ML Module "coretactics".
Set Default Proof Mode "Classic".
Reserved Notation "x -> y" (at level 99, right associativity, y at level 200).
Reserved Notation "x = y" (at level 70, no associativity).
@@ -14,7 +13,6 @@ Axiom admit : forall {T}, T.
Notation "A -> B" := (forall (_ : A), B) : type_scope.
Reserved Infix "o" (at level 40, left associativity).
Inductive paths {A : Type} (a : A) : A -> Type := idpath : paths a a where "x = y" := (@paths _ x y) : type_scope.
-Ltac constr_eq a b := let test := constr:(@idpath _ _ : a = b) in idtac.
Global Set Primitive Projections.
Delimit Scope morphism_scope with morphism.
Record PreCategory :=
diff --git a/theories/Init/Notations.v b/theories/Init/Notations.v
index edcd53005e..2b0fe13620 100644
--- a/theories/Init/Notations.v
+++ b/theories/Init/Notations.v
@@ -89,11 +89,5 @@ Open Scope type_scope.
(** ML Tactic Notations *)
Declare ML Module "ltac_plugin".
-Declare ML Module "coretactics".
-Declare ML Module "extratactics".
-Declare ML Module "g_auto".
-Declare ML Module "g_class".
-Declare ML Module "g_eqdecide".
-Declare ML Module "g_rewrite".
Global Set Default Proof Mode "Classic".
diff --git a/theories/Init/Tauto.v b/theories/Init/Tauto.v
index 1e409607ae..886533586f 100644
--- a/theories/Init/Tauto.v
+++ b/theories/Init/Tauto.v
@@ -2,7 +2,7 @@ Require Import Notations.
Require Import Datatypes.
Require Import Logic.
-Local Declare ML Module "tauto".
+Declare ML Module "tauto_plugin".
Local Ltac not_dep_intros :=
repeat match goal with
--
cgit v1.2.3
From d1d068bcc7ed43d375b1f69a3cc796fb12333519 Mon Sep 17 00:00:00 2001
From: Pierre Letouzey
Date: Thu, 15 Jun 2017 15:24:03 +0200
Subject: Makefile.build : restore (temporarily?) the anti-cmi-corruption hacks
Due to the recent conversion of many .mli-only files into .ml files
(hugely debatable impact of the API introduction), parallel make may
fail badly again (always the same race between ocamlc and ocamlopt for .cmi).
Still working on a proper fix, but meanwhile let's reintroduce the
old hacks against these corruptions.
---
Makefile.build | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/Makefile.build b/Makefile.build
index 484673e174..0dafde9977 100644
--- a/Makefile.build
+++ b/Makefile.build
@@ -516,6 +516,27 @@ COND_OPTFLAGS= \
$(SHOW)'OCAMLC $<'
$(HIDE)$(OCAMLC) $(COND_BYTEFLAGS) -c $<
+## NB: for the moment ocamlopt erases and recreates .cmi if there's no .mli around.
+## This can lead to nasty things with make -j. To avoid that:
+## 1) We make .cmx always depend on .cmi
+## 2) This .cmi will be created from the .mli, or trigger the compilation of the
+## .cmo if there's no .mli (see rule below about MLWITHOUTMLI)
+## 3) We tell ocamlopt to use the .cmi as the interface source file. With this
+## hack, everything goes as if there is a .mli, and the .cmi is preserved
+## and the .cmx is checked with respect to this .cmi
+
+HACKMLI = $(if $(wildcard $ Libnames.Qualid (loc,Nametab.shortest_qualid_of_global Idset.empty r));;
+ (fun ?loc _ r -> Libnames.Qualid (loc,Nametab.shortest_qualid_of_global Idset.empty r));;
open Coqloop
let go = loop
--
cgit v1.2.3
From da62d0dd86fc140ff58d9366a7a85e9b21b104b9 Mon Sep 17 00:00:00 2001
From: Jason Gross
Date: Wed, 14 Jun 2017 14:14:41 -0400
Subject: Strip trailing whitespace
---
tools/CoqMakefile.in | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/tools/CoqMakefile.in b/tools/CoqMakefile.in
index 5e223a0b48..bf0669578d 100644
--- a/tools/CoqMakefile.in
+++ b/tools/CoqMakefile.in
@@ -5,7 +5,7 @@
## // # ##
###############################################################################
## GNUMakefile for Coq @COQ_VERSION@
-
+
# For debugging purposes (must stay here, don't move below)
INITIAL_VARS := $(.VARIABLES)
# To implement recursion we save the name of the main Makefile
@@ -80,7 +80,7 @@ CAMLOPTLINK ?= $(OCAMLFIND) opt -rectypes -thread
CAMLDEP ?= $(OCAMLFIND) ocamldep -slash -ml-synonym .ml4 -ml-synonym .mlpack
# DESTDIR is prepended to all installation paths
-DESTDIR ?=
+DESTDIR ?=
# Debug builds, typically -g to OCaml, -debug to Coq.
CAMLDEBUG ?=
@@ -96,7 +96,7 @@ COQDEBUG ?=
#
# post-all::
# echo "All done!"
-#
+#
# in @LOCAL_FILE@
#
###############################################################################
@@ -106,7 +106,7 @@ COQDEBUG ?=
# Flags #######################################################################
#
-# We define a bunch of variables combining the parameters
+# We define a bunch of variables combining the parameters
SHOW := $(if $(VERBOSE),@true "",@echo "")
HIDE := $(if $(VERBOSE),,@)
@@ -127,7 +127,7 @@ DYNLIB:=.cmxs
endif
COQFLAGS?=-q $(OPT) $(COQLIBS) $(OTHERFLAGS)
-COQCHKFLAGS?=-silent -o $(COQLIBS)
+COQCHKFLAGS?=-silent -o $(COQLIBS)
COQDOCFLAGS?=-interpolate -utf8 $(COQLIBS_NOML)
# The version of Coq being run and the version of coq_makefile that
@@ -155,7 +155,7 @@ COQLIBINSTALL = $(COQLIB)user-contrib
COQDOCINSTALL = $(DOCDIR)user-contrib
COQTOPINSTALL = $(COQLIB)toploop
-# Retro compatibility (DESTDIR is standard on Unix, DESTROOT is not)
+# Retro compatibility (DESTDIR is standard on Unix, DESTROOT is not)
ifneq "$(DSTROOT)" ""
DESTDIR := $(DSTROOT)
endif
@@ -248,7 +248,7 @@ ALLDFILES = $(addsuffix .d,$(ALLSRCFILES))
# Compilation targets #########################################################
-all:
+all:
$(HIDE)$(MAKE) --no-print-directory -f "$(SELF)" pre-all
$(HIDE)$(MAKE) --no-print-directory -f "$(SELF)" real-all
$(HIDE)$(MAKE) --no-print-directory -f "$(SELF)" post-all
@@ -427,10 +427,10 @@ clean::
$(HIDE)rm -f $(CMOFILES)
$(HIDE)rm -f $(CMIFILES)
$(HIDE)rm -f $(CMAFILES)
- $(HIDE)rm -f $(CMOFILES:.cmo=.cmx)
+ $(HIDE)rm -f $(CMOFILES:.cmo=.cmx)
$(HIDE)rm -f $(CMXAFILES)
- $(HIDE)rm -f $(CMXSFILES)
- $(HIDE)rm -f $(CMOFILES:.cmo=.o)
+ $(HIDE)rm -f $(CMXSFILES)
+ $(HIDE)rm -f $(CMOFILES:.cmo=.o)
$(HIDE)rm -f $(CMXAFILES:.cmxa=.a)
$(HIDE)rm -f $(ALLDFILES)
$(HIDE)rm -f $(ALLNATIVEFILES)
@@ -513,7 +513,7 @@ $(MLPACKFILES:.mlpack=.cmx): %.cmx: | %.mlpack
$(SHOW)'CAMLOPT -pack -o $@'
$(HIDE)$(CAMLOPTLINK) $(CAMLDEBUG) $(CAMLFLAGS) -pack -o $@ $^
-# This rule is for _CoqProject with no .mllib nor .mlpack
+# This rule is for _CoqProject with no .mllib nor .mlpack
$(filter-out $(MLLIBFILES:.mllib=.cmxs) $(MLPACKFILES:.mlpack=.cmxs) $(addsuffix .cmxs,$(PACKEDFILES)) $(addsuffix .cmxs,$(LIBEDFILES)),$(MLFILES:.ml=.cmxs) $(ML4FILES:.ml4=.cmxs)): %.cmxs: %.cmx
$(SHOW)'[deprecated,use-mllib-or-mlpack] CAMLOPT -shared -o $@'
$(HIDE)$(CAMLOPTLINK) $(CAMLDEBUG) $(CAMLFLAGS) -shared -o $@ $<
@@ -600,7 +600,7 @@ byte:
opt:
$(HIDE)$(MAKE) all "OPT:=-opt" -f "$(SELF)"
-.PHONY: opt
+.PHONY: opt
# This is deprecated. To extend this makefile use
# extension points and @LOCAL_FILE@
@@ -655,4 +655,3 @@ debug:
.PHONY: debug
.DEFAULT_GOAL := all
-
--
cgit v1.2.3
From 15d61838d7435b45559d648bcde1ccfb6e468bcd Mon Sep 17 00:00:00 2001
From: Jason Gross
Date: Wed, 7 Jun 2017 15:54:37 -0400
Subject: Fix `make TIMED=1` garbage
It should not emit ` (user: 0.00 mem: 2852 ko)` multiple times---
tools/CoqMakefile.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/CoqMakefile.in b/tools/CoqMakefile.in
index bf0669578d..f3a645a21e 100644
--- a/tools/CoqMakefile.in
+++ b/tools/CoqMakefile.in
@@ -132,7 +132,7 @@ COQDOCFLAGS?=-interpolate -utf8 $(COQLIBS_NOML)
# The version of Coq being run and the version of coq_makefile that
# generated this makefile
-COQ_VERSION:=$(shell $(COQC) --print-version | cut -d ' ' -f 1)
+COQ_VERSION:=$(shell $(COQC) --print-version 2>/dev/null | cut -d ' ' -f 1)
COQMAKEFILE_VERSION:=@COQ_VERSION@
COQSRCLIBS?= $(foreach d,$(COQ_SRC_SUBDIRS), -I "$(COQLIB)$(d)")
--
cgit v1.2.3
From cff08a2ec4f4cf100ecd0e30a6c9202b9defa9a9 Mon Sep 17 00:00:00 2001
From: Jason Gross
Date: Wed, 14 Jun 2017 14:16:47 -0400
Subject: Move TIMER to right in front of COQC
Save the COQC variable for the actual path to coqc, as per
https://github.com/coq/coq/pull/742#pullrequestreview-44072778
---
tools/CoqMakefile.in | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/tools/CoqMakefile.in b/tools/CoqMakefile.in
index f3a645a21e..7b01c1b663 100644
--- a/tools/CoqMakefile.in
+++ b/tools/CoqMakefile.in
@@ -65,8 +65,8 @@ TIMECMD?=
STDTIME?=/usr/bin/time -f "$* (user: %U mem: %M ko)"
# Coq binaries
-COQC ?= $(TIMER) "$(COQBIN)coqc"
-COQCHK ?= $(TIMER) "$(COQBIN)coqchk"
+COQC ?= "$(COQBIN)coqc"
+COQCHK ?= "$(COQBIN)coqchk"
COQDEP ?= "$(COQBIN)coqdep"
GALLINA ?= "$(COQBIN)gallina"
COQDOC ?= "$(COQBIN)coqdoc"
@@ -132,7 +132,7 @@ COQDOCFLAGS?=-interpolate -utf8 $(COQLIBS_NOML)
# The version of Coq being run and the version of coq_makefile that
# generated this makefile
-COQ_VERSION:=$(shell $(COQC) --print-version 2>/dev/null | cut -d ' ' -f 1)
+COQ_VERSION:=$(shell $(COQC) --print-version | cut -d ' ' -f 1)
COQMAKEFILE_VERSION:=@COQ_VERSION@
COQSRCLIBS?= $(foreach d,$(COQ_SRC_SUBDIRS), -I "$(COQLIB)$(d)")
@@ -281,17 +281,17 @@ quick: $(VOFILES:.vo=.vio)
.PHONY: quick
vio2vo:
- $(COQC) $(COQDEBUG) $(COQFLAGS) \
+ $(TIMER) $(COQC) $(COQDEBUG) $(COQFLAGS) \
-schedule-vio2vo $(J) $(VOFILES:%.vo=%.vio)
.PHONY: vio2vo
checkproofs:
- $(COQC) $(COQDEBUG) $(COQFLAGS) \
+ $(TIMER) $(COQC) $(COQDEBUG) $(COQFLAGS) \
-schedule-vio-checking $(J) $(VOFILES:%.vo=%.vio)
.PHONY: checkproofs
validate: $(VOFILES)
- $(COQCHK) $(COQCHKFLAGS) $(notdir $(^:.vo=))
+ $(TIMER) $(COQCHK) $(COQCHKFLAGS) $(notdir $(^:.vo=))
.PHONY: validate
only: $(TGTS)
@@ -520,19 +520,19 @@ $(filter-out $(MLLIBFILES:.mllib=.cmxs) $(MLPACKFILES:.mlpack=.cmxs) $(addsuffix
$(VOFILES): %.vo: %.v
$(SHOW)COQC $<
- $(HIDE)$(COQC) $(COQDEBUG) $(COQFLAGS) $<
+ $(HIDE)$(TIMER) $(COQC) $(COQDEBUG) $(COQFLAGS) $<
# FIXME ?merge with .vo / .vio ?
$(GLOBFILES): %.glob: %.v
- $(COQC) $(COQDEBUG) $(COQFLAGS) $<
+ $(TIMER) $(COQC) $(COQDEBUG) $(COQFLAGS) $<
$(VFILES:.v=.vio): %.vio: %.v
$(SHOW)COQC -quick $<
- $(HIDE)$(COQC) -quick $(COQDEBUG) $(COQFLAGS) $<
+ $(HIDE)$(TIMER) $(COQC) -quick $(COQDEBUG) $(COQFLAGS) $<
$(BEAUTYFILES): %.v.beautified: %.v
$(SHOW)'BEAUTIFY $<'
- $(HIDE)$(COQC) $(COQDEBUG) $(COQFLAGS) -beautify $<
+ $(HIDE)$(TIMER) $(COQC) $(COQDEBUG) $(COQFLAGS) -beautify $<
$(GFILES): %.g: %.v
$(SHOW)'GALLINA $<'
--
cgit v1.2.3
From 44f462aa380de847452c0809d15c86649d5d6a7a Mon Sep 17 00:00:00 2001
From: Amin Timany
Date: Tue, 28 Mar 2017 19:24:02 +0200
Subject: Extend definition of inductives to include subtyping info
---
API/API.mli | 1 +
kernel/declarations.ml | 2 ++
kernel/declareops.ml | 1 +
kernel/entries.mli | 4 +++-
kernel/indtypes.ml | 29 +++++++++++++++++------------
library/declare.ml | 2 +-
vernac/command.ml | 2 +-
vernac/discharge.ml | 9 ++++++++-
vernac/record.ml | 4 ++--
vernac/record.mli | 3 ++-
10 files changed, 38 insertions(+), 19 deletions(-)
diff --git a/API/API.mli b/API/API.mli
index 69278e7c9f..e2c43dab82 100644
--- a/API/API.mli
+++ b/API/API.mli
@@ -1094,6 +1094,7 @@ sig
mind_params_ctxt : Context.Rel.t;
mind_polymorphic : bool;
mind_universes : Univ.UContext.t;
+ mind_subtyping : Univ.universe_context;
mind_private : bool option;
mind_typing_flags : Declarations.typing_flags;
}
diff --git a/kernel/declarations.ml b/kernel/declarations.ml
index 71e228b19c..9536407d38 100644
--- a/kernel/declarations.ml
+++ b/kernel/declarations.ml
@@ -190,6 +190,8 @@ type mutual_inductive_body = {
mind_universes : Univ.universe_context; (** Local universe variables and constraints *)
+ mind_subtyping : Univ.universe_context; (** Constraints for subtyping *)
+
mind_private : bool option; (** allow pattern-matching: Some true ok, Some false blocked *)
mind_typing_flags : typing_flags; (** typing flags at the time of the inductive creation *)
diff --git a/kernel/declareops.ml b/kernel/declareops.ml
index 0a822d6fad..47a23c8555 100644
--- a/kernel/declareops.ml
+++ b/kernel/declareops.ml
@@ -261,6 +261,7 @@ let subst_mind_body sub mib =
mind_packets = Array.smartmap (subst_mind_packet sub) mib.mind_packets ;
mind_polymorphic = mib.mind_polymorphic;
mind_universes = mib.mind_universes;
+ mind_subtyping = mib.mind_subtyping;
mind_private = mib.mind_private;
mind_typing_flags = mib.mind_typing_flags;
}
diff --git a/kernel/entries.mli b/kernel/entries.mli
index 1e07c96909..88584e3b3d 100644
--- a/kernel/entries.mli
+++ b/kernel/entries.mli
@@ -50,7 +50,9 @@ type mutual_inductive_entry = {
mind_entry_params : (Id.t * local_entry) list;
mind_entry_inds : one_inductive_entry list;
mind_entry_polymorphic : bool;
- mind_entry_universes : Univ.universe_context;
+ mind_entry_universes : Univ.universe_context * Univ.universe_context;
+ (* universe constraints and the constraints for subtyping of
+ inductive types in the block. *)
mind_entry_private : bool option;
}
diff --git a/kernel/indtypes.ml b/kernel/indtypes.ml
index 1e13239bfc..5d928facc7 100644
--- a/kernel/indtypes.ml
+++ b/kernel/indtypes.ml
@@ -220,7 +220,7 @@ let typecheck_inductive env mie =
(* Check unicity of names *)
mind_check_names mie;
(* Params are typed-checked here *)
- let env' = push_context mie.mind_entry_universes env in
+ let env' = push_context (fst mie.mind_entry_universes) env in
let (env_params,paramsctxt) = infer_local_decls env' mie.mind_entry_params in
(* We first type arity of each inductive definition *)
(* This allows building the environment of arities and to share *)
@@ -822,17 +822,18 @@ let build_inductive env p prv ctx env_ar paramsctxt kn isrecord isfinite inds nm
let hyps = used_section_variables env inds in
let nparamargs = Context.Rel.nhyps paramsctxt in
let nparamsctxt = Context.Rel.length paramsctxt in
- let subst, ctx = Univ.abstract_universes p ctx in
- let paramsctxt = Vars.subst_univs_level_context subst paramsctxt in
+ let substunivs, ctxunivs = Univ.abstract_universes p (fst ctx) in
+ let substsbt, ctxsbt = Univ.abstract_universes p (snd ctx) in
+ let paramsctxt = Vars.subst_univs_level_context substunivs paramsctxt in
let env_ar =
- let ctx = Environ.rel_context env_ar in
- let ctx' = Vars.subst_univs_level_context subst ctx in
- Environ.push_rel_context ctx' env
+ let ctxunivs = Environ.rel_context env_ar in
+ let ctxunivs' = Vars.subst_univs_level_context substunivs ctxunivs in
+ Environ.push_rel_context ctxunivs' env
in
(* Check one inductive *)
let build_one_packet (id,cnames,lc,(ar_sign,ar_kind)) recarg =
(* Type of constructors in normal form *)
- let lc = Array.map (Vars.subst_univs_level_constr subst) lc in
+ let lc = Array.map (Vars.subst_univs_level_constr substunivs) lc in
let splayed_lc = Array.map (dest_prod_assum env_ar) lc in
let nf_lc = Array.map (fun (d,b) -> it_mkProd_or_LetIn b d) splayed_lc in
let consnrealdecls =
@@ -841,6 +842,9 @@ let build_inductive env p prv ctx env_ar paramsctxt kn isrecord isfinite inds nm
let consnrealargs =
Array.map (fun (d,_) -> Context.Rel.nhyps d - nparamargs)
splayed_lc in
+ (* Check that the subtyping constraints (inferred outside kernel)
+ are valid. If so return (), otherwise raise an anomaly! *)
+ let () = () in
(* Elimination sorts *)
let arkind,kelim =
match ar_kind with
@@ -851,8 +855,8 @@ let build_inductive env p prv ctx env_ar paramsctxt kn isrecord isfinite inds nm
let s = sort_of_univ defs in
let kelim = allowed_sorts info s in
let ar = RegularArity
- { mind_user_arity = Vars.subst_univs_level_constr subst ar;
- mind_sort = sort_of_univ (Univ.subst_univs_level_universe subst defs); } in
+ { mind_user_arity = Vars.subst_univs_level_constr substunivs ar;
+ mind_sort = sort_of_univ (Univ.subst_univs_level_universe substunivs defs); } in
ar, kelim in
(* Assigning VM tags to constructors *)
let nconst, nblock = ref 0, ref 0 in
@@ -871,7 +875,7 @@ let build_inductive env p prv ctx env_ar paramsctxt kn isrecord isfinite inds nm
(* Build the inductive packet *)
{ mind_typename = id;
mind_arity = arkind;
- mind_arity_ctxt = Vars.subst_univs_level_context subst ar_sign;
+ mind_arity_ctxt = Vars.subst_univs_level_context substunivs ar_sign;
mind_nrealargs = Context.Rel.nhyps ar_sign - nparamargs;
mind_nrealdecls = Context.Rel.length ar_sign - nparamsctxt;
mind_kelim = kelim;
@@ -895,7 +899,7 @@ let build_inductive env p prv ctx env_ar paramsctxt kn isrecord isfinite inds nm
(** The elimination criterion ensures that all projections can be defined. *)
let u =
if p then
- subst_univs_level_instance subst (Univ.UContext.instance ctx)
+ subst_univs_level_instance substunivs (Univ.UContext.instance ctxunivs)
else Univ.Instance.empty
in
let indsp = ((kn, 0), u) in
@@ -920,7 +924,8 @@ let build_inductive env p prv ctx env_ar paramsctxt kn isrecord isfinite inds nm
mind_params_ctxt = paramsctxt;
mind_packets = packets;
mind_polymorphic = p;
- mind_universes = ctx;
+ mind_universes = ctxunivs;
+ mind_subtyping = ctxsbt;
mind_private = prv;
mind_typing_flags = Environ.typing_flags env;
}
diff --git a/library/declare.ml b/library/declare.ml
index 7d0edbc8b3..06eeeeab56 100644
--- a/library/declare.ml
+++ b/library/declare.ml
@@ -352,7 +352,7 @@ let dummy_inductive_entry (_,m) = ([],{
mind_entry_finite = Decl_kinds.BiFinite;
mind_entry_inds = List.map dummy_one_inductive_entry m.mind_entry_inds;
mind_entry_polymorphic = false;
- mind_entry_universes = Univ.UContext.empty;
+ mind_entry_universes = (Univ.UContext.empty, Univ.UContext.empty);
mind_entry_private = None;
})
diff --git a/vernac/command.ml b/vernac/command.ml
index 998e7803e1..5f95a42a37 100644
--- a/vernac/command.ml
+++ b/vernac/command.ml
@@ -656,7 +656,7 @@ let interp_mutual_inductive (paramsl,indl) notations poly prv finite =
mind_entry_inds = entries;
mind_entry_polymorphic = poly;
mind_entry_private = if prv then Some false else None;
- mind_entry_universes = uctx;
+ mind_entry_universes = (uctx, Univ.UContext.empty);
},
pl, impls
diff --git a/vernac/discharge.ml b/vernac/discharge.ml
index 65ade78876..9c70eb97ef 100644
--- a/vernac/discharge.ml
+++ b/vernac/discharge.ml
@@ -86,6 +86,13 @@ let process_inductive (sechyps,abs_ctx) modlist mib =
inst, Univ.UContext.make (inst, Univ.subst_instance_constraints inst cstrs)
else Univ.Instance.empty, mib.mind_universes
in
+ let substsbt, univssbt =
+ if mib.mind_polymorphic then
+ let inst = Univ.UContext.instance mib.mind_subtyping in
+ let cstrs = Univ.UContext.constraints mib.mind_subtyping in
+ inst, Univ.UContext.make (inst, Univ.subst_instance_constraints inst cstrs)
+ else Univ.Instance.empty, Univ.UContext.empty
+ in
let inds =
Array.map_to_list
(fun mip ->
@@ -116,5 +123,5 @@ let process_inductive (sechyps,abs_ctx) modlist mib =
mind_entry_inds = inds';
mind_entry_polymorphic = mib.mind_polymorphic;
mind_entry_private = mib.mind_private;
- mind_entry_universes = univs;
+ mind_entry_universes = (univs, univssbt);
}
diff --git a/vernac/record.ml b/vernac/record.ml
index 2400fa6814..5c76bb4b2d 100644
--- a/vernac/record.ml
+++ b/vernac/record.ml
@@ -466,7 +466,7 @@ let declare_class finite def poly ctx id idbuild paramimpls params arity
in
cref, [Name proj_name, sub, Some proj_cst]
| _ ->
- let ind = declare_structure BiFinite poly ctx (snd id) idbuild paramimpls
+ let ind = declare_structure BiFinite poly (ctx, Univ.UContext.empty) (snd id) idbuild paramimpls
params arity template fieldimpls fields
~kind:Method ~name:binder_name false (List.map (fun _ -> false) fields) sign
in
@@ -571,7 +571,7 @@ let definition_structure (kind,poly,finite,(is_coe,((loc,idstruc),pl)),ps,cfs,id
let implfs = List.map
(fun impls -> implpars @ Impargs.lift_implicits
(succ (List.length params)) impls) implfs in
- let ind = declare_structure finite poly ctx idstruc
+ let ind = declare_structure finite poly (ctx, Univ.UContext.empty) idstruc
idbuild implpars params arity template implfs
fields is_coe (List.map (fun coe -> not (Option.is_empty coe)) coers) sign in
IndRef ind
diff --git a/vernac/record.mli b/vernac/record.mli
index 3fd651db90..a380b041a4 100644
--- a/vernac/record.mli
+++ b/vernac/record.mli
@@ -26,7 +26,8 @@ val declare_projections :
val declare_structure :
Decl_kinds.recursivity_kind ->
- bool (** polymorphic?*) -> Univ.universe_context ->
+ bool (** polymorphic?*) ->
+ (Univ.universe_context * Univ.universe_context) (** universe and subtyping constraints *) ->
Id.t -> Id.t ->
manual_explicitation list -> Context.Rel.t -> (** params *) constr -> (** arity *)
bool (** template arity ? *) ->
--
cgit v1.2.3
From 4dd4f186895d16510f217778bb83933be8956082 Mon Sep 17 00:00:00 2001
From: Amin Timany
Date: Thu, 30 Mar 2017 18:12:43 +0200
Subject: New datastructure for universes of inductive types
---
engine/universes.ml | 20 +++++++++++++
engine/universes.mli | 11 +++++++
kernel/univ.ml | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++
kernel/univ.mli | 48 ++++++++++++++++++++++++++++++
4 files changed, 162 insertions(+)
diff --git a/engine/universes.ml b/engine/universes.ml
index f201081862..955e1d8b5b 100644
--- a/engine/universes.ml
+++ b/engine/universes.ml
@@ -1118,3 +1118,23 @@ let solve_constraints_system levels level_bounds level_min =
done;
done;
v
+
+
+(** Operations for universe_info_ind *)
+
+(** Given a universe context representing constraints of an inductive
+ this function produces a UInfoInd.t that with the trivial subtyping relation. *)
+let univ_inf_ind_from_universe_context univcst =
+ let freshunivs = Instance.of_array
+ (Array.map (fun _ -> new_univ_level ())
+ (Instance.to_array (UContext.instance univcst)))
+ in UInfoInd.from_universe_context univcst freshunivs
+
+(** This function adds universe constraints to the universe
+ constraints of the given universe_info_ind. However one must be
+ CAUTIOUS as it resets the subtyping constraints to equality. *)
+let univ_inf_ind_union uinfind univcst' =
+ let freshunivs = Instance.of_array
+ (Array.map (fun _ -> new_univ_level ())
+ (Instance.to_array (UContext.instance univcst')))
+ in UInfoInd.union uinfind univcst' freshunivs
diff --git a/engine/universes.mli b/engine/universes.mli
index 83ca1ea606..17a9deb3a2 100644
--- a/engine/universes.mli
+++ b/engine/universes.mli
@@ -227,3 +227,14 @@ val pr_universe_opt_subst : universe_opt_subst -> Pp.std_ppcmds
val solve_constraints_system : universe option array -> universe array -> universe array ->
universe array
+
+(** Operations for universe_info_ind *)
+
+(** Given a universe context representing constraints of an inductive
+ this function produces a UInfoInd.t that with the trivial subtyping relation. *)
+val univ_inf_ind_from_universe_context : universe_context -> universe_info_ind
+
+(** This function adds universe constraints to the universe
+ constraints of the given universe_info_ind. However one must be
+ CAUTIOUS as it resets the subtyping constraints to equality. *)
+val univ_inf_ind_union : universe_info_ind -> universe_context -> universe_info_ind
diff --git a/kernel/univ.ml b/kernel/univ.ml
index d53dd8e733..e8b9ae33a0 100644
--- a/kernel/univ.ml
+++ b/kernel/univ.ml
@@ -1028,6 +1028,83 @@ end
type universe_context = UContext.t
let hcons_universe_context = UContext.hcons
+(** Universe info for inductive types: A context of universe levels
+ with universe constraints, representing local universe variables
+ and constraints, together with a context of universe levels with
+ universe constraints, representing conditions for subtyping used
+ for inductive types.
+
+ This data structure maintains the invariant that the context for
+ subtyping constraints is exactly twice as big as the context for
+ universe constraints. *)
+module UInfoInd =
+struct
+ type t = universe_context * universe_context
+
+ let make x =
+ if (Instance.length (UContext.instance (snd x))) =
+ (Instance.length (UContext.instance (fst x))) * 2 then x
+ else anomaly (Pp.str "Invalid subtyping information encountered!")
+
+ let empty = (UContext.empty, UContext.empty)
+ let is_empty (univcst, subtypcst) = UContext.is_empty univcst && UContext.is_empty subtypcst
+
+ let halve_context (ctx : Instance.t) : Instance.t * Instance.t =
+ let len = Array.length (Instance.to_array ctx) in
+ let halflen = len / 2 in
+ (Instance.of_array (Array.sub (Instance.to_array ctx) 0 halflen),
+ Instance.of_array (Array.sub (Instance.to_array ctx) halflen len))
+
+ let pr prl (univcst, subtypcst) =
+ if UContext.is_empty univcst then mt() else
+ let (ctx, ctx') = halve_context (UContext.instance subtypcst) in
+ (UContext.pr prl univcst) ++
+ h 0 (str "~@{" ++ Instance.pr prl ctx ++ str "} <= ~@{" ++ Instance.pr prl ctx' ++ str "}")
+ ++ h 0 (v 0 (Constraint.pr prl (UContext.constraints subtypcst)))
+
+ let hcons (univcst, subtypcst) =
+ (UContext.hcons univcst, UContext.hcons subtypcst)
+
+ let univ_context (univcst, subtypcst) = univcst
+ let subtyp_context (univcst, subtypcst) = subtypcst
+
+ let create_trivial_subtyping ctx ctx' =
+ CArray.fold_left_i
+ (fun i cst l -> Constraint.add (l, Eq, Array.get ctx' i) cst)
+ Constraint.empty (Instance.to_array ctx)
+
+ (** This function takes a universe context representing constraints
+ of an inductive and a Instance.t of fresh universe names for the
+ subtyping (with the same length as the context in the given
+ universe context) and produces a UInfoInd.t that with the
+ trivial subtyping relation. *)
+ let from_universe_context univcst freshunivs =
+ let inst = (UContext.instance univcst) in
+ assert (Instance.length freshunivs = Instance.length inst);
+ (univcst, UContext.make (Instance.append inst freshunivs,
+ create_trivial_subtyping inst freshunivs))
+
+ (** This function adds universe constraints to the universe
+ constraints of the given universe_info_ind. However one must be
+ CAUTIOUS as it resets the subtyping constraints to equality. It
+ also requires fresh universes for the newly introduced
+ universes *)
+ let union (univcst, _) univcst' freshunivs =
+ assert (Instance.length freshunivs = Instance.length (UContext.instance univcst'));
+ let (ctx, ctx') = halve_context (UContext.instance univcst) in
+ let newctx' = Instance.append ctx' freshunivs in
+ let univcstunion = UContext.union univcst univcst' in
+ (univcstunion, subtyp_context (from_universe_context univcstunion newctx'))
+
+ let dest x = x
+
+ let size ((x,_), _) = Instance.length x
+
+end
+
+type universe_info_ind = UInfoInd.t
+let hcons_universe_info_ind = UInfoInd.hcons
+
(** A set of universes with universe constraints.
We linearize the set to a list after typechecking.
Beware, representation could change.
@@ -1203,6 +1280,10 @@ let subst_instance_constraints s csts =
let instantiate_univ_context (ctx, csts) =
(ctx, subst_instance_constraints ctx csts)
+(** Substitute instance inst for ctx in universe constraints and subtyping constraints *)
+let instantiate_univ_info_ind (univcst, subtpcst) =
+ (instantiate_univ_context univcst, instantiate_univ_context subtpcst)
+
let instantiate_univ_constraints u (_, csts) =
subst_instance_constraints u csts
@@ -1235,6 +1316,8 @@ let pr_constraints prl = Constraint.pr prl
let pr_universe_context = UContext.pr
+let pr_universe_info_ind = UInfoInd.pr
+
let pr_universe_context_set = ContextSet.pr
let pr_universe_subst =
diff --git a/kernel/univ.mli b/kernel/univ.mli
index 1ccdebd501..630d0d9498 100644
--- a/kernel/univ.mli
+++ b/kernel/univ.mli
@@ -315,6 +315,49 @@ end
type universe_context = UContext.t
+(** Universe info for inductive types: A context of universe levels
+ with universe constraints, representing local universe variables
+ and constraints, together with a context of universe levels with
+ universe constraints, representing conditions for subtyping used
+ for inductive types.
+
+ This data structure maintains the invariant that the context for
+ subtyping constraints is exactly twice as big as the context for
+ universe constraints. *)
+module UInfoInd :
+sig
+ type t
+
+ val make : universe_context * universe_context -> t
+
+ val empty : t
+ val is_empty : t -> bool
+
+ val univ_context : t -> universe_context
+ val subtyp_context : t -> universe_context
+
+ val dest : t -> universe_context * universe_context
+
+ (** This function takes a universe context representing constraints
+ of an inductive and a Instance.t of fresh universe names for the
+ subtyping (with the same length as the context in the given
+ universe context) and produces a UInfoInd.t that with the
+ trivial subtyping relation. *)
+ val from_universe_context : universe_context -> universe_instance -> t
+
+ (** This function adds universe constraints to the universe
+ constraints of the given universe_info_ind. However one must be
+ CAUTIOUS as it resets the subtyping constraints to equality. It
+ also requires fresh universes for the newly introduced
+ universes *)
+ val union : t -> universe_context -> universe_instance -> t
+
+ val size : t -> int
+
+end
+
+type universe_info_ind = UInfoInd.t
+
(** Universe contexts (as sets) *)
module ContextSet :
@@ -389,6 +432,9 @@ val abstract_universes : bool -> universe_context -> universe_level_subst * univ
(** Get the instantiated graph. *)
val instantiate_univ_context : universe_context -> universe_context
+(** Get the instantiated graphs for both universe constraints and subtyping constraints. *)
+val instantiate_univ_info_ind : universe_info_ind -> universe_info_ind
+
val instantiate_univ_constraints : universe_instance -> universe_context -> constraints
(** {6 Pretty-printing of universes. } *)
@@ -396,6 +442,7 @@ val instantiate_univ_constraints : universe_instance -> universe_context -> cons
val pr_constraint_type : constraint_type -> Pp.std_ppcmds
val pr_constraints : (Level.t -> Pp.std_ppcmds) -> constraints -> Pp.std_ppcmds
val pr_universe_context : (Level.t -> Pp.std_ppcmds) -> universe_context -> Pp.std_ppcmds
+val pr_universe_info_ind : (Level.t -> Pp.std_ppcmds) -> universe_info_ind -> Pp.std_ppcmds
val pr_universe_context_set : (Level.t -> Pp.std_ppcmds) -> universe_context_set -> Pp.std_ppcmds
val explain_universe_inconsistency : (Level.t -> Pp.std_ppcmds) ->
univ_inconsistency -> Pp.std_ppcmds
@@ -410,6 +457,7 @@ val hcons_constraints : constraints -> constraints
val hcons_universe_set : universe_set -> universe_set
val hcons_universe_context : universe_context -> universe_context
val hcons_universe_context_set : universe_context_set -> universe_context_set
+val hcons_universe_info_ind : universe_info_ind -> universe_info_ind
(******)
--
cgit v1.2.3
From fd1f420aef96822bed2ce14214c34e41ceda9b4e Mon Sep 17 00:00:00 2001
From: Amin Timany
Date: Sat, 1 Apr 2017 17:35:39 +0200
Subject: Using UInfoInd for universes in inductive types
It stores both universe constraints and subtyping information for
blocks of inductive declarations.
At this stage the there is no inference or checking implemented. The
subtyping information simply encodes equality of levels for the condition of
subtyping.
---
API/API.mli | 5 +++--
engine/universes.ml | 12 ++++++------
kernel/declarations.ml | 4 +---
kernel/declareops.ml | 7 +++----
kernel/entries.mli | 2 +-
kernel/indtypes.ml | 14 +++++---------
kernel/inductive.ml | 2 +-
kernel/safe_typing.ml | 2 +-
kernel/term_typing.ml | 2 +-
kernel/univ.ml | 8 ++++----
kernel/vconv.ml | 2 +-
library/declare.ml | 2 +-
library/global.ml | 12 ++++++------
pretyping/typeclasses.ml | 2 +-
pretyping/vnorm.ml | 2 +-
printing/printer.ml | 7 +++++++
printing/printer.mli | 1 +
printing/printmod.ml | 10 +++++-----
vernac/command.ml | 2 +-
vernac/discharge.ml | 16 +++++-----------
vernac/record.ml | 8 ++++----
vernac/record.mli | 2 +-
22 files changed, 60 insertions(+), 64 deletions(-)
diff --git a/API/API.mli b/API/API.mli
index e2c43dab82..cea879ba3c 100644
--- a/API/API.mli
+++ b/API/API.mli
@@ -86,6 +86,8 @@ sig
type universe_context = UContext.t
[@@ocaml.deprecated "alias of API.Names.UContext.t"]
+ type universe_info_ind = Univ.UInfoInd.t
+
module LSet : module type of struct include Univ.LSet end
module ContextSet :
sig
@@ -1093,8 +1095,7 @@ sig
mind_nparams_rec : int;
mind_params_ctxt : Context.Rel.t;
mind_polymorphic : bool;
- mind_universes : Univ.UContext.t;
- mind_subtyping : Univ.universe_context;
+ mind_universes : Univ.universe_info_ind;
mind_private : bool option;
mind_typing_flags : Declarations.typing_flags;
}
diff --git a/engine/universes.ml b/engine/universes.ml
index 955e1d8b5b..ad53bf8981 100644
--- a/engine/universes.ml
+++ b/engine/universes.ml
@@ -338,14 +338,14 @@ let fresh_constant_instance env c inst =
let fresh_inductive_instance env ind inst =
let mib, mip = Inductive.lookup_mind_specif env ind in
if mib.Declarations.mind_polymorphic then
- let inst, ctx = fresh_instance_from mib.Declarations.mind_universes inst in
+ let inst, ctx = fresh_instance_from (Univ.UInfoInd.univ_context mib.Declarations.mind_universes) inst in
((ind,inst), ctx)
else ((ind,Instance.empty), ContextSet.empty)
let fresh_constructor_instance env (ind,i) inst =
let mib, mip = Inductive.lookup_mind_specif env ind in
if mib.Declarations.mind_polymorphic then
- let inst, ctx = fresh_instance_from mib.Declarations.mind_universes inst in
+ let inst, ctx = fresh_instance_from (Univ.UInfoInd.univ_context mib.Declarations.mind_universes) inst in
(((ind,i),inst), ctx)
else (((ind,i),Instance.empty), ContextSet.empty)
@@ -360,14 +360,14 @@ let unsafe_constant_instance env c =
let unsafe_inductive_instance env ind =
let mib, mip = Inductive.lookup_mind_specif env ind in
if mib.Declarations.mind_polymorphic then
- let inst, ctx = unsafe_instance_from mib.Declarations.mind_universes in
+ let inst, ctx = unsafe_instance_from (Univ.UInfoInd.univ_context mib.Declarations.mind_universes) in
((ind,inst), ctx)
else ((ind,Instance.empty), UContext.empty)
let unsafe_constructor_instance env (ind,i) =
let mib, mip = Inductive.lookup_mind_specif env ind in
if mib.Declarations.mind_polymorphic then
- let inst, ctx = unsafe_instance_from mib.Declarations.mind_universes in
+ let inst, ctx = unsafe_instance_from (Univ.UInfoInd.univ_context mib.Declarations.mind_universes) in
(((ind,i),inst), ctx)
else (((ind,i),Instance.empty), UContext.empty)
@@ -460,7 +460,7 @@ let type_of_reference env r =
| IndRef ind ->
let (mib, oib as specif) = Inductive.lookup_mind_specif env ind in
if mib.mind_polymorphic then
- let inst, ctx = fresh_instance_from mib.mind_universes None in
+ let inst, ctx = fresh_instance_from (Univ.UInfoInd.univ_context mib.mind_universes) None in
let ty = Inductive.type_of_inductive env (specif, inst) in
ty, ctx
else
@@ -469,7 +469,7 @@ let type_of_reference env r =
| ConstructRef cstr ->
let (mib,oib as specif) = Inductive.lookup_mind_specif env (inductive_of_constructor cstr) in
if mib.mind_polymorphic then
- let inst, ctx = fresh_instance_from mib.mind_universes None in
+ let inst, ctx = fresh_instance_from (Univ.UInfoInd.univ_context mib.mind_universes) None in
Inductive.type_of_constructor (cstr,inst) specif, ctx
else Inductive.type_of_constructor (cstr,Instance.empty) specif, ContextSet.empty
diff --git a/kernel/declarations.ml b/kernel/declarations.ml
index 9536407d38..1bb1e885f2 100644
--- a/kernel/declarations.ml
+++ b/kernel/declarations.ml
@@ -188,9 +188,7 @@ type mutual_inductive_body = {
mind_polymorphic : bool; (** Is it polymorphic or not *)
- mind_universes : Univ.universe_context; (** Local universe variables and constraints *)
-
- mind_subtyping : Univ.universe_context; (** Constraints for subtyping *)
+ mind_universes : Univ.universe_info_ind; (** Local universe variables and constraints together with subtyping constraints *)
mind_private : bool option; (** allow pattern-matching: Some true ok, Some false blocked *)
diff --git a/kernel/declareops.ml b/kernel/declareops.ml
index 47a23c8555..cdea468adf 100644
--- a/kernel/declareops.ml
+++ b/kernel/declareops.ml
@@ -261,19 +261,18 @@ let subst_mind_body sub mib =
mind_packets = Array.smartmap (subst_mind_packet sub) mib.mind_packets ;
mind_polymorphic = mib.mind_polymorphic;
mind_universes = mib.mind_universes;
- mind_subtyping = mib.mind_subtyping;
mind_private = mib.mind_private;
mind_typing_flags = mib.mind_typing_flags;
}
let inductive_instance mib =
if mib.mind_polymorphic then
- Univ.UContext.instance mib.mind_universes
+ Univ.UContext.instance (Univ.UInfoInd.univ_context mib.mind_universes)
else Univ.Instance.empty
let inductive_context mib =
if mib.mind_polymorphic then
- Univ.instantiate_univ_context mib.mind_universes
+ Univ.instantiate_univ_context (Univ.UInfoInd.univ_context mib.mind_universes)
else Univ.UContext.empty
(** {6 Hash-consing of inductive declarations } *)
@@ -306,7 +305,7 @@ let hcons_mind mib =
{ mib with
mind_packets = Array.smartmap hcons_mind_packet mib.mind_packets;
mind_params_ctxt = hcons_rel_context mib.mind_params_ctxt;
- mind_universes = Univ.hcons_universe_context mib.mind_universes }
+ mind_universes = Univ.hcons_universe_info_ind mib.mind_universes }
(** {6 Stm machinery } *)
diff --git a/kernel/entries.mli b/kernel/entries.mli
index 88584e3b3d..97c28025a4 100644
--- a/kernel/entries.mli
+++ b/kernel/entries.mli
@@ -50,7 +50,7 @@ type mutual_inductive_entry = {
mind_entry_params : (Id.t * local_entry) list;
mind_entry_inds : one_inductive_entry list;
mind_entry_polymorphic : bool;
- mind_entry_universes : Univ.universe_context * Univ.universe_context;
+ mind_entry_universes : Univ.universe_info_ind;
(* universe constraints and the constraints for subtyping of
inductive types in the block. *)
mind_entry_private : bool option;
diff --git a/kernel/indtypes.ml b/kernel/indtypes.ml
index 5d928facc7..94bf1a7704 100644
--- a/kernel/indtypes.ml
+++ b/kernel/indtypes.ml
@@ -220,7 +220,7 @@ let typecheck_inductive env mie =
(* Check unicity of names *)
mind_check_names mie;
(* Params are typed-checked here *)
- let env' = push_context (fst mie.mind_entry_universes) env in
+ let env' = push_context (Univ.UInfoInd.univ_context mie.mind_entry_universes) env in
let (env_params,paramsctxt) = infer_local_decls env' mie.mind_entry_params in
(* We first type arity of each inductive definition *)
(* This allows building the environment of arities and to share *)
@@ -822,10 +822,10 @@ let build_inductive env p prv ctx env_ar paramsctxt kn isrecord isfinite inds nm
let hyps = used_section_variables env inds in
let nparamargs = Context.Rel.nhyps paramsctxt in
let nparamsctxt = Context.Rel.length paramsctxt in
- let substunivs, ctxunivs = Univ.abstract_universes p (fst ctx) in
- let substsbt, ctxsbt = Univ.abstract_universes p (snd ctx) in
+ let substunivs, ctxunivs = Univ.abstract_universes p (Univ.UInfoInd.univ_context ctx) in
+ let substsubtyp, ctxsubtyp = Univ.abstract_universes p (Univ.UInfoInd.subtyp_context ctx) in
let paramsctxt = Vars.subst_univs_level_context substunivs paramsctxt in
- let env_ar =
+ let env_ar =
let ctxunivs = Environ.rel_context env_ar in
let ctxunivs' = Vars.subst_univs_level_context substunivs ctxunivs in
Environ.push_rel_context ctxunivs' env
@@ -842,9 +842,6 @@ let build_inductive env p prv ctx env_ar paramsctxt kn isrecord isfinite inds nm
let consnrealargs =
Array.map (fun (d,_) -> Context.Rel.nhyps d - nparamargs)
splayed_lc in
- (* Check that the subtyping constraints (inferred outside kernel)
- are valid. If so return (), otherwise raise an anomaly! *)
- let () = () in
(* Elimination sorts *)
let arkind,kelim =
match ar_kind with
@@ -924,8 +921,7 @@ let build_inductive env p prv ctx env_ar paramsctxt kn isrecord isfinite inds nm
mind_params_ctxt = paramsctxt;
mind_packets = packets;
mind_polymorphic = p;
- mind_universes = ctxunivs;
- mind_subtyping = ctxsbt;
+ mind_universes = Univ.UInfoInd.make (ctxunivs, ctxsubtyp);
mind_private = prv;
mind_typing_flags = Environ.typing_flags env;
}
diff --git a/kernel/inductive.ml b/kernel/inductive.ml
index f3b03252db..0f0dc0d607 100644
--- a/kernel/inductive.ml
+++ b/kernel/inductive.ml
@@ -55,7 +55,7 @@ let inductive_paramdecls (mib,u) =
let instantiate_inductive_constraints mib u =
if mib.mind_polymorphic then
- Univ.subst_instance_constraints u (Univ.UContext.constraints mib.mind_universes)
+ Univ.subst_instance_constraints u (Univ.UContext.constraints (Univ.UInfoInd.univ_context mib.mind_universes))
else Univ.Constraint.empty
diff --git a/kernel/safe_typing.ml b/kernel/safe_typing.ml
index f5e8e86530..1568fe0bf2 100644
--- a/kernel/safe_typing.ml
+++ b/kernel/safe_typing.ml
@@ -429,7 +429,7 @@ let globalize_mind_universes mb =
if mb.mind_polymorphic then
[Now (true, Univ.ContextSet.empty)]
else
- [Now (false, Univ.ContextSet.of_context mb.mind_universes)]
+ [Now (false, Univ.ContextSet.of_context (Univ.UInfoInd.univ_context mb.mind_universes))]
let constraints_of_sfb env sfb =
match sfb with
diff --git a/kernel/term_typing.ml b/kernel/term_typing.ml
index bdfd00a8d3..3cf2299d83 100644
--- a/kernel/term_typing.ml
+++ b/kernel/term_typing.ml
@@ -313,7 +313,7 @@ let infer_declaration ~trust env kn dcl =
in
let term, typ = pb.proj_eta in
Def (Mod_subst.from_val (hcons_constr term)), RegularArity typ, Some pb,
- mib.mind_polymorphic, mib.mind_universes, false, None
+ mib.mind_polymorphic, Univ.UInfoInd.univ_context mib.mind_universes, false, None
let global_vars_set_constant_type env = function
| RegularArity t -> global_vars_set env t
diff --git a/kernel/univ.ml b/kernel/univ.ml
index e8b9ae33a0..f124bb39eb 100644
--- a/kernel/univ.ml
+++ b/kernel/univ.ml
@@ -1053,14 +1053,14 @@ struct
let len = Array.length (Instance.to_array ctx) in
let halflen = len / 2 in
(Instance.of_array (Array.sub (Instance.to_array ctx) 0 halflen),
- Instance.of_array (Array.sub (Instance.to_array ctx) halflen len))
+ Instance.of_array (Array.sub (Instance.to_array ctx) halflen halflen))
let pr prl (univcst, subtypcst) =
if UContext.is_empty univcst then mt() else
let (ctx, ctx') = halve_context (UContext.instance subtypcst) in
- (UContext.pr prl univcst) ++
- h 0 (str "~@{" ++ Instance.pr prl ctx ++ str "} <= ~@{" ++ Instance.pr prl ctx' ++ str "}")
- ++ h 0 (v 0 (Constraint.pr prl (UContext.constraints subtypcst)))
+ (UContext.pr prl univcst) ++ fnl () ++ fnl () ++
+ h 0 (str "~@{" ++ Instance.pr prl ctx ++ str "} <= ~@{" ++ Instance.pr prl ctx' ++ str "} iff ")
+ ++ fnl () ++ h 0 (v 0 (Constraint.pr prl (UContext.constraints subtypcst)))
let hcons (univcst, subtypcst) =
(UContext.hcons univcst, UContext.hcons subtypcst)
diff --git a/kernel/vconv.ml b/kernel/vconv.ml
index 74d956bef0..fa16622702 100644
--- a/kernel/vconv.ml
+++ b/kernel/vconv.ml
@@ -93,7 +93,7 @@ and conv_atom env pb k a1 stk1 a2 stk2 cu =
if Environ.polymorphic_ind ind1 env
then
let mib = Environ.lookup_mind mi env in
- let ulen = Univ.UContext.size mib.Declarations.mind_universes in
+ let ulen = Univ.UContext.size (Univ.UInfoInd.univ_context mib.Declarations.mind_universes) in
match stk1 , stk2 with
| [], [] -> assert (Int.equal ulen 0); cu
| Zapp args1 :: stk1' , Zapp args2 :: stk2' ->
diff --git a/library/declare.ml b/library/declare.ml
index 06eeeeab56..f3150174c9 100644
--- a/library/declare.ml
+++ b/library/declare.ml
@@ -352,7 +352,7 @@ let dummy_inductive_entry (_,m) = ([],{
mind_entry_finite = Decl_kinds.BiFinite;
mind_entry_inds = List.map dummy_one_inductive_entry m.mind_entry_inds;
mind_entry_polymorphic = false;
- mind_entry_universes = (Univ.UContext.empty, Univ.UContext.empty);
+ mind_entry_universes = Univ.UInfoInd.empty;
mind_entry_private = None;
})
diff --git a/library/global.ml b/library/global.ml
index 1ba86699d3..a459983849 100644
--- a/library/global.ml
+++ b/library/global.ml
@@ -178,13 +178,13 @@ let type_of_global_unsafe r =
let (mib, oib as specif) = Inductive.lookup_mind_specif env ind in
let inst =
if mib.Declarations.mind_polymorphic then
- Univ.UContext.instance mib.Declarations.mind_universes
+ Univ.UContext.instance (Univ.UInfoInd.univ_context mib.Declarations.mind_universes)
else Univ.Instance.empty
in
Inductive.type_of_inductive env (specif, inst)
| ConstructRef cstr ->
let (mib,oib as specif) = Inductive.lookup_mind_specif env (inductive_of_constructor cstr) in
- let inst = Univ.UContext.instance mib.Declarations.mind_universes in
+ let inst = Univ.UContext.instance (Univ.UInfoInd.univ_context mib.Declarations.mind_universes) in
Inductive.type_of_constructor (cstr,inst) specif
let type_of_global_in_context env r =
@@ -200,13 +200,13 @@ let type_of_global_in_context env r =
| IndRef ind ->
let (mib, oib as specif) = Inductive.lookup_mind_specif env ind in
let univs =
- if mib.mind_polymorphic then Univ.instantiate_univ_context mib.mind_universes
+ if mib.mind_polymorphic then Univ.instantiate_univ_context (Univ.UInfoInd.univ_context mib.mind_universes)
else Univ.UContext.empty
in Inductive.type_of_inductive env (specif, Univ.UContext.instance univs), univs
| ConstructRef cstr ->
let (mib,oib as specif) = Inductive.lookup_mind_specif env (inductive_of_constructor cstr) in
let univs =
- if mib.mind_polymorphic then Univ.instantiate_univ_context mib.mind_universes
+ if mib.mind_polymorphic then Univ.instantiate_univ_context (Univ.UInfoInd.univ_context mib.mind_universes)
else Univ.UContext.empty
in
let inst = Univ.UContext.instance univs in
@@ -222,10 +222,10 @@ let universes_of_global env r =
(Environ.opaque_tables env) cb
| IndRef ind ->
let (mib, oib) = Inductive.lookup_mind_specif env ind in
- Univ.instantiate_univ_context mib.mind_universes
+ Univ.instantiate_univ_context (Univ.UInfoInd.univ_context mib.mind_universes)
| ConstructRef cstr ->
let (mib,oib) = Inductive.lookup_mind_specif env (inductive_of_constructor cstr) in
- Univ.instantiate_univ_context mib.mind_universes
+ Univ.instantiate_univ_context (Univ.UInfoInd.univ_context mib.mind_universes)
let universes_of_global gr =
universes_of_global (env ()) gr
diff --git a/pretyping/typeclasses.ml b/pretyping/typeclasses.ml
index d7b4842810..152ccb0798 100644
--- a/pretyping/typeclasses.ml
+++ b/pretyping/typeclasses.ml
@@ -123,7 +123,7 @@ let typeclass_univ_instance (cl,u') =
else Univ.Instance.empty
| IndRef c ->
let mib,oib = Global.lookup_inductive c in
- if mib.mind_polymorphic then Univ.UContext.instance mib.mind_universes
+ if mib.mind_polymorphic then Univ.UContext.instance (Univ.UInfoInd.univ_context mib.mind_universes)
else Univ.Instance.empty
| _ -> Univ.Instance.empty
in Array.fold_left2 (fun subst u u' -> Univ.LMap.add u u' subst)
diff --git a/pretyping/vnorm.ml b/pretyping/vnorm.ml
index b08666483e..074b7373c7 100644
--- a/pretyping/vnorm.ml
+++ b/pretyping/vnorm.ml
@@ -174,7 +174,7 @@ and nf_whd env sigma whd typ =
| Vatom_stk(Aind ((mi,i) as ind), stk) ->
let mib = Environ.lookup_mind mi env in
let nb_univs =
- if mib.mind_polymorphic then Univ.UContext.size mib.mind_universes
+ if mib.mind_polymorphic then Univ.UContext.size (Univ.UInfoInd.univ_context mib.mind_universes)
else 0
in
let mk u =
diff --git a/printing/printer.ml b/printing/printer.ml
index d6f0778f75..c27a9b009d 100644
--- a/printing/printer.ml
+++ b/printing/printer.ml
@@ -261,6 +261,13 @@ let pr_universe_ctx sigma c =
else
mt()
+let pr_universe_info_ind sigma uii =
+ if !Detyping.print_universes && not (Univ.UInfoInd.is_empty uii) then
+ fnl()++pr_in_comment (fun uii -> v 0
+ (Univ.pr_universe_info_ind (Termops.pr_evd_level sigma) uii)) uii
+ else
+ mt()
+
(**********************************************************************)
(* Global references *)
diff --git a/printing/printer.mli b/printing/printer.mli
index 3fce065613..6531036a1f 100644
--- a/printing/printer.mli
+++ b/printing/printer.mli
@@ -97,6 +97,7 @@ val pr_sort : evar_map -> sorts -> std_ppcmds
val pr_polymorphic : bool -> std_ppcmds
val pr_universe_instance : evar_map -> Univ.universe_context -> std_ppcmds
val pr_universe_ctx : evar_map -> Univ.universe_context -> std_ppcmds
+val pr_universe_info_ind : evar_map -> Univ.universe_info_ind -> std_ppcmds
(** Printing global references using names as short as possible *)
diff --git a/printing/printmod.ml b/printing/printmod.ml
index c4affd4acd..7dc47a4a4c 100644
--- a/printing/printmod.ml
+++ b/printing/printmod.ml
@@ -89,7 +89,7 @@ let build_ind_type env mip =
let print_one_inductive env sigma mib ((_,i) as ind) =
let u = if mib.mind_polymorphic then
- Univ.UContext.instance mib.mind_universes
+ Univ.UContext.instance (Univ.UInfoInd.univ_context mib.mind_universes)
else Univ.Instance.empty in
let mip = mib.mind_packets.(i) in
let params = Inductive.inductive_paramdecls (mib,u) in
@@ -100,7 +100,7 @@ let print_one_inductive env sigma mib ((_,i) as ind) =
let envpar = push_rel_context params env in
let inst =
if mib.mind_polymorphic then
- Printer.pr_universe_instance sigma mib.mind_universes
+ Printer.pr_universe_instance sigma (Univ.UInfoInd.univ_context mib.mind_universes)
else mt ()
in
hov 0 (
@@ -124,7 +124,7 @@ let print_mutual_inductive env mind mib =
def keyword ++ spc () ++
prlist_with_sep (fun () -> fnl () ++ str" with ")
(print_one_inductive env sigma mib) inds ++
- Printer.pr_universe_ctx sigma (Univ.instantiate_univ_context mib.mind_universes))
+ Printer.pr_universe_info_ind sigma (Univ.instantiate_univ_info_ind mib.mind_universes))
let get_fields =
let rec prodec_rec l subst c =
@@ -142,7 +142,7 @@ let get_fields =
let print_record env mind mib =
let u =
if mib.mind_polymorphic then
- Univ.UContext.instance mib.mind_universes
+ Univ.UContext.instance (Univ.UInfoInd.univ_context mib.mind_universes)
else Univ.Instance.empty
in
let mip = mib.mind_packets.(0) in
@@ -175,7 +175,7 @@ let print_record env mind mib =
(fun (id,b,c) ->
pr_id id ++ str (if b then " : " else " := ") ++
Printer.pr_lconstr_env envpar sigma c) fields) ++ str" }" ++
- Printer.pr_universe_ctx sigma (Univ.instantiate_univ_context mib.mind_universes))
+ Printer.pr_universe_info_ind sigma (Univ.instantiate_univ_info_ind mib.mind_universes))
let pr_mutual_inductive_body env mind mib =
if mib.mind_record <> None && not !Flags.raw_print then
diff --git a/vernac/command.ml b/vernac/command.ml
index 5f95a42a37..b76c2247b3 100644
--- a/vernac/command.ml
+++ b/vernac/command.ml
@@ -656,7 +656,7 @@ let interp_mutual_inductive (paramsl,indl) notations poly prv finite =
mind_entry_inds = entries;
mind_entry_polymorphic = poly;
mind_entry_private = if prv then Some false else None;
- mind_entry_universes = (uctx, Univ.UContext.empty);
+ mind_entry_universes = Universes.univ_inf_ind_from_universe_context uctx;
},
pl, impls
diff --git a/vernac/discharge.ml b/vernac/discharge.ml
index 9c70eb97ef..91e126ef1d 100644
--- a/vernac/discharge.ml
+++ b/vernac/discharge.ml
@@ -81,17 +81,10 @@ let process_inductive (sechyps,abs_ctx) modlist mib =
let nparams = mib.mind_nparams in
let subst, univs =
if mib.mind_polymorphic then
- let inst = Univ.UContext.instance mib.mind_universes in
- let cstrs = Univ.UContext.constraints mib.mind_universes in
+ let inst = Univ.UContext.instance (Univ.UInfoInd.univ_context mib.mind_universes) in
+ let cstrs = Univ.UContext.constraints (Univ.UInfoInd.univ_context mib.mind_universes) in
inst, Univ.UContext.make (inst, Univ.subst_instance_constraints inst cstrs)
- else Univ.Instance.empty, mib.mind_universes
- in
- let substsbt, univssbt =
- if mib.mind_polymorphic then
- let inst = Univ.UContext.instance mib.mind_subtyping in
- let cstrs = Univ.UContext.constraints mib.mind_subtyping in
- inst, Univ.UContext.make (inst, Univ.subst_instance_constraints inst cstrs)
- else Univ.Instance.empty, Univ.UContext.empty
+ else Univ.Instance.empty, (Univ.UInfoInd.univ_context mib.mind_universes)
in
let inds =
Array.map_to_list
@@ -112,6 +105,7 @@ let process_inductive (sechyps,abs_ctx) modlist mib =
let (params',inds') = abstract_inductive sechyps' nparams inds in
let abs_ctx = Univ.instantiate_univ_context abs_ctx in
let univs = Univ.UContext.union abs_ctx univs in
+ let univ_info_ind = Universes.univ_inf_ind_from_universe_context univs in (* Here we must re-infer subtyping constraints. For now we just revert to trivial subtyping. *)
let record = match mib.mind_record with
| Some (Some (id, _, _)) -> Some (Some id)
| Some None -> Some None
@@ -123,5 +117,5 @@ let process_inductive (sechyps,abs_ctx) modlist mib =
mind_entry_inds = inds';
mind_entry_polymorphic = mib.mind_polymorphic;
mind_entry_private = mib.mind_private;
- mind_entry_universes = (univs, univssbt);
+ mind_entry_universes = univ_info_ind
}
diff --git a/vernac/record.ml b/vernac/record.ml
index 5c76bb4b2d..64f5e81d41 100644
--- a/vernac/record.ml
+++ b/vernac/record.ml
@@ -268,7 +268,7 @@ let declare_projections indsp ?(kind=StructureComponent) binder_name coers field
let u = Declareops.inductive_instance mib in
let paramdecls = Inductive.inductive_paramdecls (mib, u) in
let poly = mib.mind_polymorphic in
- let ctx = Univ.instantiate_univ_context mib.mind_universes in
+ let ctx = Univ.instantiate_univ_context (Univ.UInfoInd.univ_context mib.mind_universes) in
let indu = indsp, u in
let r = mkIndU (indsp,u) in
let rp = applist (r, Context.Rel.to_extended_list mkRel 0 paramdecls) in
@@ -466,7 +466,7 @@ let declare_class finite def poly ctx id idbuild paramimpls params arity
in
cref, [Name proj_name, sub, Some proj_cst]
| _ ->
- let ind = declare_structure BiFinite poly (ctx, Univ.UContext.empty) (snd id) idbuild paramimpls
+ let ind = declare_structure BiFinite poly (Universes.univ_inf_ind_from_universe_context ctx) (snd id) idbuild paramimpls
params arity template fieldimpls fields
~kind:Method ~name:binder_name false (List.map (fun _ -> false) fields) sign
in
@@ -515,7 +515,7 @@ let add_inductive_class ind =
let mind, oneind = Global.lookup_inductive ind in
let k =
let ctx = oneind.mind_arity_ctxt in
- let inst = Univ.UContext.instance mind.mind_universes in
+ let inst = Univ.UContext.instance (Univ.UInfoInd.univ_context mind.mind_universes) in
let ty = Inductive.type_of_inductive
(push_rel_context ctx (Global.env ()))
((mind,oneind),inst)
@@ -571,7 +571,7 @@ let definition_structure (kind,poly,finite,(is_coe,((loc,idstruc),pl)),ps,cfs,id
let implfs = List.map
(fun impls -> implpars @ Impargs.lift_implicits
(succ (List.length params)) impls) implfs in
- let ind = declare_structure finite poly (ctx, Univ.UContext.empty) idstruc
+ let ind = declare_structure finite poly (Universes.univ_inf_ind_from_universe_context ctx) idstruc
idbuild implpars params arity template implfs
fields is_coe (List.map (fun coe -> not (Option.is_empty coe)) coers) sign in
IndRef ind
diff --git a/vernac/record.mli b/vernac/record.mli
index a380b041a4..ec5d2cf83d 100644
--- a/vernac/record.mli
+++ b/vernac/record.mli
@@ -27,7 +27,7 @@ val declare_projections :
val declare_structure :
Decl_kinds.recursivity_kind ->
bool (** polymorphic?*) ->
- (Univ.universe_context * Univ.universe_context) (** universe and subtyping constraints *) ->
+ Univ.universe_info_ind (** universe and subtyping constraints *) ->
Id.t -> Id.t ->
manual_explicitation list -> Context.Rel.t -> (** params *) constr -> (** arity *)
bool (** template arity ? *) ->
--
cgit v1.2.3
From f27f3ca3a39f5320a60c82c601525e7f0fe666cb Mon Sep 17 00:00:00 2001
From: Amin Timany
Date: Mon, 3 Apr 2017 16:06:07 +0200
Subject: Check subtyping of inductive types in Kernel
---
engine/universes.ml | 9 ---------
engine/universes.mli | 5 -----
kernel/indtypes.ml | 34 ++++++++++++++++++++++++++++++++++
kernel/univ.ml | 16 ++++------------
kernel/univ.mli | 7 +------
5 files changed, 39 insertions(+), 32 deletions(-)
diff --git a/engine/universes.ml b/engine/universes.ml
index ad53bf8981..51957e00ad 100644
--- a/engine/universes.ml
+++ b/engine/universes.ml
@@ -1129,12 +1129,3 @@ let univ_inf_ind_from_universe_context univcst =
(Array.map (fun _ -> new_univ_level ())
(Instance.to_array (UContext.instance univcst)))
in UInfoInd.from_universe_context univcst freshunivs
-
-(** This function adds universe constraints to the universe
- constraints of the given universe_info_ind. However one must be
- CAUTIOUS as it resets the subtyping constraints to equality. *)
-let univ_inf_ind_union uinfind univcst' =
- let freshunivs = Instance.of_array
- (Array.map (fun _ -> new_univ_level ())
- (Instance.to_array (UContext.instance univcst')))
- in UInfoInd.union uinfind univcst' freshunivs
diff --git a/engine/universes.mli b/engine/universes.mli
index 17a9deb3a2..1b9703c7bf 100644
--- a/engine/universes.mli
+++ b/engine/universes.mli
@@ -233,8 +233,3 @@ val solve_constraints_system : universe option array -> universe array -> univer
(** Given a universe context representing constraints of an inductive
this function produces a UInfoInd.t that with the trivial subtyping relation. *)
val univ_inf_ind_from_universe_context : universe_context -> universe_info_ind
-
-(** This function adds universe constraints to the universe
- constraints of the given universe_info_ind. However one must be
- CAUTIOUS as it resets the subtyping constraints to equality. *)
-val univ_inf_ind_union : universe_info_ind -> universe_context -> universe_info_ind
diff --git a/kernel/indtypes.ml b/kernel/indtypes.ml
index 94bf1a7704..068332406e 100644
--- a/kernel/indtypes.ml
+++ b/kernel/indtypes.ml
@@ -207,6 +207,24 @@ let param_ccls paramsctxt =
in
List.fold_left fold [] paramsctxt
+(* Check arities and constructors *)
+let check_subtyping_arity_constructor env (subst : constr -> constr) (arcn : Term.types) is_arity =
+ let basic_check ev tp = conv_leq ev tp (subst tp) in
+ let check_typ typ typ_env =
+ match typ with
+ | LocalAssum (_, typ') ->
+ begin
+ try
+ basic_check env typ'; Environ.push_rel typ typ_env
+ with NotConvertible ->
+ anomaly ~label:"bad inductive subtyping relation" (Pp.str "Invalid subtyping relation!")
+ end
+ | _ -> anomaly (Pp.str "")
+ in
+ let typs, codom = dest_prod env arcn in
+ let last_env = Context.Rel.fold_outside check_typ typs ~init:env in
+ if not is_arity then basic_check last_env codom else ()
+
(* Type-check an inductive definition. Does not check positivity
conditions. *)
(* TODO check that we don't overgeneralize construcors/inductive arities with
@@ -345,6 +363,22 @@ let typecheck_inductive env mie =
in
(id,cn,lc,(sign,arity)))
inds
+ in
+ (* Check that the subtyping information inferred for inductive types in the block is correct. *)
+ (* This check produces a value of the unit type if successful or raises an anomaly if check fails. *)
+ let () =
+ let sbsubst = UInfoInd.subtyping_susbst mie.mind_entry_universes in
+ let dosubst = subst_univs_level_constr sbsubst in
+ let envsb = push_context (UInfoInd.subtyp_context mie.mind_entry_universes) env_ar_par in
+ (* process individual inductive types: *)
+ Array.iter (fun (id,cn,lc,(sign,arity)) ->
+ match arity with
+ | RegularArity (_, full_arity, _) ->
+ check_subtyping_arity_constructor envsb dosubst full_arity true;
+ Array.iter (fun cnt -> check_subtyping_arity_constructor envsb dosubst cnt true) lc
+ | TemplateArity _ -> ()
+ (* TODO: When disabling template polumorphism raise anomaly if this constructor is not removed from the code base *)
+ ) inds
in (env_arities, env_ar_par, paramsctxt, inds)
(************************************************************************)
diff --git a/kernel/univ.ml b/kernel/univ.ml
index f124bb39eb..4a4cf1baa7 100644
--- a/kernel/univ.ml
+++ b/kernel/univ.ml
@@ -1049,7 +1049,7 @@ struct
let empty = (UContext.empty, UContext.empty)
let is_empty (univcst, subtypcst) = UContext.is_empty univcst && UContext.is_empty subtypcst
- let halve_context (ctx : Instance.t) : Instance.t * Instance.t =
+ let halve_context ctx =
let len = Array.length (Instance.to_array ctx) in
let halflen = len / 2 in
(Instance.of_array (Array.sub (Instance.to_array ctx) 0 halflen),
@@ -1084,17 +1084,9 @@ struct
(univcst, UContext.make (Instance.append inst freshunivs,
create_trivial_subtyping inst freshunivs))
- (** This function adds universe constraints to the universe
- constraints of the given universe_info_ind. However one must be
- CAUTIOUS as it resets the subtyping constraints to equality. It
- also requires fresh universes for the newly introduced
- universes *)
- let union (univcst, _) univcst' freshunivs =
- assert (Instance.length freshunivs = Instance.length (UContext.instance univcst'));
- let (ctx, ctx') = halve_context (UContext.instance univcst) in
- let newctx' = Instance.append ctx' freshunivs in
- let univcstunion = UContext.union univcst univcst' in
- (univcstunion, subtyp_context (from_universe_context univcstunion newctx'))
+ let subtyping_susbst (univcst, subtypcst) =
+ let (ctx, ctx') = (halve_context (UContext.instance subtypcst))in
+ Array.fold_left2 (fun subst l1 l2 -> LMap.add l1 l2 subst) LMap.empty ctx ctx'
let dest x = x
diff --git a/kernel/univ.mli b/kernel/univ.mli
index 630d0d9498..f139a8b334 100644
--- a/kernel/univ.mli
+++ b/kernel/univ.mli
@@ -345,12 +345,7 @@ sig
trivial subtyping relation. *)
val from_universe_context : universe_context -> universe_instance -> t
- (** This function adds universe constraints to the universe
- constraints of the given universe_info_ind. However one must be
- CAUTIOUS as it resets the subtyping constraints to equality. It
- also requires fresh universes for the newly introduced
- universes *)
- val union : t -> universe_context -> universe_instance -> t
+ val subtyping_susbst : t -> universe_level_subst
val size : t -> int
--
cgit v1.2.3
From 47e010c2dd0ab6370704d8ab24552753e4e1b1dc Mon Sep 17 00:00:00 2001
From: Amin Timany
Date: Mon, 3 Apr 2017 16:28:20 +0200
Subject: Fix typo in error message
---
kernel/indtypes.ml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/indtypes.ml b/kernel/indtypes.ml
index 068332406e..91e6ec2855 100644
--- a/kernel/indtypes.ml
+++ b/kernel/indtypes.ml
@@ -217,7 +217,7 @@ let check_subtyping_arity_constructor env (subst : constr -> constr) (arcn : Ter
try
basic_check env typ'; Environ.push_rel typ typ_env
with NotConvertible ->
- anomaly ~label:"bad inductive subtyping relation" (Pp.str "Invalid subtyping relation!")
+ anomaly ~label:"bad inductive subtyping relation" (Pp.str "Invalid subtyping relation")
end
| _ -> anomaly (Pp.str "")
in
--
cgit v1.2.3
From 34c1fee1c980b433b069a59f408792142ba00f6e Mon Sep 17 00:00:00 2001
From: Amin Timany
Date: Tue, 4 Apr 2017 11:54:37 +0200
Subject: Correct subtyping check for constructors
---
kernel/indtypes.ml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/indtypes.ml b/kernel/indtypes.ml
index 91e6ec2855..17ce5483c7 100644
--- a/kernel/indtypes.ml
+++ b/kernel/indtypes.ml
@@ -375,7 +375,7 @@ let typecheck_inductive env mie =
match arity with
| RegularArity (_, full_arity, _) ->
check_subtyping_arity_constructor envsb dosubst full_arity true;
- Array.iter (fun cnt -> check_subtyping_arity_constructor envsb dosubst cnt true) lc
+ Array.iter (fun cnt -> check_subtyping_arity_constructor envsb dosubst cnt false) lc
| TemplateArity _ -> ()
(* TODO: When disabling template polumorphism raise anomaly if this constructor is not removed from the code base *)
) inds
--
cgit v1.2.3
From d83a4a93202c91095c5528fe4b54c83737e5a151 Mon Sep 17 00:00:00 2001
From: Amin Timany
Date: Tue, 4 Apr 2017 19:44:31 +0200
Subject: Add subtyping inference for inductive types
---
kernel/indtypes.ml | 21 ++++++++++++++++-----
vernac/command.ml | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 69 insertions(+), 6 deletions(-)
diff --git a/kernel/indtypes.ml b/kernel/indtypes.ml
index 17ce5483c7..15fe908359 100644
--- a/kernel/indtypes.ml
+++ b/kernel/indtypes.ml
@@ -208,8 +208,12 @@ let param_ccls paramsctxt =
List.fold_left fold [] paramsctxt
(* Check arities and constructors *)
-let check_subtyping_arity_constructor env (subst : constr -> constr) (arcn : Term.types) is_arity =
- let basic_check ev tp = conv_leq ev tp (subst tp) in
+let check_subtyping_arity_constructor env (subst : constr -> constr) (arcn : Term.types) numparams is_arity =
+ let numchecked = ref 0 in
+ let basic_check ev tp =
+ if !numchecked < numparams then () else conv_leq ev tp (subst tp);
+ numchecked := !numchecked + 1
+ in
let check_typ typ typ_env =
match typ with
| LocalAssum (_, typ') ->
@@ -367,15 +371,22 @@ let typecheck_inductive env mie =
(* Check that the subtyping information inferred for inductive types in the block is correct. *)
(* This check produces a value of the unit type if successful or raises an anomaly if check fails. *)
let () =
+ let numparams = List.length paramsctxt in
let sbsubst = UInfoInd.subtyping_susbst mie.mind_entry_universes in
let dosubst = subst_univs_level_constr sbsubst in
- let envsb = push_context (UInfoInd.subtyp_context mie.mind_entry_universes) env_ar_par in
+ let uctx = UInfoInd.univ_context mie.mind_entry_universes in
+ let instance_other = Univ.subst_univs_level_instance sbsubst (Univ.UContext.instance uctx) in
+ let constraints_other = Univ.subst_univs_level_constraints sbsubst (Univ.UContext.constraints uctx) in
+ let uctx_other = Univ.UContext.make (instance_other, constraints_other) in
+ let env' = Environ.push_context uctx env_ar_par in
+ let env'' = Environ.push_context uctx_other env' in
+ let envsb = push_context (UInfoInd.subtyp_context mie.mind_entry_universes) env'' in
(* process individual inductive types: *)
Array.iter (fun (id,cn,lc,(sign,arity)) ->
match arity with
| RegularArity (_, full_arity, _) ->
- check_subtyping_arity_constructor envsb dosubst full_arity true;
- Array.iter (fun cnt -> check_subtyping_arity_constructor envsb dosubst cnt false) lc
+ check_subtyping_arity_constructor envsb dosubst full_arity numparams true;
+ Array.iter (fun cnt -> check_subtyping_arity_constructor envsb dosubst cnt numparams false) lc
| TemplateArity _ -> ()
(* TODO: When disabling template polumorphism raise anomaly if this constructor is not removed from the code base *)
) inds
diff --git a/vernac/command.ml b/vernac/command.ml
index b76c2247b3..b23eb9e6bf 100644
--- a/vernac/command.ml
+++ b/vernac/command.ml
@@ -573,6 +573,32 @@ let check_param = function
| CLocalAssum (nas, Generalized _, _) -> ()
| CLocalPattern _ -> assert false
+let infer_inductive_subtyping_arity_constructor
+ (env, evd, csts) (subst : constr -> constr) (arcn : Term.types) is_arity =
+ let update_contexts (env, evd, csts) csts' =
+ (Environ.add_constraints csts' env, Evd.add_constraints evd csts', Univ.Constraint.union csts csts')
+ in
+ let basic_check (env, evd, csts) tp =
+ let csts' =
+ Reduction.infer_conv_leq ~evars:(Evd.existential_opt_value evd) env (Evd.universes evd) tp (subst tp)
+ in update_contexts (env, evd, csts) csts'
+ in
+ let infer_typ typ ctxs =
+ match typ with
+ | LocalAssum (_, typ') ->
+ begin
+ try
+ let (env, evd, csts) = basic_check ctxs typ' in (Environ.push_rel typ env, evd, csts)
+ with Reduction.NotConvertible ->
+ anomaly ~label:"inference of record/inductive subtyping relation failed"
+ (Pp.str "Can't infer subtyping for record/inductive type")
+ end
+ | _ -> anomaly (Pp.str "")
+ in
+ let typs, codom = Reduction.dest_prod env arcn in
+ let last_contexts = Context.Rel.fold_outside infer_typ typs ~init:(env, evd, csts) in
+ if not is_arity then basic_check last_contexts codom else last_contexts
+
let interp_mutual_inductive (paramsl,indl) notations poly prv finite =
check_all_names_different indl;
List.iter check_param paramsl;
@@ -649,6 +675,32 @@ let interp_mutual_inductive (paramsl,indl) notations poly prv finite =
indimpls, List.map (fun impls ->
userimpls @ (lift_implicits len impls)) cimpls) indimpls constructors
in
+ let ground_uinfind = Universes.univ_inf_ind_from_universe_context uctx in
+ let uinfind =
+ let sbsubst = Univ.UInfoInd.subtyping_susbst ground_uinfind in
+ let dosubst = subst_univs_level_constr sbsubst in
+ let instance_other = Univ.subst_univs_level_instance sbsubst (Univ.UContext.instance uctx) in
+ let constraints_other = Univ.subst_univs_level_constraints sbsubst (Univ.UContext.constraints uctx) in
+ let uctx_other = Univ.UContext.make (instance_other, constraints_other) in
+ let env' = Environ.push_context uctx env_ar_params in
+ let env' = Environ.push_context uctx_other env' in
+ let evd' = Evd.merge_universe_context evd (UState.of_context_set (Univ.ContextSet.of_context uctx_other)) in
+ let (_, _, subtyp_constraints) =
+ List.fold_left
+ (fun ctxs indentry ->
+ let ctxs' = infer_inductive_subtyping_arity_constructor
+ ctxs dosubst indentry.mind_entry_arity true
+ in
+ List.fold_left
+ (fun ctxs cons ->
+ infer_inductive_subtyping_arity_constructor ctxs dosubst cons false)
+ ctxs' indentry.mind_entry_lc
+ ) (env', evd', Univ.Constraint.empty) entries
+ in Univ.UInfoInd.make (Univ.UInfoInd.univ_context ground_uinfind,
+ Univ.UContext.make
+ (Univ.UContext.instance (Univ.UInfoInd.subtyp_context ground_uinfind),
+ subtyp_constraints))
+ in
(* Build the mutual inductive entry *)
{ mind_entry_params = List.map prepare_param ctx_params;
mind_entry_record = None;
@@ -656,7 +708,7 @@ let interp_mutual_inductive (paramsl,indl) notations poly prv finite =
mind_entry_inds = entries;
mind_entry_polymorphic = poly;
mind_entry_private = if prv then Some false else None;
- mind_entry_universes = Universes.univ_inf_ind_from_universe_context uctx;
+ mind_entry_universes = uinfind;
},
pl, impls
--
cgit v1.2.3
From bef2e53ae2286d0a7c61697f7a7a71bfdc0a3c99 Mon Sep 17 00:00:00 2001
From: Amin Timany
Date: Wed, 5 Apr 2017 14:49:13 +0200
Subject: Subtyping inference for inductoves and records
Also reinferred after sections discharge
---
pretyping/inductiveops.ml | 65 ++++++++++++++++++++++++++++++++++++++++++
pretyping/inductiveops.mli | 5 ++++
vernac/command.ml | 70 +++++++---------------------------------------
vernac/discharge.ml | 31 ++++++++++++++------
vernac/record.ml | 12 ++++++++
5 files changed, 114 insertions(+), 69 deletions(-)
diff --git a/pretyping/inductiveops.ml b/pretyping/inductiveops.ml
index d8252ea9bb..1f8600dc2c 100644
--- a/pretyping/inductiveops.ml
+++ b/pretyping/inductiveops.ml
@@ -655,3 +655,68 @@ let control_only_guard env c =
iter_constr_with_full_binders push_rel iter env c
in
iter env c
+
+(* inference of subtyping condition for inductive types *)
+
+let infer_inductive_subtyping_arity_constructor
+ (env, evd, csts) (subst : constr -> constr) (arcn : Term.types) is_arity =
+ let update_contexts (env, evd, csts) csts' =
+ (Environ.add_constraints csts' env, Evd.add_constraints evd csts', Univ.Constraint.union csts csts')
+ in
+ let basic_check (env, evd, csts) tp =
+ let csts' =
+ Reduction.infer_conv_leq ~evars:(Evd.existential_opt_value evd) env (Evd.universes evd) tp (subst tp)
+ in update_contexts (env, evd, csts) csts'
+ in
+ let infer_typ typ ctxs =
+ match typ with
+ | LocalAssum (_, typ') ->
+ begin
+ try
+ let (env, evd, csts) = basic_check ctxs typ' in (Environ.push_rel typ env, evd, csts)
+ with Reduction.NotConvertible ->
+ anomaly ~label:"inference of record/inductive subtyping relation failed"
+ (Pp.str "Can't infer subtyping for record/inductive type")
+ end
+ | _ -> anomaly (Pp.str "")
+ in
+ let typs, codom = Reduction.dest_prod env arcn in
+ let last_contexts = Context.Rel.fold_outside infer_typ typs ~init:(env, evd, csts) in
+ if not is_arity then basic_check last_contexts codom else last_contexts
+
+let infer_inductive_subtyping env evd mind_ent =
+ let { Entries.mind_entry_inds = entries;
+ Entries.mind_entry_polymorphic = poly;
+ Entries.mind_entry_universes = ground_uinfind;
+ } = mind_ent
+ in
+ let uinfind =
+ if poly then
+ begin
+ let uctx = Univ.UInfoInd.univ_context ground_uinfind in
+ let sbsubst = Univ.UInfoInd.subtyping_susbst ground_uinfind in
+ let dosubst = subst_univs_level_constr sbsubst in
+ let instance_other = Univ.subst_univs_level_instance sbsubst (Univ.UContext.instance uctx) in
+ let constraints_other = Univ.subst_univs_level_constraints sbsubst (Univ.UContext.constraints uctx) in
+ let uctx_other = Univ.UContext.make (instance_other, constraints_other) in
+ let env' = Environ.push_context uctx env in
+ let env' = Environ.push_context uctx_other env' in
+ let evd' = Evd.merge_universe_context evd (UState.of_context_set (Univ.ContextSet.of_context uctx_other)) in
+ let (_, _, subtyp_constraints) =
+ List.fold_left
+ (fun ctxs indentry ->
+ let ctxs' = infer_inductive_subtyping_arity_constructor
+ ctxs dosubst indentry.Entries.mind_entry_arity true
+ in
+ List.fold_left
+ (fun ctxs cons ->
+ infer_inductive_subtyping_arity_constructor ctxs dosubst cons false)
+ ctxs' indentry.Entries.mind_entry_lc
+ ) (env', evd', Univ.Constraint.empty) entries
+ in Univ.UInfoInd.make (Univ.UInfoInd.univ_context ground_uinfind,
+ Univ.UContext.make
+ (Univ.UContext.instance (Univ.UInfoInd.subtyp_context ground_uinfind),
+ subtyp_constraints))
+ end
+ else ground_uinfind
+ in {mind_ent with Entries.mind_entry_universes = uinfind;}
diff --git a/pretyping/inductiveops.mli b/pretyping/inductiveops.mli
index bdb6f996b9..7d89b1b2bd 100644
--- a/pretyping/inductiveops.mli
+++ b/pretyping/inductiveops.mli
@@ -199,3 +199,8 @@ val type_of_inductive_knowing_conclusion :
(********************)
val control_only_guard : env -> types -> unit
+
+(* inference of subtyping condition for inductive types *)
+
+val infer_inductive_subtyping : Environ.env -> Evd.evar_map -> Entries.mutual_inductive_entry ->
+ Entries.mutual_inductive_entry
diff --git a/vernac/command.ml b/vernac/command.ml
index b23eb9e6bf..35b75370e4 100644
--- a/vernac/command.ml
+++ b/vernac/command.ml
@@ -573,32 +573,6 @@ let check_param = function
| CLocalAssum (nas, Generalized _, _) -> ()
| CLocalPattern _ -> assert false
-let infer_inductive_subtyping_arity_constructor
- (env, evd, csts) (subst : constr -> constr) (arcn : Term.types) is_arity =
- let update_contexts (env, evd, csts) csts' =
- (Environ.add_constraints csts' env, Evd.add_constraints evd csts', Univ.Constraint.union csts csts')
- in
- let basic_check (env, evd, csts) tp =
- let csts' =
- Reduction.infer_conv_leq ~evars:(Evd.existential_opt_value evd) env (Evd.universes evd) tp (subst tp)
- in update_contexts (env, evd, csts) csts'
- in
- let infer_typ typ ctxs =
- match typ with
- | LocalAssum (_, typ') ->
- begin
- try
- let (env, evd, csts) = basic_check ctxs typ' in (Environ.push_rel typ env, evd, csts)
- with Reduction.NotConvertible ->
- anomaly ~label:"inference of record/inductive subtyping relation failed"
- (Pp.str "Can't infer subtyping for record/inductive type")
- end
- | _ -> anomaly (Pp.str "")
- in
- let typs, codom = Reduction.dest_prod env arcn in
- let last_contexts = Context.Rel.fold_outside infer_typ typs ~init:(env, evd, csts) in
- if not is_arity then basic_check last_contexts codom else last_contexts
-
let interp_mutual_inductive (paramsl,indl) notations poly prv finite =
check_all_names_different indl;
List.iter check_param paramsl;
@@ -676,41 +650,17 @@ let interp_mutual_inductive (paramsl,indl) notations poly prv finite =
userimpls @ (lift_implicits len impls)) cimpls) indimpls constructors
in
let ground_uinfind = Universes.univ_inf_ind_from_universe_context uctx in
- let uinfind =
- let sbsubst = Univ.UInfoInd.subtyping_susbst ground_uinfind in
- let dosubst = subst_univs_level_constr sbsubst in
- let instance_other = Univ.subst_univs_level_instance sbsubst (Univ.UContext.instance uctx) in
- let constraints_other = Univ.subst_univs_level_constraints sbsubst (Univ.UContext.constraints uctx) in
- let uctx_other = Univ.UContext.make (instance_other, constraints_other) in
- let env' = Environ.push_context uctx env_ar_params in
- let env' = Environ.push_context uctx_other env' in
- let evd' = Evd.merge_universe_context evd (UState.of_context_set (Univ.ContextSet.of_context uctx_other)) in
- let (_, _, subtyp_constraints) =
- List.fold_left
- (fun ctxs indentry ->
- let ctxs' = infer_inductive_subtyping_arity_constructor
- ctxs dosubst indentry.mind_entry_arity true
- in
- List.fold_left
- (fun ctxs cons ->
- infer_inductive_subtyping_arity_constructor ctxs dosubst cons false)
- ctxs' indentry.mind_entry_lc
- ) (env', evd', Univ.Constraint.empty) entries
- in Univ.UInfoInd.make (Univ.UInfoInd.univ_context ground_uinfind,
- Univ.UContext.make
- (Univ.UContext.instance (Univ.UInfoInd.subtyp_context ground_uinfind),
- subtyp_constraints))
- in
(* Build the mutual inductive entry *)
- { mind_entry_params = List.map prepare_param ctx_params;
- mind_entry_record = None;
- mind_entry_finite = finite;
- mind_entry_inds = entries;
- mind_entry_polymorphic = poly;
- mind_entry_private = if prv then Some false else None;
- mind_entry_universes = uinfind;
- },
- pl, impls
+ let mind_ent =
+ { mind_entry_params = List.map prepare_param ctx_params;
+ mind_entry_record = None;
+ mind_entry_finite = finite;
+ mind_entry_inds = entries;
+ mind_entry_polymorphic = poly;
+ mind_entry_private = if prv then Some false else None;
+ mind_entry_universes = ground_uinfind;
+ }
+ in (Inductiveops.infer_inductive_subtyping env_ar_params evd mind_ent), pl, impls
(* Very syntactical equality *)
let eq_local_binders bl1 bl2 =
diff --git a/vernac/discharge.ml b/vernac/discharge.ml
index 91e126ef1d..21ffa4cbff 100644
--- a/vernac/discharge.ml
+++ b/vernac/discharge.ml
@@ -105,17 +105,30 @@ let process_inductive (sechyps,abs_ctx) modlist mib =
let (params',inds') = abstract_inductive sechyps' nparams inds in
let abs_ctx = Univ.instantiate_univ_context abs_ctx in
let univs = Univ.UContext.union abs_ctx univs in
- let univ_info_ind = Universes.univ_inf_ind_from_universe_context univs in (* Here we must re-infer subtyping constraints. For now we just revert to trivial subtyping. *)
+ let univ_info_ind = Universes.univ_inf_ind_from_universe_context univs in
let record = match mib.mind_record with
| Some (Some (id, _, _)) -> Some (Some id)
| Some None -> Some None
| None -> None
in
- { mind_entry_record = record;
- mind_entry_finite = mib.mind_finite;
- mind_entry_params = params';
- mind_entry_inds = inds';
- mind_entry_polymorphic = mib.mind_polymorphic;
- mind_entry_private = mib.mind_private;
- mind_entry_universes = univ_info_ind
- }
+ let mind_ent =
+ { mind_entry_record = record;
+ mind_entry_finite = mib.mind_finite;
+ mind_entry_params = params';
+ mind_entry_inds = inds';
+ mind_entry_polymorphic = mib.mind_polymorphic;
+ mind_entry_private = mib.mind_private;
+ mind_entry_universes = univ_info_ind
+ }
+ in
+ if mib.mind_polymorphic then
+ begin
+ let env = Global.env () in
+ let env' = Environ.push_context univs env in
+ let (env'', typed_params) = Typeops.infer_local_decls env' params' in
+ let evd = Evd.from_env env'' in
+ Inductiveops.infer_inductive_subtyping env'' evd mind_ent
+ end
+ else
+ mind_ent
+
diff --git a/vernac/record.ml b/vernac/record.ml
index 64f5e81d41..84312594d5 100644
--- a/vernac/record.ml
+++ b/vernac/record.ml
@@ -405,6 +405,18 @@ let declare_structure finite poly ctx id idbuild paramimpls params arity templat
mind_entry_universes = ctx;
}
in
+ let mie =
+ if poly then
+ begin
+ let env = Global.env () in
+ let env' = Environ.push_context (Univ.UInfoInd.univ_context ctx) env in
+ let env'' = Environ.push_rel_context params env' in
+ let evd = Evd.from_env env'' in
+ Inductiveops.infer_inductive_subtyping env'' evd mie
+ end
+ else
+ mie
+ in
let kn = Command.declare_mutual_inductive_with_eliminations mie [] [(paramimpls,[])] in
let rsp = (kn,0) in (* This is ind path of idstruc *)
let cstr = (rsp,1) in
--
cgit v1.2.3
From c07215582ab75faeea864827b153eed80a28527a Mon Sep 17 00:00:00 2001
From: Amin Timany
Date: Thu, 6 Apr 2017 19:03:24 +0200
Subject: Change the place of inference after sect discharge
---
library/declare.ml | 18 +++++++++++++++++-
vernac/command.ml | 5 ++++-
vernac/discharge.ml | 28 ++++++++--------------------
3 files changed, 29 insertions(+), 22 deletions(-)
diff --git a/library/declare.ml b/library/declare.ml
index f3150174c9..fcaadaa6e0 100644
--- a/library/declare.ml
+++ b/library/declare.ml
@@ -356,6 +356,21 @@ let dummy_inductive_entry (_,m) = ([],{
mind_entry_private = None;
})
+(* reinfer subtyping constraints for inductive after section is dischared. *)
+let infer_inductive_subtyping (pth, mind_ent) =
+ if mind_ent.mind_entry_polymorphic then
+ begin
+ let env = Global.env () in
+ let env' =
+ Environ.push_context (Univ.UInfoInd.univ_context mind_ent.mind_entry_universes) env
+ in
+ let (env'', typed_params) = Typeops.infer_local_decls env' (mind_ent.mind_entry_params) in
+ let evd = Evd.from_env env'' in
+ (pth, Inductiveops.infer_inductive_subtyping env'' evd mind_ent)
+ end
+ else (pth, mind_ent)
+
+
type inductive_obj = Dischargedhypsmap.discharged_hyps * mutual_inductive_entry
let inInductive : inductive_obj -> obj =
@@ -365,7 +380,8 @@ let inInductive : inductive_obj -> obj =
open_function = open_inductive;
classify_function = (fun a -> Substitute (dummy_inductive_entry a));
subst_function = ident_subst_function;
- discharge_function = discharge_inductive }
+ discharge_function = discharge_inductive;
+ rebuild_function = infer_inductive_subtyping }
let declare_projections mind =
let spec,_ = Inductive.lookup_mind_specif (Global.env ()) (mind,0) in
diff --git a/vernac/command.ml b/vernac/command.ml
index 35b75370e4..2d4f051345 100644
--- a/vernac/command.ml
+++ b/vernac/command.ml
@@ -660,7 +660,10 @@ let interp_mutual_inductive (paramsl,indl) notations poly prv finite =
mind_entry_private = if prv then Some false else None;
mind_entry_universes = ground_uinfind;
}
- in (Inductiveops.infer_inductive_subtyping env_ar_params evd mind_ent), pl, impls
+ in
+ (if poly then
+ Inductiveops.infer_inductive_subtyping env_ar_params evd mind_ent
+ else mind_ent), pl, impls
(* Very syntactical equality *)
let eq_local_binders bl1 bl2 =
diff --git a/vernac/discharge.ml b/vernac/discharge.ml
index 21ffa4cbff..c7a741c13f 100644
--- a/vernac/discharge.ml
+++ b/vernac/discharge.ml
@@ -111,24 +111,12 @@ let process_inductive (sechyps,abs_ctx) modlist mib =
| Some None -> Some None
| None -> None
in
- let mind_ent =
- { mind_entry_record = record;
- mind_entry_finite = mib.mind_finite;
- mind_entry_params = params';
- mind_entry_inds = inds';
- mind_entry_polymorphic = mib.mind_polymorphic;
- mind_entry_private = mib.mind_private;
- mind_entry_universes = univ_info_ind
- }
- in
- if mib.mind_polymorphic then
- begin
- let env = Global.env () in
- let env' = Environ.push_context univs env in
- let (env'', typed_params) = Typeops.infer_local_decls env' params' in
- let evd = Evd.from_env env'' in
- Inductiveops.infer_inductive_subtyping env'' evd mind_ent
- end
- else
- mind_ent
+ { mind_entry_record = record;
+ mind_entry_finite = mib.mind_finite;
+ mind_entry_params = params';
+ mind_entry_inds = inds';
+ mind_entry_polymorphic = mib.mind_polymorphic;
+ mind_entry_private = mib.mind_private;
+ mind_entry_universes = univ_info_ind
+ }
--
cgit v1.2.3
From ab86b9b3999f3860bdb69824f585b9cf461ff295 Mon Sep 17 00:00:00 2001
From: Amin Timany
Date: Fri, 7 Apr 2017 12:44:12 +0200
Subject: Use inductive subtyping for conv/cumul
---
kernel/reduction.ml | 139 +++++++++++++++++++++++++++++++---------------
kernel/reduction.mli | 2 +
pretyping/reductionops.ml | 17 +++++-
3 files changed, 112 insertions(+), 46 deletions(-)
diff --git a/kernel/reduction.ml b/kernel/reduction.ml
index b6786c045c..0d2399e025 100644
--- a/kernel/reduction.ml
+++ b/kernel/reduction.ml
@@ -191,6 +191,7 @@ type 'a universe_compare =
{ (* Might raise NotConvertible *)
compare : env -> conv_pb -> sorts -> sorts -> 'a -> 'a;
compare_instances: flex:bool -> Univ.Instance.t -> Univ.Instance.t -> 'a -> 'a;
+ leq_inductives : flex:bool -> Univ.UInfoInd.t -> Univ.Instance.t -> Univ.Instance.t -> 'a -> 'a;
}
type 'a universe_state = 'a * 'a universe_compare
@@ -207,6 +208,9 @@ let sort_cmp_universes env pb s0 s1 (u, check) =
let convert_instances ~flex u u' (s, check) =
(check.compare_instances ~flex u u' s, check)
+let compare_leq_inductives ~flex uinfind u u' (s, check) =
+ (check.leq_inductives ~flex uinfind u u' s, check)
+
let conv_table_key infos k1 k2 cuniv =
if k1 == k2 then cuniv else
match k1, k2 with
@@ -299,11 +303,11 @@ let unfold_projection infos p c =
else None
(* Conversion between [lft1]term1 and [lft2]term2 *)
-let rec ccnv cv_pb l2r infos lft1 lft2 term1 term2 cuniv =
- eqappr cv_pb l2r infos (lft1, (term1,[])) (lft2, (term2,[])) cuniv
+let rec ccnv env cv_pb l2r infos lft1 lft2 term1 term2 cuniv =
+ eqappr env cv_pb l2r infos (lft1, (term1,[])) (lft2, (term2,[])) cuniv
(* Conversion between [lft1](hd1 v1) and [lft2](hd2 v2) *)
-and eqappr cv_pb l2r infos (lft1,st1) (lft2,st2) cuniv =
+and eqappr env cv_pb l2r infos (lft1,st1) (lft2,st2) cuniv =
Control.check_for_interrupt ();
(* First head reduce both terms *)
let whd = whd_stack (infos_with_reds infos betaiotazeta) in
@@ -328,13 +332,13 @@ and eqappr cv_pb l2r infos (lft1,st1) (lft2,st2) cuniv =
sort_cmp_universes (env_of_infos infos) cv_pb s1 s2 cuniv
| (Meta n, Meta m) ->
if Int.equal n m
- then convert_stacks l2r infos lft1 lft2 v1 v2 cuniv
+ then convert_stacks env l2r infos lft1 lft2 v1 v2 cuniv
else raise NotConvertible
| _ -> raise NotConvertible)
| (FEvar ((ev1,args1),env1), FEvar ((ev2,args2),env2)) ->
if Evar.equal ev1 ev2 then
- let cuniv = convert_stacks l2r infos lft1 lft2 v1 v2 cuniv in
- convert_vect l2r infos el1 el2
+ let cuniv = convert_stacks env l2r infos lft1 lft2 v1 v2 cuniv in
+ convert_vect env l2r infos el1 el2
(Array.map (mk_clos env1) args1)
(Array.map (mk_clos env2) args2) cuniv
else raise NotConvertible
@@ -342,14 +346,14 @@ and eqappr cv_pb l2r infos (lft1,st1) (lft2,st2) cuniv =
(* 2 index known to be bound to no constant *)
| (FRel n, FRel m) ->
if Int.equal (reloc_rel n el1) (reloc_rel m el2)
- then convert_stacks l2r infos lft1 lft2 v1 v2 cuniv
+ then convert_stacks env l2r infos lft1 lft2 v1 v2 cuniv
else raise NotConvertible
(* 2 constants, 2 local defined vars or 2 defined rels *)
| (FFlex fl1, FFlex fl2) ->
(try
let cuniv = conv_table_key infos fl1 fl2 cuniv in
- convert_stacks l2r infos lft1 lft2 v1 v2 cuniv
+ convert_stacks env l2r infos lft1 lft2 v1 v2 cuniv
with NotConvertible | Univ.UniverseInconsistency _ ->
(* else the oracle tells which constant is to be expanded *)
let oracle = CClosure.oracle_of_infos infos in
@@ -369,7 +373,7 @@ and eqappr cv_pb l2r infos (lft1,st1) (lft2,st2) cuniv =
| Some def1 -> ((lft1, (def1, v1)), appr2)
| None -> raise NotConvertible)
in
- eqappr cv_pb l2r infos app1 app2 cuniv)
+ eqappr env cv_pb l2r infos app1 app2 cuniv)
| (FProj (p1,c1), FProj (p2, c2)) ->
(* Projections: prefer unfolding to first-order unification,
@@ -377,42 +381,42 @@ and eqappr cv_pb l2r infos (lft1,st1) (lft2,st2) cuniv =
form *)
(match unfold_projection infos p1 c1 with
| Some (def1,s1) ->
- eqappr cv_pb l2r infos (lft1, (def1, s1 :: v1)) appr2 cuniv
+ eqappr env cv_pb l2r infos (lft1, (def1, (s1 :: v1))) appr2 cuniv
| None ->
match unfold_projection infos p2 c2 with
| Some (def2,s2) ->
- eqappr cv_pb l2r infos appr1 (lft2, (def2, s2 :: v2)) cuniv
+ eqappr env cv_pb l2r infos appr1 (lft2, (def2, (s2 :: v2))) cuniv
| None ->
if Constant.equal (Projection.constant p1) (Projection.constant p2)
&& compare_stack_shape v1 v2 then
- let u1 = ccnv CONV l2r infos el1 el2 c1 c2 cuniv in
- convert_stacks l2r infos lft1 lft2 v1 v2 u1
+ let u1 = ccnv env CONV l2r infos el1 el2 c1 c2 cuniv in
+ convert_stacks env l2r infos lft1 lft2 v1 v2 u1
else (* Two projections in WHNF: unfold *)
raise NotConvertible)
| (FProj (p1,c1), t2) ->
(match unfold_projection infos p1 c1 with
| Some (def1,s1) ->
- eqappr cv_pb l2r infos (lft1, (def1, s1 :: v1)) appr2 cuniv
+ eqappr env cv_pb l2r infos (lft1, (def1, (s1 :: v1))) appr2 cuniv
| None ->
(match t2 with
| FFlex fl2 ->
(match unfold_reference infos fl2 with
| Some def2 ->
- eqappr cv_pb l2r infos appr1 (lft2, (def2, v2)) cuniv
+ eqappr env cv_pb l2r infos appr1 (lft2, (def2, v2)) cuniv
| None -> raise NotConvertible)
| _ -> raise NotConvertible))
| (t1, FProj (p2,c2)) ->
(match unfold_projection infos p2 c2 with
| Some (def2,s2) ->
- eqappr cv_pb l2r infos appr1 (lft2, (def2, s2 :: v2)) cuniv
+ eqappr env cv_pb l2r infos appr1 (lft2, (def2, (s2 :: v2))) cuniv
| None ->
(match t1 with
| FFlex fl1 ->
(match unfold_reference infos fl1 with
| Some def1 ->
- eqappr cv_pb l2r infos (lft1, (def1, v1)) appr2 cuniv
+ eqappr env cv_pb l2r infos (lft1, (def1, v1)) appr2 cuniv
| None -> raise NotConvertible)
| _ -> raise NotConvertible))
@@ -424,15 +428,15 @@ and eqappr cv_pb l2r infos (lft1,st1) (lft2,st2) cuniv =
anomaly (Pp.str "conversion was given ill-typed terms (FLambda).");
let (_,ty1,bd1) = destFLambda mk_clos hd1 in
let (_,ty2,bd2) = destFLambda mk_clos hd2 in
- let cuniv = ccnv CONV l2r infos el1 el2 ty1 ty2 cuniv in
- ccnv CONV l2r infos (el_lift el1) (el_lift el2) bd1 bd2 cuniv
+ let cuniv = ccnv env CONV l2r infos el1 el2 ty1 ty2 cuniv in
+ ccnv env CONV l2r infos (el_lift el1) (el_lift el2) bd1 bd2 cuniv
| (FProd (_,c1,c2), FProd (_,c'1,c'2)) ->
if not (is_empty_stack v1 && is_empty_stack v2) then
anomaly (Pp.str "conversion was given ill-typed terms (FProd).");
(* Luo's system *)
- let cuniv = ccnv CONV l2r infos el1 el2 c1 c'1 cuniv in
- ccnv cv_pb l2r infos (el_lift el1) (el_lift el2) c2 c'2 cuniv
+ let cuniv = ccnv env CONV l2r infos el1 el2 c1 c'1 cuniv in
+ ccnv env cv_pb l2r infos (el_lift el1) (el_lift el2) c2 c'2 cuniv
(* Eta-expansion on the fly *)
| (FLambda _, _) ->
@@ -442,7 +446,7 @@ and eqappr cv_pb l2r infos (lft1,st1) (lft2,st2) cuniv =
anomaly (Pp.str "conversion was given unreduced term (FLambda).")
in
let (_,_ty1,bd1) = destFLambda mk_clos hd1 in
- eqappr CONV l2r infos
+ eqappr env CONV l2r infos
(el_lift lft1, (bd1, [])) (el_lift lft2, (hd2, eta_expand_stack v2)) cuniv
| (_, FLambda _) ->
let () = match v2 with
@@ -451,34 +455,34 @@ and eqappr cv_pb l2r infos (lft1,st1) (lft2,st2) cuniv =
anomaly (Pp.str "conversion was given unreduced term (FLambda).")
in
let (_,_ty2,bd2) = destFLambda mk_clos hd2 in
- eqappr CONV l2r infos
+ eqappr env CONV l2r infos
(el_lift lft1, (hd1, eta_expand_stack v1)) (el_lift lft2, (bd2, [])) cuniv
(* only one constant, defined var or defined rel *)
| (FFlex fl1, c2) ->
(match unfold_reference infos fl1 with
| Some def1 ->
- eqappr cv_pb l2r infos (lft1, (def1, v1)) appr2 cuniv
+ eqappr env cv_pb l2r infos (lft1, (def1, v1)) appr2 cuniv
| None ->
match c2 with
| FConstruct ((ind2,j2),u2) ->
(try
let v2, v1 =
eta_expand_ind_stack (info_env infos) ind2 hd2 v2 (snd appr1)
- in convert_stacks l2r infos lft1 lft2 v1 v2 cuniv
+ in convert_stacks env l2r infos lft1 lft2 v1 v2 cuniv
with Not_found -> raise NotConvertible)
| _ -> raise NotConvertible)
| (c1, FFlex fl2) ->
(match unfold_reference infos fl2 with
| Some def2 ->
- eqappr cv_pb l2r infos appr1 (lft2, (def2, v2)) cuniv
+ eqappr env cv_pb l2r infos appr1 (lft2, (def2, v2)) cuniv
| None ->
match c1 with
| FConstruct ((ind1,j1),u1) ->
(try let v1, v2 =
eta_expand_ind_stack (info_env infos) ind1 hd1 v1 (snd appr2)
- in convert_stacks l2r infos lft1 lft2 v1 v2 cuniv
+ in convert_stacks env l2r infos lft1 lft2 v1 v2 cuniv
with Not_found -> raise NotConvertible)
| _ -> raise NotConvertible)
@@ -487,15 +491,33 @@ and eqappr cv_pb l2r infos (lft1,st1) (lft2,st2) cuniv =
| (FInd (ind1,u1), FInd (ind2,u2)) ->
if eq_ind ind1 ind2
then
- (let cuniv = convert_instances ~flex:false u1 u2 cuniv in
- convert_stacks l2r infos lft1 lft2 v1 v2 cuniv)
+ begin
+ let mind = Environ.lookup_mind (fst ind1) env in
+ if mind.Declarations.mind_polymorphic then
+ begin
+ let num_param_arity =
+ Context.Rel.length (mind.Declarations.mind_packets.(snd ind1).Declarations.mind_arity_ctxt)
+ in
+ (if not (num_param_arity = CClosure.stack_args_size v1 && num_param_arity = CClosure.stack_args_size v2) then
+ raise NotConvertible else ());
+ let uinfind = mind.Declarations.mind_universes in
+ let cuniv = compare_leq_inductives ~flex:false uinfind u1 u2 cuniv in
+ let cuniv = if cv_pb = CONV then compare_leq_inductives ~flex:false uinfind u2 u1 cuniv else cuniv in
+ convert_stacks env l2r infos lft1 lft2 v1 v2 cuniv
+ end
+ else
+ begin
+ let cuniv = convert_instances ~flex:false u1 u2 cuniv in
+ convert_stacks env l2r infos lft1 lft2 v1 v2 cuniv
+ end
+ end
else raise NotConvertible
| (FConstruct ((ind1,j1),u1), FConstruct ((ind2,j2),u2)) ->
if Int.equal j1 j2 && eq_ind ind1 ind2
then
(let cuniv = convert_instances ~flex:false u1 u2 cuniv in
- convert_stacks l2r infos lft1 lft2 v1 v2 cuniv)
+ convert_stacks env l2r infos lft1 lft2 v1 v2 cuniv)
else raise NotConvertible
(* Eta expansion of records *)
@@ -503,14 +525,14 @@ and eqappr cv_pb l2r infos (lft1,st1) (lft2,st2) cuniv =
(try
let v1, v2 =
eta_expand_ind_stack (info_env infos) ind1 hd1 v1 (snd appr2)
- in convert_stacks l2r infos lft1 lft2 v1 v2 cuniv
+ in convert_stacks env l2r infos lft1 lft2 v1 v2 cuniv
with Not_found -> raise NotConvertible)
| (_, FConstruct ((ind2,j2),u2)) ->
(try
let v2, v1 =
eta_expand_ind_stack (info_env infos) ind2 hd2 v2 (snd appr1)
- in convert_stacks l2r infos lft1 lft2 v1 v2 cuniv
+ in convert_stacks env l2r infos lft1 lft2 v1 v2 cuniv
with Not_found -> raise NotConvertible)
| (FFix (((op1, i1),(_,tys1,cl1)),e1), FFix(((op2, i2),(_,tys2,cl2)),e2)) ->
@@ -521,11 +543,11 @@ and eqappr cv_pb l2r infos (lft1,st1) (lft2,st2) cuniv =
let fty2 = Array.map (mk_clos e2) tys2 in
let fcl1 = Array.map (mk_clos (subs_liftn n e1)) cl1 in
let fcl2 = Array.map (mk_clos (subs_liftn n e2)) cl2 in
- let cuniv = convert_vect l2r infos el1 el2 fty1 fty2 cuniv in
+ let cuniv = convert_vect env l2r infos el1 el2 fty1 fty2 cuniv in
let cuniv =
- convert_vect l2r infos
+ convert_vect env l2r infos
(el_liftn n el1) (el_liftn n el2) fcl1 fcl2 cuniv in
- convert_stacks l2r infos lft1 lft2 v1 v2 cuniv
+ convert_stacks env l2r infos lft1 lft2 v1 v2 cuniv
else raise NotConvertible
| (FCoFix ((op1,(_,tys1,cl1)),e1), FCoFix((op2,(_,tys2,cl2)),e2)) ->
@@ -536,11 +558,11 @@ and eqappr cv_pb l2r infos (lft1,st1) (lft2,st2) cuniv =
let fty2 = Array.map (mk_clos e2) tys2 in
let fcl1 = Array.map (mk_clos (subs_liftn n e1)) cl1 in
let fcl2 = Array.map (mk_clos (subs_liftn n e2)) cl2 in
- let cuniv = convert_vect l2r infos el1 el2 fty1 fty2 cuniv in
+ let cuniv = convert_vect env l2r infos el1 el2 fty1 fty2 cuniv in
let cuniv =
- convert_vect l2r infos
+ convert_vect env l2r infos
(el_liftn n el1) (el_liftn n el2) fcl1 fcl2 cuniv in
- convert_stacks l2r infos lft1 lft2 v1 v2 cuniv
+ convert_stacks env l2r infos lft1 lft2 v1 v2 cuniv
else raise NotConvertible
(* Should not happen because both (hd1,v1) and (hd2,v2) are in whnf *)
@@ -551,13 +573,13 @@ and eqappr cv_pb l2r infos (lft1,st1) (lft2,st2) cuniv =
(* In all other cases, terms are not convertible *)
| _ -> raise NotConvertible
-and convert_stacks l2r infos lft1 lft2 stk1 stk2 cuniv =
+and convert_stacks env l2r infos lft1 lft2 stk1 stk2 cuniv =
compare_stacks
- (fun (l1,t1) (l2,t2) cuniv -> ccnv CONV l2r infos l1 l2 t1 t2 cuniv)
+ (fun (l1,t1) (l2,t2) cuniv -> ccnv env CONV l2r infos l1 l2 t1 t2 cuniv)
(eq_ind)
lft1 stk1 lft2 stk2 cuniv
-and convert_vect l2r infos lft1 lft2 v1 v2 cuniv =
+and convert_vect env l2r infos lft1 lft2 v1 v2 cuniv =
let lv1 = Array.length v1 in
let lv2 = Array.length v2 in
if Int.equal lv1 lv2
@@ -565,7 +587,7 @@ and convert_vect l2r infos lft1 lft2 v1 v2 cuniv =
let rec fold n cuniv =
if n >= lv1 then cuniv
else
- let cuniv = ccnv CONV l2r infos lft1 lft2 v1.(n) v2.(n) cuniv in
+ let cuniv = ccnv env CONV l2r infos lft1 lft2 v1.(n) v2.(n) cuniv in
fold (n+1) cuniv in
fold 0 cuniv
else raise NotConvertible
@@ -573,7 +595,7 @@ and convert_vect l2r infos lft1 lft2 v1 v2 cuniv =
let clos_gen_conv trans cv_pb l2r evars env univs t1 t2 =
let reds = CClosure.RedFlags.red_add_transparent betaiotazeta trans in
let infos = create_clos_infos ~evars reds env in
- ccnv cv_pb l2r infos el_id el_id (inject t1) (inject t2) univs
+ ccnv env cv_pb l2r infos el_id el_id (inject t1) (inject t2) univs
let check_eq univs u u' =
@@ -610,9 +632,24 @@ let check_convert_instances ~flex u u' univs =
if UGraph.check_eq_instances univs u u' then univs
else raise NotConvertible
+let check_leq_inductives ~flex uinfind u u' univs =
+ let ind_instance = Univ.UContext.instance (Univ.UInfoInd.univ_context uinfind) in
+ let ind_sbcst = Univ.UContext.constraints (Univ.UInfoInd.subtyp_context uinfind) in
+ if not ((Univ.Instance.length ind_instance = Univ.Instance.length u) &&
+ (Univ.Instance.length ind_instance = Univ.Instance.length u')) then
+ anomaly (Pp.str "Invalid inductive subtyping encountered!")
+ else
+ begin
+ let comp_subst = (Univ.Instance.append u u') in
+ let comp_cst = Univ.subst_instance_constraints comp_subst ind_sbcst in
+ if UGraph.check_constraints comp_cst univs then univs
+ else raise NotConvertible
+ end
+
let checked_universes =
{ compare = checked_sort_cmp_universes;
- compare_instances = check_convert_instances }
+ compare_instances = check_convert_instances;
+ leq_inductives = check_leq_inductives }
let infer_eq (univs, cstrs as cuniv) u u' =
if UGraph.check_eq univs u u' then cuniv
@@ -649,9 +686,21 @@ let infer_cmp_universes env pb s0 s1 univs =
let infer_convert_instances ~flex u u' (univs,cstrs) =
(univs, Univ.enforce_eq_instances u u' cstrs)
+let infer_leq_inductives ~flex uinfind u u' (univs, cstrs) =
+ let ind_instance = Univ.UContext.instance (Univ.UInfoInd.univ_context uinfind) in
+ let ind_sbcst = Univ.UContext.constraints (Univ.UInfoInd.subtyp_context uinfind) in
+ if not ((Univ.Instance.length ind_instance = Univ.Instance.length u) &&
+ (Univ.Instance.length ind_instance = Univ.Instance.length u')) then
+ anomaly (Pp.str "Invalid inductive subtyping encountered!")
+ else
+ let comp_subst = (Univ.Instance.append u u') in
+ let comp_cst = Univ.subst_instance_constraints comp_subst ind_sbcst in
+ (univs, Univ.Constraint.union cstrs comp_cst)
+
let inferred_universes : (UGraph.t * Univ.Constraint.t) universe_compare =
{ compare = infer_cmp_universes;
- compare_instances = infer_convert_instances }
+ compare_instances = infer_convert_instances;
+ leq_inductives = infer_leq_inductives }
let gen_conv cv_pb l2r reds env evars univs t1 t2 =
let b =
diff --git a/kernel/reduction.mli b/kernel/reduction.mli
index 8a2b2469d6..72f0ecffd0 100644
--- a/kernel/reduction.mli
+++ b/kernel/reduction.mli
@@ -40,6 +40,8 @@ type 'a universe_compare =
compare : env -> conv_pb -> sorts -> sorts -> 'a -> 'a;
compare_instances: flex:bool ->
Univ.Instance.t -> Univ.Instance.t -> 'a -> 'a;
+ leq_inductives : flex:bool -> Univ.UInfoInd.t ->
+ Univ.Instance.t -> Univ.Instance.t -> 'a -> 'a;
}
type 'a universe_state = 'a * 'a universe_compare
diff --git a/pretyping/reductionops.ml b/pretyping/reductionops.ml
index c2a6483012..971ad78e67 100644
--- a/pretyping/reductionops.ml
+++ b/pretyping/reductionops.ml
@@ -1361,9 +1361,24 @@ let sigma_compare_instances ~flex i0 i1 sigma =
| Univ.UniverseInconsistency _ ->
raise Reduction.NotConvertible
+let sigma_leq_inductives ~flex uinfind i0 i1 sigma =
+ let ind_instance = Univ.UContext.instance (Univ.UInfoInd.univ_context uinfind) in
+ let ind_sbcst = Univ.UContext.constraints (Univ.UInfoInd.subtyp_context uinfind) in
+ if not ((Univ.Instance.length ind_instance = Univ.Instance.length i0) &&
+ (Univ.Instance.length ind_instance = Univ.Instance.length i1)) then
+ anomaly (Pp.str "Invalid inductive subtyping encountered!")
+ else
+ let comp_subst = (Univ.Instance.append i0 i1) in
+ let comp_cst = Univ.subst_instance_constraints comp_subst ind_sbcst in
+ try Evd.add_constraints sigma comp_cst
+ with Evd.UniversesDiffer
+ | Univ.UniverseInconsistency _ ->
+ raise Reduction.NotConvertible
+
let sigma_univ_state =
{ Reduction.compare = sigma_compare_sorts;
- Reduction.compare_instances = sigma_compare_instances }
+ Reduction.compare_instances = sigma_compare_instances;
+ Reduction.leq_inductives = sigma_leq_inductives }
let infer_conv_gen conv_fun ?(catch_incon=true) ?(pb=Reduction.CUMUL)
?(ts=full_transparent_state) env sigma x y =
--
cgit v1.2.3
From 0d884e0852ae388becc5b74c6a8cb30088f7b79b Mon Sep 17 00:00:00 2001
From: Amin Timany
Date: Sat, 8 Apr 2017 16:10:19 +0200
Subject: Fix cum/conv for inductive types
Fall back to the equating levels in case inductive is not fully applied
instead of failing.
---
kernel/reduction.ml | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/kernel/reduction.ml b/kernel/reduction.ml
index 0d2399e025..c8fad60ebe 100644
--- a/kernel/reduction.ml
+++ b/kernel/reduction.ml
@@ -492,24 +492,28 @@ and eqappr env cv_pb l2r infos (lft1,st1) (lft2,st2) cuniv =
if eq_ind ind1 ind2
then
begin
+ let fall_back () =
+ let cuniv = convert_instances ~flex:false u1 u2 cuniv in
+ convert_stacks env l2r infos lft1 lft2 v1 v2 cuniv
+ in
let mind = Environ.lookup_mind (fst ind1) env in
if mind.Declarations.mind_polymorphic then
begin
let num_param_arity =
Context.Rel.length (mind.Declarations.mind_packets.(snd ind1).Declarations.mind_arity_ctxt)
in
- (if not (num_param_arity = CClosure.stack_args_size v1 && num_param_arity = CClosure.stack_args_size v2) then
- raise NotConvertible else ());
- let uinfind = mind.Declarations.mind_universes in
- let cuniv = compare_leq_inductives ~flex:false uinfind u1 u2 cuniv in
- let cuniv = if cv_pb = CONV then compare_leq_inductives ~flex:false uinfind u2 u1 cuniv else cuniv in
- convert_stacks env l2r infos lft1 lft2 v1 v2 cuniv
+ if not (num_param_arity = CClosure.stack_args_size v1 && num_param_arity = CClosure.stack_args_size v2) then
+ fall_back ()
+ else
+ begin
+ let uinfind = mind.Declarations.mind_universes in
+ let cuniv = compare_leq_inductives ~flex:false uinfind u1 u2 cuniv in
+ let cuniv = if cv_pb = CONV then compare_leq_inductives ~flex:false uinfind u2 u1 cuniv else cuniv in
+ convert_stacks env l2r infos lft1 lft2 v1 v2 cuniv
+ end
end
else
- begin
- let cuniv = convert_instances ~flex:false u1 u2 cuniv in
- convert_stacks env l2r infos lft1 lft2 v1 v2 cuniv
- end
+ fall_back ()
end
else raise NotConvertible
--
cgit v1.2.3
From 4385872b2d82fbad2be84f2423802e00e9d9575f Mon Sep 17 00:00:00 2001
From: Amin Timany
Date: Sat, 8 Apr 2017 22:01:30 +0200
Subject: Make unification use subtyping info of inductives
---
pretyping/evarconv.ml | 74 ++++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 64 insertions(+), 10 deletions(-)
diff --git a/pretyping/evarconv.ml b/pretyping/evarconv.ml
index 3757ba7e6d..882ea61a9d 100644
--- a/pretyping/evarconv.ml
+++ b/pretyping/evarconv.ml
@@ -350,6 +350,21 @@ let exact_ise_stack2 env evd f sk1 sk2 =
ise_stack2 evd (List.rev sk1) (List.rev sk2)
else UnifFailure (evd, (* Dummy *) NotSameHead)
+let check_leq_inductives evd uinfind u u' =
+ let u = EConstr.EInstance.kind evd u in
+ let u' = EConstr.EInstance.kind evd u' in
+ let ind_instance = Univ.UContext.instance (Univ.UInfoInd.univ_context uinfind) in
+ let ind_sbcst = Univ.UContext.constraints (Univ.UInfoInd.subtyp_context uinfind) in
+ if not ((Univ.Instance.length ind_instance = Univ.Instance.length u) &&
+ (Univ.Instance.length ind_instance = Univ.Instance.length u')) then
+ anomaly (Pp.str "Invalid inductive subtyping encountered!")
+ else
+ begin
+ let comp_subst = (Univ.Instance.append u u') in
+ let comp_cst = Univ.subst_instance_constraints comp_subst ind_sbcst in
+ Evd.add_constraints evd comp_cst
+ end
+
let rec evar_conv_x ts env evd pbty term1 term2 =
let term1 = whd_head_evar evd term1 in
let term2 = whd_head_evar evd term2 in
@@ -439,16 +454,55 @@ and evar_eqappr_x ?(rhs_is_already_stuck = false) ts env evd pbty
else evar_eqappr_x ts env' evd CONV out2 out1
in
let rigids env evd sk term sk' term' =
- let univs = EConstr.eq_constr_universes evd term term' in
- match univs with
- | Some univs ->
- ise_and evd [(fun i ->
- let cstrs = Universes.to_constraints (Evd.universes i) univs in
- try Success (Evd.add_constraints i cstrs)
- with Univ.UniverseInconsistency p -> UnifFailure (i, UnifUnivInconsistency p));
- (fun i -> exact_ise_stack2 env i (evar_conv_x ts) sk sk')]
- | None ->
- UnifFailure (evd,NotSameHead)
+ let fall_back () =
+ let univs = EConstr.eq_constr_universes evd term term' in
+ match univs with
+ | Some univs ->
+ begin
+ let cstrs = Universes.to_constraints (Evd.universes evd) univs in
+ try Success (Evd.add_constraints evd cstrs)
+ with Univ.UniverseInconsistency p -> UnifFailure (evd, UnifUnivInconsistency p)
+ end
+ | None ->
+ UnifFailure (evd, NotSameHead)
+ in
+ let compare_heads evd =
+ match EConstr.kind evd term, EConstr.kind evd term' with
+ | Const (c, u), Const (c', u') ->
+ fall_back ()
+ | Ind (ind, u), Ind (ind', u') ->
+ let nparamsaplied = Stack.args_size sk in
+ let nparamsaplied' = Stack.args_size sk' in
+ if Names.eq_ind ind ind' then
+ begin
+ let mind = Environ.lookup_mind (fst ind) env in
+ if mind.Declarations.mind_polymorphic then
+ begin
+ let num_param_arity =
+ Context.Rel.length (mind.Declarations.mind_packets.(snd ind).Declarations.mind_arity_ctxt)
+ in
+ if not (num_param_arity = nparamsaplied && num_param_arity = nparamsaplied') then
+ fall_back ()
+ else
+ begin
+ let uinfind = mind.Declarations.mind_universes in
+ let evd' = check_leq_inductives evd uinfind u u' in
+ Success (check_leq_inductives evd' uinfind u' u)
+ end
+ end
+ else
+ fall_back ()
+ end
+ else UnifFailure (evd, NotSameHead)
+ | Construct (cons, u), Construct (cons', u') ->
+ fall_back ()
+ | _, _ -> anomaly (Pp.str "")
+ in
+ ise_and evd [(fun i ->
+ try compare_heads i
+ with Univ.UniverseInconsistency p -> UnifFailure (i, UnifUnivInconsistency p));
+ (fun i -> exact_ise_stack2 env i (evar_conv_x ts) sk sk')]
+(* >>>>>>> Make unification use subtyping info of inductives *)
in
let flex_maybeflex on_left ev ((termF,skF as apprF),cstsF) ((termM, skM as apprM),cstsM) vM =
let switch f a b = if on_left then f a b else f b a in
--
cgit v1.2.3
From 40f56eb0f79e208fc4b1b4ed2f0fb49c69c13a2f Mon Sep 17 00:00:00 2001
From: Amin Timany
Date: Sun, 21 May 2017 14:46:30 +0200
Subject: Squashed commit of the following:
Except I have disabled the minimization of universes after sections as
it seems to interfere with the STM machinery causing files like
test-suite/vio/print.v to loop when processed asynchronously.
This is very peculiar and needs more investigation as the aforementioned
file does not have any sections or any universe polymorphic definitions!
commit fc785326080b9451eb4700b16ccd3f7df214e0ed
Author: Amin Timany
Date: Mon Apr 24 17:14:21 2017 +0200
Revert STL to monomorphic
commit 62b573fb13d290d8fe4c85822da62d3e5e2a6996
Author: Amin Timany
Date: Mon Apr 24 17:02:42 2017 +0200
Try unifying universes before apply subtyping
commit ff393742c37b9241c83498e84c2274967a1a58dc
Author: Amin Timany
Date: Sun Apr 23 13:49:04 2017 +0200
Compile more of STL with universe polymorphism
commit 5c831b41ebd1fc32e2dd976697c8e474f48580d6
Author: Amin Timany
Date: Tue Apr 18 21:26:45 2017 +0200
Made more progress on compiling the standard library
commit b8550ffcce0861794116eb3b12b84e1158c2b4f8
Author: Amin Timany
Date: Sun Apr 16 22:55:19 2017 +0200
Make more number theoretic modules monomorphic
commit 29d126d4d4910683f7e6aada2a25209151e41b10
Author: Amin Timany
Date: Fri Apr 14 16:11:48 2017 +0200
WIP more of standard library compiles
Also: Matthieu fixed a bug in rewrite system which was faulty when
introducing new morphisms (Add Morphism) command.
commit 23bc33b843f098acaba4c63c71c68f79c4641f8c
Author: Amin Timany
Date: Fri Apr 14 11:39:21 2017 +0200
WIP: more of the standard library compiles
We have implemented convertibility of constructors up-to mutual
subtyping of their corresponding inductive types. This is similar to
the behavior of template polymorphism.
commit d0abc5c50d593404fb41b98d588c3843382afd4f
Author: Amin Timany
Date: Wed Apr 12 19:02:39 2017 +0200
WIP: trying to get the standard library compile with universe polymorphism
We are trying to prune universes after section ends. Sections add a
load of universes that are not appearing in the body, type or the
constraints.
---
API/API.ml | 1 +
API/API.mli | 7 +++-
dev/include | 1 +
dev/top_printers.ml | 1 +
engine/termops.ml | 3 ++
engine/uState.ml | 2 +-
engine/universes.ml | 30 --------------
engine/universes.mli | 4 --
kernel/declareops.ml | 21 ++++++----
kernel/kernel.mllib | 1 +
kernel/reduction.ml | 70 +++++++++++++++++++++----------
kernel/subtyping.ml | 5 +++
kernel/univ.ml | 3 ++
kernel/univ.mli | 3 ++
kernel/univops.ml | 70 +++++++++++++++++++++++++++++++
kernel/univops.mli | 17 ++++++++
plugins/setoid_ring/newring.ml | 4 +-
pretyping/evarconv.ml | 94 ++++++++++++++++++++++++++++++------------
pretyping/reductionops.ml | 4 +-
proofs/proof_global.ml | 8 ++--
tactics/elimschemes.ml | 30 +++++++-------
vernac/classes.ml | 10 +++--
vernac/command.ml | 12 +++---
23 files changed, 276 insertions(+), 125 deletions(-)
create mode 100644 kernel/univops.ml
create mode 100644 kernel/univops.mli
diff --git a/API/API.ml b/API/API.ml
index 2b7bbd561b..515b152e42 100644
--- a/API/API.ml
+++ b/API/API.ml
@@ -138,6 +138,7 @@ module Typeclasses = Typeclasses
module Pretype_errors = Pretype_errors
module Notation = Notation
module Declarations = Declarations
+module Univops = Univops
module Declareops = Declareops
module Globnames = Globnames
module Environ = Environ
diff --git a/API/API.mli b/API/API.mli
index cea879ba3c..a4ae6347c0 100644
--- a/API/API.mli
+++ b/API/API.mli
@@ -1124,6 +1124,11 @@ sig
| SFBmodtype of module_type_body
end
+module Univops : sig
+ val universes_of_constr : Term.constr -> Univ.LSet.t
+ val restrict_universe_context : Univ.ContextSet.t -> Univ.LSet.t -> Univ.ContextSet.t
+end
+
module Environ :
sig
type env = Prelude.env
@@ -2651,8 +2656,6 @@ sig
val new_Type : Names.DirPath.t -> Term.types
val unsafe_type_of_global : Globnames.global_reference -> Term.types
val constr_of_global : Prelude.global_reference -> Term.constr
- val universes_of_constr : Term.constr -> Univ.LSet.t
- val restrict_universe_context : Univ.ContextSet.t -> Univ.LSet.t -> Univ.ContextSet.t
val new_univ_level : Names.DirPath.t -> Univ.Level.t
val unsafe_constr_of_global : Globnames.global_reference -> Term.constr Univ.in_universe_context
val new_sort_in_family : Sorts.family -> Sorts.t
diff --git a/dev/include b/dev/include
index 0f43f00729..4835b360db 100644
--- a/dev/include
+++ b/dev/include
@@ -41,6 +41,7 @@
#install_printer (* univ context *) ppuniverse_context;;
#install_printer (* univ context future *) ppuniverse_context_future;;
#install_printer (* univ context set *) ppuniverse_context_set;;
+#install_printer (* univ info *) ppuniverse_info;;
#install_printer (* univ set *) ppuniverse_set;;
#install_printer (* univ instance *) ppuniverse_instance;;
#install_printer (* univ subst *) ppuniverse_subst;;
diff --git a/dev/top_printers.ml b/dev/top_printers.ml
index 6ae5125f6d..e902da0b19 100644
--- a/dev/top_printers.ml
+++ b/dev/top_printers.ml
@@ -215,6 +215,7 @@ let ppuniverseconstraints c = pp (Universes.Constraints.pr c)
let ppuniverse_context_future c =
let ctx = Future.force c in
ppuniverse_context ctx
+let ppuniverse_info c = pp (Univ.pr_universe_info_ind Univ.Level.pr c)
let ppuniverses u = pp (UGraph.pr_universes Level.pr u)
let ppnamedcontextval e =
pp (pr_named_context (Global.env ()) Evd.empty (named_context_of_val e))
diff --git a/engine/termops.ml b/engine/termops.ml
index 92016d4af4..3eef71b2d0 100644
--- a/engine/termops.ml
+++ b/engine/termops.ml
@@ -1173,6 +1173,9 @@ let compare_constr_univ sigma f cv_pb t1 t2 =
Sort s1, Sort s2 -> base_sort_cmp cv_pb (ESorts.kind sigma s1) (ESorts.kind sigma s2)
| Prod (_,t1,c1), Prod (_,t2,c2) ->
f Reduction.CONV t1 t2 && f cv_pb c1 c2
+ | Const (c, u), Const (c', u') -> Constant.equal c c'
+ | Ind (i, _), Ind (i', _) -> eq_ind i i'
+ | Construct (i, _), Construct (i', _) -> eq_constructor i i'
| _ -> EConstr.compare_constr sigma (fun t1 t2 -> f Reduction.CONV t1 t2) t1 t2
let constr_cmp sigma cv_pb t1 t2 =
diff --git a/engine/uState.ml b/engine/uState.ml
index acef901432..0973ca457f 100644
--- a/engine/uState.ml
+++ b/engine/uState.ml
@@ -284,7 +284,7 @@ let universe_context ?names ctx =
in map, ctx
let restrict ctx vars =
- let uctx' = Universes.restrict_universe_context ctx.uctx_local vars in
+ let uctx' = Univops.restrict_universe_context ctx.uctx_local vars in
{ ctx with uctx_local = uctx' }
type rigid =
diff --git a/engine/universes.ml b/engine/universes.ml
index 51957e00ad..a12b42ab17 100644
--- a/engine/universes.ml
+++ b/engine/universes.ml
@@ -976,36 +976,6 @@ let normalize_context_set ctx us algs =
(* let normalize_conkey = Profile.declare_profile "normalize_context_set" *)
(* let normalize_context_set a b c = Profile.profile3 normalize_conkey normalize_context_set a b c *)
-let universes_of_constr c =
- let rec aux s c =
- match kind_of_term c with
- | Const (_, u) | Ind (_, u) | Construct (_, u) ->
- LSet.fold LSet.add (Instance.levels u) s
- | Sort u when not (Sorts.is_small u) ->
- let u = univ_of_sort u in
- LSet.fold LSet.add (Universe.levels u) s
- | _ -> fold_constr aux s c
- in aux LSet.empty c
-
-let restrict_universe_context (univs,csts) s =
- (* Universes that are not necessary to typecheck the term.
- E.g. univs introduced by tactics and not used in the proof term. *)
- let diff = LSet.diff univs s in
- let rec aux diff candid univs ness =
- let (diff', candid', univs', ness') =
- Constraint.fold
- (fun (l, d, r as c) (diff, candid, univs, csts) ->
- if not (LSet.mem l diff) then
- (LSet.remove r diff, candid, univs, Constraint.add c csts)
- else if not (LSet.mem r diff) then
- (LSet.remove l diff, candid, univs, Constraint.add c csts)
- else (diff, Constraint.add c candid, univs, csts))
- candid (diff, Constraint.empty, univs, ness)
- in
- if ness' == ness then (LSet.diff univs diff', ness)
- else aux diff' candid' univs' ness'
- in aux diff csts univs Constraint.empty
-
let simplify_universe_context (univs,csts) =
let uf = UF.create () in
let noneqs =
diff --git a/engine/universes.mli b/engine/universes.mli
index 1b9703c7bf..c600f4af61 100644
--- a/engine/universes.mli
+++ b/engine/universes.mli
@@ -210,10 +210,6 @@ val unsafe_type_of_global : Globnames.global_reference -> types
val nf_evars_and_universes_opt_subst : (existential -> constr option) ->
universe_opt_subst -> constr -> constr
-(** Shrink a universe context to a restricted set of variables *)
-
-val universes_of_constr : constr -> universe_set
-val restrict_universe_context : universe_context_set -> universe_set -> universe_context_set
val simplify_universe_context : universe_context_set ->
universe_context_set * universe_level_subst
diff --git a/kernel/declareops.ml b/kernel/declareops.ml
index cdea468adf..8838966520 100644
--- a/kernel/declareops.ml
+++ b/kernel/declareops.ml
@@ -49,6 +49,11 @@ let instantiate cb c =
Vars.subst_instance_constr (Univ.UContext.instance cb.const_universes) c
else c
+let instantiate_constraints cb cst =
+ if cb.const_polymorphic then
+ Univ.subst_instance_constraints (Univ.UContext.instance cb.const_universes) cst
+ else cst
+
let body_of_constant otab cb = match cb.const_body with
| Undef _ -> None
| Def c -> Some (instantiate cb (force_constr c))
@@ -61,13 +66,15 @@ let type_of_constant cb =
if t' == t then x else RegularArity t'
| TemplateArity _ as x -> x
-let constraints_of_constant otab cb = Univ.Constraint.union
- (Univ.UContext.constraints cb.const_universes)
- (match cb.const_body with
- | Undef _ -> Univ.empty_constraint
- | Def c -> Univ.empty_constraint
- | OpaqueDef o ->
- Univ.ContextSet.constraints (Opaqueproof.force_constraints otab o))
+let constraints_of_constant otab cb =
+ let cst = Univ.Constraint.union
+ (Univ.UContext.constraints cb.const_universes)
+ (match cb.const_body with
+ | Undef _ -> Univ.empty_constraint
+ | Def c -> Univ.empty_constraint
+ | OpaqueDef o ->
+ Univ.ContextSet.constraints (Opaqueproof.force_constraints otab o))
+ in instantiate_constraints cb cst
let universes_of_constant otab cb =
match cb.const_body with
diff --git a/kernel/kernel.mllib b/kernel/kernel.mllib
index 2f49982ce2..8132d66850 100644
--- a/kernel/kernel.mllib
+++ b/kernel/kernel.mllib
@@ -43,3 +43,4 @@ Vm
Csymtable
Vconv
Declarations
+Univops
diff --git a/kernel/reduction.ml b/kernel/reduction.ml
index c8fad60ebe..a872a103a5 100644
--- a/kernel/reduction.ml
+++ b/kernel/reduction.ml
@@ -489,8 +489,8 @@ and eqappr env cv_pb l2r infos (lft1,st1) (lft2,st2) cuniv =
(* Inductive types: MutInd MutConstruct Fix Cofix *)
| (FInd (ind1,u1), FInd (ind2,u2)) ->
- if eq_ind ind1 ind2
- then
+ if eq_ind ind1 ind2
+ then
begin
let fall_back () =
let cuniv = convert_instances ~flex:false u1 u2 cuniv in
@@ -498,31 +498,54 @@ and eqappr env cv_pb l2r infos (lft1,st1) (lft2,st2) cuniv =
in
let mind = Environ.lookup_mind (fst ind1) env in
if mind.Declarations.mind_polymorphic then
- begin
- let num_param_arity =
- Context.Rel.length (mind.Declarations.mind_packets.(snd ind1).Declarations.mind_arity_ctxt)
- in
- if not (num_param_arity = CClosure.stack_args_size v1 && num_param_arity = CClosure.stack_args_size v2) then
- fall_back ()
- else
begin
- let uinfind = mind.Declarations.mind_universes in
- let cuniv = compare_leq_inductives ~flex:false uinfind u1 u2 cuniv in
- let cuniv = if cv_pb = CONV then compare_leq_inductives ~flex:false uinfind u2 u1 cuniv else cuniv in
- convert_stacks env l2r infos lft1 lft2 v1 v2 cuniv
+ let num_param_arity =
+ Context.Rel.length (mind.Declarations.mind_packets.(snd ind1).Declarations.mind_arity_ctxt)
+ in
+ if not (num_param_arity = CClosure.stack_args_size v1 && num_param_arity = CClosure.stack_args_size v2) then
+ fall_back ()
+ else
+ begin
+ let uinfind = mind.Declarations.mind_universes in
+ let cuniv = compare_leq_inductives ~flex:false uinfind u1 u2 cuniv in
+ let cuniv = if cv_pb = CONV then compare_leq_inductives ~flex:false uinfind u2 u1 cuniv else cuniv in
+ convert_stacks env l2r infos lft1 lft2 v1 v2 cuniv
+ end
end
- end
else
fall_back ()
end
- else raise NotConvertible
+ else raise NotConvertible
| (FConstruct ((ind1,j1),u1), FConstruct ((ind2,j2),u2)) ->
- if Int.equal j1 j2 && eq_ind ind1 ind2
- then
- (let cuniv = convert_instances ~flex:false u1 u2 cuniv in
- convert_stacks env l2r infos lft1 lft2 v1 v2 cuniv)
- else raise NotConvertible
+ if Int.equal j1 j2 && eq_ind ind1 ind2
+ then
+ begin
+ let fall_back () =
+ let cuniv = convert_instances ~flex:false u1 u2 cuniv in
+ convert_stacks env l2r infos lft1 lft2 v1 v2 cuniv
+ in
+ let mind = Environ.lookup_mind (fst ind1) env in
+ if mind.Declarations.mind_polymorphic then
+ begin
+ let num_cnstr_args =
+ let nparamsctxt = Context.Rel.length mind.Declarations.mind_params_ctxt in
+ nparamsctxt + mind.Declarations.mind_packets.(snd ind1).Declarations.mind_consnrealargs.(j1 - 1)
+ in
+ if not (num_cnstr_args = CClosure.stack_args_size v1 && num_cnstr_args = CClosure.stack_args_size v2) then
+ fall_back ()
+ else
+ begin (* we don't consider subtyping for constructors. *)
+ let uinfind = mind.Declarations.mind_universes in
+ let cuniv = compare_leq_inductives ~flex:false uinfind u1 u2 cuniv in
+ let cuniv = compare_leq_inductives ~flex:false uinfind u2 u1 cuniv in
+ convert_stacks env l2r infos lft1 lft2 v1 v2 cuniv
+ end
+ end
+ else
+ fall_back ()
+ end
+ else raise NotConvertible
(* Eta expansion of records *)
| (FConstruct ((ind1,j1),u1), _) ->
@@ -688,7 +711,12 @@ let infer_cmp_universes env pb s0 s1 univs =
else univs
let infer_convert_instances ~flex u u' (univs,cstrs) =
- (univs, Univ.enforce_eq_instances u u' cstrs)
+ let cstrs' =
+ if flex then
+ if UGraph.check_eq_instances univs u u' then cstrs
+ else raise NotConvertible
+ else Univ.enforce_eq_instances u u' cstrs
+ in (univs, cstrs')
let infer_leq_inductives ~flex uinfind u u' (univs, cstrs) =
let ind_instance = Univ.UContext.instance (Univ.UInfoInd.univ_context uinfind) in
diff --git a/kernel/subtyping.ml b/kernel/subtyping.ml
index f779f68be4..60cd77f402 100644
--- a/kernel/subtyping.ml
+++ b/kernel/subtyping.ml
@@ -90,6 +90,7 @@ let check_conv_error error why cst poly u f env a1 a2 =
else error (IncompatiblePolymorphism (env, a1, a2))
else Constraint.union cst cst'
with NotConvertible -> error why
+ | Univ.UniverseInconsistency e -> error (IncompatibleUniverses e)
(* for now we do not allow reorderings *)
@@ -302,6 +303,10 @@ let check_constant cst env mp1 l info1 cb2 spec2 subst1 subst2 =
let ctx2 = Univ.instantiate_univ_context cb2.const_universes in
let inst1, ctx1 = Univ.UContext.dest ctx1 in
let inst2, ctx2 = Univ.UContext.dest ctx2 in
+ output_string stderr "\ninst1:\n";
+ output_string stderr (Pp.string_of_ppcmds (Univ.Instance.pr Univ.Level.pr inst1));
+ output_string stderr "\ninst2:\n";
+ output_string stderr (Pp.string_of_ppcmds (Univ.Instance.pr Univ.Level.pr inst2)); flush stderr;
if not (Univ.Instance.length inst1 == Univ.Instance.length inst2) then
error IncompatibleInstances
else
diff --git a/kernel/univ.ml b/kernel/univ.ml
index 4a4cf1baa7..5de45cf2b9 100644
--- a/kernel/univ.ml
+++ b/kernel/univ.ml
@@ -725,8 +725,11 @@ struct
pp_std ++ prl u1 ++ pr_constraint_type op ++
prl u2 ++ fnl () ) c (str "")
+ let universes_of c =
+ fold (fun (u1, op, u2) unvs -> LSet.add u2 (LSet.add u1 unvs)) c LSet.empty
end
+let universes_of_constraints = Constraint.universes_of
let empty_constraint = Constraint.empty
let union_constraint = Constraint.union
let eq_constraint = Constraint.equal
diff --git a/kernel/univ.mli b/kernel/univ.mli
index f139a8b334..1141933293 100644
--- a/kernel/univ.mli
+++ b/kernel/univ.mli
@@ -462,3 +462,6 @@ val eq_levels : universe_level -> universe_level -> bool
(** deprecated: Equality of formal universe expressions. *)
val equal_universes : universe -> universe -> bool
+
+(** Universes of constraints *)
+val universes_of_constraints : constraints -> universe_set
diff --git a/kernel/univops.ml b/kernel/univops.ml
new file mode 100644
index 0000000000..e9383c6d9f
--- /dev/null
+++ b/kernel/univops.ml
@@ -0,0 +1,70 @@
+(************************************************************************)
+(* v * The Coq Proof Assistant / The Coq Development Team *)
+(*
+ LSet.fold LSet.add (Instance.levels u) s
+ | Sort u when not (Sorts.is_small u) ->
+ let u = univ_of_sort u in
+ LSet.fold LSet.add (Universe.levels u) s
+ | _ -> fold_constr aux s c
+ in aux LSet.empty c
+
+let universes_of_inductive mind =
+ if mind.mind_polymorphic then
+ begin
+ let u = Univ.UContext.instance (Univ.UInfoInd.univ_context mind.mind_universes) in
+ let univ_of_one_ind oind =
+ let arity_univs =
+ Context.Rel.fold_outside
+ (fun decl unvs ->
+ Univ.LSet.union
+ (Context.Rel.Declaration.fold_constr
+ (fun cnstr unvs ->
+ let cnstr = Vars.subst_instance_constr u cnstr in
+ Univ.LSet.union
+ (universes_of_constr cnstr) unvs)
+ decl Univ.LSet.empty) unvs)
+ oind.mind_arity_ctxt ~init:Univ.LSet.empty
+ in
+ Array.fold_left (fun unvs cns ->
+ let cns = Vars.subst_instance_constr u cns in
+ Univ.LSet.union (universes_of_constr cns) unvs) arity_univs
+ oind.mind_nf_lc
+ in
+ let univs = Array.fold_left (fun unvs pk -> Univ.LSet.union (univ_of_one_ind pk) unvs) Univ.LSet.empty mind.mind_packets in
+ let mindcnt = Univ.UContext.constraints (Univ.instantiate_univ_context (Univ.UInfoInd.univ_context mind.mind_universes)) in
+ let univs = Univ.LSet.union univs (Univ.universes_of_constraints mindcnt) in
+ univs
+ end
+ else LSet.empty
+
+let restrict_universe_context (univs,csts) s =
+ (* Universes that are not necessary to typecheck the term.
+ E.g. univs introduced by tactics and not used in the proof term. *)
+ let diff = LSet.diff univs s in
+ let rec aux diff candid univs ness =
+ let (diff', candid', univs', ness') =
+ Constraint.fold
+ (fun (l, d, r as c) (diff, candid, univs, csts) ->
+ if not (LSet.mem l diff) then
+ (LSet.remove r diff, candid, univs, Constraint.add c csts)
+ else if not (LSet.mem r diff) then
+ (LSet.remove l diff, candid, univs, Constraint.add c csts)
+ else (diff, Constraint.add c candid, univs, csts))
+ candid (diff, Constraint.empty, univs, ness)
+ in
+ if ness' == ness then (LSet.diff univs diff', ness)
+ else aux diff' candid' univs' ness'
+ in aux diff csts univs Constraint.empty
diff --git a/kernel/univops.mli b/kernel/univops.mli
new file mode 100644
index 0000000000..5b499c75bc
--- /dev/null
+++ b/kernel/univops.mli
@@ -0,0 +1,17 @@
+(************************************************************************)
+(* v * The Coq Proof Assistant / The Coq Development Team *)
+(* universe_set
+val universes_of_inductive : mutual_inductive_body -> universe_set
+val restrict_universe_context : universe_context_set -> universe_set -> universe_context_set
diff --git a/plugins/setoid_ring/newring.ml b/plugins/setoid_ring/newring.ml
index ee75d2908e..da21f64ab1 100644
--- a/plugins/setoid_ring/newring.ml
+++ b/plugins/setoid_ring/newring.ml
@@ -153,8 +153,8 @@ let ic_unsafe c = (*FIXME remove *)
let decl_constant na ctx c =
let open Term in
- let vars = Universes.universes_of_constr c in
- let ctx = Universes.restrict_universe_context (Univ.ContextSet.of_context ctx) vars in
+ let vars = Univops.universes_of_constr c in
+ let ctx = Univops.restrict_universe_context (Univ.ContextSet.of_context ctx) vars in
mkConst(declare_constant (Id.of_string na)
(DefinitionEntry (definition_entry ~opaque:true
~univs:(Univ.ContextSet.to_context ctx) c),
diff --git a/pretyping/evarconv.ml b/pretyping/evarconv.ml
index 882ea61a9d..eb8a0c85a0 100644
--- a/pretyping/evarconv.ml
+++ b/pretyping/evarconv.ml
@@ -454,48 +454,88 @@ and evar_eqappr_x ?(rhs_is_already_stuck = false) ts env evd pbty
else evar_eqappr_x ts env' evd CONV out2 out1
in
let rigids env evd sk term sk' term' =
- let fall_back () =
+ let check_strict () =
let univs = EConstr.eq_constr_universes evd term term' in
+ match univs with
+ | Some univs ->
+ begin
+ let cstrs = Universes.to_constraints (Evd.universes evd) univs in
+ try Success (Evd.add_constraints evd cstrs)
+ with Univ.UniverseInconsistency p -> UnifFailure (evd, UnifUnivInconsistency p)
+ end
+ | None ->
+ UnifFailure (evd, NotSameHead)
+ in
+ let first_try_strict_check cond u u' try_subtyping_constraints =
+ if cond then
+ let univs = EConstr.eq_constr_universes evd term term' in
match univs with
| Some univs ->
begin
let cstrs = Universes.to_constraints (Evd.universes evd) univs in
try Success (Evd.add_constraints evd cstrs)
- with Univ.UniverseInconsistency p -> UnifFailure (evd, UnifUnivInconsistency p)
+ with Univ.UniverseInconsistency p -> try_subtyping_constraints ()
end
| None ->
UnifFailure (evd, NotSameHead)
+ else
+ UnifFailure (evd, NotSameHead)
in
let compare_heads evd =
match EConstr.kind evd term, EConstr.kind evd term' with
| Const (c, u), Const (c', u') ->
- fall_back ()
+ check_strict ()
| Ind (ind, u), Ind (ind', u') ->
- let nparamsaplied = Stack.args_size sk in
- let nparamsaplied' = Stack.args_size sk' in
- if Names.eq_ind ind ind' then
- begin
- let mind = Environ.lookup_mind (fst ind) env in
- if mind.Declarations.mind_polymorphic then
- begin
- let num_param_arity =
- Context.Rel.length (mind.Declarations.mind_packets.(snd ind).Declarations.mind_arity_ctxt)
- in
- if not (num_param_arity = nparamsaplied && num_param_arity = nparamsaplied') then
- fall_back ()
- else
- begin
- let uinfind = mind.Declarations.mind_universes in
- let evd' = check_leq_inductives evd uinfind u u' in
- Success (check_leq_inductives evd' uinfind u' u)
- end
- end
- else
- fall_back ()
- end
- else UnifFailure (evd, NotSameHead)
+ let check_subtyping_constraints () =
+ let nparamsaplied = Stack.args_size sk in
+ let nparamsaplied' = Stack.args_size sk' in
+ begin
+ let mind = Environ.lookup_mind (fst ind) env in
+ if mind.Declarations.mind_polymorphic then
+ begin
+ let num_param_arity =
+ Context.Rel.length (mind.Declarations.mind_packets.(snd ind).Declarations.mind_arity_ctxt)
+ in
+ if not (num_param_arity = nparamsaplied && num_param_arity = nparamsaplied') then
+ UnifFailure (evd, NotSameHead)
+ else
+ begin
+ let uinfind = mind.Declarations.mind_universes in
+ let evd' = check_leq_inductives evd uinfind u u' in
+ Success (check_leq_inductives evd' uinfind u' u)
+ end
+ end
+ else
+ UnifFailure (evd, NotSameHead)
+ end
+ in
+ first_try_strict_check (Names.eq_ind ind ind') u u' check_subtyping_constraints
| Construct (cons, u), Construct (cons', u') ->
- fall_back ()
+ let check_subtyping_constraints () =
+ let ind, ind' = fst cons, fst cons' in
+ let j, j' = snd cons, snd cons' in
+ let nparamsaplied = Stack.args_size sk in
+ let nparamsaplied' = Stack.args_size sk' in
+ let mind = Environ.lookup_mind (fst ind) env in
+ if mind.Declarations.mind_polymorphic then
+ begin
+ let num_cnstr_args =
+ let nparamsctxt = Context.Rel.length mind.Declarations.mind_params_ctxt in
+ nparamsctxt + mind.Declarations.mind_packets.(snd ind).Declarations.mind_consnrealargs.(j - 1)
+ in
+ if not (num_cnstr_args = nparamsaplied && num_cnstr_args = nparamsaplied') then
+ UnifFailure (evd, NotSameHead)
+ else
+ begin
+ let uinfind = mind.Declarations.mind_universes in
+ let evd' = check_leq_inductives evd uinfind u u' in
+ Success (check_leq_inductives evd' uinfind u' u)
+ end
+ end
+ else
+ UnifFailure (evd, NotSameHead)
+ in
+ first_try_strict_check (Names.eq_constructor cons cons') u u' check_subtyping_constraints
| _, _ -> anomaly (Pp.str "")
in
ise_and evd [(fun i ->
diff --git a/pretyping/reductionops.ml b/pretyping/reductionops.ml
index 971ad78e67..e374f7b3bb 100644
--- a/pretyping/reductionops.ml
+++ b/pretyping/reductionops.ml
@@ -1313,8 +1313,8 @@ let pb_equal = function
| Reduction.CUMUL -> Reduction.CONV
| Reduction.CONV -> Reduction.CONV
-let report_anomaly _ =
- let e = UserError (None, Pp.str "Conversion test raised an anomaly") in
+let report_anomaly e =
+ let e = UserError (None, Pp.(str "Conversion test raised an anomaly" ++ print e)) in
let e = CErrors.push e in
iraise e
diff --git a/proofs/proof_global.ml b/proofs/proof_global.ml
index 5ec34a6387..f5664aed00 100644
--- a/proofs/proof_global.ml
+++ b/proofs/proof_global.ml
@@ -343,8 +343,8 @@ let close_proof ~keep_body_ucst_separate ?feedback_id ~now
nf t
else t
in
- let used_univs_body = Universes.universes_of_constr body in
- let used_univs_typ = Universes.universes_of_constr typ in
+ let used_univs_body = Univops.universes_of_constr body in
+ let used_univs_typ = Univops.universes_of_constr typ in
if keep_body_ucst_separate ||
not (Safe_typing.empty_private_constants = eff) then
let initunivs = Evd.evar_context_universe_context initial_euctx in
@@ -353,7 +353,7 @@ let close_proof ~keep_body_ucst_separate ?feedback_id ~now
* complement the univ constraints of the typ with the ones of
* the body. So we keep the two sets distinct. *)
let used_univs = Univ.LSet.union used_univs_body used_univs_typ in
- let ctx_body = restrict_universe_context ctx used_univs in
+ let ctx_body = Univops.restrict_universe_context ctx used_univs in
(initunivs, typ), ((body, ctx_body), eff)
else
let initunivs = Univ.UContext.empty in
@@ -362,7 +362,7 @@ let close_proof ~keep_body_ucst_separate ?feedback_id ~now
* constraints in which we merge the ones for the body and the ones
* for the typ *)
let used_univs = Univ.LSet.union used_univs_body used_univs_typ in
- let ctx = restrict_universe_context ctx used_univs in
+ let ctx = Univops.restrict_universe_context ctx used_univs in
let univs = Univ.ContextSet.to_context ctx in
(univs, typ), ((body, Univ.ContextSet.empty), eff)
in
diff --git a/tactics/elimschemes.ml b/tactics/elimschemes.ml
index 466b1350d9..8d8e198119 100644
--- a/tactics/elimschemes.ml
+++ b/tactics/elimschemes.ml
@@ -80,30 +80,30 @@ let rect_dep_scheme_kind_from_type =
declare_individual_scheme_object "_rect" ~aux:"_rect_from_type"
(fun _ x -> build_induction_scheme_in_type true InType x, Safe_typing.empty_private_constants)
-let ind_scheme_kind_from_type =
- declare_individual_scheme_object "_ind_nodep"
- (optimize_non_type_induction_scheme rect_scheme_kind_from_type false InProp)
-
-let ind_scheme_kind_from_prop =
- declare_individual_scheme_object "_ind" ~aux:"_ind_from_prop"
- (optimize_non_type_induction_scheme rect_scheme_kind_from_prop false InProp)
-
-let ind_dep_scheme_kind_from_type =
- declare_individual_scheme_object "_ind" ~aux:"_ind_from_type"
- (optimize_non_type_induction_scheme rect_dep_scheme_kind_from_type true InProp)
+let rec_scheme_kind_from_type =
+ declare_individual_scheme_object "_rec_nodep" ~aux:"_rec_nodep_from_type"
+ (optimize_non_type_induction_scheme rect_scheme_kind_from_type false InSet)
let rec_scheme_kind_from_prop =
declare_individual_scheme_object "_rec" ~aux:"_rec_from_prop"
(optimize_non_type_induction_scheme rect_scheme_kind_from_prop false InSet)
-let rec_scheme_kind_from_type =
- declare_individual_scheme_object "_rec_nodep" ~aux:"_rec_nodep_from_type"
- (optimize_non_type_induction_scheme rect_scheme_kind_from_type false InSet)
-
let rec_dep_scheme_kind_from_type =
declare_individual_scheme_object "_rec" ~aux:"_rec_from_type"
(optimize_non_type_induction_scheme rect_dep_scheme_kind_from_type true InSet)
+let ind_scheme_kind_from_type =
+ declare_individual_scheme_object "_ind_nodep"
+ (optimize_non_type_induction_scheme rec_scheme_kind_from_type false InProp)
+
+let ind_dep_scheme_kind_from_type =
+ declare_individual_scheme_object "_ind" ~aux:"_ind_from_type"
+ (optimize_non_type_induction_scheme rec_dep_scheme_kind_from_type true InProp)
+
+let ind_scheme_kind_from_prop =
+ declare_individual_scheme_object "_ind" ~aux:"_ind_from_prop"
+ (optimize_non_type_induction_scheme rec_scheme_kind_from_prop false InProp)
+
(* Case analysis *)
let build_case_analysis_scheme_in_type dep sort ind =
diff --git a/vernac/classes.ml b/vernac/classes.ml
index aba61146c7..007b70bc0f 100644
--- a/vernac/classes.ml
+++ b/vernac/classes.ml
@@ -114,8 +114,8 @@ let instance_hook k info global imps ?hook cst =
let declare_instance_constant k info global imps ?hook id pl poly evm term termtype =
let kind = IsDefinition Instance in
let evm =
- let levels = Univ.LSet.union (Universes.universes_of_constr termtype)
- (Universes.universes_of_constr term) in
+ let levels = Univ.LSet.union (Univops.universes_of_constr termtype)
+ (Univops.universes_of_constr term) in
Evd.restrict_universe_context evm levels
in
let pl, uctx = Evd.universe_context ?names:pl evm in
@@ -420,6 +420,8 @@ let context poly l =
let _ = Command.declare_definition id decl entry [] [] hook in
Lib.sections_are_opened () || Lib.is_modtype_strict ()
in
- let () = uctx := Univ.ContextSet.empty in
status && nstatus
- in List.fold_left fn true (List.rev ctx)
+ in
+ if Lib.sections_are_opened () then
+ Declare.declare_universe_context poly !uctx;
+ List.fold_left fn true (List.rev ctx)
diff --git a/vernac/command.ml b/vernac/command.ml
index 2d4f051345..116a7aee16 100644
--- a/vernac/command.ml
+++ b/vernac/command.ml
@@ -106,7 +106,7 @@ let interp_definition pl bl p red_option c ctypopt =
let c = EConstr.Unsafe.to_constr c in
let nf,subst = Evarutil.e_nf_evars_and_universes evdref in
let body = nf (it_mkLambda_or_LetIn c ctx) in
- let vars = Universes.universes_of_constr body in
+ let vars = Univops.universes_of_constr body in
let evd = Evd.restrict_universe_context !evdref vars in
let pl, uctx = Evd.universe_context ?names:pl evd in
imps1@(Impargs.lift_implicits nb_args imps2), pl,
@@ -131,8 +131,8 @@ let interp_definition pl bl p red_option c ctypopt =
in
if not (try List.for_all chk imps2 with Not_found -> false)
then warn_implicits_in_term ();
- let vars = Univ.LSet.union (Universes.universes_of_constr body)
- (Universes.universes_of_constr typ) in
+ let vars = Univ.LSet.union (Univops.universes_of_constr body)
+ (Univops.universes_of_constr typ) in
let ctx = Evd.restrict_universe_context !evdref vars in
let pl, uctx = Evd.universe_context ?names:pl ctx in
imps1@(Impargs.lift_implicits nb_args impsty), pl,
@@ -329,7 +329,7 @@ let do_assumptions_bound_univs coe kind nl id pl c =
let nf, subst = Evarutil.e_nf_evars_and_universes evdref in
let ty = EConstr.Unsafe.to_constr ty in
let ty = nf ty in
- let vars = Universes.universes_of_constr ty in
+ let vars = Univops.universes_of_constr ty in
let evd = Evd.restrict_universe_context !evdref vars in
let pl, uctx = Evd.universe_context ?names:pl evd in
let uctx = Univ.ContextSet.of_context uctx in
@@ -1213,7 +1213,7 @@ let declare_fixpoint local poly ((fixnames,fixdefs,fixtypes),pl,ctx,fiximps) ind
let env = Global.env() in
let indexes = search_guard env indexes fixdecls in
let fiximps = List.map (fun (n,r,p) -> r) fiximps in
- let vars = Universes.universes_of_constr (mkFix ((indexes,0),fixdecls)) in
+ let vars = Univops.universes_of_constr (mkFix ((indexes,0),fixdecls)) in
let fixdecls =
List.map_i (fun i _ -> mkFix ((indexes,i),fixdecls)) 0 fixnames in
let evd = Evd.from_ctx ctx in
@@ -1245,7 +1245,7 @@ let declare_cofixpoint local poly ((fixnames,fixdefs,fixtypes),pl,ctx,fiximps) n
let fixdefs = List.map Option.get fixdefs in
let fixdecls = prepare_recursive_declaration fixnames fixtypes fixdefs in
let fixdecls = List.map_i (fun i _ -> mkCoFix (i,fixdecls)) 0 fixnames in
- let vars = Universes.universes_of_constr (List.hd fixdecls) in
+ let vars = Univops.universes_of_constr (List.hd fixdecls) in
let fixdecls = List.map Safe_typing.mk_pure_proof fixdecls in
let fiximps = List.map (fun (len,imps,idx) -> imps) fiximps in
let evd = Evd.from_ctx ctx in
--
cgit v1.2.3
From 7b5fcef8a0fb3b97a3980f10596137234061990f Mon Sep 17 00:00:00 2001
From: Amin Timany
Date: Wed, 26 Apr 2017 15:24:35 +0200
Subject: Fix bugs
---
kernel/indtypes.ml | 61 ++++++++++++++++++++-------------------
kernel/indtypes.mli | 11 +++++++
kernel/reduction.ml | 4 +--
library/declare.ml | 6 ++--
pretyping/evarconv.ml | 6 ++--
pretyping/inductiveops.ml | 41 ++++++++++++++++----------
pretyping/inductiveops.mli | 4 +++
test-suite/success/polymorphism.v | 20 +++++++++++++
vernac/command.ml | 2 +-
vernac/record.ml | 6 ++--
10 files changed, 106 insertions(+), 55 deletions(-)
diff --git a/kernel/indtypes.ml b/kernel/indtypes.ml
index 15fe908359..a4c7a0573c 100644
--- a/kernel/indtypes.ml
+++ b/kernel/indtypes.ml
@@ -215,20 +215,42 @@ let check_subtyping_arity_constructor env (subst : constr -> constr) (arcn : Ter
numchecked := !numchecked + 1
in
let check_typ typ typ_env =
- match typ with
- | LocalAssum (_, typ') ->
- begin
- try
- basic_check env typ'; Environ.push_rel typ typ_env
- with NotConvertible ->
- anomaly ~label:"bad inductive subtyping relation" (Pp.str "Invalid subtyping relation")
- end
- | _ -> anomaly (Pp.str "")
+ match typ with
+ | LocalAssum (_, typ') ->
+ begin
+ try
+ basic_check typ_env typ'; Environ.push_rel typ typ_env
+ with NotConvertible ->
+ anomaly ~label:"bad inductive subtyping relation" (Pp.str "Invalid subtyping relation")
+ end
+ | _ -> anomaly (Pp.str "")
in
let typs, codom = dest_prod env arcn in
let last_env = Context.Rel.fold_outside check_typ typs ~init:env in
if not is_arity then basic_check last_env codom else ()
+(* Check that the subtyping information inferred for inductive types in the block is correct. *)
+(* This check produces a value of the unit type if successful or raises an anomaly if check fails. *)
+let check_subtyping mie paramsctxt env_ar inds =
+ let numparams = Context.Rel.nhyps paramsctxt in
+ let sbsubst = UInfoInd.subtyping_susbst mie.mind_entry_universes in
+ let dosubst = subst_univs_level_constr sbsubst in
+ let uctx = UInfoInd.univ_context mie.mind_entry_universes in
+ let instance_other = Univ.subst_univs_level_instance sbsubst (Univ.UContext.instance uctx) in
+ let constraints_other = Univ.subst_univs_level_constraints sbsubst (Univ.UContext.constraints uctx) in
+ let uctx_other = Univ.UContext.make (instance_other, constraints_other) in
+ let env' = Environ.push_context uctx env_ar in
+ let env'' = Environ.push_context uctx_other env' in
+ let envsb = push_context (UInfoInd.subtyp_context mie.mind_entry_universes) env'' in
+ (* process individual inductive types: *)
+ Array.iter (fun (id,cn,lc,(sign,arity)) ->
+ match arity with
+ | RegularArity (_, full_arity, _) ->
+ check_subtyping_arity_constructor envsb dosubst full_arity numparams true;
+ Array.iter (fun cnt -> check_subtyping_arity_constructor envsb dosubst cnt numparams false) lc
+ | TemplateArity _ -> ()
+ ) inds
+
(* Type-check an inductive definition. Does not check positivity
conditions. *)
(* TODO check that we don't overgeneralize construcors/inductive arities with
@@ -370,26 +392,7 @@ let typecheck_inductive env mie =
in
(* Check that the subtyping information inferred for inductive types in the block is correct. *)
(* This check produces a value of the unit type if successful or raises an anomaly if check fails. *)
- let () =
- let numparams = List.length paramsctxt in
- let sbsubst = UInfoInd.subtyping_susbst mie.mind_entry_universes in
- let dosubst = subst_univs_level_constr sbsubst in
- let uctx = UInfoInd.univ_context mie.mind_entry_universes in
- let instance_other = Univ.subst_univs_level_instance sbsubst (Univ.UContext.instance uctx) in
- let constraints_other = Univ.subst_univs_level_constraints sbsubst (Univ.UContext.constraints uctx) in
- let uctx_other = Univ.UContext.make (instance_other, constraints_other) in
- let env' = Environ.push_context uctx env_ar_par in
- let env'' = Environ.push_context uctx_other env' in
- let envsb = push_context (UInfoInd.subtyp_context mie.mind_entry_universes) env'' in
- (* process individual inductive types: *)
- Array.iter (fun (id,cn,lc,(sign,arity)) ->
- match arity with
- | RegularArity (_, full_arity, _) ->
- check_subtyping_arity_constructor envsb dosubst full_arity numparams true;
- Array.iter (fun cnt -> check_subtyping_arity_constructor envsb dosubst cnt numparams false) lc
- | TemplateArity _ -> ()
- (* TODO: When disabling template polumorphism raise anomaly if this constructor is not removed from the code base *)
- ) inds
+ let () = check_subtyping mie paramsctxt env_arities inds
in (env_arities, env_ar_par, paramsctxt, inds)
(************************************************************************)
diff --git a/kernel/indtypes.mli b/kernel/indtypes.mli
index 5b4615399d..7b0f017941 100644
--- a/kernel/indtypes.mli
+++ b/kernel/indtypes.mli
@@ -32,6 +32,17 @@ type inductive_error =
exception InductiveError of inductive_error
+val check_subtyping_arity_constructor : Environ.env ->
+(Term.constr -> Term.constr) -> Term.types -> int -> bool -> unit
+
+(* This needs not be exposed. Exposing for debugging purposes! *)
+val check_subtyping : Entries.mutual_inductive_entry ->
+Context.Rel.t ->
+Environ.env ->
+('b * 'c * Term.types array *
+ ('d * ('e * Term.types * 'f, 'g) Declarations.declaration_arity))
+array -> unit
+
(** The following function does checks on inductive declarations. *)
val check_inductive : env -> mutual_inductive -> mutual_inductive_entry -> mutual_inductive_body
diff --git a/kernel/reduction.ml b/kernel/reduction.ml
index a872a103a5..33dd53a5b1 100644
--- a/kernel/reduction.ml
+++ b/kernel/reduction.ml
@@ -500,7 +500,7 @@ and eqappr env cv_pb l2r infos (lft1,st1) (lft2,st2) cuniv =
if mind.Declarations.mind_polymorphic then
begin
let num_param_arity =
- Context.Rel.length (mind.Declarations.mind_packets.(snd ind1).Declarations.mind_arity_ctxt)
+ mind.Declarations.mind_nparams + mind.Declarations.mind_packets.(snd ind1).Declarations.mind_nrealargs
in
if not (num_param_arity = CClosure.stack_args_size v1 && num_param_arity = CClosure.stack_args_size v2) then
fall_back ()
@@ -535,7 +535,7 @@ and eqappr env cv_pb l2r infos (lft1,st1) (lft2,st2) cuniv =
if not (num_cnstr_args = CClosure.stack_args_size v1 && num_cnstr_args = CClosure.stack_args_size v2) then
fall_back ()
else
- begin (* we don't consider subtyping for constructors. *)
+ begin (* we consider subtyping for constructors. *)
let uinfind = mind.Declarations.mind_universes in
let cuniv = compare_leq_inductives ~flex:false uinfind u1 u2 cuniv in
let cuniv = compare_leq_inductives ~flex:false uinfind u2 u1 cuniv in
diff --git a/library/declare.ml b/library/declare.ml
index fcaadaa6e0..bf5313545c 100644
--- a/library/declare.ml
+++ b/library/declare.ml
@@ -364,9 +364,9 @@ let infer_inductive_subtyping (pth, mind_ent) =
let env' =
Environ.push_context (Univ.UInfoInd.univ_context mind_ent.mind_entry_universes) env
in
- let (env'', typed_params) = Typeops.infer_local_decls env' (mind_ent.mind_entry_params) in
- let evd = Evd.from_env env'' in
- (pth, Inductiveops.infer_inductive_subtyping env'' evd mind_ent)
+ (* let (env'', typed_params) = Typeops.infer_local_decls env' (mind_ent.mind_entry_params) in *)
+ let evd = Evd.from_env env' in
+ (pth, Inductiveops.infer_inductive_subtyping env' evd mind_ent)
end
else (pth, mind_ent)
diff --git a/pretyping/evarconv.ml b/pretyping/evarconv.ml
index eb8a0c85a0..ea22c3708f 100644
--- a/pretyping/evarconv.ml
+++ b/pretyping/evarconv.ml
@@ -494,7 +494,7 @@ and evar_eqappr_x ?(rhs_is_already_stuck = false) ts env evd pbty
if mind.Declarations.mind_polymorphic then
begin
let num_param_arity =
- Context.Rel.length (mind.Declarations.mind_packets.(snd ind).Declarations.mind_arity_ctxt)
+ mind.Declarations.mind_nparams + mind.Declarations.mind_packets.(snd ind).Declarations.mind_nrealargs
in
if not (num_param_arity = nparamsaplied && num_param_arity = nparamsaplied') then
UnifFailure (evd, NotSameHead)
@@ -520,7 +520,9 @@ and evar_eqappr_x ?(rhs_is_already_stuck = false) ts env evd pbty
if mind.Declarations.mind_polymorphic then
begin
let num_cnstr_args =
- let nparamsctxt = Context.Rel.length mind.Declarations.mind_params_ctxt in
+ let nparamsctxt =
+ mind.Declarations.mind_nparams + mind.Declarations.mind_packets.(snd ind).Declarations.mind_nrealargs
+ in
nparamsctxt + mind.Declarations.mind_packets.(snd ind).Declarations.mind_consnrealargs.(j - 1)
in
if not (num_cnstr_args = nparamsaplied && num_cnstr_args = nparamsaplied') then
diff --git a/pretyping/inductiveops.ml b/pretyping/inductiveops.ml
index 1f8600dc2c..ebfb1f8a7c 100644
--- a/pretyping/inductiveops.ml
+++ b/pretyping/inductiveops.ml
@@ -659,14 +659,22 @@ let control_only_guard env c =
(* inference of subtyping condition for inductive types *)
let infer_inductive_subtyping_arity_constructor
- (env, evd, csts) (subst : constr -> constr) (arcn : Term.types) is_arity =
+ (env, evd, csts) (subst : constr -> constr) (arcn : Term.types) is_arity (params : Context.Rel.t) =
+ let numchecked = ref 0 in
+ let numparams = Context.Rel.nhyps params in
let update_contexts (env, evd, csts) csts' =
(Environ.add_constraints csts' env, Evd.add_constraints evd csts', Univ.Constraint.union csts csts')
in
let basic_check (env, evd, csts) tp =
- let csts' =
- Reduction.infer_conv_leq ~evars:(Evd.existential_opt_value evd) env (Evd.universes evd) tp (subst tp)
- in update_contexts (env, evd, csts) csts'
+ let result =
+ if !numchecked >= numparams then
+ let csts' =
+ Reduction.infer_conv_leq ~evars:(Evd.existential_opt_value evd) env (Evd.universes evd) tp (subst tp)
+ in update_contexts (env, evd, csts) csts'
+ else
+ (env, evd, csts)
+ in
+ numchecked := !numchecked + 1; result
in
let infer_typ typ ctxs =
match typ with
@@ -680,12 +688,14 @@ let infer_inductive_subtyping_arity_constructor
end
| _ -> anomaly (Pp.str "")
in
- let typs, codom = Reduction.dest_prod env arcn in
+ let arcn' = Term.it_mkProd_or_LetIn arcn params in
+ let typs, codom = Reduction.dest_prod env arcn' in
let last_contexts = Context.Rel.fold_outside infer_typ typs ~init:(env, evd, csts) in
if not is_arity then basic_check last_contexts codom else last_contexts
let infer_inductive_subtyping env evd mind_ent =
- let { Entries.mind_entry_inds = entries;
+ let { Entries.mind_entry_params = params;
+ Entries.mind_entry_inds = entries;
Entries.mind_entry_polymorphic = poly;
Entries.mind_entry_universes = ground_uinfind;
} = mind_ent
@@ -704,15 +714,16 @@ let infer_inductive_subtyping env evd mind_ent =
let evd' = Evd.merge_universe_context evd (UState.of_context_set (Univ.ContextSet.of_context uctx_other)) in
let (_, _, subtyp_constraints) =
List.fold_left
- (fun ctxs indentry ->
- let ctxs' = infer_inductive_subtyping_arity_constructor
- ctxs dosubst indentry.Entries.mind_entry_arity true
- in
- List.fold_left
- (fun ctxs cons ->
- infer_inductive_subtyping_arity_constructor ctxs dosubst cons false)
- ctxs' indentry.Entries.mind_entry_lc
- ) (env', evd', Univ.Constraint.empty) entries
+ (fun ctxs indentry ->
+ let _, params = Typeops.infer_local_decls env params in
+ let ctxs' = infer_inductive_subtyping_arity_constructor
+ ctxs dosubst indentry.Entries.mind_entry_arity true params
+ in
+ List.fold_left
+ (fun ctxs cons ->
+ infer_inductive_subtyping_arity_constructor ctxs dosubst cons false params)
+ ctxs' indentry.Entries.mind_entry_lc
+ ) (env', evd', Univ.Constraint.empty) entries
in Univ.UInfoInd.make (Univ.UInfoInd.univ_context ground_uinfind,
Univ.UContext.make
(Univ.UContext.instance (Univ.UInfoInd.subtyp_context ground_uinfind),
diff --git a/pretyping/inductiveops.mli b/pretyping/inductiveops.mli
index 7d89b1b2bd..811f47f39a 100644
--- a/pretyping/inductiveops.mli
+++ b/pretyping/inductiveops.mli
@@ -201,6 +201,10 @@ val type_of_inductive_knowing_conclusion :
val control_only_guard : env -> types -> unit
(* inference of subtyping condition for inductive types *)
+(* for debugging purposes only to be removed *)
+val infer_inductive_subtyping_arity_constructor : Environ.env * Evd.evar_map * Univ.Constraint.t ->
+(Term.constr -> Term.constr) ->
+Term.types -> bool -> Context.Rel.t -> Environ.env * Evd.evar_map * Univ.Constraint.t
val infer_inductive_subtyping : Environ.env -> Evd.evar_map -> Entries.mutual_inductive_entry ->
Entries.mutual_inductive_entry
diff --git a/test-suite/success/polymorphism.v b/test-suite/success/polymorphism.v
index 66ff55edcb..3e90825ab2 100644
--- a/test-suite/success/polymorphism.v
+++ b/test-suite/success/polymorphism.v
@@ -316,6 +316,26 @@ Module Hurkens'.
Polymorphic Record box (X : Type) (T := Type) : Type := wrap { unwrap : T }.
+Section test_letin_subtyping.
+ Universe i j k i' j' k'.
+ Constraint j < j'.
+
+ Context (W : Type) (X : box@{i j k} W).
+ Definition Y := X : box@{i' j' k'} W.
+
+ Universe i1 j1 k1 i2 j2 k2.
+ Constraint i1 < i2, k2 < k1.
+ Definition Z : box@{i1 j1 k1} W := {| unwrap := W |}.
+ Definition Z' : box@{i2 j2 k2} W := {| unwrap := W |}.
+ Lemma ZZ' : @eq (box@{i2 j2 k2} W) Z Z'.
+ Proof.
+ Set Printing All. Set Printing Universes.
+ cbv.
+ reflexivity.
+ Qed.
+
+End test_letin_subtyping.
+
Definition unwrap' := fun (X : Type) (b : box X) => let (unw) := b in unw.
Fail Definition bad : False := TypeNeqSmallType.paradox (unwrap' Type (wrap _
diff --git a/vernac/command.ml b/vernac/command.ml
index 116a7aee16..6c59976232 100644
--- a/vernac/command.ml
+++ b/vernac/command.ml
@@ -662,7 +662,7 @@ let interp_mutual_inductive (paramsl,indl) notations poly prv finite =
}
in
(if poly then
- Inductiveops.infer_inductive_subtyping env_ar_params evd mind_ent
+ Inductiveops.infer_inductive_subtyping env_ar evd mind_ent
else mind_ent), pl, impls
(* Very syntactical equality *)
diff --git a/vernac/record.ml b/vernac/record.ml
index 84312594d5..093a31c194 100644
--- a/vernac/record.ml
+++ b/vernac/record.ml
@@ -410,9 +410,9 @@ let declare_structure finite poly ctx id idbuild paramimpls params arity templat
begin
let env = Global.env () in
let env' = Environ.push_context (Univ.UInfoInd.univ_context ctx) env in
- let env'' = Environ.push_rel_context params env' in
- let evd = Evd.from_env env'' in
- Inductiveops.infer_inductive_subtyping env'' evd mie
+ (* let env'' = Environ.push_rel_context params env' in *)
+ let evd = Evd.from_env env' in
+ Inductiveops.infer_inductive_subtyping env' evd mie
end
else
mie
--
cgit v1.2.3
From 9468e4b49bd2f397b5e1bd2b7994cc84929fb6ac Mon Sep 17 00:00:00 2001
From: Amin Timany
Date: Thu, 27 Apr 2017 20:16:35 +0200
Subject: Fix bugs and add an option for cumulativity
---
API/API.mli | 12 +-
ide/texmacspp.ml | 769 ++++++++++++++++++++++++++++++++
intf/decl_kinds.ml | 4 +-
intf/vernacexpr.ml | 2 +-
kernel/declarations.ml | 2 +
kernel/declareops.ml | 1 +
kernel/entries.mli | 3 +-
kernel/indtypes.ml | 7 +-
kernel/reduction.ml | 190 +++++---
kernel/reduction.mli | 11 +-
lib/flags.ml | 4 +
lib/flags.mli | 4 +
library/declare.ml | 4 +-
parsing/g_vernac.ml4 | 14 +-
plugins/funind/glob_term_to_relation.ml | 8 +-
plugins/funind/merge.ml | 2 +-
pretyping/evarconv.ml | 2 +
pretyping/reductionops.ml | 64 ++-
printing/ppvernac.ml | 14 +-
stm/vernac_classifier.ml | 2 +-
test-suite/bugs/closed/3330.v | 11 +-
test-suite/success/polymorphism.v | 52 ++-
vernac/command.ml | 7 +-
vernac/command.mli | 10 +-
vernac/discharge.ml | 1 +
vernac/record.ml | 13 +-
vernac/record.mli | 7 +-
vernac/vernacentries.ml | 28 +-
28 files changed, 1093 insertions(+), 155 deletions(-)
create mode 100644 ide/texmacspp.ml
diff --git a/API/API.mli b/API/API.mli
index a4ae6347c0..a993b0277c 100644
--- a/API/API.mli
+++ b/API/API.mli
@@ -1095,6 +1095,7 @@ sig
mind_nparams_rec : int;
mind_params_ctxt : Context.Rel.t;
mind_polymorphic : bool;
+ mind_cumulative : bool;
mind_universes : Univ.universe_info_ind;
mind_private : bool option;
mind_typing_flags : Declarations.typing_flags;
@@ -1907,6 +1908,7 @@ end
module Decl_kinds :
sig
type polymorphic = bool
+ type cumulative_inductive_flag = bool
type recursivity_kind = Decl_kinds.recursivity_kind =
| Finite
| CoFinite
@@ -2388,7 +2390,7 @@ sig
| VernacExactProof of Constrexpr.constr_expr
| VernacAssumption of (Decl_kinds.locality option * Decl_kinds.assumption_object_kind) *
inline * (plident list * Constrexpr.constr_expr) with_coercion list
- | VernacInductive of Decl_kinds.private_flag * inductive_flag * (inductive_expr * decl_notation list) list
+ | VernacInductive of Decl_kinds.cumulative_inductive_flag * Decl_kinds.private_flag * inductive_flag * (inductive_expr * decl_notation list) list
| VernacFixpoint of
Decl_kinds.locality option * (fixpoint_expr * decl_notation list) list
| VernacCoFixpoint of
@@ -4743,7 +4745,9 @@ sig
type one_inductive_impls = Command.one_inductive_impls
val do_mutual_inductive :
- (Vernacexpr.one_inductive_expr * Vernacexpr.decl_notation list) list -> Decl_kinds.polymorphic ->
+ (Vernacexpr.one_inductive_expr * Vernacexpr.decl_notation list) list ->
+ Decl_kinds.cumulative_inductive_flag ->
+ Decl_kinds.polymorphic ->
Decl_kinds.private_flag -> Decl_kinds.recursivity_kind -> unit
val do_definition : Names.Id.t -> Decl_kinds.definition_kind -> Vernacexpr.lident list option ->
@@ -4767,7 +4771,9 @@ sig
structured_inductive_expr * Libnames.qualid list * Vernacexpr.decl_notation list
val interp_mutual_inductive :
- structured_inductive_expr -> Vernacexpr.decl_notation list -> Decl_kinds.polymorphic ->
+ structured_inductive_expr -> Vernacexpr.decl_notation list ->
+ Decl_kinds.cumulative_inductive_flag ->
+ Decl_kinds.polymorphic ->
Decl_kinds.private_flag -> Decl_kinds.recursivity_kind ->
Entries.mutual_inductive_entry * Universes.universe_binders * one_inductive_impls list
diff --git a/ide/texmacspp.ml b/ide/texmacspp.ml
new file mode 100644
index 0000000000..8409c75218
--- /dev/null
+++ b/ide/texmacspp.ml
@@ -0,0 +1,769 @@
+(************************************************************************)
+(* v * The Coq Proof Assistant / The Coq Development Team *)
+(* (List.filter (fun (a,_) -> a = attr) attrs)
+ | _ -> [])
+ xml_list in
+ match List.flatten attrs_list with
+ | [] -> (attr, "")
+ | l -> (List.hd l)
+
+let backstep_loc xmllist =
+ let start_att = get_fst_attr_in_xml_list "begin" xmllist in
+ let stop_att = get_fst_attr_in_xml_list "end" (List.rev xmllist) in
+ [start_att ; stop_att]
+
+let compare_begin_att xml1 xml2 =
+ let att1 = get_fst_attr_in_xml_list "begin" [xml1] in
+ let att2 = get_fst_attr_in_xml_list "begin" [xml2] in
+ match att1, att2 with
+ | (_, s1), (_, s2) when s1 == "" || s2 == "" -> 0
+ | (_, s1), (_, s2) when int_of_string s1 > int_of_string s2 -> 1
+ | (_, s1), (_, s2) when int_of_string s1 < int_of_string s2 -> -1
+ | _ -> 0
+
+let xmlBeginSection ?loc name = xmlWithLoc ?loc "beginsection" ["name", name] []
+
+let xmlEndSegment ?loc name = xmlWithLoc ?loc "endsegment" ["name", name] []
+
+let xmlThm ?loc typ name xml =
+ xmlWithLoc ?loc "theorem" ["type", typ; "name", name] xml
+
+let xmlDef ?loc typ name xml =
+ xmlWithLoc ?loc "definition" ["type", typ; "name", name] xml
+
+let xmlNotation ?loc attr name xml =
+ xmlWithLoc ?loc "notation" (("name", name) :: attr) xml
+
+let xmlReservedNotation ?loc attr name =
+ xmlWithLoc ?loc "reservednotation" (("name", name) :: attr) []
+
+let xmlCst ?loc ?(attr=[]) name =
+ xmlWithLoc ?loc "constant" (("name", name) :: attr) []
+
+let xmlOperator ?loc ?(attr=[]) ?(pprules=[]) name =
+ xmlWithLoc ?loc "operator"
+ (("name", name) :: List.map (fun (a,b) -> "format"^a,b) pprules @ attr) []
+
+let xmlApply ?loc ?(attr=[]) xml = xmlWithLoc ?loc "apply" attr xml
+
+let xmlToken ?loc ?(attr=[]) xml = xmlWithLoc ?loc "token" attr xml
+
+let xmlTyped xml = Element("typed", (backstep_loc xml), xml)
+
+let xmlReturn ?(attr=[]) xml = Element("return", attr, xml)
+
+let xmlCase xml = Element("case", [], xml)
+
+let xmlScrutinee ?(attr=[]) xml = Element("scrutinee", attr, xml)
+
+let xmlWith xml = Element("with", [], xml)
+
+let xmlAssign id xml = Element("assign", ["target",string_of_id id], [xml])
+
+let xmlInductive ?loc kind xml = xmlWithLoc ?loc "inductive" ["kind",kind] xml
+
+let xmlCoFixpoint xml = Element("cofixpoint", [], xml)
+
+let xmlFixpoint xml = Element("fixpoint", [], xml)
+
+let xmlCheck ?loc xml = xmlWithLoc ?loc "check" [] xml
+
+let xmlAssumption ?loc kind xml = xmlWithLoc ?loc "assumption" ["kind",kind] xml
+
+let xmlComment ?loc xml = xmlWithLoc ?loc "comment" [] xml
+
+let xmlCanonicalStructure ?loc attr = xmlWithLoc ?loc "canonicalstructure" attr []
+
+let xmlQed ?loc ?(attr=[]) = xmlWithLoc ?loc "qed" attr []
+
+let xmlPatvar ?loc id = xmlWithLoc ?loc "patvar" ["id", id] []
+
+let xmlReference ref =
+ let name = Libnames.string_of_reference ref in
+ let i, j = Option.cata Loc.unloc (0,0) (Libnames.loc_of_reference ref) in
+ let b, e = string_of_int i, string_of_int j in
+ Element("reference",["name", name; "begin", b; "end", e] ,[])
+
+let xmlRequire ?loc ?(attr=[]) xml = xmlWithLoc ?loc "require" attr xml
+let xmlImport ?loc ?(attr=[]) xml = xmlWithLoc ?loc "import" attr xml
+
+let xmlAddLoadPath ?loc ?(attr=[]) xml = xmlWithLoc ?loc "addloadpath" attr xml
+let xmlRemoveLoadPath ?loc ?(attr=[]) = xmlWithLoc ?loc "removeloadpath" attr
+let xmlAddMLPath ?loc ?(attr=[]) = xmlWithLoc ?loc "addmlpath" attr
+
+let xmlExtend ?loc xml = xmlWithLoc ?loc "extend" [] xml
+
+let xmlScope ?loc ?(attr=[]) action name xml =
+ xmlWithLoc ?loc "scope" (["name",name;"action",action] @ attr) xml
+
+let xmlProofMode ?loc name = xmlWithLoc ?loc "proofmode" ["name",name] []
+
+let xmlProof ?loc xml = xmlWithLoc ?loc "proof" [] xml
+
+let xmlSectionSubsetDescr name ssd =
+ Element("sectionsubsetdescr",["name",name],
+ [PCData (Proof_using.to_string ssd)])
+
+let xmlDeclareMLModule ?loc s =
+ xmlWithLoc ?loc "declarexmlmodule" []
+ (List.map (fun x -> Element("path",["value",x],[])) s)
+
+(* tactics *)
+let xmlLtac ?loc xml = xmlWithLoc ?loc "ltac" [] xml
+
+(* toplevel commands *)
+let xmlGallina ?loc xml = xmlWithLoc ?loc "gallina" [] xml
+
+let xmlTODO ?loc x =
+ xmlWithLoc ?loc "todo" [] [PCData (Pp.string_of_ppcmds (Ppvernac.pr_vernac x))]
+
+let string_of_name n =
+ match n with
+ | Anonymous -> "_"
+ | Name id -> Id.to_string id
+
+let string_of_glob_sort s =
+ match s with
+ | GProp -> "Prop"
+ | GSet -> "Set"
+ | GType _ -> "Type"
+
+let string_of_cast_sort c =
+ match c with
+ | CastConv _ -> "CastConv"
+ | CastVM _ -> "CastVM"
+ | CastNative _ -> "CastNative"
+ | CastCoerce -> "CastCoerce"
+
+let string_of_case_style s =
+ match s with
+ | LetStyle -> "Let"
+ | IfStyle -> "If"
+ | LetPatternStyle -> "LetPattern"
+ | MatchStyle -> "Match"
+ | RegularStyle -> "Regular"
+
+let attribute_of_syntax_modifier sm =
+match sm with
+ | SetItemLevel (sl, NumLevel n) ->
+ List.map (fun s -> ("itemlevel", s)) sl @ ["level", string_of_int n]
+ | SetItemLevel (sl, NextLevel) ->
+ List.map (fun s -> ("itemlevel", s)) sl @ ["level", "next"]
+ | SetLevel i -> ["level", string_of_int i]
+ | SetAssoc a ->
+ begin match a with
+ | NonA -> ["",""]
+ | RightA -> ["associativity", "right"]
+ | LeftA -> ["associativity", "left"]
+ end
+ | SetEntryType (s, _) -> ["entrytype", s]
+ | SetOnlyPrinting -> ["onlyprinting", ""]
+ | SetOnlyParsing -> ["onlyparsing", ""]
+ | SetCompatVersion v -> ["compat", Flags.pr_version v]
+ | SetFormat (system, (loc, s)) ->
+ let start, stop = unlock ?loc in
+ ["format-"^system, s; "begin", start; "end", stop]
+
+let string_of_assumption_kind l a many =
+ match l, a, many with
+ | (Discharge, Logical, true) -> "Hypotheses"
+ | (Discharge, Logical, false) -> "Hypothesis"
+ | (Discharge, Definitional, true) -> "Variables"
+ | (Discharge, Definitional, false) -> "Variable"
+ | (Global, Logical, true) -> "Axioms"
+ | (Global, Logical, false) -> "Axiom"
+ | (Global, Definitional, true) -> "Parameters"
+ | (Global, Definitional, false) -> "Parameter"
+ | (Local, Logical, true) -> "Local Axioms"
+ | (Local, Logical, false) -> "Local Axiom"
+ | (Local, Definitional, true) -> "Local Parameters"
+ | (Local, Definitional, false) -> "Local Parameter"
+ | (Global, Conjectural, _) -> "Conjecture"
+ | ((Discharge | Local), Conjectural, _) -> assert false
+
+let rec pp_bindlist bl =
+ let tlist =
+ List.flatten
+ (List.map
+ (fun (loc_names, _, e) ->
+ let names =
+ (List.map
+ (fun (loc, name) ->
+ xmlCst ?loc (string_of_name name)) loc_names) in
+ match e.CAst.v with
+ | CHole _ -> names
+ | _ -> names @ [pp_expr e])
+ bl) in
+ match tlist with
+ | [e] -> e
+ | l -> xmlTyped l
+and pp_decl_notation ((_, s), ce, sc) = (* don't know what it is for now *)
+ Element ("decl_notation", ["name", s], [pp_expr ce])
+and pp_local_binder lb = (* don't know what it is for now *)
+ match lb with
+ | CLocalDef ((loc, nam), ce, ty) ->
+ let attrs = ["name", string_of_name nam] in
+ let value = match ty with
+ Some t -> CAst.make ?loc:(Loc.merge_opt (constr_loc ce) (constr_loc t)) @@ CCast (ce, CastConv t)
+ | None -> ce in
+ pp_expr ~attr:attrs value
+ | CLocalAssum (namll, _, ce) ->
+ let ppl =
+ List.map (fun (loc, nam) -> (xmlCst ?loc (string_of_name nam))) namll in
+ xmlTyped (ppl @ [pp_expr ce])
+ | CLocalPattern _ ->
+ assert false
+and pp_local_decl_expr lde = (* don't know what it is for now *)
+ match lde with
+ | AssumExpr (_, ce) -> pp_expr ce
+ | DefExpr (_, ce, _) -> pp_expr ce
+and pp_inductive_expr ((_, ((l, id),_)), lbl, ceo, _, cl_or_rdexpr) =
+ (* inductive_expr *)
+ let b,e = Option.cata Loc.unloc (0,0) l in
+ let location = ["begin", string_of_int b; "end", string_of_int e] in
+ [Element ("lident", ["name", Id.to_string id] @ location, [])] @ (* inductive name *)
+ begin match cl_or_rdexpr with
+ | Constructors coel -> List.map (fun (_, (_, ce)) -> pp_expr ce) coel
+ | RecordDecl (_, ldewwwl) ->
+ List.map (fun (((_, x), _), _) -> pp_local_decl_expr x) ldewwwl
+ end @
+ begin match ceo with (* don't know what it is for now *)
+ | Some ce -> [pp_expr ce]
+ | None -> []
+ end @
+ (List.map pp_local_binder lbl)
+and pp_recursion_order_expr optid roe = (* don't know what it is for now *)
+ let attrs =
+ match optid with
+ | None -> []
+ | Some (loc, id) ->
+ let start, stop = unlock ?loc in
+ ["begin", start; "end", stop ; "name", Id.to_string id] in
+ let kind, expr =
+ match roe with
+ | CStructRec -> "struct", []
+ | CWfRec e -> "rec", [pp_expr e]
+ | CMeasureRec (e, None) -> "mesrec", [pp_expr e]
+ | CMeasureRec (e, Some rel) -> "mesrec", [pp_expr e] @ [pp_expr rel] in
+ Element ("recursion_order", ["kind", kind] @ attrs, expr)
+and pp_fixpoint_expr (((loc, id), pl), (optid, roe), lbl, ce, ceo) =
+ (* fixpoint_expr *)
+ let start, stop = unlock ?loc in
+ let id = Id.to_string id in
+ [Element ("lident", ["begin", start; "end", stop ; "name", id], [])] @
+ (* fixpoint name *)
+ [pp_recursion_order_expr optid roe] @
+ (List.map pp_local_binder lbl) @
+ [pp_expr ce] @
+ begin match ceo with (* don't know what it is for now *)
+ | Some ce -> [pp_expr ce]
+ | None -> []
+ end
+and pp_cofixpoint_expr (((loc, id), pl), lbl, ce, ceo) = (* cofixpoint_expr *)
+ (* Nota: it is like fixpoint_expr without (optid, roe)
+ * so could be merged if there is no more differences *)
+ let start, stop = unlock ?loc in
+ let id = Id.to_string id in
+ [Element ("lident", ["begin", start; "end", stop ; "name", id], [])] @
+ (* cofixpoint name *)
+ (List.map pp_local_binder lbl) @
+ [pp_expr ce] @
+ begin match ceo with (* don't know what it is for now *)
+ | Some ce -> [pp_expr ce]
+ | None -> []
+ end
+and pp_lident (loc, id) = xmlCst ?loc (Id.to_string id)
+and pp_simple_binder (idl, ce) = List.map pp_lident idl @ [pp_expr ce]
+and pp_cases_pattern_expr {loc ; CAst.v = cpe} =
+ match cpe with
+ | CPatAlias (cpe, id) ->
+ xmlApply ?loc
+ (xmlOperator ?loc ~attr:["name", string_of_id id] "alias" ::
+ [pp_cases_pattern_expr cpe])
+ | CPatCstr (ref, None, cpel2) ->
+ xmlApply ?loc
+ (xmlOperator ?loc "reference"
+ ~attr:["name", Libnames.string_of_reference ref] ::
+ [Element ("impargs", [], []);
+ Element ("args", [], (List.map pp_cases_pattern_expr cpel2))])
+ | CPatCstr (ref, Some cpel1, cpel2) ->
+ xmlApply ?loc
+ (xmlOperator ?loc "reference"
+ ~attr:["name", Libnames.string_of_reference ref] ::
+ [Element ("impargs", [], (List.map pp_cases_pattern_expr cpel1));
+ Element ("args", [], (List.map pp_cases_pattern_expr cpel2))])
+ | CPatAtom optr ->
+ let attrs = match optr with
+ | None -> []
+ | Some r -> ["name", Libnames.string_of_reference r] in
+ xmlApply ?loc (xmlOperator ?loc "atom" ~attr:attrs :: [])
+ | CPatOr cpel ->
+ xmlApply ?loc (xmlOperator ?loc "or" :: List.map pp_cases_pattern_expr cpel)
+ | CPatNotation (n, (subst_constr, subst_rec), cpel) ->
+ xmlApply ?loc
+ (xmlOperator ?loc "notation" ::
+ [xmlOperator ?loc n;
+ Element ("subst", [],
+ [Element ("subterms", [],
+ List.map pp_cases_pattern_expr subst_constr);
+ Element ("recsubterms", [],
+ List.map
+ (fun (cpel) ->
+ Element ("recsubterm", [],
+ List.map pp_cases_pattern_expr cpel))
+ subst_rec)]);
+ Element ("args", [], (List.map pp_cases_pattern_expr cpel))])
+ | CPatPrim tok -> pp_token ?loc tok
+ | CPatRecord rcl ->
+ xmlApply ?loc
+ (xmlOperator ?loc "record" ::
+ List.map (fun (r, cpe) ->
+ Element ("field",
+ ["reference", Libnames.string_of_reference r],
+ [pp_cases_pattern_expr cpe]))
+ rcl)
+ | CPatDelimiters (delim, cpe) ->
+ xmlApply ?loc
+ (xmlOperator ?loc "delimiter" ~attr:["name", delim] ::
+ [pp_cases_pattern_expr cpe])
+ | CPatCast _ -> assert false
+and pp_case_expr (e, name, pat) =
+ match name, pat with
+ | None, None -> xmlScrutinee [pp_expr e]
+ | Some (loc, name), None ->
+ let start, stop= unlock ?loc in
+ xmlScrutinee ~attr:["name", string_of_name name;
+ "begin", start; "end", stop] [pp_expr e]
+ | Some (loc, name), Some p ->
+ let start, stop= unlock ?loc in
+ xmlScrutinee ~attr:["name", string_of_name name;
+ "begin", start; "end", stop]
+ [Element ("in", [], [pp_cases_pattern_expr p]) ; pp_expr e]
+ | None, Some p ->
+ xmlScrutinee [Element ("in", [], [pp_cases_pattern_expr p]) ; pp_expr e]
+and pp_branch_expr_list bel =
+ xmlWith
+ (List.map
+ (fun (_, (cpel, e)) ->
+ let ppcepl =
+ List.map pp_cases_pattern_expr (List.flatten (List.map snd cpel)) in
+ let ppe = [pp_expr e] in
+ xmlCase (ppcepl @ ppe))
+ bel)
+and pp_token ?loc tok =
+ let tokstr =
+ match tok with
+ | String s -> PCData s
+ | Numeral n -> PCData (to_string n) in
+ xmlToken ?loc [tokstr]
+and pp_local_binder_list lbl =
+ let l = (List.map pp_local_binder lbl) in
+ Element ("recurse", (backstep_loc l), l)
+and pp_const_expr_list cel =
+ let l = List.map pp_expr cel in
+ Element ("recurse", (backstep_loc l), l)
+and pp_expr ?(attr=[]) { loc; CAst.v = e } =
+ match e with
+ | CRef (r, _) ->
+ xmlCst ?loc:(Libnames.loc_of_reference r) ~attr (Libnames.string_of_reference r)
+ | CProdN (bl, e) ->
+ xmlApply ?loc
+ (xmlOperator ?loc "forall" :: [pp_bindlist bl] @ [pp_expr e])
+ | CApp ((_, hd), args) ->
+ xmlApply ?loc ~attr (pp_expr hd :: List.map (fun (e,_) -> pp_expr e) args)
+ | CAppExpl ((_, r, _), args) ->
+ xmlApply ?loc ~attr
+ (xmlCst ?loc:(Libnames.loc_of_reference r) (Libnames.string_of_reference r)
+ :: List.map pp_expr args)
+ | CNotation (notation, ([],[],[])) ->
+ xmlOperator ?loc notation
+ | CNotation (notation, (args, cell, lbll)) ->
+ let fmts = Notation.find_notation_extra_printing_rules notation in
+ let oper = xmlOperator ?loc notation ~pprules:fmts in
+ let cels = List.map pp_const_expr_list cell in
+ let lbls = List.map pp_local_binder_list lbll in
+ let args = List.map pp_expr args in
+ xmlApply ?loc (oper :: (List.sort compare_begin_att (args @ cels @ lbls)))
+ | CSort(s) ->
+ xmlOperator ?loc (string_of_glob_sort s)
+ | CDelimiters (scope, ce) ->
+ xmlApply ?loc (xmlOperator ?loc "delimiter" ~attr:["name", scope] ::
+ [pp_expr ce])
+ | CPrim tok -> pp_token ?loc tok
+ | CGeneralization (kind, _, e) ->
+ let kind= match kind with
+ | Explicit -> "explicit"
+ | Implicit -> "implicit" in
+ xmlApply ?loc
+ (xmlOperator ?loc ~attr:["kind", kind] "generalization" :: [pp_expr e])
+ | CCast (e, tc) ->
+ begin match tc with
+ | CastConv t | CastVM t |CastNative t ->
+ xmlApply ?loc
+ (xmlOperator ?loc ":" ~attr:["kind", (string_of_cast_sort tc)] ::
+ [pp_expr e; pp_expr t])
+ | CastCoerce ->
+ xmlApply ?loc
+ (xmlOperator ?loc ":" ~attr:["kind", "CastCoerce"] ::
+ [pp_expr e])
+ end
+ | CEvar (ek, cel) ->
+ let ppcel = List.map (fun (id,e) -> xmlAssign id (pp_expr e)) cel in
+ xmlApply ?loc
+ (xmlOperator ?loc "evar" ~attr:["id", string_of_id ek] ::
+ ppcel)
+ | CPatVar id -> xmlPatvar ?loc (string_of_id id)
+ | CHole (_, _, _) -> xmlCst ?loc ~attr "_"
+ | CIf (test, (_, ret), th, el) ->
+ let return = match ret with
+ | None -> []
+ | Some r -> [xmlReturn [pp_expr r]] in
+ xmlApply ?loc
+ (xmlOperator ?loc "if" ::
+ return @ [pp_expr th] @ [pp_expr el])
+ | CLetTuple (names, (_, ret), value, body) ->
+ let return = match ret with
+ | None -> []
+ | Some r -> [xmlReturn [pp_expr r]] in
+ xmlApply ?loc
+ (xmlOperator ?loc "lettuple" ::
+ return @
+ (List.map (fun (loc, var) -> xmlCst ?loc (string_of_name var)) names) @
+ [pp_expr value; pp_expr body])
+ | CCases (sty, ret, cel, bel) ->
+ let return = match ret with
+ | None -> []
+ | Some r -> [xmlReturn [pp_expr r]] in
+ xmlApply ?loc
+ (xmlOperator ?loc ~attr:["style", (string_of_case_style sty)] "match" ::
+ (return @
+ [Element ("scrutinees", [], List.map pp_case_expr cel)] @
+ [pp_branch_expr_list bel]))
+ | CRecord _ -> assert false
+ | CLetIn ((varloc, var), value, typ, body) ->
+ let value = match typ with
+ | Some t ->
+ CAst.make ?loc:(Loc.merge_opt (constr_loc value) (constr_loc t)) (CCast (value, CastConv t))
+ | None -> value in
+ xmlApply ?loc
+ (xmlOperator ?loc "let" ::
+ [xmlCst ?loc:varloc (string_of_name var) ; pp_expr value; pp_expr body])
+ | CLambdaN (bl, e) ->
+ xmlApply ?loc
+ (xmlOperator ?loc "lambda" :: [pp_bindlist bl] @ [pp_expr e])
+ | CCoFix (_, _) -> assert false
+ | CFix (lid, fel) ->
+ xmlApply ?loc
+ (xmlOperator ?loc "fix" ::
+ List.flatten (List.map
+ (fun (a,b,cl,c,d) -> pp_fixpoint_expr ((a,None),b,cl,c,Some d))
+ fel))
+
+let pp_comment c =
+ match c with
+ | CommentConstr e -> [pp_expr e]
+ | CommentString s -> [Element ("string", [], [PCData s])]
+ | CommentInt i -> [PCData (string_of_int i)]
+
+let rec tmpp ?loc v =
+ match v with
+ (* Control *)
+ | VernacLoad (verbose,f) ->
+ xmlWithLoc ?loc "load" ["verbose",string_of_bool verbose;"file",f] []
+ | VernacTime (loc,e) ->
+ xmlApply ?loc (Element("time",[],[]) ::
+ [tmpp ?loc e])
+ | VernacRedirect (s, (loc,e)) ->
+ xmlApply ?loc (Element("redirect",["path", s],[]) ::
+ [tmpp ?loc e])
+ | VernacTimeout (s,e) ->
+ xmlApply ?loc (Element("timeout",["val",string_of_int s],[]) ::
+ [tmpp ?loc e])
+ | VernacFail e -> xmlApply ?loc (Element("fail",[],[]) :: [tmpp ?loc e])
+
+ (* Syntax *)
+ | VernacSyntaxExtension (_, ((_, name), sml)) ->
+ let attrs = List.flatten (List.map attribute_of_syntax_modifier sml) in
+ xmlReservedNotation ?loc attrs name
+
+ | VernacOpenCloseScope (_,(true,name)) -> xmlScope ?loc "open" name []
+ | VernacOpenCloseScope (_,(false,name)) -> xmlScope ?loc "close" name []
+ | VernacDelimiters (name,Some tag) ->
+ xmlScope ?loc "delimit" name ~attr:["delimiter",tag] []
+ | VernacDelimiters (name,None) ->
+ xmlScope ?loc "undelimit" name ~attr:[] []
+ | VernacInfix (_,((_,name),sml),ce,sn) ->
+ let attrs = List.flatten (List.map attribute_of_syntax_modifier sml) in
+ let sc_attr =
+ match sn with
+ | Some scope -> ["scope", scope]
+ | None -> [] in
+ xmlNotation ?loc (sc_attr @ attrs) name [pp_expr ce]
+ | VernacNotation (_, ce, (lstr, sml), sn) ->
+ let name = snd lstr in
+ let attrs = List.flatten (List.map attribute_of_syntax_modifier sml) in
+ let sc_attr =
+ match sn with
+ | Some scope -> ["scope", scope]
+ | None -> [] in
+ xmlNotation ?loc (sc_attr @ attrs) name [pp_expr ce]
+ | VernacBindScope _ as x -> xmlTODO ?loc x
+ | VernacNotationAddFormat _ as x -> xmlTODO ?loc x
+ | VernacUniverse _
+ | VernacConstraint _
+ | VernacPolymorphic (_, _) as x -> xmlTODO ?loc x
+ (* Gallina *)
+ | VernacDefinition (ldk, ((_,id),_), de) ->
+ let l, dk =
+ match ldk with
+ | Some l, dk -> (l, dk)
+ | None, dk -> (Global, dk) in (* Like in ppvernac.ml, l 585 *)
+ let e =
+ match de with
+ | ProveBody (_, ce) -> ce
+ | DefineBody (_, Some _, ce, None) -> ce
+ | DefineBody (_, None , ce, None) -> ce
+ | DefineBody (_, Some _, ce, Some _) -> ce
+ | DefineBody (_, None , ce, Some _) -> ce in
+ let str_dk = Kindops.string_of_definition_kind (l, false, dk) in
+ let str_id = Id.to_string id in
+ (xmlDef ?loc str_dk str_id [pp_expr e])
+ | VernacStartTheoremProof (tk, [ Some ((_,id),_), ([], statement, None) ], b) ->
+ let str_tk = Kindops.string_of_theorem_kind tk in
+ let str_id = Id.to_string id in
+ (xmlThm ?loc str_tk str_id [pp_expr statement])
+ | VernacStartTheoremProof _ as x -> xmlTODO ?loc x
+ | VernacEndProof pe ->
+ begin
+ match pe with
+ | Admitted -> xmlQed ?loc ?attr:None
+ | Proved (_, Some ((_, id), Some tk)) ->
+ let nam = Id.to_string id in
+ let typ = Kindops.string_of_theorem_kind tk in
+ xmlQed ?loc ~attr:["name", nam; "type", typ]
+ | Proved (_, Some ((_, id), None)) ->
+ let nam = Id.to_string id in
+ xmlQed ?loc ~attr:["name", nam]
+ | Proved _ -> xmlQed ?loc ?attr:None
+ end
+ | VernacExactProof _ as x -> xmlTODO ?loc x
+ | VernacAssumption ((l, a), _, sbwcl) ->
+ let binders = List.map (fun (_, (id, c)) -> (List.map fst id, c)) sbwcl in
+ let many =
+ List.length (List.flatten (List.map fst binders)) > 1 in
+ let exprs =
+ List.flatten (List.map pp_simple_binder binders) in
+ let l = match l with Some x -> x | None -> Decl_kinds.Global in
+ let kind = string_of_assumption_kind l a many in
+ xmlAssumption ?loc kind exprs
+ | VernacInductive (_, _, _, iednll) ->
+ let kind =
+ let (_, _, _, k, _), _ = List.hd iednll in
+ begin
+ match k with
+ | Record -> "Record"
+ | Structure -> "Structure"
+ | Inductive_kw -> "Inductive"
+ | CoInductive -> "CoInductive"
+ | Class _ -> "Class"
+ | Variant -> "Variant"
+ end in
+ let exprs =
+ List.flatten (* should probably not be flattened *)
+ (List.map
+ (fun (ie, dnl) -> (pp_inductive_expr ie) @
+ (List.map pp_decl_notation dnl)) iednll) in
+ xmlInductive ?loc kind exprs
+ | VernacFixpoint (_, fednll) ->
+ let exprs =
+ List.flatten (* should probably not be flattened *)
+ (List.map
+ (fun (fe, dnl) -> (pp_fixpoint_expr fe) @
+ (List.map pp_decl_notation dnl)) fednll) in
+ xmlFixpoint exprs
+ | VernacCoFixpoint (_, cfednll) ->
+ (* Nota: it is like VernacFixpoint without so could be merged *)
+ let exprs =
+ List.flatten (* should probably not be flattened *)
+ (List.map
+ (fun (cfe, dnl) -> (pp_cofixpoint_expr cfe) @
+ (List.map pp_decl_notation dnl)) cfednll) in
+ xmlCoFixpoint exprs
+ | VernacScheme _ as x -> xmlTODO ?loc x
+ | VernacCombinedScheme _ as x -> xmlTODO ?loc x
+
+ (* Gallina extensions *)
+ | VernacBeginSection (_, id) -> xmlBeginSection ?loc (Id.to_string id)
+ | VernacEndSegment (_, id) -> xmlEndSegment ?loc (Id.to_string id)
+ | VernacNameSectionHypSet _ as x -> xmlTODO ?loc x
+ | VernacRequire (from, import, l) ->
+ let import = match import with
+ | None -> []
+ | Some true -> ["export","true"]
+ | Some false -> ["import","true"]
+ in
+ let from = match from with
+ | None -> []
+ | Some r -> ["from", Libnames.string_of_reference r]
+ in
+ xmlRequire ?loc ~attr:(from @ import) (List.map (fun ref ->
+ xmlReference ref) l)
+ | VernacImport (true,l) ->
+ xmlImport ?loc ~attr:["export","true"] (List.map (fun ref ->
+ xmlReference ref) l)
+ | VernacImport (false,l) ->
+ xmlImport ?loc (List.map (fun ref -> xmlReference ref) l)
+ | VernacCanonical r ->
+ let attr =
+ match r with
+ | AN (Qualid (_, q)) -> ["qualid", string_of_qualid q]
+ | AN (Ident (_, id)) -> ["id", Id.to_string id]
+ | ByNotation (_, (s, _)) -> ["notation", s] in
+ xmlCanonicalStructure ?loc attr
+ | VernacCoercion _ as x -> xmlTODO ?loc x
+ | VernacIdentityCoercion _ as x -> xmlTODO ?loc x
+
+ (* Type classes *)
+ | VernacInstance _ as x -> xmlTODO ?loc x
+
+ | VernacContext _ as x -> xmlTODO ?loc x
+
+ | VernacDeclareInstances _ as x -> xmlTODO ?loc x
+
+ | VernacDeclareClass _ as x -> xmlTODO ?loc x
+
+ (* Modules and Module Types *)
+ | VernacDeclareModule _ as x -> xmlTODO ?loc x
+ | VernacDefineModule _ as x -> xmlTODO ?loc x
+ | VernacDeclareModuleType _ as x -> xmlTODO ?loc x
+ | VernacInclude _ as x -> xmlTODO ?loc x
+
+ (* Solving *)
+
+ | (VernacSolveExistential _) as x ->
+ xmlLtac ?loc [PCData (Pp.string_of_ppcmds (Ppvernac.pr_vernac x))]
+
+ (* Auxiliary file and library management *)
+ | VernacAddLoadPath (recf,name,None) ->
+ xmlAddLoadPath ?loc ~attr:["rec",string_of_bool recf;"path",name] []
+ | VernacAddLoadPath (recf,name,Some dp) ->
+ xmlAddLoadPath ?loc ~attr:["rec",string_of_bool recf;"path",name]
+ [PCData (Names.DirPath.to_string dp)]
+ | VernacRemoveLoadPath name -> xmlRemoveLoadPath ?loc ~attr:["path",name] []
+ | VernacAddMLPath (recf,name) ->
+ xmlAddMLPath ?loc ~attr:["rec",string_of_bool recf;"path",name] []
+ | VernacDeclareMLModule sl -> xmlDeclareMLModule ?loc sl
+ | VernacChdir _ as x -> xmlTODO ?loc x
+
+ (* State management *)
+ | VernacWriteState _ as x -> xmlTODO ?loc x
+ | VernacRestoreState _ as x -> xmlTODO ?loc x
+
+ (* Resetting *)
+ | VernacResetName _ as x -> xmlTODO ?loc x
+ | VernacResetInitial as x -> xmlTODO ?loc x
+ | VernacBack _ as x -> xmlTODO ?loc x
+ | VernacBackTo _ -> PCData "VernacBackTo"
+
+ (* Commands *)
+ | VernacCreateHintDb _ as x -> xmlTODO ?loc x
+ | VernacRemoveHints _ as x -> xmlTODO ?loc x
+ | VernacHints _ as x -> xmlTODO ?loc x
+ | VernacSyntacticDefinition ((_, name), (idl, ce), _, _) ->
+ let name = Id.to_string name in
+ let attrs = List.map (fun id -> ("id", Id.to_string id)) idl in
+ xmlNotation ?loc attrs name [pp_expr ce]
+ | VernacDeclareImplicits _ as x -> xmlTODO ?loc x
+ | VernacArguments _ as x -> xmlTODO ?loc x
+ | VernacArgumentsScope _ as x -> xmlTODO ?loc x
+ | VernacReserve _ as x -> xmlTODO ?loc x
+ | VernacGeneralizable _ as x -> xmlTODO ?loc x
+ | VernacSetOpacity _ as x -> xmlTODO ?loc x
+ | VernacSetStrategy _ as x -> xmlTODO ?loc x
+ | VernacUnsetOption _ as x -> xmlTODO ?loc x
+ | VernacSetOption _ as x -> xmlTODO ?loc x
+ | VernacSetAppendOption _ as x -> xmlTODO ?loc x
+ | VernacAddOption _ as x -> xmlTODO ?loc x
+ | VernacRemoveOption _ as x -> xmlTODO ?loc x
+ | VernacMemOption _ as x -> xmlTODO ?loc x
+ | VernacPrintOption _ as x -> xmlTODO ?loc x
+ | VernacCheckMayEval (_,_,e) -> xmlCheck ?loc [pp_expr e]
+ | VernacGlobalCheck _ as x -> xmlTODO ?loc x
+ | VernacDeclareReduction _ as x -> xmlTODO ?loc x
+ | VernacPrint _ as x -> xmlTODO ?loc x
+ | VernacSearch _ as x -> xmlTODO ?loc x
+ | VernacLocate _ as x -> xmlTODO ?loc x
+ | VernacRegister _ as x -> xmlTODO ?loc x
+ | VernacComments (cl) ->
+ xmlComment ?loc (List.flatten (List.map pp_comment cl))
+
+ (* Stm backdoor *)
+ | VernacStm _ as x -> xmlTODO ?loc x
+
+ (* Proof management *)
+ | VernacGoal _ as x -> xmlTODO ?loc x
+ | VernacAbort _ as x -> xmlTODO ?loc x
+ | VernacAbortAll -> PCData "VernacAbortAll"
+ | VernacRestart as x -> xmlTODO ?loc x
+ | VernacUndo _ as x -> xmlTODO ?loc x
+ | VernacUndoTo _ as x -> xmlTODO ?loc x
+ | VernacBacktrack _ as x -> xmlTODO ?loc x
+ | VernacFocus _ as x -> xmlTODO ?loc x
+ | VernacUnfocus as x -> xmlTODO ?loc x
+ | VernacUnfocused as x -> xmlTODO ?loc x
+ | VernacBullet _ as x -> xmlTODO ?loc x
+ | VernacSubproof _ as x -> xmlTODO ?loc x
+ | VernacEndSubproof as x -> xmlTODO ?loc x
+ | VernacShow _ as x -> xmlTODO ?loc x
+ | VernacCheckGuard as x -> xmlTODO ?loc x
+ | VernacProof (tac,using) ->
+ let tac = None (** FIXME *) in
+ let using = Option.map (xmlSectionSubsetDescr "using") using in
+ xmlProof ?loc (Option.List.(cons tac (cons using [])))
+ | VernacProofMode name -> xmlProofMode ?loc name
+
+ (* Toplevel control *)
+ | VernacToplevelControl _ as x -> xmlTODO ?loc x
+
+ (* For extension *)
+ | VernacExtend _ as x ->
+ xmlExtend ?loc [PCData (Pp.string_of_ppcmds (Ppvernac.pr_vernac x))]
+
+ (* Flags *)
+ | VernacProgram e -> xmlApply ?loc (Element("program",[],[]) :: [tmpp ?loc e])
+ | VernacLocal (b,e) ->
+ xmlApply ?loc (Element("local",["flag",string_of_bool b],[]) ::
+ [tmpp ?loc e])
+
+let tmpp ?loc v =
+ match tmpp ?loc v with
+ | Element("ltac",_,_) as x -> x
+ | xml -> xmlGallina ?loc [xml]
diff --git a/intf/decl_kinds.ml b/intf/decl_kinds.ml
index 8254b1b802..c15c009887 100644
--- a/intf/decl_kinds.ml
+++ b/intf/decl_kinds.ml
@@ -14,7 +14,9 @@ type binding_kind = Explicit | Implicit
type polymorphic = bool
-type private_flag = bool
+type private_flag = bool
+
+type cumulative_inductive_flag = bool
type theorem_kind =
| Theorem
diff --git a/intf/vernacexpr.ml b/intf/vernacexpr.ml
index cabd06735f..26a6db4ec9 100644
--- a/intf/vernacexpr.ml
+++ b/intf/vernacexpr.ml
@@ -336,7 +336,7 @@ type vernac_expr =
| VernacExactProof of constr_expr
| VernacAssumption of (locality option * assumption_object_kind) *
inline * (plident list * constr_expr) with_coercion list
- | VernacInductive of private_flag * inductive_flag * (inductive_expr * decl_notation list) list
+ | VernacInductive of cumulative_inductive_flag * private_flag * inductive_flag * (inductive_expr * decl_notation list) list
| VernacFixpoint of
locality option * (fixpoint_expr * decl_notation list) list
| VernacCoFixpoint of
diff --git a/kernel/declarations.ml b/kernel/declarations.ml
index 1bb1e885f2..ae47324560 100644
--- a/kernel/declarations.ml
+++ b/kernel/declarations.ml
@@ -188,6 +188,8 @@ type mutual_inductive_body = {
mind_polymorphic : bool; (** Is it polymorphic or not *)
+ mind_cumulative : bool; (** Is it cumulative or not *)
+
mind_universes : Univ.universe_info_ind; (** Local universe variables and constraints together with subtyping constraints *)
mind_private : bool option; (** allow pattern-matching: Some true ok, Some false blocked *)
diff --git a/kernel/declareops.ml b/kernel/declareops.ml
index 8838966520..1d91b2d414 100644
--- a/kernel/declareops.ml
+++ b/kernel/declareops.ml
@@ -267,6 +267,7 @@ let subst_mind_body sub mib =
Context.Rel.map (subst_mps sub) mib.mind_params_ctxt;
mind_packets = Array.smartmap (subst_mind_packet sub) mib.mind_packets ;
mind_polymorphic = mib.mind_polymorphic;
+ mind_cumulative = mib.mind_cumulative;
mind_universes = mib.mind_universes;
mind_private = mib.mind_private;
mind_typing_flags = mib.mind_typing_flags;
diff --git a/kernel/entries.mli b/kernel/entries.mli
index 97c28025a4..9c17346f22 100644
--- a/kernel/entries.mli
+++ b/kernel/entries.mli
@@ -49,7 +49,8 @@ type mutual_inductive_entry = {
mind_entry_finite : Decl_kinds.recursivity_kind;
mind_entry_params : (Id.t * local_entry) list;
mind_entry_inds : one_inductive_entry list;
- mind_entry_polymorphic : bool;
+ mind_entry_polymorphic : bool;
+ mind_entry_cumulative : bool;
mind_entry_universes : Univ.universe_info_ind;
(* universe constraints and the constraints for subtyping of
inductive types in the block. *)
diff --git a/kernel/indtypes.ml b/kernel/indtypes.ml
index a4c7a0573c..5cfcbba606 100644
--- a/kernel/indtypes.ml
+++ b/kernel/indtypes.ml
@@ -392,7 +392,7 @@ let typecheck_inductive env mie =
in
(* Check that the subtyping information inferred for inductive types in the block is correct. *)
(* This check produces a value of the unit type if successful or raises an anomaly if check fails. *)
- let () = check_subtyping mie paramsctxt env_arities inds
+ let () = if mie.mind_entry_cumulative then check_subtyping mie paramsctxt env_arities inds
in (env_arities, env_ar_par, paramsctxt, inds)
(************************************************************************)
@@ -864,7 +864,7 @@ let compute_projections ((kn, _ as ind), u as indu) n x nparamargs params
Array.of_list (List.rev kns),
Array.of_list (List.rev pbs)
-let build_inductive env p prv ctx env_ar paramsctxt kn isrecord isfinite inds nmr recargs =
+let build_inductive env cum p prv ctx env_ar paramsctxt kn isrecord isfinite inds nmr recargs =
let ntypes = Array.length inds in
(* Compute the set of used section variables *)
let hyps = used_section_variables env inds in
@@ -969,6 +969,7 @@ let build_inductive env p prv ctx env_ar paramsctxt kn isrecord isfinite inds nm
mind_params_ctxt = paramsctxt;
mind_packets = packets;
mind_polymorphic = p;
+ mind_cumulative = cum;
mind_universes = Univ.UInfoInd.make (ctxunivs, ctxsubtyp);
mind_private = prv;
mind_typing_flags = Environ.typing_flags env;
@@ -984,7 +985,7 @@ let check_inductive env kn mie =
let chkpos = (Environ.typing_flags env).check_guarded in
let (nmr,recargs) = check_positivity ~chkpos kn env_ar_par paramsctxt mie.mind_entry_finite inds in
(* Build the inductive packets *)
- build_inductive env mie.mind_entry_polymorphic mie.mind_entry_private
+ build_inductive env mie.mind_entry_cumulative mie.mind_entry_polymorphic mie.mind_entry_private
mie.mind_entry_universes
env_ar paramsctxt kn mie.mind_entry_record mie.mind_entry_finite
inds nmr recargs
diff --git a/kernel/reduction.ml b/kernel/reduction.ml
index 33dd53a5b1..ea583fdac8 100644
--- a/kernel/reduction.ml
+++ b/kernel/reduction.ml
@@ -191,7 +191,10 @@ type 'a universe_compare =
{ (* Might raise NotConvertible *)
compare : env -> conv_pb -> sorts -> sorts -> 'a -> 'a;
compare_instances: flex:bool -> Univ.Instance.t -> Univ.Instance.t -> 'a -> 'a;
- leq_inductives : flex:bool -> Univ.UInfoInd.t -> Univ.Instance.t -> Univ.Instance.t -> 'a -> 'a;
+ conv_inductives : conv_pb -> (Declarations.mutual_inductive_body * int) -> Univ.Instance.t -> int ->
+ Univ.Instance.t -> int -> 'a -> 'a;
+ conv_constructors : (Declarations.mutual_inductive_body * int * int) ->
+ Univ.Instance.t -> int -> Univ.Instance.t -> int -> 'a -> 'a;
}
type 'a universe_state = 'a * 'a universe_compare
@@ -207,9 +210,12 @@ let sort_cmp_universes env pb s0 s1 (u, check) =
constructors. *)
let convert_instances ~flex u u' (s, check) =
(check.compare_instances ~flex u u' s, check)
+
+let convert_inductives cv_pb ind u1 sv1 u2 sv2 (s, check) =
+ (check.conv_inductives cv_pb ind u1 sv1 u2 sv2 s, check)
-let compare_leq_inductives ~flex uinfind u u' (s, check) =
- (check.leq_inductives ~flex uinfind u u' s, check)
+let convert_constructors cons u1 sv1 u2 sv2 (s, check) =
+ (check.conv_constructors cons u1 sv1 u2 sv2 s, check)
let conv_table_key infos k1 k2 cuniv =
if k1 == k2 then cuniv else
@@ -487,64 +493,31 @@ and eqappr env cv_pb l2r infos (lft1,st1) (lft2,st2) cuniv =
| _ -> raise NotConvertible)
(* Inductive types: MutInd MutConstruct Fix Cofix *)
-
| (FInd (ind1,u1), FInd (ind2,u2)) ->
- if eq_ind ind1 ind2
- then
- begin
- let fall_back () =
- let cuniv = convert_instances ~flex:false u1 u2 cuniv in
- convert_stacks env l2r infos lft1 lft2 v1 v2 cuniv
- in
- let mind = Environ.lookup_mind (fst ind1) env in
- if mind.Declarations.mind_polymorphic then
- begin
- let num_param_arity =
- mind.Declarations.mind_nparams + mind.Declarations.mind_packets.(snd ind1).Declarations.mind_nrealargs
- in
- if not (num_param_arity = CClosure.stack_args_size v1 && num_param_arity = CClosure.stack_args_size v2) then
- fall_back ()
- else
- begin
- let uinfind = mind.Declarations.mind_universes in
- let cuniv = compare_leq_inductives ~flex:false uinfind u1 u2 cuniv in
- let cuniv = if cv_pb = CONV then compare_leq_inductives ~flex:false uinfind u2 u1 cuniv else cuniv in
- convert_stacks env l2r infos lft1 lft2 v1 v2 cuniv
- end
- end
+ if eq_ind ind1 ind2 then
+ let mind = Environ.lookup_mind (fst ind1) env in
+ let cuniv =
+ if mind.Declarations.mind_polymorphic && mind.Declarations.mind_cumulative then
+ convert_inductives cv_pb (mind, snd ind1) u1 (CClosure.stack_args_size v1)
+ u2 (CClosure.stack_args_size v2) cuniv
else
- fall_back ()
- end
+ convert_instances ~flex:false u1 u2 cuniv
+ in
+ convert_stacks env l2r infos lft1 lft2 v1 v2 cuniv
else raise NotConvertible
| (FConstruct ((ind1,j1),u1), FConstruct ((ind2,j2),u2)) ->
- if Int.equal j1 j2 && eq_ind ind1 ind2
- then
- begin
- let fall_back () =
- let cuniv = convert_instances ~flex:false u1 u2 cuniv in
- convert_stacks env l2r infos lft1 lft2 v1 v2 cuniv
- in
- let mind = Environ.lookup_mind (fst ind1) env in
- if mind.Declarations.mind_polymorphic then
- begin
- let num_cnstr_args =
- let nparamsctxt = Context.Rel.length mind.Declarations.mind_params_ctxt in
- nparamsctxt + mind.Declarations.mind_packets.(snd ind1).Declarations.mind_consnrealargs.(j1 - 1)
- in
- if not (num_cnstr_args = CClosure.stack_args_size v1 && num_cnstr_args = CClosure.stack_args_size v2) then
- fall_back ()
- else
- begin (* we consider subtyping for constructors. *)
- let uinfind = mind.Declarations.mind_universes in
- let cuniv = compare_leq_inductives ~flex:false uinfind u1 u2 cuniv in
- let cuniv = compare_leq_inductives ~flex:false uinfind u2 u1 cuniv in
- convert_stacks env l2r infos lft1 lft2 v1 v2 cuniv
- end
- end
+ if Int.equal j1 j2 && eq_ind ind1 ind2 then
+ let mind = Environ.lookup_mind (fst ind1) env in
+ let cuniv =
+ if mind.Declarations.mind_polymorphic && mind.Declarations.mind_cumulative then
+ convert_constructors
+ (mind, snd ind1, j1) u1 (CClosure.stack_args_size v1)
+ u2 (CClosure.stack_args_size v2) cuniv
else
- fall_back ()
- end
+ convert_instances ~flex:false u1 u2 cuniv
+ in
+ convert_stacks env l2r infos lft1 lft2 v1 v2 cuniv
else raise NotConvertible
(* Eta expansion of records *)
@@ -659,24 +632,79 @@ let check_convert_instances ~flex u u' univs =
if UGraph.check_eq_instances univs u u' then univs
else raise NotConvertible
-let check_leq_inductives ~flex uinfind u u' univs =
+(* general conversion and inference functions *)
+let infer_check_conv_inductives
+ infer_check_convert_instances
+ infer_check_inductive_instances
+ cv_pb (mind, ind) u1 sv1 u2 sv2 univs =
+ if mind.Declarations.mind_polymorphic then
+ let num_param_arity =
+ mind.Declarations.mind_nparams + mind.Declarations.mind_packets.(ind).Declarations.mind_nrealargs
+ in
+ if not (num_param_arity = sv1 && num_param_arity = sv2) then
+ infer_check_convert_instances ~flex:false u1 u2 univs
+ else
+ let uinfind = mind.Declarations.mind_universes in
+ infer_check_inductive_instances cv_pb uinfind u1 u2 univs
+ else infer_check_convert_instances ~flex:false u1 u2 univs
+
+let infer_check_conv_constructors
+ infer_check_convert_instances
+ infer_check_inductive_instances
+ (mind, ind, cns) u1 sv1 u2 sv2 univs =
+ if mind.Declarations.mind_polymorphic then
+ let num_cnstr_args =
+ let nparamsctxt =
+ mind.Declarations.mind_nparams + mind.Declarations.mind_packets.(ind).Declarations.mind_nrealargs
+ (* Context.Rel.length mind.Declarations.mind_params_ctxt *) in
+ nparamsctxt + mind.Declarations.mind_packets.(ind).Declarations.mind_consnrealargs.(cns - 1)
+ in
+ if not (num_cnstr_args = sv1 && num_cnstr_args = sv2) then
+ infer_check_convert_instances ~flex:false u1 u2 univs
+ else
+ let uinfind = mind.Declarations.mind_universes in
+ infer_check_inductive_instances CONV uinfind u1 u2 univs
+ else infer_check_convert_instances ~flex:false u1 u2 univs
+
+let check_inductive_instances cv_pb uinfind u u' univs =
let ind_instance = Univ.UContext.instance (Univ.UInfoInd.univ_context uinfind) in
let ind_sbcst = Univ.UContext.constraints (Univ.UInfoInd.subtyp_context uinfind) in
if not ((Univ.Instance.length ind_instance = Univ.Instance.length u) &&
(Univ.Instance.length ind_instance = Univ.Instance.length u')) then
anomaly (Pp.str "Invalid inductive subtyping encountered!")
else
- begin
- let comp_subst = (Univ.Instance.append u u') in
- let comp_cst = Univ.subst_instance_constraints comp_subst ind_sbcst in
- if UGraph.check_constraints comp_cst univs then univs
- else raise NotConvertible
- end
+ let comp_cst =
+ let comp_subst = (Univ.Instance.append u u') in
+ Univ.subst_instance_constraints comp_subst ind_sbcst
+ in
+ let comp_cst =
+ match cv_pb with
+ CONV ->
+ let comp_subst = (Univ.Instance.append u' u) in
+ let comp_cst' = (Univ.subst_instance_constraints comp_subst ind_sbcst) in
+ Univ.Constraint.union comp_cst comp_cst'
+ | CUMUL -> comp_cst
+ in
+ if (UGraph.check_constraints comp_cst univs) then univs
+ else raise NotConvertible
+
+let check_conv_inductives cv_pb ind u1 sv1 u2 sv2 univs =
+ infer_check_conv_inductives
+ check_convert_instances
+ check_inductive_instances
+ cv_pb ind u1 sv1 u2 sv2 univs
+
+let check_conv_constructors cns u1 sv1 u2 sv2 univs =
+ infer_check_conv_constructors
+ check_convert_instances
+ check_inductive_instances
+ cns u1 sv1 u2 sv2 univs
let checked_universes =
{ compare = checked_sort_cmp_universes;
compare_instances = check_convert_instances;
- leq_inductives = check_leq_inductives }
+ conv_inductives = check_conv_inductives;
+ conv_constructors = check_conv_constructors}
let infer_eq (univs, cstrs as cuniv) u u' =
if UGraph.check_eq univs u u' then cuniv
@@ -718,21 +746,45 @@ let infer_convert_instances ~flex u u' (univs,cstrs) =
else Univ.enforce_eq_instances u u' cstrs
in (univs, cstrs')
-let infer_leq_inductives ~flex uinfind u u' (univs, cstrs) =
+let infer_inductive_instances cv_pb uinfind u u' (univs, cstrs) =
let ind_instance = Univ.UContext.instance (Univ.UInfoInd.univ_context uinfind) in
let ind_sbcst = Univ.UContext.constraints (Univ.UInfoInd.subtyp_context uinfind) in
if not ((Univ.Instance.length ind_instance = Univ.Instance.length u) &&
(Univ.Instance.length ind_instance = Univ.Instance.length u')) then
anomaly (Pp.str "Invalid inductive subtyping encountered!")
else
- let comp_subst = (Univ.Instance.append u u') in
- let comp_cst = Univ.subst_instance_constraints comp_subst ind_sbcst in
- (univs, Univ.Constraint.union cstrs comp_cst)
-
+ let comp_cst =
+ let comp_subst = (Univ.Instance.append u u') in
+ Univ.subst_instance_constraints comp_subst ind_sbcst
+ in
+ let comp_cst =
+ match cv_pb with
+ CONV ->
+ let comp_subst = (Univ.Instance.append u' u) in
+ let comp_cst' = (Univ.subst_instance_constraints comp_subst ind_sbcst) in
+ Univ.Constraint.union comp_cst comp_cst'
+ | CUMUL -> comp_cst
+ in
+ (univs, Univ.Constraint.union cstrs comp_cst)
+
+
+let infer_conv_inductives cv_pb ind u1 sv1 u2 sv2 univs =
+ infer_check_conv_inductives
+ infer_convert_instances
+ infer_inductive_instances
+ cv_pb ind u1 sv1 u2 sv2 univs
+
+let infer_conv_constructors cns u1 sv1 u2 sv2 univs =
+ infer_check_conv_constructors
+ infer_convert_instances
+ infer_inductive_instances
+ cns u1 sv1 u2 sv2 univs
+
let inferred_universes : (UGraph.t * Univ.Constraint.t) universe_compare =
{ compare = infer_cmp_universes;
compare_instances = infer_convert_instances;
- leq_inductives = infer_leq_inductives }
+ conv_inductives = infer_conv_inductives;
+ conv_constructors = infer_conv_constructors}
let gen_conv cv_pb l2r reds env evars univs t1 t2 =
let b =
diff --git a/kernel/reduction.mli b/kernel/reduction.mli
index 72f0ecffd0..b6d88c2b9b 100644
--- a/kernel/reduction.mli
+++ b/kernel/reduction.mli
@@ -36,12 +36,13 @@ type 'a extended_conversion_function =
type conv_pb = CONV | CUMUL
type 'a universe_compare =
- { (* Might raise NotConvertible or UnivInconsistency *)
+ { (* Might raise NotConvertible *)
compare : env -> conv_pb -> sorts -> sorts -> 'a -> 'a;
- compare_instances: flex:bool ->
- Univ.Instance.t -> Univ.Instance.t -> 'a -> 'a;
- leq_inductives : flex:bool -> Univ.UInfoInd.t ->
- Univ.Instance.t -> Univ.Instance.t -> 'a -> 'a;
+ compare_instances: flex:bool -> Univ.Instance.t -> Univ.Instance.t -> 'a -> 'a;
+ conv_inductives : conv_pb -> (Declarations.mutual_inductive_body * int) -> Univ.Instance.t -> int ->
+ Univ.Instance.t -> int -> 'a -> 'a;
+ conv_constructors : (Declarations.mutual_inductive_body * int * int) ->
+ Univ.Instance.t -> int -> Univ.Instance.t -> int -> 'a -> 'a;
}
type 'a universe_state = 'a * 'a universe_compare
diff --git a/lib/flags.ml b/lib/flags.ml
index 13539bced3..46bbba8e55 100644
--- a/lib/flags.ml
+++ b/lib/flags.ml
@@ -163,6 +163,10 @@ let use_polymorphic_flag () =
let make_polymorphic_flag b =
local_polymorphic_flag := Some b
+let inductive_cumulativity = ref false
+let make_inductive_cumulativity b = inductive_cumulativity := b
+let is_inductive_cumulativity () = !inductive_cumulativity
+
(** [program_mode] tells that Program mode has been activated, either
globally via [Set Program] or locally via the Program command prefix. *)
diff --git a/lib/flags.mli b/lib/flags.mli
index 0026aba2e3..5e78f0a041 100644
--- a/lib/flags.mli
+++ b/lib/flags.mli
@@ -119,6 +119,10 @@ val is_universe_polymorphism : unit -> bool
val make_polymorphic_flag : bool -> unit
val use_polymorphic_flag : unit -> bool
+(** Global inductive cumulativity flag. *)
+val make_inductive_cumulativity : bool -> unit
+val is_inductive_cumulativity : unit -> bool
+
val warn : bool ref
val make_warn : bool -> unit
val if_warn : ('a -> unit) -> 'a -> unit
diff --git a/library/declare.ml b/library/declare.ml
index bf5313545c..e2b726f457 100644
--- a/library/declare.ml
+++ b/library/declare.ml
@@ -352,13 +352,14 @@ let dummy_inductive_entry (_,m) = ([],{
mind_entry_finite = Decl_kinds.BiFinite;
mind_entry_inds = List.map dummy_one_inductive_entry m.mind_entry_inds;
mind_entry_polymorphic = false;
+ mind_entry_cumulative = false;
mind_entry_universes = Univ.UInfoInd.empty;
mind_entry_private = None;
})
(* reinfer subtyping constraints for inductive after section is dischared. *)
let infer_inductive_subtyping (pth, mind_ent) =
- if mind_ent.mind_entry_polymorphic then
+ if mind_ent.mind_entry_polymorphic && mind_ent.mind_entry_cumulative then
begin
let env = Global.env () in
let env' =
@@ -370,7 +371,6 @@ let infer_inductive_subtyping (pth, mind_ent) =
end
else (pth, mind_ent)
-
type inductive_obj = Dischargedhypsmap.discharged_hyps * mutual_inductive_entry
let inInductive : inductive_obj -> obj =
diff --git a/parsing/g_vernac.ml4 b/parsing/g_vernac.ml4
index b605a44c87..e6b28b1d87 100644
--- a/parsing/g_vernac.ml4
+++ b/parsing/g_vernac.ml4
@@ -162,11 +162,16 @@ GEXTEND Gram
| IDENT "Let"; id = identref; b = def_body ->
VernacDefinition ((Some Discharge, Definition), (id, None), b)
(* Gallina inductive declarations *)
- | priv = private_token; f = finite_token;
+ | cum = cumulativity_token; priv = private_token; f = finite_token;
indl = LIST1 inductive_definition SEP "with" ->
let (k,f) = f in
- let indl=List.map (fun ((a,b,c,d),e) -> ((a,b,c,k,d),e)) indl in
- VernacInductive (priv,f,indl)
+ let indl=List.map (fun ((a,b,c,d),e) -> ((a,b,c,k,d),e)) indl in
+ let cum =
+ match cum with
+ Some b -> b
+ | None -> Flags.is_inductive_cumulativity ()
+ in
+ VernacInductive (cum, priv,f,indl)
| "Fixpoint"; recs = LIST1 rec_definition SEP "with" ->
VernacFixpoint (None, recs)
| IDENT "Let"; "Fixpoint"; recs = LIST1 rec_definition SEP "with" ->
@@ -234,6 +239,9 @@ GEXTEND Gram
| IDENT "Structure" -> (Structure,BiFinite)
| IDENT "Class" -> (Class true,BiFinite) ] ]
;
+ cumulativity_token:
+ [ [ IDENT "Cumulative" -> Some true | IDENT "NonCumulative" -> Some false | -> None ] ]
+ ;
private_token:
[ [ IDENT "Private" -> true | -> false ] ]
;
diff --git a/plugins/funind/glob_term_to_relation.ml b/plugins/funind/glob_term_to_relation.ml
index 0e2ca49000..db2af2be53 100644
--- a/plugins/funind/glob_term_to_relation.ml
+++ b/plugins/funind/glob_term_to_relation.ml
@@ -1459,7 +1459,9 @@ let do_build_inductive
(* in *)
let _time2 = System.get_time () in
try
- with_full_print (Flags.silently (Command.do_mutual_inductive rel_inds (Flags.is_universe_polymorphism ()) false)) Decl_kinds.Finite
+ with_full_print
+ (Flags.silently (Command.do_mutual_inductive rel_inds (Flags.is_universe_polymorphism ()) false false))
+ Decl_kinds.Finite
with
| UserError(s,msg) as e ->
let _time3 = System.get_time () in
@@ -1470,7 +1472,7 @@ let do_build_inductive
in
let msg =
str "while trying to define"++ spc () ++
- Ppvernac.pr_vernac (Vernacexpr.VernacInductive(false,Decl_kinds.Finite,repacked_rel_inds))
+ Ppvernac.pr_vernac (Vernacexpr.VernacInductive(false,false,Decl_kinds.Finite,repacked_rel_inds))
++ fnl () ++
msg
in
@@ -1485,7 +1487,7 @@ let do_build_inductive
in
let msg =
str "while trying to define"++ spc () ++
- Ppvernac.pr_vernac (Vernacexpr.VernacInductive(false,Decl_kinds.Finite,repacked_rel_inds))
+ Ppvernac.pr_vernac (Vernacexpr.VernacInductive(false,false,Decl_kinds.Finite,repacked_rel_inds))
++ fnl () ++
CErrors.print reraise
in
diff --git a/plugins/funind/merge.ml b/plugins/funind/merge.ml
index c75f7f868c..ba88563d3b 100644
--- a/plugins/funind/merge.ml
+++ b/plugins/funind/merge.ml
@@ -880,7 +880,7 @@ let merge_inductive (ind1: inductive) (ind2: inductive)
(* Declare inductive *)
let indl,_,_ = Command.extract_mutual_inductive_declaration_components [(indexpr,[])] in
let mie,pl,impls = Command.interp_mutual_inductive indl []
- false (*FIXMEnon-poly *) false (* means not private *) Decl_kinds.Finite (* means: not coinductive *) in
+ false (* non-cumulative *) false (*FIXMEnon-poly *) false (* means not private *) Decl_kinds.Finite (* means: not coinductive *) in
(* Declare the mutual inductive block with its associated schemes *)
ignore (Command.declare_mutual_inductive_with_eliminations mie pl impls)
diff --git a/pretyping/evarconv.ml b/pretyping/evarconv.ml
index ea22c3708f..be2fd81290 100644
--- a/pretyping/evarconv.ml
+++ b/pretyping/evarconv.ml
@@ -494,6 +494,7 @@ and evar_eqappr_x ?(rhs_is_already_stuck = false) ts env evd pbty
if mind.Declarations.mind_polymorphic then
begin
let num_param_arity =
+ (* Context.Rel.length (mind.Declarations.mind_packets.(snd ind).Declarations.mind_arity_ctxt) *)
mind.Declarations.mind_nparams + mind.Declarations.mind_packets.(snd ind).Declarations.mind_nrealargs
in
if not (num_param_arity = nparamsaplied && num_param_arity = nparamsaplied') then
@@ -521,6 +522,7 @@ and evar_eqappr_x ?(rhs_is_already_stuck = false) ts env evd pbty
begin
let num_cnstr_args =
let nparamsctxt =
+ (* Context.Rel.length mind.Declarations.mind_params_ctxt *)
mind.Declarations.mind_nparams + mind.Declarations.mind_packets.(snd ind).Declarations.mind_nrealargs
in
nparamsctxt + mind.Declarations.mind_packets.(snd ind).Declarations.mind_consnrealargs.(j - 1)
diff --git a/pretyping/reductionops.ml b/pretyping/reductionops.ml
index e374f7b3bb..2040acba79 100644
--- a/pretyping/reductionops.ml
+++ b/pretyping/reductionops.ml
@@ -1361,24 +1361,68 @@ let sigma_compare_instances ~flex i0 i1 sigma =
| Univ.UniverseInconsistency _ ->
raise Reduction.NotConvertible
-let sigma_leq_inductives ~flex uinfind i0 i1 sigma =
+let sigma_check_inductive_instances cv_pb uinfind u u' sigma =
let ind_instance = Univ.UContext.instance (Univ.UInfoInd.univ_context uinfind) in
let ind_sbcst = Univ.UContext.constraints (Univ.UInfoInd.subtyp_context uinfind) in
- if not ((Univ.Instance.length ind_instance = Univ.Instance.length i0) &&
- (Univ.Instance.length ind_instance = Univ.Instance.length i1)) then
+ if not ((Univ.Instance.length ind_instance = Univ.Instance.length u) &&
+ (Univ.Instance.length ind_instance = Univ.Instance.length u')) then
anomaly (Pp.str "Invalid inductive subtyping encountered!")
else
- let comp_subst = (Univ.Instance.append i0 i1) in
- let comp_cst = Univ.subst_instance_constraints comp_subst ind_sbcst in
- try Evd.add_constraints sigma comp_cst
- with Evd.UniversesDiffer
- | Univ.UniverseInconsistency _ ->
- raise Reduction.NotConvertible
+ let comp_cst =
+ let comp_subst = (Univ.Instance.append u u') in
+ Univ.subst_instance_constraints comp_subst ind_sbcst
+ in
+ let comp_cst =
+ match cv_pb with
+ Reduction.CONV ->
+ let comp_subst = (Univ.Instance.append u' u) in
+ let comp_cst' = (Univ.subst_instance_constraints comp_subst ind_sbcst) in
+ Univ.Constraint.union comp_cst comp_cst'
+ | Reduction.CUMUL -> comp_cst
+ in
+ try Evd.add_constraints sigma comp_cst
+ with Evd.UniversesDiffer
+ | Univ.UniverseInconsistency _ ->
+ raise Reduction.NotConvertible
+
+let sigma_conv_inductives
+ cv_pb (mind, ind) u1 sv1 u2 sv2 sigma =
+ try sigma_compare_instances ~flex:false u1 u2 sigma with
+ Reduction.NotConvertible ->
+ if mind.Declarations.mind_polymorphic then
+ let num_param_arity =
+ mind.Declarations.mind_nparams + mind.Declarations.mind_packets.(ind).Declarations.mind_nrealargs
+ in
+ if not (num_param_arity = sv1 && num_param_arity = sv2) then
+ raise Reduction.NotConvertible
+ else
+ let uinfind = mind.Declarations.mind_universes in
+ sigma_check_inductive_instances cv_pb uinfind u1 u2 sigma
+ else raise Reduction.NotConvertible
+
+let sigma_conv_constructors
+ (mind, ind, cns) u1 sv1 u2 sv2 sigma =
+ try sigma_compare_instances ~flex:false u1 u2 sigma with
+ Reduction.NotConvertible ->
+ if mind.Declarations.mind_polymorphic then
+ let num_cnstr_args =
+ let nparamsctxt =
+ mind.Declarations.mind_nparams + mind.Declarations.mind_packets.(ind).Declarations.mind_nrealargs
+ (* Context.Rel.length mind.Declarations.mind_params_ctxt *) in
+ nparamsctxt + mind.Declarations.mind_packets.(ind).Declarations.mind_consnrealargs.(cns - 1)
+ in
+ if not (num_cnstr_args = sv1 && num_cnstr_args = sv2) then
+ raise Reduction.NotConvertible
+ else
+ let uinfind = mind.Declarations.mind_universes in
+ sigma_check_inductive_instances Reduction.CONV uinfind u1 u2 sigma
+ else raise Reduction.NotConvertible
let sigma_univ_state =
{ Reduction.compare = sigma_compare_sorts;
Reduction.compare_instances = sigma_compare_instances;
- Reduction.leq_inductives = sigma_leq_inductives }
+ Reduction.conv_inductives = sigma_conv_inductives;
+ Reduction.conv_constructors = sigma_conv_constructors}
let infer_conv_gen conv_fun ?(catch_incon=true) ?(pb=Reduction.CUMUL)
?(ts=full_transparent_state) env sigma x y =
diff --git a/printing/ppvernac.ml b/printing/ppvernac.ml
index 9d28bc4f84..6a47c308d3 100644
--- a/printing/ppvernac.ml
+++ b/printing/ppvernac.ml
@@ -727,7 +727,7 @@ open Decl_kinds
let assumptions = prlist_with_sep spc (fun p -> hov 1 (str "(" ++ pr_params p ++ str ")")) l in
return (hov 2 (pr_assumption_token (n > 1) stre ++
pr_non_empty_arg pr_assumption_inline t ++ spc() ++ assumptions))
- | VernacInductive (p,f,l) ->
+ | VernacInductive (cum, p,f,l) ->
let pr_constructor (coe,(id,c)) =
hov 2 (pr_lident id ++ str" " ++
(if coe then str":>" else str":") ++
@@ -754,13 +754,17 @@ open Decl_kinds
in
let key =
let (_,_,_,k,_),_ = List.hd l in
- match k with Record -> "Record" | Structure -> "Structure"
- | Inductive_kw -> "Inductive" | CoInductive -> "CoInductive"
- | Class _ -> "Class" | Variant -> "Variant"
+ let kind =
+ match k with Record -> "Record" | Structure -> "Structure"
+ | Inductive_kw -> "Inductive" | CoInductive -> "CoInductive"
+ | Class _ -> "Class" | Variant -> "Variant"
+ in
+ let cm = if cum then "Cumulative" else "NonCumulative" in
+ cm ^ " " ^ kind
in
return (
hov 1 (pr_oneind key (List.hd l)) ++
- (prlist (fun ind -> fnl() ++ hov 1 (pr_oneind "with" ind)) (List.tl l))
+ (prlist (fun ind -> fnl() ++ hov 1 (pr_oneind "with" ind)) (List.tl l))
)
| VernacFixpoint (local, recs) ->
diff --git a/stm/vernac_classifier.ml b/stm/vernac_classifier.ml
index 471e05e458..87d9e411a7 100644
--- a/stm/vernac_classifier.ml
+++ b/stm/vernac_classifier.ml
@@ -142,7 +142,7 @@ let rec classify_vernac e =
let ids = List.flatten (List.map (fun (_,(l,_)) -> List.map (fun (id, _) -> snd id) l) l) in
VtSideff ids, VtLater
| VernacDefinition (_,((_,id),_),DefineBody _) -> VtSideff [id], VtLater
- | VernacInductive (_,_,l) ->
+ | VernacInductive (_, _,_,l) ->
let ids = List.map (fun (((_,((_,id),_)),_,_,_,cl),_) -> id :: match cl with
| Constructors l -> List.map (fun (_,((_,id),_)) -> id) l
| RecordDecl (oid,l) -> (match oid with Some (_,x) -> [x] | _ -> []) @
diff --git a/test-suite/bugs/closed/3330.v b/test-suite/bugs/closed/3330.v
index e3b5e94356..a497e7a987 100644
--- a/test-suite/bugs/closed/3330.v
+++ b/test-suite/bugs/closed/3330.v
@@ -41,6 +41,8 @@ Notation "g 'o' f" := (compose g f) (at level 40, left associativity) : function
Open Scope function_scope.
+Set Printing Universes. Set Printing All.
+
Inductive paths {A : Type} (a : A) : A -> Type :=
idpath : paths a a.
@@ -156,7 +158,8 @@ Delimit Scope morphism_scope with morphism.
Delimit Scope category_scope with category.
Delimit Scope object_scope with object.
-
+Set Printing Universes.
+Set Printing All.
Record PreCategory :=
Build_PreCategory' {
object :> Type;
@@ -1069,8 +1072,10 @@ Section Adjunction.
Variable F : Functor C D.
Variable G : Functor D C.
- Let Adjunction_Type :=
- Eval simpl in (hom_functor D) o (F^op, 1) <~=~> (hom_functor C) o (1, G).
+(* Let Adjunction_Type :=
+ Eval simpl in (hom_functor D) o (F^op, 1) <~=~> (hom_functor C) o (1, G).*)
+
+ Set Printing All. Set Printing Universes.
Record AdjunctionHom :=
{
diff --git a/test-suite/success/polymorphism.v b/test-suite/success/polymorphism.v
index 3e90825ab2..f57cbcc2b7 100644
--- a/test-suite/success/polymorphism.v
+++ b/test-suite/success/polymorphism.v
@@ -316,26 +316,6 @@ Module Hurkens'.
Polymorphic Record box (X : Type) (T := Type) : Type := wrap { unwrap : T }.
-Section test_letin_subtyping.
- Universe i j k i' j' k'.
- Constraint j < j'.
-
- Context (W : Type) (X : box@{i j k} W).
- Definition Y := X : box@{i' j' k'} W.
-
- Universe i1 j1 k1 i2 j2 k2.
- Constraint i1 < i2, k2 < k1.
- Definition Z : box@{i1 j1 k1} W := {| unwrap := W |}.
- Definition Z' : box@{i2 j2 k2} W := {| unwrap := W |}.
- Lemma ZZ' : @eq (box@{i2 j2 k2} W) Z Z'.
- Proof.
- Set Printing All. Set Printing Universes.
- cbv.
- reflexivity.
- Qed.
-
-End test_letin_subtyping.
-
Definition unwrap' := fun (X : Type) (b : box X) => let (unw) := b in unw.
Fail Definition bad : False := TypeNeqSmallType.paradox (unwrap' Type (wrap _
@@ -372,3 +352,35 @@ Module Anonymous.
Check collapsethemiddle@{_ _}.
End Anonymous.
+
+Module F.
+ Context {A B : Type}.
+ Definition foo : Type := B.
+End F.
+
+Set Universe Polymorphism.
+
+Record box (X : Type) (T := Type) : Type := wrap { unwrap : T }.
+
+Section test_letin_subtyping.
+ Universe i j k i' j' k'.
+ Constraint j < j'.
+
+ Context (W : Type) (X : box@{i j k} W).
+ Definition Y := X : box@{i' j' k'} W.
+
+ Universe i1 j1 k1 i2 j2 k2.
+ Constraint i1 < i2.
+ Constraint k2 < k1.
+ Context (V : Type).
+
+ Definition Z : box@{i1 j1 k1} V := {| unwrap := V |}.
+ Definition Z' : box@{i2 j2 k2} V := {| unwrap := V |}.
+ Lemma ZZ' : @eq (box@{i2 j2 k2} V) Z Z'.
+ Proof.
+ Set Printing All. Set Printing Universes.
+ cbv.
+ reflexivity.
+ Qed.
+
+End test_letin_subtyping.
diff --git a/vernac/command.ml b/vernac/command.ml
index 6c59976232..2345cb4c51 100644
--- a/vernac/command.ml
+++ b/vernac/command.ml
@@ -573,7 +573,7 @@ let check_param = function
| CLocalAssum (nas, Generalized _, _) -> ()
| CLocalPattern _ -> assert false
-let interp_mutual_inductive (paramsl,indl) notations poly prv finite =
+let interp_mutual_inductive (paramsl,indl) notations cum poly prv finite =
check_all_names_different indl;
List.iter check_param paramsl;
let env0 = Global.env() in
@@ -657,6 +657,7 @@ let interp_mutual_inductive (paramsl,indl) notations poly prv finite =
mind_entry_finite = finite;
mind_entry_inds = entries;
mind_entry_polymorphic = poly;
+ mind_entry_cumulative = cum;
mind_entry_private = if prv then Some false else None;
mind_entry_universes = ground_uinfind;
}
@@ -747,10 +748,10 @@ type one_inductive_impls =
Impargs.manual_explicitation list (* for inds *)*
Impargs.manual_explicitation list list (* for constrs *)
-let do_mutual_inductive indl poly prv finite =
+let do_mutual_inductive indl cum poly prv finite =
let indl,coes,ntns = extract_mutual_inductive_declaration_components indl in
(* Interpret the types *)
- let mie,pl,impls = interp_mutual_inductive indl ntns poly prv finite in
+ let mie,pl,impls = interp_mutual_inductive indl ntns cum poly prv finite in
(* Declare the mutual inductive block with its associated schemes *)
ignore (declare_mutual_inductive_with_eliminations mie pl impls);
(* Declare the possible notations of inductive types *)
diff --git a/vernac/command.mli b/vernac/command.mli
index 2a52d9bcb5..a636bc03c5 100644
--- a/vernac/command.mli
+++ b/vernac/command.mli
@@ -90,9 +90,9 @@ type one_inductive_impls =
Impargs.manual_implicits list (** for constrs *)
val interp_mutual_inductive :
- structured_inductive_expr -> decl_notation list -> polymorphic ->
- private_flag -> Decl_kinds.recursivity_kind ->
- mutual_inductive_entry * Universes.universe_binders * one_inductive_impls list
+ structured_inductive_expr -> decl_notation list -> cumulative_inductive_flag ->
+ polymorphic -> private_flag -> Decl_kinds.recursivity_kind ->
+ mutual_inductive_entry * Universes.universe_binders * one_inductive_impls list
(** Registering a mutual inductive definition together with its
associated schemes *)
@@ -104,8 +104,8 @@ val declare_mutual_inductive_with_eliminations :
(** Entry points for the vernacular commands Inductive and CoInductive *)
val do_mutual_inductive :
- (one_inductive_expr * decl_notation list) list -> polymorphic ->
- private_flag -> Decl_kinds.recursivity_kind -> unit
+ (one_inductive_expr * decl_notation list) list -> cumulative_inductive_flag ->
+ polymorphic -> private_flag -> Decl_kinds.recursivity_kind -> unit
(** {6 Fixpoints and cofixpoints} *)
diff --git a/vernac/discharge.ml b/vernac/discharge.ml
index c7a741c13f..738e27f635 100644
--- a/vernac/discharge.ml
+++ b/vernac/discharge.ml
@@ -116,6 +116,7 @@ let process_inductive (sechyps,abs_ctx) modlist mib =
mind_entry_params = params';
mind_entry_inds = inds';
mind_entry_polymorphic = mib.mind_polymorphic;
+ mind_entry_cumulative = mib.mind_cumulative;
mind_entry_private = mib.mind_private;
mind_entry_universes = univ_info_ind
}
diff --git a/vernac/record.ml b/vernac/record.ml
index 093a31c194..8a83dceeff 100644
--- a/vernac/record.ml
+++ b/vernac/record.ml
@@ -377,7 +377,7 @@ let structure_signature ctx =
open Typeclasses
-let declare_structure finite poly ctx id idbuild paramimpls params arity template
+let declare_structure finite cum poly ctx id idbuild paramimpls params arity template
fieldimpls fields ?(kind=StructureComponent) ?name is_coe coers sign =
let nparams = List.length params and nfields = List.length fields in
let args = Context.Rel.to_extended_list mkRel nfields params in
@@ -401,6 +401,7 @@ let declare_structure finite poly ctx id idbuild paramimpls params arity templat
mind_entry_finite = finite;
mind_entry_inds = [mie_ind];
mind_entry_polymorphic = poly;
+ mind_entry_cumulative = cum;
mind_entry_private = None;
mind_entry_universes = ctx;
}
@@ -435,7 +436,7 @@ let implicits_of_context ctx =
in ExplByPos (i, explname), (true, true, true))
1 (List.rev (Anonymous :: (List.map RelDecl.get_name ctx)))
-let declare_class finite def poly ctx id idbuild paramimpls params arity
+let declare_class finite def cum poly ctx id idbuild paramimpls params arity
template fieldimpls fields ?(kind=StructureComponent) is_coe coers priorities sign =
let fieldimpls =
(* Make the class implicit in the projections, and the params if applicable. *)
@@ -478,7 +479,7 @@ let declare_class finite def poly ctx id idbuild paramimpls params arity
in
cref, [Name proj_name, sub, Some proj_cst]
| _ ->
- let ind = declare_structure BiFinite poly (Universes.univ_inf_ind_from_universe_context ctx) (snd id) idbuild paramimpls
+ let ind = declare_structure BiFinite cum poly (Universes.univ_inf_ind_from_universe_context ctx) (snd id) idbuild paramimpls
params arity template fieldimpls fields
~kind:Method ~name:binder_name false (List.map (fun _ -> false) fields) sign
in
@@ -552,7 +553,7 @@ open Vernacexpr
(* [fs] corresponds to fields and [ps] to parameters; [coers] is a
list telling if the corresponding fields must me declared as coercions
or subinstances. *)
-let definition_structure (kind,poly,finite,(is_coe,((loc,idstruc),pl)),ps,cfs,idbuild,s) =
+let definition_structure (kind,cum,poly,finite,(is_coe,((loc,idstruc),pl)),ps,cfs,idbuild,s) =
let cfs,notations = List.split cfs in
let cfs,priorities = List.split cfs in
let coers,fs = List.split cfs in
@@ -576,14 +577,14 @@ let definition_structure (kind,poly,finite,(is_coe,((loc,idstruc),pl)),ps,cfs,id
let gr = match kind with
| Class def ->
let priorities = List.map (fun id -> {hint_priority = id; hint_pattern = None}) priorities in
- let gr = declare_class finite def poly ctx (loc,idstruc) idbuild
+ let gr = declare_class finite def cum poly ctx (loc,idstruc) idbuild
implpars params arity template implfs fields is_coe coers priorities sign in
gr
| _ ->
let implfs = List.map
(fun impls -> implpars @ Impargs.lift_implicits
(succ (List.length params)) impls) implfs in
- let ind = declare_structure finite poly (Universes.univ_inf_ind_from_universe_context ctx) idstruc
+ let ind = declare_structure Finite cum poly (Universes.univ_inf_ind_from_universe_context ctx) idstruc
idbuild implpars params arity template implfs
fields is_coe (List.map (fun coe -> not (Option.is_empty coe)) coers) sign in
IndRef ind
diff --git a/vernac/record.mli b/vernac/record.mli
index ec5d2cf83d..c43d833b0b 100644
--- a/vernac/record.mli
+++ b/vernac/record.mli
@@ -26,7 +26,8 @@ val declare_projections :
val declare_structure :
Decl_kinds.recursivity_kind ->
- bool (** polymorphic?*) ->
+ Decl_kinds.cumulative_inductive_flag ->
+ Decl_kinds.polymorphic ->
Univ.universe_info_ind (** universe and subtyping constraints *) ->
Id.t -> Id.t ->
manual_explicitation list -> Context.Rel.t -> (** params *) constr -> (** arity *)
@@ -39,8 +40,8 @@ val declare_structure :
inductive
val definition_structure :
- inductive_kind * Decl_kinds.polymorphic * Decl_kinds.recursivity_kind *
- plident with_coercion * local_binder_expr list *
+ inductive_kind * Decl_kinds.cumulative_inductive_flag * Decl_kinds.polymorphic *
+ Decl_kinds.recursivity_kind * plident with_coercion * local_binder_expr list *
(local_decl_expr with_instance with_priority with_notation) list *
Id.t * constr_expr option -> global_reference
diff --git a/vernac/vernacentries.ml b/vernac/vernacentries.ml
index d0f9c7de74..f130708c40 100644
--- a/vernac/vernacentries.ml
+++ b/vernac/vernacentries.ml
@@ -526,7 +526,7 @@ let vernac_assumption locality poly (local, kind) l nl =
let status = do_assumptions kind nl l in
if not status then Feedback.feedback Feedback.AddedAxiom
-let vernac_record k poly finite struc binders sort nameopt cfs =
+let vernac_record cum k poly finite struc binders sort nameopt cfs =
let const = match nameopt with
| None -> add_prefix "Build_" (snd (fst (snd struc)))
| Some (_,id as lid) ->
@@ -537,13 +537,13 @@ let vernac_record k poly finite struc binders sort nameopt cfs =
match x with
| Vernacexpr.AssumExpr ((loc, Name id), _) -> Dumpglob.dump_definition (loc,id) false "proj"
| _ -> ()) cfs);
- ignore(Record.definition_structure (k,poly,finite,struc,binders,cfs,const,sort))
+ ignore(Record.definition_structure (k,cum,poly,finite,struc,binders,cfs,const,sort))
(** When [poly] is true the type is declared polymorphic. When [lo] is true,
then the type is declared private (as per the [Private] keyword). [finite]
indicates whether the type is inductive, co-inductive or
neither. *)
-let vernac_inductive poly lo finite indl =
+let vernac_inductive cum poly lo finite indl =
if Dumpglob.dump () then
List.iter (fun (((coe,(lid,_)), _, _, _, cstrs), _) ->
match cstrs with
@@ -559,14 +559,14 @@ let vernac_inductive poly lo finite indl =
| [ (_ , _ , _ ,Variant, RecordDecl _),_ ] ->
user_err Pp.(str "The Variant keyword does not support syntax { ... }.")
| [ ( id , bl , c , b, RecordDecl (oc,fs) ), [] ] ->
- vernac_record (match b with Class _ -> Class false | _ -> b)
+ vernac_record cum (match b with Class _ -> Class false | _ -> b)
poly finite id bl c oc fs
| [ ( id , bl , c , Class _, Constructors [l]), [] ] ->
let f =
let (coe, ((loc, id), ce)) = l in
let coe' = if coe then Some true else None in
(((coe', AssumExpr ((loc, Name id), ce)), None), [])
- in vernac_record (Class true) poly finite id bl c None [f]
+ in vernac_record cum (Class true) poly finite id bl c None [f]
| [ ( _ , _, _, Class _, Constructors _), [] ] ->
user_err Pp.(str "Inductive classes not supported")
| [ ( id , bl , c , Class _, _), _ :: _ ] ->
@@ -580,7 +580,7 @@ let vernac_inductive poly lo finite indl =
| _ -> user_err Pp.(str "Cannot handle mutually (co)inductive records.")
in
let indl = List.map unpack indl in
- do_mutual_inductive indl poly lo finite
+ do_mutual_inductive indl cum poly lo finite
let vernac_fixpoint locality poly local l =
let local = enforce_locality_exp locality local in
@@ -1364,6 +1364,14 @@ let _ =
optread = Flags.is_universe_polymorphism;
optwrite = Flags.make_universe_polymorphism }
+let _ =
+ declare_bool_option
+ { optdepr = false;
+ optname = "inductive cumulativity";
+ optkey = ["Inductive"; "Cumulativity"];
+ optread = Flags.is_universe_polymorphism;
+ optwrite = Flags.make_universe_polymorphism }
+
let _ =
declare_int_option
{ optdepr = false;
@@ -1933,7 +1941,7 @@ let interp ?proof ?loc locality poly c =
| VernacEndProof e -> vernac_end_proof ?proof e
| VernacExactProof c -> vernac_exact_proof c
| VernacAssumption (stre,nl,l) -> vernac_assumption locality poly stre l nl
- | VernacInductive (priv,finite,l) -> vernac_inductive poly priv finite l
+ | VernacInductive (cum, priv,finite,l) -> vernac_inductive cum poly priv finite l
| VernacFixpoint (local, l) -> vernac_fixpoint locality poly local l
| VernacCoFixpoint (local, l) -> vernac_cofixpoint locality poly local l
| VernacScheme l -> vernac_scheme l
@@ -2083,6 +2091,12 @@ let enforce_polymorphism = function
| None -> Flags.is_universe_polymorphism ()
| Some b -> Flags.make_polymorphic_flag b; b
+let check_vernac_supports_cumulativity c p =
+ match p, c with
+ | None, _ -> ()
+ | Some _, (VernacInductive _ ) -> ()
+ | Some _, _ -> CErrors.error "This command does not support Cumulativity"
+
(** A global default timeout, controlled by option "Set Default Timeout n".
Use "Unset Default Timeout" to deactivate it (or set it to 0). *)
--
cgit v1.2.3
From 9903b47cdccc2fe98a905ab085cb24ca36de1aed Mon Sep 17 00:00:00 2001
From: Amin Timany
Date: Fri, 28 Apr 2017 11:12:26 +0200
Subject: Disable debug printing
Fix a mistake in record declaration
---
kernel/subtyping.ml | 4 ----
test-suite/bugs/closed/3330.v | 6 ++----
test-suite/success/polymorphism.v | 2 +-
vernac/record.ml | 2 +-
4 files changed, 4 insertions(+), 10 deletions(-)
diff --git a/kernel/subtyping.ml b/kernel/subtyping.ml
index 60cd77f402..60e630a6db 100644
--- a/kernel/subtyping.ml
+++ b/kernel/subtyping.ml
@@ -303,10 +303,6 @@ let check_constant cst env mp1 l info1 cb2 spec2 subst1 subst2 =
let ctx2 = Univ.instantiate_univ_context cb2.const_universes in
let inst1, ctx1 = Univ.UContext.dest ctx1 in
let inst2, ctx2 = Univ.UContext.dest ctx2 in
- output_string stderr "\ninst1:\n";
- output_string stderr (Pp.string_of_ppcmds (Univ.Instance.pr Univ.Level.pr inst1));
- output_string stderr "\ninst2:\n";
- output_string stderr (Pp.string_of_ppcmds (Univ.Instance.pr Univ.Level.pr inst2)); flush stderr;
if not (Univ.Instance.length inst1 == Univ.Instance.length inst2) then
error IncompatibleInstances
else
diff --git a/test-suite/bugs/closed/3330.v b/test-suite/bugs/closed/3330.v
index a497e7a987..672fb3f131 100644
--- a/test-suite/bugs/closed/3330.v
+++ b/test-suite/bugs/closed/3330.v
@@ -1072,10 +1072,8 @@ Section Adjunction.
Variable F : Functor C D.
Variable G : Functor D C.
-(* Let Adjunction_Type :=
- Eval simpl in (hom_functor D) o (F^op, 1) <~=~> (hom_functor C) o (1, G).*)
-
- Set Printing All. Set Printing Universes.
+ Let Adjunction_Type :=
+ Eval simpl in (hom_functor D) o (F^op, 1) <~=~> (hom_functor C) o (1, G).
Record AdjunctionHom :=
{
diff --git a/test-suite/success/polymorphism.v b/test-suite/success/polymorphism.v
index f57cbcc2b7..ecc988507c 100644
--- a/test-suite/success/polymorphism.v
+++ b/test-suite/success/polymorphism.v
@@ -360,7 +360,7 @@ End F.
Set Universe Polymorphism.
-Record box (X : Type) (T := Type) : Type := wrap { unwrap : T }.
+Cumulative Record box (X : Type) (T := Type) : Type := wrap { unwrap : T }.
Section test_letin_subtyping.
Universe i j k i' j' k'.
diff --git a/vernac/record.ml b/vernac/record.ml
index 8a83dceeff..b95131b724 100644
--- a/vernac/record.ml
+++ b/vernac/record.ml
@@ -584,7 +584,7 @@ let definition_structure (kind,cum,poly,finite,(is_coe,((loc,idstruc),pl)),ps,cf
let implfs = List.map
(fun impls -> implpars @ Impargs.lift_implicits
(succ (List.length params)) impls) implfs in
- let ind = declare_structure Finite cum poly (Universes.univ_inf_ind_from_universe_context ctx) idstruc
+ let ind = declare_structure finite cum poly (Universes.univ_inf_ind_from_universe_context ctx) idstruc
idbuild implpars params arity template implfs
fields is_coe (List.map (fun coe -> not (Option.is_empty coe)) coers) sign in
IndRef ind
--
cgit v1.2.3
From fece24ec8aa88950477ccfed70b511f05b438718 Mon Sep 17 00:00:00 2001
From: Amin Timany
Date: Fri, 28 Apr 2017 12:49:38 +0200
Subject: Fix a bug
Incorrect environment was used when checking subtyping information of
inductive types.
---
pretyping/inductiveops.ml | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/pretyping/inductiveops.ml b/pretyping/inductiveops.ml
index ebfb1f8a7c..1ef4a9f5e7 100644
--- a/pretyping/inductiveops.ml
+++ b/pretyping/inductiveops.ml
@@ -697,11 +697,12 @@ let infer_inductive_subtyping env evd mind_ent =
let { Entries.mind_entry_params = params;
Entries.mind_entry_inds = entries;
Entries.mind_entry_polymorphic = poly;
+ Entries.mind_entry_cumulative = cum;
Entries.mind_entry_universes = ground_uinfind;
} = mind_ent
in
let uinfind =
- if poly then
+ if poly && cum then
begin
let uctx = Univ.UInfoInd.univ_context ground_uinfind in
let sbsubst = Univ.UInfoInd.subtyping_susbst ground_uinfind in
@@ -709,9 +710,9 @@ let infer_inductive_subtyping env evd mind_ent =
let instance_other = Univ.subst_univs_level_instance sbsubst (Univ.UContext.instance uctx) in
let constraints_other = Univ.subst_univs_level_constraints sbsubst (Univ.UContext.constraints uctx) in
let uctx_other = Univ.UContext.make (instance_other, constraints_other) in
- let env' = Environ.push_context uctx env in
- let env' = Environ.push_context uctx_other env' in
- let evd' = Evd.merge_universe_context evd (UState.of_context_set (Univ.ContextSet.of_context uctx_other)) in
+ let env = Environ.push_context uctx env in
+ let env = Environ.push_context uctx_other env in
+ let evd = Evd.merge_universe_context evd (UState.of_context_set (Univ.ContextSet.of_context uctx_other)) in
let (_, _, subtyp_constraints) =
List.fold_left
(fun ctxs indentry ->
@@ -723,7 +724,7 @@ let infer_inductive_subtyping env evd mind_ent =
(fun ctxs cons ->
infer_inductive_subtyping_arity_constructor ctxs dosubst cons false params)
ctxs' indentry.Entries.mind_entry_lc
- ) (env', evd', Univ.Constraint.empty) entries
+ ) (env, evd, Univ.Constraint.empty) entries
in Univ.UInfoInd.make (Univ.UInfoInd.univ_context ground_uinfind,
Univ.UContext.make
(Univ.UContext.instance (Univ.UInfoInd.subtyp_context ground_uinfind),
--
cgit v1.2.3
From 4bf85270a36a0a3f9517d8bce92d843f882af00a Mon Sep 17 00:00:00 2001
From: Amin Timany
Date: Tue, 2 May 2017 12:56:14 +0200
Subject: Simplify Univ.ml
---
kernel/univ.ml | 4 ----
kernel/univ.mli | 4 ----
2 files changed, 8 deletions(-)
diff --git a/kernel/univ.ml b/kernel/univ.ml
index 5de45cf2b9..eb45f022e9 100644
--- a/kernel/univ.ml
+++ b/kernel/univ.ml
@@ -1091,10 +1091,6 @@ struct
let (ctx, ctx') = (halve_context (UContext.instance subtypcst))in
Array.fold_left2 (fun subst l1 l2 -> LMap.add l1 l2 subst) LMap.empty ctx ctx'
- let dest x = x
-
- let size ((x,_), _) = Instance.length x
-
end
type universe_info_ind = UInfoInd.t
diff --git a/kernel/univ.mli b/kernel/univ.mli
index 1141933293..53af804488 100644
--- a/kernel/univ.mli
+++ b/kernel/univ.mli
@@ -336,8 +336,6 @@ sig
val univ_context : t -> universe_context
val subtyp_context : t -> universe_context
- val dest : t -> universe_context * universe_context
-
(** This function takes a universe context representing constraints
of an inductive and a Instance.t of fresh universe names for the
subtyping (with the same length as the context in the given
@@ -347,8 +345,6 @@ sig
val subtyping_susbst : t -> universe_level_subst
- val size : t -> int
-
end
type universe_info_ind = UInfoInd.t
--
cgit v1.2.3
From d6898781f9cd52ac36a4891d7b169ddab7b8af50 Mon Sep 17 00:00:00 2001
From: Amin Timany
Date: Tue, 2 May 2017 19:53:05 +0200
Subject: Correct coqchk reduction
---
checker/cic.mli | 4 +-
checker/closure.ml | 6 +++
checker/closure.mli | 3 ++
checker/indtypes.ml | 46 ++++++++++++++++++++
checker/inductive.ml | 2 +-
checker/reduction.ml | 91 +++++++++++++++++++++++++++++++++-------
checker/subtyping.ml | 4 +-
checker/term.ml | 36 ++++++++++++++++
checker/term.mli | 3 ++
checker/univ.ml | 65 +++++++++++++++++++++++++++-
checker/univ.mli | 32 +++++++++++++-
checker/values.ml | 5 ++-
test-suite/coqchk/cumulativity.v | 52 +++++++++++++++++++++++
vernac/vernacentries.ml | 6 +--
14 files changed, 328 insertions(+), 27 deletions(-)
create mode 100644 test-suite/coqchk/cumulativity.v
diff --git a/checker/cic.mli b/checker/cic.mli
index 3645587554..f9d082ab1c 100644
--- a/checker/cic.mli
+++ b/checker/cic.mli
@@ -323,7 +323,9 @@ type mutual_inductive_body = {
mind_polymorphic : bool; (** Is it polymorphic or not *)
- mind_universes : Univ.universe_context; (** Local universe variables and constraints *)
+ mind_cumulative : bool; (** Is it cumulative or not *)
+
+ mind_universes : Univ.universe_info_ind; (** Local universe variables and constraints together with subtyping constraints *)
mind_private : bool option; (** allow pattern-matching: Some true ok, Some false blocked *)
diff --git a/checker/closure.ml b/checker/closure.ml
index b8294e7958..ac8388f6ed 100644
--- a/checker/closure.ml
+++ b/checker/closure.ml
@@ -328,6 +328,12 @@ let zshift n s =
| (_,Zshift(k)::s) -> Zshift(n+k)::s
| _ -> Zshift(n)::s
+let rec stack_args_size = function
+ | Zapp v :: s -> Array.length v + stack_args_size s
+ | Zshift(_)::s -> stack_args_size s
+ | Zupdate(_)::s -> stack_args_size s
+ | _ -> 0
+
(* Lifting. Preserves sharing (useful only for cell with norm=Red).
lft_fconstr always create a new cell, while lift_fconstr avoids it
when the lift is 0. *)
diff --git a/checker/closure.mli b/checker/closure.mli
index 8b1f246c28..8da9ad4ea5 100644
--- a/checker/closure.mli
+++ b/checker/closure.mli
@@ -125,6 +125,9 @@ type stack_member =
and stack = stack_member list
val append_stack : fconstr array -> stack -> stack
+
+val stack_args_size : stack -> int
+
val eta_expand_stack : stack -> stack
val eta_expand_ind_stack : env -> inductive -> fconstr -> stack ->
diff --git a/checker/indtypes.ml b/checker/indtypes.ml
index 6c38f38e29..00ff447cc9 100644
--- a/checker/indtypes.ml
+++ b/checker/indtypes.ml
@@ -524,6 +524,50 @@ let check_positivity env_ar mind params nrecp inds =
let wfp = Rtree.mk_rec irecargs in
Array.iter2 (fun ind wfpi -> check_subtree ind.mind_recargs wfpi) inds wfp
+(* Check arities and constructors *)
+let check_subtyping_arity_constructor env (subst : constr -> constr) (arcn : constr) numparams is_arity =
+ let numchecked = ref 0 in
+ let basic_check ev tp =
+ if !numchecked < numparams then () else conv_leq ev tp (subst tp);
+ numchecked := !numchecked + 1
+ in
+ let check_typ typ typ_env =
+ match typ with
+ | LocalAssum (_, typ') ->
+ begin
+ try
+ basic_check typ_env typ'; Environ.push_rel typ typ_env
+ with NotConvertible ->
+ anomaly ~label:"bad inductive subtyping relation" (Pp.str "Invalid subtyping relation")
+ end
+ | _ -> anomaly (Pp.str "")
+ in
+ let typs, codom = dest_prod env arcn in
+ let last_env = fold_rel_context_outside check_typ typs ~init:env in
+ if not is_arity then basic_check last_env codom else ()
+
+(* Check that the subtyping information inferred for inductive types in the block is correct. *)
+(* This check produces a value of the unit type if successful or raises an anomaly if check fails. *)
+let check_subtyping mib paramsctxt env_ar inds =
+ let numparams = rel_context_nhyps paramsctxt in
+ let sbsubst = Univ.UInfoInd.subtyping_susbst mib.mind_universes in
+ let dosubst = subst_univs_level_constr sbsubst in
+ let uctx = Univ.UInfoInd.univ_context mib.mind_universes in
+ let instance_other = Univ.subst_univs_level_instance sbsubst (Univ.UContext.instance uctx) in
+ let constraints_other = Univ.subst_univs_level_constraints sbsubst (Univ.UContext.constraints uctx) in
+ let uctx_other = Univ.UContext.make (instance_other, constraints_other) in
+ let env' = Environ.push_context uctx env_ar in
+ let env'' = Environ.push_context uctx_other env' in
+ let envsb = push_context (Univ.UInfoInd.subtyp_context mib.mind_universes) env'' in
+ (* process individual inductive types: *)
+ Array.iter (fun { mind_user_lc = lc; mind_arity = arity } ->
+ match arity with
+ | RegularArity { mind_user_arity = full_arity} ->
+ check_subtyping_arity_constructor envsb dosubst full_arity numparams true;
+ Array.iter (fun cnt -> check_subtyping_arity_constructor envsb dosubst cnt numparams false) lc
+ | TemplateArity _ -> ()
+ ) inds
+
(************************************************************************)
(************************************************************************)
@@ -547,6 +591,8 @@ let check_inductive env kn mib =
let env_ar = typecheck_arity env params mib.mind_packets in
(* - check constructor types *)
Array.iter (typecheck_one_inductive env_ar params mib) mib.mind_packets;
+ (* check the inferred subtyping relation *)
+ (* check_subtyping mib params env_ar mib.mind_packets; *)
(* check mind_nparams_rec: positivity condition *)
check_positivity env_ar kn params mib.mind_nparams_rec mib.mind_packets;
(* check mind_equiv... *)
diff --git a/checker/inductive.ml b/checker/inductive.ml
index f890adba9a..30c5f878a1 100644
--- a/checker/inductive.ml
+++ b/checker/inductive.ml
@@ -56,7 +56,7 @@ let inductive_params (mib,_) = mib.mind_nparams
let inductive_instance mib =
if mib.mind_polymorphic then
- UContext.instance mib.mind_universes
+ UContext.instance (UInfoInd.univ_context mib.mind_universes)
else Instance.empty
(************************************************************************)
diff --git a/checker/reduction.ml b/checker/reduction.ml
index ba0b017844..70c0bdad02 100644
--- a/checker/reduction.ml
+++ b/checker/reduction.ml
@@ -117,6 +117,10 @@ let beta_appvect c v =
(* Conversion *)
(********************************************************************)
+type conv_pb =
+ | CONV
+ | CUMUL
+
(* Conversion utility functions *)
type 'a conversion_function = env -> 'a -> 'a -> unit
@@ -152,11 +156,53 @@ let compare_stacks f fmind lft1 stk1 lft2 stk2 =
cmp_rec (pure_stack lft1 stk1) (pure_stack lft2 stk2)
else raise NotConvertible
-(* Convertibility of sorts *)
+let convert_inductive_instances cv_pb uinfind u u' univs =
+ let ind_instance = Univ.UContext.instance (Univ.UInfoInd.univ_context uinfind) in
+ let ind_sbcst = Univ.UContext.constraints (Univ.UInfoInd.subtyp_context uinfind) in
+ if not ((Univ.Instance.length ind_instance = Univ.Instance.length u) &&
+ (Univ.Instance.length ind_instance = Univ.Instance.length u')) then
+ anomaly (Pp.str "Invalid inductive subtyping encountered!")
+ else
+ let comp_cst =
+ let comp_subst = (Univ.Instance.append u u') in
+ Univ.subst_instance_constraints comp_subst ind_sbcst
+ in
+ let comp_cst =
+ match cv_pb with
+ CONV ->
+ let comp_subst = (Univ.Instance.append u' u) in
+ let comp_cst' = (Univ.subst_instance_constraints comp_subst ind_sbcst) in
+ Univ.Constraint.union comp_cst comp_cst'
+ | CUMUL -> comp_cst
+ in
+ if (Univ.check_constraints comp_cst univs) then () else raise NotConvertible
+
+let convert_inductives
+ cv_pb (mind, ind) u1 sv1 u2 sv2 univs =
+ let num_param_arity =
+ mind.mind_nparams + mind.mind_packets.(ind).mind_nrealargs
+ in
+ if not (num_param_arity = sv1 && num_param_arity = sv2) then
+ convert_universes univs u1 u2
+ else
+ let uinfind = mind.mind_universes in
+ convert_inductive_instances cv_pb uinfind u1 u2 univs
+
+let convert_constructors
+ (mind, ind, cns) u1 sv1 u2 sv2 univs =
+ let num_cnstr_args =
+ let nparamsctxt =
+ mind.mind_nparams + mind.mind_packets.(ind).mind_nrealargs
+ in
+ nparamsctxt + mind.mind_packets.(ind).mind_consnrealargs.(cns - 1)
+ in
+ if not (num_cnstr_args = sv1 && num_cnstr_args = sv2) then
+ convert_universes univs u1 u2
+ else
+ let uinfind = mind.mind_universes in
+ convert_inductive_instances CONV uinfind u1 u2 univs
-type conv_pb =
- | CONV
- | CUMUL
+(* Convertibility of sorts *)
let sort_cmp env univ pb s0 s1 =
match (s0,s1) with
@@ -375,18 +421,31 @@ and eqappr univ cv_pb infos (lft1,st1) (lft2,st2) =
(* Inductive types: MutInd MutConstruct Fix Cofix *)
| (FInd (ind1,u1), FInd (ind2,u2)) ->
- if mind_equiv_infos infos ind1 ind2
- then
- (let () = convert_universes univ u1 u2 in
- convert_stacks univ infos lft1 lft2 v1 v2)
- else raise NotConvertible
-
- | (FConstruct ((ind1,j1),u1), FConstruct ((ind2,j2),u2)) ->
- if Int.equal j1 j2 && mind_equiv_infos infos ind1 ind2
- then
- (let () = convert_universes univ u1 u2 in
- convert_stacks univ infos lft1 lft2 v1 v2)
- else raise NotConvertible
+ if mind_equiv_infos infos ind1 ind2 then
+ let mind = Environ.lookup_mind (fst ind1) (infos_env infos) in
+ let () =
+ if mind.mind_polymorphic && mind.mind_cumulative then
+ convert_inductives cv_pb (mind, snd ind1) u1 (stack_args_size v1)
+ u2 (stack_args_size v2) univ
+ else
+ convert_universes univ u1 u2
+ in
+ convert_stacks univ infos lft1 lft2 v1 v2
+ else raise NotConvertible
+
+ | (FConstruct ((ind1,j1),u1), FConstruct ((ind2,j2),u2)) ->
+ if Int.equal j1 j2 && mind_equiv_infos infos ind1 ind2 then
+ let mind = Environ.lookup_mind (fst ind1) (infos_env infos) in
+ let () =
+ if mind.mind_polymorphic && mind.mind_cumulative then
+ convert_constructors
+ (mind, snd ind1, j1) u1 (stack_args_size v1)
+ u2 (stack_args_size v2) univ
+ else
+ convert_universes univ u1 u2
+ in
+ convert_stacks univ infos lft1 lft2 v1 v2
+ else raise NotConvertible
(* Eta expansion of records *)
| (FConstruct ((ind1,j1),u1), _) ->
diff --git a/checker/subtyping.ml b/checker/subtyping.ml
index 2d04b77e46..8c10bd6eca 100644
--- a/checker/subtyping.ml
+++ b/checker/subtyping.ml
@@ -97,8 +97,8 @@ let check_inductive env mp1 l info1 mib2 spec2 subst1 subst2=
let u =
check bool_equal (fun x -> x.mind_polymorphic);
if mib1.mind_polymorphic then (
- check Univ.Instance.equal (fun x -> Univ.UContext.instance x.mind_universes);
- Univ.UContext.instance mib1.mind_universes)
+ check Univ.Instance.equal (fun x -> Univ.UContext.instance (Univ.UInfoInd.univ_context x.mind_universes));
+ Univ.UContext.instance (Univ.UInfoInd.univ_context mib1.mind_universes))
else Univ.Instance.empty
in
let eq_projection_body p1 p2 =
diff --git a/checker/term.ml b/checker/term.ml
index 75c566aeb7..f604ac4bd3 100644
--- a/checker/term.ml
+++ b/checker/term.ml
@@ -227,6 +227,8 @@ let rel_context_nhyps hyps =
nhyps 0 hyps
let fold_rel_context f l ~init = List.fold_right f l init
+let fold_rel_context_outside f l ~init = List.fold_right f l init
+
let map_rel_decl f = function
| LocalAssum (n, typ) as decl ->
let typ' = f typ in
@@ -447,3 +449,37 @@ let subst_instance_constr subst c =
let subst_instance_context s ctx =
if Univ.Instance.is_empty s then ctx
else map_rel_context (fun x -> subst_instance_constr s x) ctx
+
+let subst_univs_level_constr subst c =
+ if Univ.is_empty_level_subst subst then c
+ else
+ let f = Univ.Instance.subst_fn (Univ.subst_univs_level_level subst) in
+ let changed = ref false in
+ let rec aux t =
+ match t with
+ | Const (c, u) ->
+ if Univ.Instance.is_empty u then t
+ else
+ let u' = f u in
+ if u' == u then t
+ else (changed := true; Const (c, u'))
+ | Ind (i, u) ->
+ if Univ.Instance.is_empty u then t
+ else
+ let u' = f u in
+ if u' == u then t
+ else (changed := true; Ind (i, u'))
+ | Construct (c, u) ->
+ if Univ.Instance.is_empty u then t
+ else
+ let u' = f u in
+ if u' == u then t
+ else (changed := true; Construct (c, u'))
+ | Sort (Type u) ->
+ let u' = Univ.subst_univs_level_universe subst u in
+ if u' == u then t else
+ (changed := true; Sort (sort_of_univ u'))
+ | _ -> map_constr aux t
+ in
+ let c' = aux c in
+ if !changed then c' else c
diff --git a/checker/term.mli b/checker/term.mli
index 6b026d056f..ccf5b59e0c 100644
--- a/checker/term.mli
+++ b/checker/term.mli
@@ -33,6 +33,8 @@ val rel_context_length : rel_context -> int
val rel_context_nhyps : rel_context -> int
val fold_rel_context :
(rel_declaration -> 'a -> 'a) -> rel_context -> init:'a -> 'a
+val fold_rel_context_outside :
+ (rel_declaration -> 'a -> 'a) -> rel_context -> init:'a -> 'a
val map_rel_decl : (constr -> constr) -> rel_declaration -> rel_declaration
val map_rel_context : (constr -> constr) -> rel_context -> rel_context
val extended_rel_list : int -> rel_context -> constr list
@@ -55,3 +57,4 @@ val eq_constr : constr -> constr -> bool
(** Instance substitution for polymorphism. *)
val subst_instance_constr : Univ.universe_instance -> constr -> constr
val subst_instance_context : Univ.universe_instance -> rel_context -> rel_context
+val subst_univs_level_constr : Univ.universe_level_subst -> constr -> constr
diff --git a/checker/univ.ml b/checker/univ.ml
index 5717432315..fa884d9d06 100644
--- a/checker/univ.ml
+++ b/checker/univ.ml
@@ -1056,7 +1056,9 @@ module Instance : sig
val subst_fn : universe_level_subst_fn -> t -> t
val subst : universe_level_subst -> t -> t
val pr : t -> Pp.std_ppcmds
- val check_eq : t check_function
+ val check_eq : t check_function
+ val length : t -> int
+ val append : t -> t -> t
end =
struct
type t = Level.t array
@@ -1099,6 +1101,7 @@ struct
(* [h] must be positive. *)
let h = !accu land 0x3FFFFFFF in
h
+
end
module HInstance = Hashcons.Make(HInstancestruct)
@@ -1135,6 +1138,10 @@ struct
(Int.equal i (Array.length t1)) || (check_eq_level g t1.(i) t2.(i) && aux (i + 1))
in aux 0)
+ let length = Array.length
+
+ let append = Array.append
+
end
type universe_instance = Instance.t
@@ -1156,6 +1163,44 @@ end
type universe_context = UContext.t
+module UInfoInd =
+struct
+ type t = universe_context * universe_context
+
+ let make x =
+ if (Array.length (UContext.instance (snd x))) =
+ (Array.length (UContext.instance (fst x))) * 2 then x
+ else anomaly (Pp.str "Invalid subtyping information encountered!")
+
+ let empty = (UContext.empty, UContext.empty)
+
+ let halve_context ctx =
+ let len = Array.length ctx in
+ let halflen = len / 2 in
+ ((Array.sub ctx 0 halflen), (Array.sub ctx halflen halflen))
+
+ let univ_context (univcst, subtypcst) = univcst
+ let subtyp_context (univcst, subtypcst) = subtypcst
+
+ let create_trivial_subtyping ctx ctx' =
+ CArray.fold_left_i
+ (fun i cst l -> Constraint.add (l, Eq, Array.get ctx' i) cst)
+ Constraint.empty ctx
+
+ let from_universe_context univcst freshunivs =
+ let inst = (UContext.instance univcst) in
+ assert (Array.length freshunivs = Array.length inst);
+ (univcst, UContext.make (Array.append inst freshunivs,
+ create_trivial_subtyping inst freshunivs))
+
+ let subtyping_susbst (univcst, subtypcst) =
+ let (ctx, ctx') = (halve_context (UContext.instance subtypcst)) in
+ Array.fold_left2 (fun subst l1 l2 -> LMap.add l1 l2 subst) LMap.empty ctx ctx'
+
+end
+
+type universe_info_ind = UInfoInd.t
+
module ContextSet =
struct
type t = LSet.t constrained
@@ -1166,6 +1211,8 @@ struct
end
type universe_context_set = ContextSet.t
+
+
(** Substitutions. *)
let is_empty_subst = LMap.is_empty
@@ -1185,6 +1232,22 @@ let subst_univs_level_universe subst u =
if u == u' then u
else Universe.sort u'
+let subst_univs_level_instance subst i =
+ let i' = Instance.subst_fn (subst_univs_level_level subst) i in
+ if i == i' then i
+ else i'
+
+let subst_univs_level_constraint subst (u,d,v) =
+ let u' = subst_univs_level_level subst u
+ and v' = subst_univs_level_level subst v in
+ if d != Lt && Level.equal u' v' then None
+ else Some (u',d,v')
+
+let subst_univs_level_constraints subst csts =
+ Constraint.fold
+ (fun c -> Option.fold_right Constraint.add (subst_univs_level_constraint subst c))
+ csts Constraint.empty
+
(** Substitute instance inst for ctx in csts *)
let subst_instance_level s l =
diff --git a/checker/univ.mli b/checker/univ.mli
index 7d4c629ab9..edf828daeb 100644
--- a/checker/univ.mli
+++ b/checker/univ.mli
@@ -71,6 +71,8 @@ type 'a check_function = universes -> 'a -> 'a -> bool
val check_leq : universe check_function
val check_eq : universe check_function
+
+
(** The initial graph of universes: Prop < Set *)
val initial_universes : universes
@@ -170,6 +172,12 @@ sig
val check_eq : t check_function
(** Check equality of instances w.r.t. a universe graph *)
+
+ val length : t -> int
+ (** Compute the length of the instance *)
+
+ val append : t -> t -> t
+ (** Append two universe instances *)
end
type universe_instance = Instance.t
@@ -190,6 +198,27 @@ sig
end
+type universe_context = UContext.t
+
+module UInfoInd :
+sig
+ type t
+
+ val make : universe_context * universe_context -> t
+
+ val empty : t
+
+ val univ_context : t -> universe_context
+ val subtyp_context : t -> universe_context
+
+ val from_universe_context : universe_context -> universe_instance -> t
+
+ val subtyping_susbst : t -> universe_level_subst
+
+end
+
+type universe_info_ind = UInfoInd.t
+
module ContextSet :
sig
type t
@@ -198,7 +227,6 @@ module ContextSet :
val constraints : t -> constraints
end
-type universe_context = UContext.t
type universe_context_set = ContextSet.t
val merge_context : bool -> universe_context -> universes -> universes
@@ -210,6 +238,8 @@ val is_empty_level_subst : universe_level_subst -> bool
(** Substitution of universes. *)
val subst_univs_level_level : universe_level_subst -> universe_level -> universe_level
val subst_univs_level_universe : universe_level_subst -> universe -> universe
+val subst_univs_level_instance : universe_level_subst -> universe_instance -> universe_instance
+val subst_univs_level_constraints : universe_level_subst -> constraints -> constraints
(** Level to universe substitutions. *)
diff --git a/checker/values.ml b/checker/values.ml
index c175aed680..c58f56a9bd 100644
--- a/checker/values.ml
+++ b/checker/values.ml
@@ -13,7 +13,7 @@
To ensure this file is up-to-date, 'make' now compares the md5 of cic.mli
with a copy we maintain here:
-MD5 6466d8cc443b5896cb905776df0cc49e checker/cic.mli
+MD5 6153d4f8fb414a8f14797636ab10f55e checker/cic.mli
*)
@@ -272,7 +272,8 @@ let v_ind_pack = v_tuple "mutual_inductive_body"
Int;
v_rctxt;
v_bool;
- v_context;
+ v_bool;
+ v_tuple "universes" [|v_context; v_context|];
Opt v_bool;
v_typing_flags|]
diff --git a/test-suite/coqchk/cumulativity.v b/test-suite/coqchk/cumulativity.v
new file mode 100644
index 0000000000..5d245aaa5d
--- /dev/null
+++ b/test-suite/coqchk/cumulativity.v
@@ -0,0 +1,52 @@
+Set Universe Polymorphism.
+Set Ind Cumulativity.
+Set Printing Universes.
+
+Inductive List (A: Type) := nil | cons : A -> List A -> List A.
+
+Section ListLift.
+ Universe i j.
+
+ Constraint i < j.
+
+ Definition LiftL {A} : List@{i} A -> List@{j} A := fun x => x.
+
+End ListLift.
+
+Lemma LiftL_Lem A (l : List A) : l = LiftL l.
+Proof. reflexivity. Qed.
+
+Section ListLower.
+ Universe i j.
+
+ Constraint i < j.
+
+ Definition LowerL {A : Type@{i}} : List@{j} A -> List@{i} A := fun x => x.
+
+End ListLower.
+
+Lemma LowerL_Lem@{i j} (A : Type@{j}) (l : List@{i} A) : l = LowerL l.
+Proof. reflexivity. Qed.
+
+Inductive Tp := tp : Type -> Tp.
+
+Section TpLift.
+ Universe i j.
+
+ Constraint i < j.
+
+ Definition LiftTp : Tp@{i} -> Tp@{j} := fun x => x.
+
+End TpLift.
+
+Lemma LiftC_Lem (t : Tp) : LiftTp t = t.
+Proof. reflexivity. Qed.
+
+Section TpLower.
+ Universe i j.
+
+ Constraint i < j.
+
+ Fail Definition LowerTp : Tp@{j} -> Tp@{i} := fun x => x.
+
+End TpLower.
\ No newline at end of file
diff --git a/vernac/vernacentries.ml b/vernac/vernacentries.ml
index f130708c40..580c81a0bd 100644
--- a/vernac/vernacentries.ml
+++ b/vernac/vernacentries.ml
@@ -1368,9 +1368,9 @@ let _ =
declare_bool_option
{ optdepr = false;
optname = "inductive cumulativity";
- optkey = ["Inductive"; "Cumulativity"];
- optread = Flags.is_universe_polymorphism;
- optwrite = Flags.make_universe_polymorphism }
+ optkey = ["Ind"; "Cumulativity"];
+ optread = Flags.is_inductive_cumulativity;
+ optwrite = Flags.make_inductive_cumulativity }
let _ =
declare_int_option
--
cgit v1.2.3
From 763f5d5d5c6f8b798cc138d0c68fffcb7c544e41 Mon Sep 17 00:00:00 2001
From: Amin Timany
Date: Wed, 3 May 2017 11:21:47 +0200
Subject: Correct coqchk checking subtyping relation for inductives
---
checker/indtypes.ml | 6 +++---
checker/univ.ml | 19 +------------------
checker/univ.mli | 4 +---
3 files changed, 5 insertions(+), 24 deletions(-)
diff --git a/checker/indtypes.ml b/checker/indtypes.ml
index 00ff447cc9..69dd6f57a8 100644
--- a/checker/indtypes.ml
+++ b/checker/indtypes.ml
@@ -551,10 +551,10 @@ let check_subtyping_arity_constructor env (subst : constr -> constr) (arcn : con
let check_subtyping mib paramsctxt env_ar inds =
let numparams = rel_context_nhyps paramsctxt in
let sbsubst = Univ.UInfoInd.subtyping_susbst mib.mind_universes in
- let dosubst = subst_univs_level_constr sbsubst in
+ let dosubst = subst_instance_constr sbsubst in
let uctx = Univ.UInfoInd.univ_context mib.mind_universes in
- let instance_other = Univ.subst_univs_level_instance sbsubst (Univ.UContext.instance uctx) in
- let constraints_other = Univ.subst_univs_level_constraints sbsubst (Univ.UContext.constraints uctx) in
+ let instance_other = Univ.subst_instance_instance sbsubst (Univ.UContext.instance uctx) in
+ let constraints_other = Univ.subst_instance_constraints sbsubst (Univ.UContext.constraints uctx) in
let uctx_other = Univ.UContext.make (instance_other, constraints_other) in
let env' = Environ.push_context uctx env_ar in
let env'' = Environ.push_context uctx_other env' in
diff --git a/checker/univ.ml b/checker/univ.ml
index fa884d9d06..525f535e92 100644
--- a/checker/univ.ml
+++ b/checker/univ.ml
@@ -1194,8 +1194,7 @@ struct
create_trivial_subtyping inst freshunivs))
let subtyping_susbst (univcst, subtypcst) =
- let (ctx, ctx') = (halve_context (UContext.instance subtypcst)) in
- Array.fold_left2 (fun subst l1 l2 -> LMap.add l1 l2 subst) LMap.empty ctx ctx'
+ let (_, ctx') = (halve_context (UContext.instance subtypcst)) in ctx'
end
@@ -1232,22 +1231,6 @@ let subst_univs_level_universe subst u =
if u == u' then u
else Universe.sort u'
-let subst_univs_level_instance subst i =
- let i' = Instance.subst_fn (subst_univs_level_level subst) i in
- if i == i' then i
- else i'
-
-let subst_univs_level_constraint subst (u,d,v) =
- let u' = subst_univs_level_level subst u
- and v' = subst_univs_level_level subst v in
- if d != Lt && Level.equal u' v' then None
- else Some (u',d,v')
-
-let subst_univs_level_constraints subst csts =
- Constraint.fold
- (fun c -> Option.fold_right Constraint.add (subst_univs_level_constraint subst c))
- csts Constraint.empty
-
(** Substitute instance inst for ctx in csts *)
let subst_instance_level s l =
diff --git a/checker/univ.mli b/checker/univ.mli
index edf828daeb..2bc2653e09 100644
--- a/checker/univ.mli
+++ b/checker/univ.mli
@@ -213,7 +213,7 @@ sig
val from_universe_context : universe_context -> universe_instance -> t
- val subtyping_susbst : t -> universe_level_subst
+ val subtyping_susbst : t -> universe_instance
end
@@ -238,8 +238,6 @@ val is_empty_level_subst : universe_level_subst -> bool
(** Substitution of universes. *)
val subst_univs_level_level : universe_level_subst -> universe_level -> universe_level
val subst_univs_level_universe : universe_level_subst -> universe -> universe
-val subst_univs_level_instance : universe_level_subst -> universe_instance -> universe_instance
-val subst_univs_level_constraints : universe_level_subst -> constraints -> constraints
(** Level to universe substitutions. *)
--
cgit v1.2.3
From 47ce63d23b8efe35babe0f4429c550400afd6b4f Mon Sep 17 00:00:00 2001
From: Amin Timany
Date: Thu, 4 May 2017 17:53:12 +0200
Subject: Move univops from kernel to library
---
kernel/kernel.mllib | 3 +--
kernel/univops.ml | 70 ---------------------------------------------------
kernel/univops.mli | 17 -------------
library/library.mllib | 1 +
library/univops.ml | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++
library/univops.mli | 17 +++++++++++++
6 files changed, 89 insertions(+), 89 deletions(-)
delete mode 100644 kernel/univops.ml
delete mode 100644 kernel/univops.mli
create mode 100644 library/univops.ml
create mode 100644 library/univops.mli
diff --git a/kernel/kernel.mllib b/kernel/kernel.mllib
index 8132d66850..0813315b5b 100644
--- a/kernel/kernel.mllib
+++ b/kernel/kernel.mllib
@@ -41,6 +41,5 @@ Nativelibrary
Safe_typing
Vm
Csymtable
-Vconv
Declarations
-Univops
+Vconv
diff --git a/kernel/univops.ml b/kernel/univops.ml
deleted file mode 100644
index e9383c6d9f..0000000000
--- a/kernel/univops.ml
+++ /dev/null
@@ -1,70 +0,0 @@
-(************************************************************************)
-(* v * The Coq Proof Assistant / The Coq Development Team *)
-(*
- LSet.fold LSet.add (Instance.levels u) s
- | Sort u when not (Sorts.is_small u) ->
- let u = univ_of_sort u in
- LSet.fold LSet.add (Universe.levels u) s
- | _ -> fold_constr aux s c
- in aux LSet.empty c
-
-let universes_of_inductive mind =
- if mind.mind_polymorphic then
- begin
- let u = Univ.UContext.instance (Univ.UInfoInd.univ_context mind.mind_universes) in
- let univ_of_one_ind oind =
- let arity_univs =
- Context.Rel.fold_outside
- (fun decl unvs ->
- Univ.LSet.union
- (Context.Rel.Declaration.fold_constr
- (fun cnstr unvs ->
- let cnstr = Vars.subst_instance_constr u cnstr in
- Univ.LSet.union
- (universes_of_constr cnstr) unvs)
- decl Univ.LSet.empty) unvs)
- oind.mind_arity_ctxt ~init:Univ.LSet.empty
- in
- Array.fold_left (fun unvs cns ->
- let cns = Vars.subst_instance_constr u cns in
- Univ.LSet.union (universes_of_constr cns) unvs) arity_univs
- oind.mind_nf_lc
- in
- let univs = Array.fold_left (fun unvs pk -> Univ.LSet.union (univ_of_one_ind pk) unvs) Univ.LSet.empty mind.mind_packets in
- let mindcnt = Univ.UContext.constraints (Univ.instantiate_univ_context (Univ.UInfoInd.univ_context mind.mind_universes)) in
- let univs = Univ.LSet.union univs (Univ.universes_of_constraints mindcnt) in
- univs
- end
- else LSet.empty
-
-let restrict_universe_context (univs,csts) s =
- (* Universes that are not necessary to typecheck the term.
- E.g. univs introduced by tactics and not used in the proof term. *)
- let diff = LSet.diff univs s in
- let rec aux diff candid univs ness =
- let (diff', candid', univs', ness') =
- Constraint.fold
- (fun (l, d, r as c) (diff, candid, univs, csts) ->
- if not (LSet.mem l diff) then
- (LSet.remove r diff, candid, univs, Constraint.add c csts)
- else if not (LSet.mem r diff) then
- (LSet.remove l diff, candid, univs, Constraint.add c csts)
- else (diff, Constraint.add c candid, univs, csts))
- candid (diff, Constraint.empty, univs, ness)
- in
- if ness' == ness then (LSet.diff univs diff', ness)
- else aux diff' candid' univs' ness'
- in aux diff csts univs Constraint.empty
diff --git a/kernel/univops.mli b/kernel/univops.mli
deleted file mode 100644
index 5b499c75bc..0000000000
--- a/kernel/univops.mli
+++ /dev/null
@@ -1,17 +0,0 @@
-(************************************************************************)
-(* v * The Coq Proof Assistant / The Coq Development Team *)
-(* universe_set
-val universes_of_inductive : mutual_inductive_body -> universe_set
-val restrict_universe_context : universe_context_set -> universe_set -> universe_context_set
diff --git a/library/library.mllib b/library/library.mllib
index 6f433b77d1..d94fc22919 100644
--- a/library/library.mllib
+++ b/library/library.mllib
@@ -1,3 +1,4 @@
+Univops
Nameops
Libnames
Globnames
diff --git a/library/univops.ml b/library/univops.ml
new file mode 100644
index 0000000000..e9383c6d9f
--- /dev/null
+++ b/library/univops.ml
@@ -0,0 +1,70 @@
+(************************************************************************)
+(* v * The Coq Proof Assistant / The Coq Development Team *)
+(*
+ LSet.fold LSet.add (Instance.levels u) s
+ | Sort u when not (Sorts.is_small u) ->
+ let u = univ_of_sort u in
+ LSet.fold LSet.add (Universe.levels u) s
+ | _ -> fold_constr aux s c
+ in aux LSet.empty c
+
+let universes_of_inductive mind =
+ if mind.mind_polymorphic then
+ begin
+ let u = Univ.UContext.instance (Univ.UInfoInd.univ_context mind.mind_universes) in
+ let univ_of_one_ind oind =
+ let arity_univs =
+ Context.Rel.fold_outside
+ (fun decl unvs ->
+ Univ.LSet.union
+ (Context.Rel.Declaration.fold_constr
+ (fun cnstr unvs ->
+ let cnstr = Vars.subst_instance_constr u cnstr in
+ Univ.LSet.union
+ (universes_of_constr cnstr) unvs)
+ decl Univ.LSet.empty) unvs)
+ oind.mind_arity_ctxt ~init:Univ.LSet.empty
+ in
+ Array.fold_left (fun unvs cns ->
+ let cns = Vars.subst_instance_constr u cns in
+ Univ.LSet.union (universes_of_constr cns) unvs) arity_univs
+ oind.mind_nf_lc
+ in
+ let univs = Array.fold_left (fun unvs pk -> Univ.LSet.union (univ_of_one_ind pk) unvs) Univ.LSet.empty mind.mind_packets in
+ let mindcnt = Univ.UContext.constraints (Univ.instantiate_univ_context (Univ.UInfoInd.univ_context mind.mind_universes)) in
+ let univs = Univ.LSet.union univs (Univ.universes_of_constraints mindcnt) in
+ univs
+ end
+ else LSet.empty
+
+let restrict_universe_context (univs,csts) s =
+ (* Universes that are not necessary to typecheck the term.
+ E.g. univs introduced by tactics and not used in the proof term. *)
+ let diff = LSet.diff univs s in
+ let rec aux diff candid univs ness =
+ let (diff', candid', univs', ness') =
+ Constraint.fold
+ (fun (l, d, r as c) (diff, candid, univs, csts) ->
+ if not (LSet.mem l diff) then
+ (LSet.remove r diff, candid, univs, Constraint.add c csts)
+ else if not (LSet.mem r diff) then
+ (LSet.remove l diff, candid, univs, Constraint.add c csts)
+ else (diff, Constraint.add c candid, univs, csts))
+ candid (diff, Constraint.empty, univs, ness)
+ in
+ if ness' == ness then (LSet.diff univs diff', ness)
+ else aux diff' candid' univs' ness'
+ in aux diff csts univs Constraint.empty
diff --git a/library/univops.mli b/library/univops.mli
new file mode 100644
index 0000000000..5b499c75bc
--- /dev/null
+++ b/library/univops.mli
@@ -0,0 +1,17 @@
+(************************************************************************)
+(* v * The Coq Proof Assistant / The Coq Development Team *)
+(* universe_set
+val universes_of_inductive : mutual_inductive_body -> universe_set
+val restrict_universe_context : universe_context_set -> universe_set -> universe_context_set
--
cgit v1.2.3
From 0c94de1f8c598c1869f71fee86bdbe4f0000a502 Mon Sep 17 00:00:00 2001
From: Amin Timany
Date: Thu, 4 May 2017 19:12:45 +0200
Subject: Add printing of cumulativity in inductive types
---
printing/ppvernac.ml | 6 ++++--
printing/printer.ml | 5 +++++
printing/printer.mli | 1 +
printing/printmod.ml | 10 ++++++----
4 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/printing/ppvernac.ml b/printing/ppvernac.ml
index 6a47c308d3..4a5cfe6301 100644
--- a/printing/ppvernac.ml
+++ b/printing/ppvernac.ml
@@ -759,8 +759,10 @@ open Decl_kinds
| Inductive_kw -> "Inductive" | CoInductive -> "CoInductive"
| Class _ -> "Class" | Variant -> "Variant"
in
- let cm = if cum then "Cumulative" else "NonCumulative" in
- cm ^ " " ^ kind
+ if p then
+ let cm = if cum then "Cumulative" else "NonCumulative" in
+ cm ^ " " ^ kind
+ else kind
in
return (
hov 1 (pr_oneind key (List.hd l)) ++
diff --git a/printing/printer.ml b/printing/printer.ml
index c27a9b009d..1d7b7cff0f 100644
--- a/printing/printer.ml
+++ b/printing/printer.ml
@@ -998,6 +998,11 @@ let pr_assumptionset env s =
let xor a b =
(a && not b) || (not a && b)
+let pr_cumulative p b =
+ if p then
+ if b then str "Cumulative " else str "NonCumulative "
+ else str ""
+
let pr_polymorphic b =
let print = xor (Flags.is_universe_polymorphism ()) b in
if print then
diff --git a/printing/printer.mli b/printing/printer.mli
index 6531036a1f..9f4ea23b74 100644
--- a/printing/printer.mli
+++ b/printing/printer.mli
@@ -95,6 +95,7 @@ val pr_sort : evar_map -> sorts -> std_ppcmds
(** Universe constraints *)
val pr_polymorphic : bool -> std_ppcmds
+val pr_cumulative : bool -> bool -> std_ppcmds
val pr_universe_instance : evar_map -> Univ.universe_context -> std_ppcmds
val pr_universe_ctx : evar_map -> Univ.universe_context -> std_ppcmds
val pr_universe_info_ind : evar_map -> Univ.universe_info_ind -> std_ppcmds
diff --git a/printing/printmod.ml b/printing/printmod.ml
index 7dc47a4a4c..be8940b6ff 100644
--- a/printing/printmod.ml
+++ b/printing/printmod.ml
@@ -121,10 +121,11 @@ let print_mutual_inductive env mind mib =
let bl = Universes.universe_binders_of_global (IndRef (mind, 0)) in
let sigma = Evd.from_ctx (Evd.evar_universe_context_of_binders bl) in
hov 0 (Printer.pr_polymorphic mib.mind_polymorphic ++
- def keyword ++ spc () ++
- prlist_with_sep (fun () -> fnl () ++ str" with ")
- (print_one_inductive env sigma mib) inds ++
- Printer.pr_universe_info_ind sigma (Univ.instantiate_univ_info_ind mib.mind_universes))
+ Printer.pr_cumulative mib.mind_polymorphic mib.mind_cumulative ++
+ def keyword ++ spc () ++
+ prlist_with_sep (fun () -> fnl () ++ str" with ")
+ (print_one_inductive env sigma mib) inds ++
+ Printer.pr_universe_info_ind sigma (Univ.instantiate_univ_info_ind mib.mind_universes))
let get_fields =
let rec prodec_rec l subst c =
@@ -165,6 +166,7 @@ let print_record env mind mib =
hov 0 (
hov 0 (
Printer.pr_polymorphic mib.mind_polymorphic ++
+ Printer.pr_cumulative mib.mind_polymorphic mib.mind_cumulative ++
def keyword ++ spc () ++ pr_id mip.mind_typename ++ brk(1,4) ++
print_params env sigma params ++
str ": " ++ Printer.pr_lconstr_env envpar sigma arity ++ brk(1,2) ++
--
cgit v1.2.3
From 7b323421ba558011c304a686c4cd368e1ff39440 Mon Sep 17 00:00:00 2001
From: Amin Timany
Date: Fri, 5 May 2017 13:33:18 +0200
Subject: Change the option to Set Inductive Cumulativity
This requires to change the status of Inductive (we have also changed
CoInductive and Variant) from keyword to identifier.
---
parsing/g_vernac.ml4 | 6 +++---
test-suite/coqchk/cumulativity.v | 2 +-
vernac/vernacentries.ml | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/parsing/g_vernac.ml4 b/parsing/g_vernac.ml4
index e6b28b1d87..dbd2fc4016 100644
--- a/parsing/g_vernac.ml4
+++ b/parsing/g_vernac.ml4
@@ -232,9 +232,9 @@ GEXTEND Gram
r = universe_level -> (l, ord, r) ] ]
;
finite_token:
- [ [ "Inductive" -> (Inductive_kw,Finite)
- | "CoInductive" -> (CoInductive,CoFinite)
- | "Variant" -> (Variant,BiFinite)
+ [ [ IDENT "Inductive" -> (Inductive_kw,Finite)
+ | IDENT "CoInductive" -> (CoInductive,CoFinite)
+ | IDENT "Variant" -> (Variant,BiFinite)
| IDENT "Record" -> (Record,BiFinite)
| IDENT "Structure" -> (Structure,BiFinite)
| IDENT "Class" -> (Class true,BiFinite) ] ]
diff --git a/test-suite/coqchk/cumulativity.v b/test-suite/coqchk/cumulativity.v
index 5d245aaa5d..3a8f9fa22f 100644
--- a/test-suite/coqchk/cumulativity.v
+++ b/test-suite/coqchk/cumulativity.v
@@ -1,5 +1,5 @@
Set Universe Polymorphism.
-Set Ind Cumulativity.
+Set Inductive Cumulativity.
Set Printing Universes.
Inductive List (A: Type) := nil | cons : A -> List A -> List A.
diff --git a/vernac/vernacentries.ml b/vernac/vernacentries.ml
index 580c81a0bd..957911e1e5 100644
--- a/vernac/vernacentries.ml
+++ b/vernac/vernacentries.ml
@@ -1368,7 +1368,7 @@ let _ =
declare_bool_option
{ optdepr = false;
optname = "inductive cumulativity";
- optkey = ["Ind"; "Cumulativity"];
+ optkey = ["Inductive"; "Cumulativity"];
optread = Flags.is_inductive_cumulativity;
optwrite = Flags.make_inductive_cumulativity }
--
cgit v1.2.3
From e28d3a488c81c6dc59aa8f53d98a95ee93a84d37 Mon Sep 17 00:00:00 2001
From: Amin Timany
Date: Tue, 23 May 2017 23:28:39 +0200
Subject: Document cumulativity for inductive types
---
CHANGES | 6 ++++++
doc/refman/RefMan-cic.tex | 24 +++++++++++++++++++++++-
doc/refman/Universes.tex | 46 ++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 75 insertions(+), 1 deletion(-)
diff --git a/CHANGES b/CHANGES
index b5aaad725e..deca62f921 100644
--- a/CHANGES
+++ b/CHANGES
@@ -94,6 +94,12 @@ Build Infrastructure
access to the same .cmi files. In short, use "make -j && make -j byte"
instead of "make -j world byte".
+Universes
+
+- Cumulative inductive types. see prefixes "Cumulative", "NonCumulative"
+ for inductive definitions and the option "Set Inductive Cumulativity"
+ in the reference manual.
+
Changes from V8.6beta1 to V8.6
==============================
diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex
index fdd2725810..96fb1eb752 100644
--- a/doc/refman/RefMan-cic.tex
+++ b/doc/refman/RefMan-cic.tex
@@ -461,6 +461,13 @@ recursively convertible to $u'_1$, or, symmetrically, $u_2$ is $\lb
x:T\mto u'_2$ and $u_1\,x$ is recursively convertible to $u'_2$. We
then write $\WTEGCONV{t_1}{t_2}$.
+Apart from this we consider two instances of polymorphic and cumulative (see Chapter~\ref{Universes-full}) inductive types (see below)
+convertible $\WTEGCONV{t\ w_1 \dots w_m}{t\ w_1' \dots w_m'}$ if we have subtypings (see below) in both directions, i.e.,
+$\WTEGLECONV{t\ w_1 \dots w_m}{t\ w_1' \dots w_m'}$ and $\WTEGLECONV{t\ w_1' \dots w_m'}{t\ w_1 \dots w_m}$.
+Furthermore, we consider $\WTEGCONV{c\ v_1 \dots v_m}{c'\ v_1' \dots v_m'}$ convertible if $\WTEGCONV{v_i}{v_i'}$
+and we have that $c$ and $c'$ are the same constructors of different instances the same inductive types (differing only in universe levels)
+such that $\WTEG{c\ v_1 \dots v_m}{t\ w_1 \dots w_m}$ and $\WTEG{c'\ v_1' \dots v_m'}{t'\ w_1' \dots w_m'}$ and we have $\WTEGCONV{t\ w_1 \dots w_m}{t\ w_1' \dots w_m'}$.
+
The convertibility relation allows introducing a new typing rule
which says that two convertible well-formed types have the same
inhabitants.
@@ -480,6 +487,17 @@ convertibility into a {\em subtyping} relation inductively defined by:
\item $\WTEGLECONV{\Prop}{\Set}$, hence, by transitivity,
$\WTEGLECONV{\Prop}{\Type(i)}$, for any $i$
\item if $\WTEGCONV{T}{U}$ and $\WTELECONV{\Gamma::(x:T)}{T'}{U'}$ then $\WTEGLECONV{\forall~x:T, T'}{\forall~x:U, U'}$.
+\item if $\Ind{}{p}{\Gamma_I}{\Gamma_C}$ is a universe polymorphic and cumulative (see Chapter~\ref{Universes-full})
+ inductive type (see below) and $(t : \forall\Gamma_P,\forall\Gamma_{\mathit{Arr}(t)}, \Sort)\in\Gamma_I$
+ and $(t' : \forall\Gamma_P',\forall\Gamma_{\mathit{Arr}(t)}', \Sort')\in\Gamma_I$
+ are two different instances of \emph{the same} inductive type (differing only in universe levels) with constructors
+ \[[c_1: \forall\Gamma_P,\forall T_{1,1} \dots T_{1,n_1},t\ v_{1,1} \dots v_{1,m}; \dots; c_k: \forall\Gamma_P,\forall T_{k, 1} \dots T_{k,n_k},t\ v_{n,1}\dots v_{n,m}]\]
+ and
+ \[[c_1: \forall\Gamma_P',\forall T_{1,1}' \dots T_{1,n_1}',t'\ v_{1,1}' \dots v_{1,m}'; \dots; c_k: \forall\Gamma_P',\forall T_{k, 1}' \dots T_{k,n_k}',t\ v_{n,1}'\dots v_{n,m}']\]
+ respectively then $\WTEGLECONV{t\ w_1 \dots w_m}{t\ w_1' \dots w_m'}$ (notice that $t$ and $t'$ are both fully applied, i.e., they have a sort as a type)
+ if $\WTEGCONV{w_i}{w_i'}$ for $1 \le i \le m$ and we have
+ \[ \WTEGLECONV{T_{i,j}}{T_{i,j}'} \text{ and } \WTEGLECONV{A_i}{A_i'}\]
+ where $\Gamma_{\mathit{Arr}(t)} = [a_1 : A_1; a_1 : A_l]$ and $\Gamma_{\mathit{Arr}(t)} = [a_1 : A_1'; a_1 : A_l']$.
\end{enumerate}
The conversion rule up to subtyping is now exactly:
@@ -530,8 +548,12 @@ Formally, we can represent any {\em inductive definition\index{definition!induct
These inductive definitions, together with global assumptions and global definitions, then form the global environment.
%
Additionally, for any $p$ there always exists $\Gamma_P=[a_1:A_1;\dots;a_p:A_p]$
-such that each $(t:T)\in\Gamma_I\cup\Gamma_C$ can be written as:
+such that each $T$ in $(t:T)\in\Gamma_I\cup\Gamma_C$ can be written as:
$\forall\Gamma_P, T^\prime$ where $\Gamma_P$ is called the {\em context of parameters\index{context of parameters}}.
+Furthermore, we must have that each $T$ in $(t:T)\in\Gamma_I$ can be written as:
+$\forall\Gamma_P,\forall\Gamma_{\mathit{Arr}(t)}, \Sort$ where $\Gamma_{\mathit{Arr}(t)}$ is called the
+{\em Arity} of the inductive type\index{arity of inductive type} $t$ and
+$\Sort$ is called the sort of the inductive type $t$.
\paragraph{Examples}
diff --git a/doc/refman/Universes.tex b/doc/refman/Universes.tex
index 36518e6fae..2bb1301c79 100644
--- a/doc/refman/Universes.tex
+++ b/doc/refman/Universes.tex
@@ -131,6 +131,52 @@ producing global universe constraints, one can use the
polymorphically, not at a single instance.
\end{itemize}
+\asection{{\tt Cumulative, NonCumulative}}
+\comindex{Cumulative}
+\comindex{NonCumulative}
+\optindex{Inductive Cumulativity}
+
+Inductive types, coinductive types, variants and records can be
+declared cumulative using the \texttt{Cumulative}. Alternatively,
+there is an option \texttt{Set Inductive Cumulativity} which when set,
+makes all subsequent inductive definitions cumulative. Consider the examples below.
+\begin{coq_example*}
+Polymorphic Cumulative Inductive list {A : Type} :=
+| nil : list
+| cons : A -> list -> list.
+\end{coq_example*}
+\begin{coq_example}
+Print list.
+\end{coq_example}
+When printing \texttt{list}, the part of the output of the form
+\texttt{$\mathtt{\sim}$@\{i\} <= $\mathtt{\sim}$@\{j\} iff }
+indicates the universe constraints in order to have the subtyping
+$\WTEGLECONV{\mathtt{list@\{i\}} A}{\mathtt{list@\{j\}} B}$
+(for fully applied instances of \texttt{list}) whenever $\WTEGCONV{A}{B}$.
+In the case of \texttt{list} there is no constraint!
+This also means that any two instances of \texttt{list} are convertible:
+$\WTEGCONV{\mathtt{list@\{i\}} A}{\mathtt{list@\{j\}} B}$ whenever $\WTEGCONV{A}{B}$ and
+furthermore their corresponding (when fully applied to convertible arguments) constructors.
+See Chapter~\ref{Cic} for more details on convertibility and subtyping.
+Also notice the subtyping constraints for the \emph{non-cumulative} version of list:
+\begin{coq_example*}
+Polymorphic NonCumulative Inductive list' {A : Type} :=
+| nil' : list'
+| cons' : A -> list' -> list'.
+\end{coq_example*}
+\begin{coq_example}
+Print list'.
+\end{coq_example}
+The following is an example of a record with non-trivial subtyping relation:
+\begin{coq_example*}
+Polymorphic Cumulative Record packType := {pk : Type}.
+\end{coq_example*}
+\begin{coq_example}
+Print packType.
+\end{coq_example}
+Notice that as expected, \texttt{packType@\{i\}} and \texttt{packType@\{j\}} are convertible if and only if \texttt{i $=$ j}.
+
+
\asection{Global and local universes}
Each universe is declared in a global or local environment before it can
--
cgit v1.2.3
From c01d225f9e112bb08f9df26f70805bde0c0d127a Mon Sep 17 00:00:00 2001
From: Amin Timany
Date: Wed, 24 May 2017 13:45:08 +0200
Subject: Enable the checking of ind subtyping in checker
---
checker/indtypes.ml | 36 ++++++++++++++++++------------------
checker/univ.ml | 33 +++++++++++++++++++++++++++++++--
checker/univ.mli | 14 ++++++++++++--
3 files changed, 61 insertions(+), 22 deletions(-)
diff --git a/checker/indtypes.ml b/checker/indtypes.ml
index 69dd6f57a8..cac7e63134 100644
--- a/checker/indtypes.ml
+++ b/checker/indtypes.ml
@@ -549,25 +549,24 @@ let check_subtyping_arity_constructor env (subst : constr -> constr) (arcn : con
(* Check that the subtyping information inferred for inductive types in the block is correct. *)
(* This check produces a value of the unit type if successful or raises an anomaly if check fails. *)
let check_subtyping mib paramsctxt env_ar inds =
- let numparams = rel_context_nhyps paramsctxt in
- let sbsubst = Univ.UInfoInd.subtyping_susbst mib.mind_universes in
- let dosubst = subst_instance_constr sbsubst in
- let uctx = Univ.UInfoInd.univ_context mib.mind_universes in
- let instance_other = Univ.subst_instance_instance sbsubst (Univ.UContext.instance uctx) in
- let constraints_other = Univ.subst_instance_constraints sbsubst (Univ.UContext.constraints uctx) in
- let uctx_other = Univ.UContext.make (instance_other, constraints_other) in
- let env' = Environ.push_context uctx env_ar in
- let env'' = Environ.push_context uctx_other env' in
- let envsb = push_context (Univ.UInfoInd.subtyp_context mib.mind_universes) env'' in
- (* process individual inductive types: *)
- Array.iter (fun { mind_user_lc = lc; mind_arity = arity } ->
+ let numparams = rel_context_nhyps paramsctxt in
+ let sbsubst = Univ.UInfoInd.subtyping_susbst mib.mind_universes in
+ let other_instnace = Univ.UInfoInd.subtyping_other_instance mib.mind_universes in
+ let dosubst = subst_univs_level_constr sbsubst in
+ let uctx = Univ.UInfoInd.univ_context mib.mind_universes in
+ let uctx_other = Univ.UContext.make (other_instnace, Univ.UContext.constraints uctx) in
+ let env = Environ.push_context uctx env_ar in
+ let env = Environ.push_context uctx_other env in
+ let env = Environ.push_context (Univ.instantiate_univ_context (Univ.UInfoInd.subtyp_context mib.mind_universes)) env in
+ (* process individual inductive types: *)
+ Array.iter (fun { mind_user_lc = lc; mind_arity = arity } ->
match arity with
- | RegularArity { mind_user_arity = full_arity} ->
- check_subtyping_arity_constructor envsb dosubst full_arity numparams true;
- Array.iter (fun cnt -> check_subtyping_arity_constructor envsb dosubst cnt numparams false) lc
- | TemplateArity _ -> ()
+ | RegularArity { mind_user_arity = full_arity} ->
+ check_subtyping_arity_constructor env dosubst full_arity numparams true;
+ Array.iter (fun cnt -> check_subtyping_arity_constructor env dosubst cnt numparams false) lc
+ | TemplateArity _ -> ()
) inds
-
+
(************************************************************************)
(************************************************************************)
@@ -592,7 +591,8 @@ let check_inductive env kn mib =
(* - check constructor types *)
Array.iter (typecheck_one_inductive env_ar params mib) mib.mind_packets;
(* check the inferred subtyping relation *)
- (* check_subtyping mib params env_ar mib.mind_packets; *)
+ if mib.mind_cumulative then
+ check_subtyping mib params env_ar mib.mind_packets;
(* check mind_nparams_rec: positivity condition *)
check_positivity env_ar kn params mib.mind_nparams_rec mib.mind_packets;
(* check mind_equiv... *)
diff --git a/checker/univ.ml b/checker/univ.ml
index 525f535e92..92b6a9e867 100644
--- a/checker/univ.ml
+++ b/checker/univ.ml
@@ -968,7 +968,23 @@ struct
else Level.compare v v'
end
-module Constraint = Set.Make(UConstraintOrd)
+let pr_constraint_type op =
+ let op_str = match op with
+ | Lt -> " < "
+ | Le -> " <= "
+ | Eq -> " = "
+ in str op_str
+
+module Constraint =
+struct
+ module S = Set.Make(UConstraintOrd)
+ include S
+
+ let pr prl c =
+ fold (fun (u1,op,u2) pp_std ->
+ pp_std ++ prl u1 ++ pr_constraint_type op ++
+ prl u2 ++ fnl () ) c (str "")
+end
let empty_constraint = Constraint.empty
let merge_constraints c g =
@@ -1159,6 +1175,11 @@ struct
let make x = x
let instance (univs, cst) = univs
let constraints (univs, cst) = cst
+
+ let is_empty (univs, cst) = Instance.is_empty univs && Constraint.is_empty cst
+ let pr prl (univs, cst as ctx) =
+ if is_empty ctx then mt() else
+ h 0 (Instance.pr univs ++ str " |= ") ++ h 0 (v 0 (Constraint.pr prl cst))
end
type universe_context = UContext.t
@@ -1193,8 +1214,12 @@ struct
(univcst, UContext.make (Array.append inst freshunivs,
create_trivial_subtyping inst freshunivs))
+ let subtyping_other_instance (univcst, subtypcst) =
+ let (_, ctx') = (halve_context (UContext.instance subtypcst)) in ctx'
+
let subtyping_susbst (univcst, subtypcst) =
- let (_, ctx') = (halve_context (UContext.instance subtypcst)) in ctx'
+ let (ctx, ctx') = (halve_context (UContext.instance subtypcst)) in
+ Array.fold_left2 (fun subst l1 l2 -> LMap.add l1 l2 subst) LMap.empty ctx ctx'
end
@@ -1308,6 +1333,10 @@ let merge_context_set strict ctx g =
(** Pretty-printing *)
+let pr_constraints prl = Constraint.pr prl
+
+let pr_universe_context = UContext.pr
+
let pr_arc = function
| _, Canonical {univ=u; lt=[]; le=[]} ->
mt ()
diff --git a/checker/univ.mli b/checker/univ.mli
index 2bc2653e09..018f8aee2e 100644
--- a/checker/univ.mli
+++ b/checker/univ.mli
@@ -18,6 +18,9 @@ sig
(** Create a new universe level from a unique identifier and an associated
module path. *)
+ val pr : t -> Pp.std_ppcmds
+ (** Pretty-printing *)
+
val equal : t -> t -> bool
end
@@ -195,7 +198,8 @@ sig
val make : universe_instance constrained -> t
val instance : t -> Instance.t
val constraints : t -> constraints
-
+ val is_empty : t -> bool
+
end
type universe_context = UContext.t
@@ -213,7 +217,9 @@ sig
val from_universe_context : universe_context -> universe_instance -> t
- val subtyping_susbst : t -> universe_instance
+ val subtyping_other_instance : t -> universe_instance
+
+ val subtyping_susbst : t -> universe_level_subst
end
@@ -263,4 +269,8 @@ val make_abstract_instance : universe_context -> universe_instance
(** {6 Pretty-printing of universes. } *)
+val pr_constraint_type : constraint_type -> Pp.std_ppcmds
+val pr_constraints : (Level.t -> Pp.std_ppcmds) -> constraints -> Pp.std_ppcmds
+val pr_universe_context : (Level.t -> Pp.std_ppcmds) -> universe_context -> Pp.std_ppcmds
+
val pr_universes : universes -> Pp.std_ppcmds
--
cgit v1.2.3
From 960b6d7e17d7a44ad2e058a5b24a2628293408bc Mon Sep 17 00:00:00 2001
From: Amin Timany
Date: Wed, 24 May 2017 13:56:51 +0200
Subject: Properly instantiate contexts before pushing
---
checker/indtypes.ml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/checker/indtypes.ml b/checker/indtypes.ml
index cac7e63134..2716489a4f 100644
--- a/checker/indtypes.ml
+++ b/checker/indtypes.ml
@@ -555,8 +555,8 @@ let check_subtyping mib paramsctxt env_ar inds =
let dosubst = subst_univs_level_constr sbsubst in
let uctx = Univ.UInfoInd.univ_context mib.mind_universes in
let uctx_other = Univ.UContext.make (other_instnace, Univ.UContext.constraints uctx) in
- let env = Environ.push_context uctx env_ar in
- let env = Environ.push_context uctx_other env in
+ let env = Environ.push_context (Univ.instantiate_univ_context uctx) env_ar in
+ let env = Environ.push_context (Univ.instantiate_univ_context uctx_other) env in
let env = Environ.push_context (Univ.instantiate_univ_context (Univ.UInfoInd.subtyp_context mib.mind_universes)) env in
(* process individual inductive types: *)
Array.iter (fun { mind_user_lc = lc; mind_arity = arity } ->
--
cgit v1.2.3
From 81a22cd3bee8fa6144d4eb46128ee8bb287ecb36 Mon Sep 17 00:00:00 2001
From: Amin Timany
Date: Wed, 24 May 2017 14:40:36 +0200
Subject: Checker add test for non-trivial constraints
---
checker/indtypes.ml | 2 +-
test-suite/coqchk/cumulativity.v | 11 ++++++++++-
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/checker/indtypes.ml b/checker/indtypes.ml
index 2716489a4f..cc3493aa25 100644
--- a/checker/indtypes.ml
+++ b/checker/indtypes.ml
@@ -573,7 +573,7 @@ let check_subtyping mib paramsctxt env_ar inds =
let check_inductive env kn mib =
Flags.if_verbose Feedback.msg_notice (str " checking ind: " ++ MutInd.print kn);
(* check mind_constraints: should be consistent with env *)
- let env = Environ.push_context (Univ.instantiate_univ_context mib.mind_universes) env in
+ let env = Environ.push_context (Univ.instantiate_univ_context (Univ.UInfoInd.univ_context mib.mind_universes)) env in
(* check mind_record : TODO ? check #constructor = 1 ? *)
(* check mind_finite : always OK *)
(* check mind_ntypes *)
diff --git a/test-suite/coqchk/cumulativity.v b/test-suite/coqchk/cumulativity.v
index 3a8f9fa22f..ecf9035bfe 100644
--- a/test-suite/coqchk/cumulativity.v
+++ b/test-suite/coqchk/cumulativity.v
@@ -49,4 +49,13 @@ Section TpLower.
Fail Definition LowerTp : Tp@{j} -> Tp@{i} := fun x => x.
-End TpLower.
\ No newline at end of file
+End TpLower.
+
+
+Section subtyping_test.
+ Universe i j.
+ Constraint i < j.
+
+ Inductive TP2 := tp2 : Type@{i} -> Type@{j} -> TP2.
+
+End subtyping_test.
\ No newline at end of file
--
cgit v1.2.3
From 249a1910a2474216b7f98491afafc6019a04c894 Mon Sep 17 00:00:00 2001
From: Amin Timany
Date: Wed, 24 May 2017 23:46:23 +0200
Subject: Remove Warnings: unused value ...
---
proofs/proof_global.ml | 1 -
vernac/vernacentries.ml | 6 ------
2 files changed, 7 deletions(-)
diff --git a/proofs/proof_global.ml b/proofs/proof_global.ml
index f5664aed00..d5fbdbb830 100644
--- a/proofs/proof_global.ml
+++ b/proofs/proof_global.ml
@@ -336,7 +336,6 @@ let close_proof ~keep_body_ucst_separate ?feedback_id ~now
let make_body =
if poly || now then
let make_body t (c, eff) =
- let open Universes in
let body = c in
let typ =
if not (keep_body_ucst_separate || not (Safe_typing.empty_private_constants = eff)) then
diff --git a/vernac/vernacentries.ml b/vernac/vernacentries.ml
index 957911e1e5..21f053fb9b 100644
--- a/vernac/vernacentries.ml
+++ b/vernac/vernacentries.ml
@@ -2091,12 +2091,6 @@ let enforce_polymorphism = function
| None -> Flags.is_universe_polymorphism ()
| Some b -> Flags.make_polymorphic_flag b; b
-let check_vernac_supports_cumulativity c p =
- match p, c with
- | None, _ -> ()
- | Some _, (VernacInductive _ ) -> ()
- | Some _, _ -> CErrors.error "This command does not support Cumulativity"
-
(** A global default timeout, controlled by option "Set Default Timeout n".
Use "Unset Default Timeout" to deactivate it (or set it to 0). *)
--
cgit v1.2.3
From 3380f47d2bb38d549fcdac8fb073f9aa1f259a23 Mon Sep 17 00:00:00 2001
From: Amin Timany
Date: Sat, 27 May 2017 09:48:53 +0200
Subject: Move (part of) tests from checker to success
Due to some unknown problem coqchk fails on some inductive types when it is
compiled with ocaml4.02.3+32bit and camlp5-4.16 which is the case for Travis
tests.
---
test-suite/coqchk/cumulativity.v | 43 +++++++++++++++------------
test-suite/success/cumulativity.v | 61 +++++++++++++++++++++++++++++++++++++++
2 files changed, 86 insertions(+), 18 deletions(-)
create mode 100644 test-suite/success/cumulativity.v
diff --git a/test-suite/coqchk/cumulativity.v b/test-suite/coqchk/cumulativity.v
index ecf9035bfe..84121ea925 100644
--- a/test-suite/coqchk/cumulativity.v
+++ b/test-suite/coqchk/cumulativity.v
@@ -28,34 +28,41 @@ End ListLower.
Lemma LowerL_Lem@{i j} (A : Type@{j}) (l : List@{i} A) : l = LowerL l.
Proof. reflexivity. Qed.
-Inductive Tp := tp : Type -> Tp.
+(* I disable these tests because cqochk can't process them when compiled with
+ ocaml-4.02.3+32bit and camlp5-4.16 which is the case for Travis!
-Section TpLift.
- Universe i j.
+ I have added this file (including the commented parts below) in
+ test-suite/success/cumulativity.v which doesn't run coqchk on them.
+*)
- Constraint i < j.
+(* Inductive Tp := tp : Type -> Tp. *)
- Definition LiftTp : Tp@{i} -> Tp@{j} := fun x => x.
+(* Section TpLift. *)
+(* Universe i j. *)
-End TpLift.
+(* Constraint i < j. *)
-Lemma LiftC_Lem (t : Tp) : LiftTp t = t.
-Proof. reflexivity. Qed.
+(* Definition LiftTp : Tp@{i} -> Tp@{j} := fun x => x. *)
-Section TpLower.
- Universe i j.
+(* End TpLift. *)
- Constraint i < j.
+(* Lemma LiftC_Lem (t : Tp) : LiftTp t = t. *)
+(* Proof. reflexivity. Qed. *)
- Fail Definition LowerTp : Tp@{j} -> Tp@{i} := fun x => x.
+(* Section TpLower. *)
+(* Universe i j. *)
-End TpLower.
+(* Constraint i < j. *)
+(* Fail Definition LowerTp : Tp@{j} -> Tp@{i} := fun x => x. *)
-Section subtyping_test.
- Universe i j.
- Constraint i < j.
+(* End TpLower. *)
+
+
+(* Section subtyping_test. *)
+(* Universe i j. *)
+(* Constraint i < j. *)
- Inductive TP2 := tp2 : Type@{i} -> Type@{j} -> TP2.
+(* Inductive TP2 := tp2 : Type@{i} -> Type@{j} -> TP2. *)
-End subtyping_test.
\ No newline at end of file
+(* End subtyping_test. *)
\ No newline at end of file
diff --git a/test-suite/success/cumulativity.v b/test-suite/success/cumulativity.v
new file mode 100644
index 0000000000..ecf9035bfe
--- /dev/null
+++ b/test-suite/success/cumulativity.v
@@ -0,0 +1,61 @@
+Set Universe Polymorphism.
+Set Inductive Cumulativity.
+Set Printing Universes.
+
+Inductive List (A: Type) := nil | cons : A -> List A -> List A.
+
+Section ListLift.
+ Universe i j.
+
+ Constraint i < j.
+
+ Definition LiftL {A} : List@{i} A -> List@{j} A := fun x => x.
+
+End ListLift.
+
+Lemma LiftL_Lem A (l : List A) : l = LiftL l.
+Proof. reflexivity. Qed.
+
+Section ListLower.
+ Universe i j.
+
+ Constraint i < j.
+
+ Definition LowerL {A : Type@{i}} : List@{j} A -> List@{i} A := fun x => x.
+
+End ListLower.
+
+Lemma LowerL_Lem@{i j} (A : Type@{j}) (l : List@{i} A) : l = LowerL l.
+Proof. reflexivity. Qed.
+
+Inductive Tp := tp : Type -> Tp.
+
+Section TpLift.
+ Universe i j.
+
+ Constraint i < j.
+
+ Definition LiftTp : Tp@{i} -> Tp@{j} := fun x => x.
+
+End TpLift.
+
+Lemma LiftC_Lem (t : Tp) : LiftTp t = t.
+Proof. reflexivity. Qed.
+
+Section TpLower.
+ Universe i j.
+
+ Constraint i < j.
+
+ Fail Definition LowerTp : Tp@{j} -> Tp@{i} := fun x => x.
+
+End TpLower.
+
+
+Section subtyping_test.
+ Universe i j.
+ Constraint i < j.
+
+ Inductive TP2 := tp2 : Type@{i} -> Type@{j} -> TP2.
+
+End subtyping_test.
\ No newline at end of file
--
cgit v1.2.3
From ff918e4bb0ae23566e038f4b55d84dd2c343f95e Mon Sep 17 00:00:00 2001
From: Amin Timany
Date: Thu, 1 Jun 2017 16:18:19 +0200
Subject: Clean up universes of constants and inductives
---
API/API.mli | 19 ++++--
checker/cic.mli | 16 +++--
checker/declarations.ml | 5 ++
checker/declarations.mli | 1 +
checker/environ.ml | 27 +++++---
checker/environ.mli | 2 +-
checker/indtypes.ml | 36 +++++++---
checker/inductive.ml | 33 ++++++++--
checker/inductive.mli | 8 ++-
checker/mod_checking.ml | 20 +++---
checker/modops.ml | 8 +--
checker/reduction.ml | 75 +++++++++++----------
checker/subtyping.ml | 27 +++++---
checker/typeops.ml | 1 -
checker/univ.ml | 20 ++++--
checker/univ.mli | 33 ++++++++--
checker/values.ml | 17 +++--
dev/base_include | 2 +-
dev/include | 2 +-
dev/top_printers.ml | 2 +-
engine/universes.ml | 139 +++++++++++++++++++++++++--------------
engine/universes.mli | 6 +-
kernel/cbytegen.ml | 4 +-
kernel/cbytegen.mli | 2 +-
kernel/cooking.ml | 43 ++++++------
kernel/cooking.mli | 3 +-
kernel/declarations.ml | 16 +++--
kernel/declareops.ml | 124 +++++++++++++++++++++++-----------
kernel/declareops.mli | 15 ++++-
kernel/entries.mli | 9 ++-
kernel/environ.ml | 46 ++++++++-----
kernel/environ.mli | 5 +-
kernel/indtypes.ml | 69 ++++++++++++-------
kernel/indtypes.mli | 11 ----
kernel/inductive.ml | 10 ++-
kernel/mod_typing.ml | 23 +++----
kernel/modops.ml | 11 ++--
kernel/modops.mli | 1 +
kernel/nativecode.ml | 7 +-
kernel/opaqueproof.ml | 2 +-
kernel/opaqueproof.mli | 2 +-
kernel/reduction.ml | 67 +++++++++++--------
kernel/safe_typing.ml | 79 +++++++++++++---------
kernel/subtyping.ml | 87 +++++++++++++-----------
kernel/term_typing.ml | 97 +++++++++++++++++----------
kernel/typeops.ml | 2 +-
kernel/univ.ml | 66 ++++++++++++++-----
kernel/univ.mli | 55 +++++++++++++---
kernel/vconv.ml | 50 +++++++-------
library/declare.ml | 19 +++---
library/global.ml | 38 +++++------
library/lib.ml | 6 +-
library/lib.mli | 2 +-
library/univops.ml | 23 +++++--
pretyping/arguments_renaming.ml | 2 +-
pretyping/evarconv.ml | 55 +++++++++-------
pretyping/inductiveops.ml | 77 +++++++++++++---------
pretyping/recordops.ml | 5 +-
pretyping/reductionops.ml | 45 ++++++++-----
pretyping/typeclasses.ml | 8 +--
pretyping/vnorm.ml | 6 +-
printing/prettyp.ml | 10 ++-
printing/printer.ml | 17 ++---
printing/printer.mli | 2 +-
printing/printmod.ml | 43 ++++++++----
tactics/elimschemes.ml | 4 +-
tactics/elimschemes.mli | 8 +++
tactics/hints.ml | 3 +-
test-suite/coqchk/cumulativity.v | 5 +-
vernac/command.ml | 17 +++--
vernac/discharge.ml | 25 ++++---
vernac/discharge.mli | 3 +-
vernac/himsg.ml | 4 ++
vernac/ind_tables.ml | 4 +-
vernac/obligations.ml | 4 +-
vernac/record.ml | 55 ++++++++++++----
vernac/record.mli | 4 +-
vernac/search.ml | 2 +-
78 files changed, 1187 insertions(+), 714 deletions(-)
diff --git a/API/API.mli b/API/API.mli
index a993b0277c..ecce22c1de 100644
--- a/API/API.mli
+++ b/API/API.mli
@@ -84,9 +84,11 @@ sig
end
type universe_context = UContext.t
- [@@ocaml.deprecated "alias of API.Names.UContext.t"]
+ [@@ocaml.deprecated "alias of API.Univ.UContext.t"]
- type universe_info_ind = Univ.UInfoInd.t
+ type abstract_universe_context = Univ.AUContext.t
+ type cumulativity_info = Univ.CumulativityInfo.t
+ type abstract_cumulativity_info = Univ.ACumulativityInfo.t
module LSet : module type of struct include Univ.LSet end
module ContextSet :
@@ -1047,12 +1049,12 @@ sig
proj_body : Term.constr;
}
type typing_flags = Declarations.typing_flags
+
type constant_body = Declarations.constant_body = {
const_hyps : Context.Named.t;
const_body : constant_def;
const_type : constant_type;
const_body_code : Cemitcodes.to_patch_substituted option;
- const_polymorphic : bool;
const_universes : constant_universes;
const_proj : projection_body option;
const_inline_code : bool;
@@ -1085,6 +1087,13 @@ sig
| MEident of Names.ModPath.t
| MEapply of module_alg_expr * Names.ModPath.t
| MEwith of module_alg_expr * with_declaration
+
+ type abstrac_inductive_universes = Declarations.abstrac_inductive_universes =
+ | Monomorphic_ind of Univ.UContext.t
+ | Polymorphic_ind of Univ.abstract_universe_context
+ | Cumulative_ind of Univ.abstract_cumulativity_info
+
+
type mutual_inductive_body = Declarations.mutual_inductive_body = {
mind_packets : one_inductive_body array;
mind_record : Declarations.record_body option;
@@ -1094,9 +1103,7 @@ sig
mind_nparams : int;
mind_nparams_rec : int;
mind_params_ctxt : Context.Rel.t;
- mind_polymorphic : bool;
- mind_cumulative : bool;
- mind_universes : Univ.universe_info_ind;
+ mind_universes : abstrac_inductive_universes;
mind_private : bool option;
mind_typing_flags : Declarations.typing_flags;
}
diff --git a/checker/cic.mli b/checker/cic.mli
index f9d082ab1c..bbddb678bc 100644
--- a/checker/cic.mli
+++ b/checker/cic.mli
@@ -209,7 +209,9 @@ type constant_def =
| Def of constr_substituted
| OpaqueDef of lazy_constr
-type constant_universes = Univ.universe_context
+type constant_universes =
+ | Monomorphic_const of Univ.universe_context
+ | Polymorphic_const of Univ.abstract_universe_context
(** The [typing_flags] are instructions to the type-checker which
modify its behaviour. The typing flags used in the type-checking
@@ -226,7 +228,6 @@ type constant_body = {
const_body : constant_def;
const_type : constant_type;
const_body_code : to_patch_substituted;
- const_polymorphic : bool; (** Is it polymorphic or not *)
const_universes : constant_universes;
const_proj : projection_body option;
const_inline_code : bool;
@@ -303,6 +304,11 @@ type one_inductive_body = {
mind_reloc_tbl : reloc_table;
}
+type abstrac_inductive_universes =
+ | Monomorphic_ind of Univ.universe_context
+ | Polymorphic_ind of Univ.abstract_universe_context
+ | Cumulative_ind of Univ.abstract_cumulativity_info
+
type mutual_inductive_body = {
mind_packets : one_inductive_body array; (** The component of the mutual inductive block *)
@@ -321,11 +327,7 @@ type mutual_inductive_body = {
mind_params_ctxt : rel_context; (** The context of parameters (includes let-in declaration) *)
- mind_polymorphic : bool; (** Is it polymorphic or not *)
-
- mind_cumulative : bool; (** Is it cumulative or not *)
-
- mind_universes : Univ.universe_info_ind; (** Local universe variables and constraints together with subtyping constraints *)
+ mind_universes : abstrac_inductive_universes; (** Local universe variables and constraints together with subtyping constraints *)
mind_private : bool option; (** allow pattern-matching: Some true ok, Some false blocked *)
diff --git a/checker/declarations.ml b/checker/declarations.ml
index ad93146d55..2eefe47816 100644
--- a/checker/declarations.ml
+++ b/checker/declarations.ml
@@ -521,6 +521,11 @@ let subst_template_cst_arity sub (ctx,s as arity) =
let subst_arity sub s = subst_decl_arity subst_mps subst_template_cst_arity sub s
+let constant_is_polymorphic cb =
+ match cb.const_universes with
+ | Monomorphic_const _ -> false
+ | Polymorphic_const _ -> true
+
(* TODO: should be changed to non-coping after Term.subst_mps *)
(* NB: we leave bytecode and native code fields untouched *)
let subst_const_body sub cb =
diff --git a/checker/declarations.mli b/checker/declarations.mli
index 456df83699..6fc71bb942 100644
--- a/checker/declarations.mli
+++ b/checker/declarations.mli
@@ -14,6 +14,7 @@ val body_of_constant : constant_body -> constr option
val constant_has_body : constant_body -> bool
val is_opaque : constant_body -> bool
val opaque_univ_context : constant_body -> Univ.ContextSet.t
+val constant_is_polymorphic : constant_body -> bool
(* Mutual inductives *)
diff --git a/checker/environ.ml b/checker/environ.ml
index 22d1eec178..11b8ea67cc 100644
--- a/checker/environ.ml
+++ b/checker/environ.ml
@@ -115,13 +115,15 @@ let add_constant kn cs env =
env_constants = new_constants } in
{ env with env_globals = new_globals }
-type const_evaluation_result = NoBody | Opaque
+type const_evaluation_result = NoBody | Opaque | IsProj
(* Constant types *)
let constraints_of cb u =
- let univs = cb.const_universes in
- Univ.subst_instance_constraints u (Univ.UContext.constraints univs)
+ match cb.const_universes with
+ | Monomorphic_const _ -> Univ.Constraint.empty
+ | Polymorphic_const ctx ->
+ Univ.UContext.constraints (Univ.subst_instance_context u ctx)
let map_regular_arity f = function
| RegularArity a as ar ->
@@ -132,23 +134,28 @@ let map_regular_arity f = function
(* constant_type gives the type of a constant *)
let constant_type env (kn,u) =
let cb = lookup_constant kn env in
- if cb.const_polymorphic then
- let csts = constraints_of cb u in
- (map_regular_arity (subst_instance_constr u) cb.const_type, csts)
- else cb.const_type, Univ.Constraint.empty
+ match cb.const_universes with
+ | Monomorphic_const _ -> cb.const_type, Univ.Constraint.empty
+ | Polymorphic_const ctx ->
+ let csts = constraints_of cb u in
+ (map_regular_arity (subst_instance_constr u) cb.const_type, csts)
exception NotEvaluableConst of const_evaluation_result
let constant_value env (kn,u) =
let cb = lookup_constant kn env in
+ if cb.const_proj = None then
match cb.const_body with
| Def l_body ->
let b = force_constr l_body in
- if cb.const_polymorphic then
- subst_instance_constr u (force_constr l_body)
- else b
+ begin
+ match cb.const_universes with
+ | Monomorphic_const _ -> b
+ | Polymorphic_const _ -> subst_instance_constr u (force_constr l_body)
+ end
| OpaqueDef _ -> raise (NotEvaluableConst Opaque)
| Undef _ -> raise (NotEvaluableConst NoBody)
+ else raise (NotEvaluableConst IsProj)
(* A global const is evaluable if it is defined and not opaque *)
let evaluable_constant cst env =
diff --git a/checker/environ.mli b/checker/environ.mli
index 87f143d1bb..754c295d27 100644
--- a/checker/environ.mli
+++ b/checker/environ.mli
@@ -47,7 +47,7 @@ val check_constraints : Univ.constraints -> env -> bool
val lookup_constant : constant -> env -> Cic.constant_body
val add_constant : constant -> Cic.constant_body -> env -> env
val constant_type : env -> constant puniverses -> constant_type Univ.constrained
-type const_evaluation_result = NoBody | Opaque
+type const_evaluation_result = NoBody | Opaque | IsProj
exception NotEvaluableConst of const_evaluation_result
val constant_value : env -> constant puniverses -> constr
val evaluable_constant : constant -> env -> bool
diff --git a/checker/indtypes.ml b/checker/indtypes.ml
index cc3493aa25..54dec56b54 100644
--- a/checker/indtypes.ml
+++ b/checker/indtypes.ml
@@ -548,16 +548,20 @@ let check_subtyping_arity_constructor env (subst : constr -> constr) (arcn : con
(* Check that the subtyping information inferred for inductive types in the block is correct. *)
(* This check produces a value of the unit type if successful or raises an anomaly if check fails. *)
-let check_subtyping mib paramsctxt env_ar inds =
+let check_subtyping cumi paramsctxt env_ar inds =
let numparams = rel_context_nhyps paramsctxt in
- let sbsubst = Univ.UInfoInd.subtyping_susbst mib.mind_universes in
- let other_instnace = Univ.UInfoInd.subtyping_other_instance mib.mind_universes in
+ let sbsubst = Univ.CumulativityInfo.subtyping_susbst cumi in
+ let other_instnace = Univ.CumulativityInfo.subtyping_other_instance cumi in
let dosubst = subst_univs_level_constr sbsubst in
- let uctx = Univ.UInfoInd.univ_context mib.mind_universes in
+ let uctx = Univ.CumulativityInfo.univ_context cumi in
let uctx_other = Univ.UContext.make (other_instnace, Univ.UContext.constraints uctx) in
- let env = Environ.push_context (Univ.instantiate_univ_context uctx) env_ar in
- let env = Environ.push_context (Univ.instantiate_univ_context uctx_other) env in
- let env = Environ.push_context (Univ.instantiate_univ_context (Univ.UInfoInd.subtyp_context mib.mind_universes)) env in
+ let env = Environ.push_context uctx env_ar
+ in
+ let env = Environ.push_context uctx_other env
+ in
+ let env = Environ.push_context
+ (Univ.CumulativityInfo.subtyp_context cumi) env
+ in
(* process individual inductive types: *)
Array.iter (fun { mind_user_lc = lc; mind_arity = arity } ->
match arity with
@@ -573,7 +577,14 @@ let check_subtyping mib paramsctxt env_ar inds =
let check_inductive env kn mib =
Flags.if_verbose Feedback.msg_notice (str " checking ind: " ++ MutInd.print kn);
(* check mind_constraints: should be consistent with env *)
- let env = Environ.push_context (Univ.instantiate_univ_context (Univ.UInfoInd.univ_context mib.mind_universes)) env in
+ let ind_ctx =
+ match mib.mind_universes with
+ | Monomorphic_ind ctx -> ctx
+ | Polymorphic_ind auctx -> Univ.instantiate_univ_context auctx
+ | Cumulative_ind cumi ->
+ Univ.instantiate_univ_context (Univ.ACumulativityInfo.univ_context cumi)
+ in
+ let env = Environ.push_context ind_ctx env in
(* check mind_record : TODO ? check #constructor = 1 ? *)
(* check mind_finite : always OK *)
(* check mind_ntypes *)
@@ -591,8 +602,13 @@ let check_inductive env kn mib =
(* - check constructor types *)
Array.iter (typecheck_one_inductive env_ar params mib) mib.mind_packets;
(* check the inferred subtyping relation *)
- if mib.mind_cumulative then
- check_subtyping mib params env_ar mib.mind_packets;
+ let () =
+ match mib.mind_universes with
+ | Monomorphic_ind _ | Polymorphic_ind _ -> ()
+ | Cumulative_ind acumi ->
+ check_subtyping
+ (Univ.instantiate_cumulativity_info acumi) params env_ar mib.mind_packets
+ in
(* check mind_nparams_rec: positivity condition *)
check_positivity env_ar kn params mib.mind_nparams_rec mib.mind_packets;
(* check mind_equiv... *)
diff --git a/checker/inductive.ml b/checker/inductive.ml
index 30c5f878a1..e1860a23f0 100644
--- a/checker/inductive.ml
+++ b/checker/inductive.ml
@@ -54,10 +54,31 @@ let inductive_params (mib,_) = mib.mind_nparams
(** Polymorphic inductives *)
-let inductive_instance mib =
- if mib.mind_polymorphic then
- UContext.instance (UInfoInd.univ_context mib.mind_universes)
- else Instance.empty
+let inductive_is_polymorphic mib =
+ match mib.mind_universes with
+ | Monomorphic_ind _ -> false
+ | Polymorphic_ind ctx -> true
+ | Cumulative_ind cumi -> true
+
+let inductive_is_cumulative mib =
+ match mib.mind_universes with
+ | Monomorphic_ind _ -> false
+ | Polymorphic_ind ctx -> false
+ | Cumulative_ind cumi -> true
+
+let inductive_polymorphic_instance mib =
+ match mib.mind_universes with
+ | Monomorphic_ind _ -> Univ.Instance.empty
+ | Polymorphic_ind ctx -> Univ.AUContext.instance ctx
+ | Cumulative_ind cumi ->
+ Univ.AUContext.instance (Univ.ACumulativityInfo.univ_context cumi)
+
+let inductive_polymorphic_context mib =
+ match mib.mind_universes with
+ | Monomorphic_ind _ -> Univ.UContext.empty
+ | Polymorphic_ind ctx -> Univ.instantiate_univ_context ctx
+ | Cumulative_ind cumi ->
+ Univ.instantiate_univ_context (Univ.ACumulativityInfo.univ_context cumi)
(************************************************************************)
@@ -93,7 +114,7 @@ let instantiate_params full t u args sign =
let full_inductive_instantiate mib u params sign =
let dummy = Prop Null in
- let t = mkArity (subst_instance_context u sign,dummy) in
+ let t = mkArity (Term.subst_instance_context u sign,dummy) in
fst (destArity (instantiate_params true t u params mib.mind_params_ctxt))
let full_constructor_instantiate ((mind,_),u,(mib,_),params) t =
@@ -199,7 +220,7 @@ let instantiate_universes env ctx ar argsorts =
let type_of_inductive_gen env ((mib,mip),u) paramtyps =
match mip.mind_arity with
| RegularArity a ->
- if not mib.mind_polymorphic then a.mind_user_arity
+ if not (inductive_is_polymorphic mib) then a.mind_user_arity
else subst_instance_constr u a.mind_user_arity
| TemplateArity ar ->
let ctx = List.rev mip.mind_arity_ctxt in
diff --git a/checker/inductive.mli b/checker/inductive.mli
index ed3a7b53ce..9a5541f39b 100644
--- a/checker/inductive.mli
+++ b/checker/inductive.mli
@@ -22,7 +22,13 @@ type mind_specif = mutual_inductive_body * one_inductive_body
Raises [Not_found] if the inductive type is not found. *)
val lookup_mind_specif : env -> inductive -> mind_specif
-val inductive_instance : mutual_inductive_body -> Univ.universe_instance
+val inductive_is_polymorphic : mutual_inductive_body -> bool
+
+val inductive_is_cumulative : mutual_inductive_body -> bool
+
+val inductive_polymorphic_instance : mutual_inductive_body -> Univ.universe_instance
+
+val inductive_polymorphic_context : mutual_inductive_body -> Univ.universe_context
val type_of_inductive : env -> mind_specif puniverses -> constr
diff --git a/checker/mod_checking.ml b/checker/mod_checking.ml
index 7f93e15609..15e9ae2951 100644
--- a/checker/mod_checking.ml
+++ b/checker/mod_checking.ml
@@ -1,4 +1,3 @@
-
open Pp
open Util
open Names
@@ -26,21 +25,23 @@ let refresh_arity ar =
| _ -> ar, Univ.ContextSet.empty
let check_constant_declaration env kn cb =
- Flags.if_verbose Feedback.msg_notice (str " checking cst: " ++ prcon kn);
- let env' =
- if cb.const_polymorphic then
- let inst = Univ.make_abstract_instance cb.const_universes in
- let ctx = Univ.UContext.make (inst, Univ.UContext.constraints cb.const_universes) in
- push_context ~strict:false ctx env
- else push_context ~strict:true cb.const_universes env
+ Feedback.msg_notice (str " checking cst:" ++ prcon kn);
+ let env', u =
+ match cb.const_universes with
+ | Monomorphic_const ctx -> push_context ~strict:true ctx env, Univ.Instance.empty
+ | Polymorphic_const auctx ->
+ let ctx = Univ.instantiate_univ_context auctx in
+ push_context ~strict:false ctx env, Univ.UContext.instance ctx
in
let envty, ty =
match cb.const_type with
RegularArity ty ->
+ let ty = subst_instance_constr u ty in
let ty', cu = refresh_arity ty in
let envty = push_context_set cu env' in
let _ = infer_type envty ty' in envty, ty
| TemplateArity(ctxt,par) ->
+ assert(Univ.Instance.is_empty u);
let _ = check_ctxt env' ctxt in
check_polymorphic_arity env' ctxt par;
env', it_mkProd_or_LetIn (Sort(Type par.template_level)) ctxt
@@ -48,6 +49,7 @@ let check_constant_declaration env kn cb =
let () =
match body_of_constant cb with
| Some bd ->
+ let bd = subst_instance_constr u bd in
(match cb.const_proj with
| None -> let j = infer envty bd in
conv_leq envty j ty
@@ -57,7 +59,7 @@ let check_constant_declaration env kn cb =
conv_leq envty j ty)
| None -> ()
in
- if cb.const_polymorphic then add_constant kn cb env
+ if constant_is_polymorphic cb then add_constant kn cb env
else add_constant kn cb env'
(** {6 Checking modules } *)
diff --git a/checker/modops.ml b/checker/modops.ml
index bed31143bf..be35c7e981 100644
--- a/checker/modops.ml
+++ b/checker/modops.ml
@@ -83,10 +83,10 @@ let strengthen_const mp_from l cb resolver =
| Def _ -> cb
| _ ->
let con = Constant.make2 mp_from l in
- let u =
- if cb.const_polymorphic then
- Univ.make_abstract_instance cb.const_universes
- else Univ.Instance.empty
+ let u =
+ match cb.const_universes with
+ | Monomorphic_const _ -> Univ.Instance.empty
+ | Polymorphic_const auctx -> Univ.make_abstract_instance auctx
in
{ cb with
const_body = Def (Declarations.from_val (Const (con,u))) }
diff --git a/checker/reduction.ml b/checker/reduction.ml
index 70c0bdad02..5010920bcb 100644
--- a/checker/reduction.ml
+++ b/checker/reduction.ml
@@ -156,22 +156,27 @@ let compare_stacks f fmind lft1 stk1 lft2 stk2 =
cmp_rec (pure_stack lft1 stk1) (pure_stack lft2 stk2)
else raise NotConvertible
-let convert_inductive_instances cv_pb uinfind u u' univs =
- let ind_instance = Univ.UContext.instance (Univ.UInfoInd.univ_context uinfind) in
- let ind_sbcst = Univ.UContext.constraints (Univ.UInfoInd.subtyp_context uinfind) in
+let convert_inductive_instances cv_pb cumi u u' univs =
+ let ind_instance =
+ Univ.AUContext.instance (Univ.ACumulativityInfo.univ_context cumi) in
+ let ind_subtypctx = Univ.ACumulativityInfo.subtyp_context cumi in
if not ((Univ.Instance.length ind_instance = Univ.Instance.length u) &&
(Univ.Instance.length ind_instance = Univ.Instance.length u')) then
- anomaly (Pp.str "Invalid inductive subtyping encountered!")
+ anomaly (Pp.str "Invalid inductive subtyping encountered!")
else
let comp_cst =
let comp_subst = (Univ.Instance.append u u') in
- Univ.subst_instance_constraints comp_subst ind_sbcst
+ Univ.UContext.constraints
+ (Univ.subst_instance_context comp_subst ind_subtypctx)
in
let comp_cst =
match cv_pb with
CONV ->
- let comp_subst = (Univ.Instance.append u' u) in
- let comp_cst' = (Univ.subst_instance_constraints comp_subst ind_sbcst) in
+ let comp_cst' =
+ let comp_subst = (Univ.Instance.append u' u) in
+ Univ.UContext.constraints
+ (Univ.subst_instance_context comp_subst ind_subtypctx)
+ in
Univ.Constraint.union comp_cst comp_cst'
| CUMUL -> comp_cst
in
@@ -179,28 +184,32 @@ let convert_inductive_instances cv_pb uinfind u u' univs =
let convert_inductives
cv_pb (mind, ind) u1 sv1 u2 sv2 univs =
- let num_param_arity =
- mind.mind_nparams + mind.mind_packets.(ind).mind_nrealargs
- in
- if not (num_param_arity = sv1 && num_param_arity = sv2) then
- convert_universes univs u1 u2
- else
- let uinfind = mind.mind_universes in
- convert_inductive_instances cv_pb uinfind u1 u2 univs
+ match mind.mind_universes with
+ | Monomorphic_ind _ | Polymorphic_ind _ -> convert_universes univs u1 u2
+ | Cumulative_ind cumi ->
+ let num_param_arity =
+ mind.mind_nparams + mind.mind_packets.(ind).mind_nrealargs
+ in
+ if not (num_param_arity = sv1 && num_param_arity = sv2) then
+ convert_universes univs u1 u2
+ else
+ convert_inductive_instances cv_pb cumi u1 u2 univs
let convert_constructors
(mind, ind, cns) u1 sv1 u2 sv2 univs =
- let num_cnstr_args =
- let nparamsctxt =
- mind.mind_nparams + mind.mind_packets.(ind).mind_nrealargs
+ match mind.mind_universes with
+ | Monomorphic_ind _ | Polymorphic_ind _ -> convert_universes univs u1 u2
+ | Cumulative_ind cumi ->
+ let num_cnstr_args =
+ let nparamsctxt =
+ mind.mind_nparams + mind.mind_packets.(ind).mind_nrealargs
+ in
+ nparamsctxt + mind.mind_packets.(ind).mind_consnrealargs.(cns - 1)
in
- nparamsctxt + mind.mind_packets.(ind).mind_consnrealargs.(cns - 1)
- in
- if not (num_cnstr_args = sv1 && num_cnstr_args = sv2) then
- convert_universes univs u1 u2
- else
- let uinfind = mind.mind_universes in
- convert_inductive_instances CONV uinfind u1 u2 univs
+ if not (num_cnstr_args = sv1 && num_cnstr_args = sv2) then
+ convert_universes univs u1 u2
+ else
+ convert_inductive_instances CONV cumi u1 u2 univs
(* Convertibility of sorts *)
@@ -424,11 +433,8 @@ and eqappr univ cv_pb infos (lft1,st1) (lft2,st2) =
if mind_equiv_infos infos ind1 ind2 then
let mind = Environ.lookup_mind (fst ind1) (infos_env infos) in
let () =
- if mind.mind_polymorphic && mind.mind_cumulative then
- convert_inductives cv_pb (mind, snd ind1) u1 (stack_args_size v1)
- u2 (stack_args_size v2) univ
- else
- convert_universes univ u1 u2
+ convert_inductives cv_pb (mind, snd ind1) u1 (stack_args_size v1)
+ u2 (stack_args_size v2) univ
in
convert_stacks univ infos lft1 lft2 v1 v2
else raise NotConvertible
@@ -437,12 +443,9 @@ and eqappr univ cv_pb infos (lft1,st1) (lft2,st2) =
if Int.equal j1 j2 && mind_equiv_infos infos ind1 ind2 then
let mind = Environ.lookup_mind (fst ind1) (infos_env infos) in
let () =
- if mind.mind_polymorphic && mind.mind_cumulative then
- convert_constructors
- (mind, snd ind1, j1) u1 (stack_args_size v1)
- u2 (stack_args_size v2) univ
- else
- convert_universes univ u1 u2
+ convert_constructors
+ (mind, snd ind1, j1) u1 (stack_args_size v1)
+ u2 (stack_args_size v2) univ
in
convert_stacks univ infos lft1 lft2 v1 v2
else raise NotConvertible
diff --git a/checker/subtyping.ml b/checker/subtyping.ml
index 8c10bd6eca..bfe19584a7 100644
--- a/checker/subtyping.ml
+++ b/checker/subtyping.ml
@@ -88,18 +88,25 @@ let check_inductive env mp1 l info1 mib2 spec2 subst1 subst2=
let check_conv f = check_conv_error error f in
let mib1 =
match info1 with
- | IndType ((_,0), mib) -> mib
+ | IndType ((_,0), mib) -> subst_mind subst1 mib
| _ -> error ()
in
let mib2 = subst_mind subst2 mib2 in
let check eq f = if not (eq (f mib1) (f mib2)) then error () in
- let bool_equal (x : bool) (y : bool) = x = y in
- let u =
- check bool_equal (fun x -> x.mind_polymorphic);
- if mib1.mind_polymorphic then (
- check Univ.Instance.equal (fun x -> Univ.UContext.instance (Univ.UInfoInd.univ_context x.mind_universes));
- Univ.UContext.instance (Univ.UInfoInd.univ_context mib1.mind_universes))
- else Univ.Instance.empty
+ let u =
+ let process inst inst' =
+ if Univ.Instance.equal inst inst' then inst else error ()
+ in
+ match mib1.mind_universes, mib2.mind_universes with
+ | Monomorphic_ind _, Monomorphic_ind _ -> Univ.Instance.empty
+ | Polymorphic_ind auctx, Polymorphic_ind auctx' ->
+ process
+ (Univ.AUContext.instance auctx) (Univ.AUContext.instance auctx')
+ | Cumulative_ind cumi, Cumulative_ind cumi' ->
+ process
+ (Univ.AUContext.instance (Univ.ACumulativityInfo.univ_context cumi))
+ (Univ.AUContext.instance (Univ.ACumulativityInfo.univ_context cumi'))
+ | _ -> error ()
in
let eq_projection_body p1 p2 =
let check eq f = if not (eq (f p1) (f p2)) then error () in
@@ -308,7 +315,7 @@ let check_constant env mp1 l info1 cb2 spec2 subst1 subst2 =
"inductive type and give a definition to map the old name to the new " ^
"name.")));
if constant_has_body cb2 then error () ;
- let u = inductive_instance mind1 in
+ let u = inductive_polymorphic_instance mind1 in
let arity1 = type_of_inductive env ((mind1,mind1.mind_packets.(i)),u) in
let typ2 = Typeops.type_of_constant_type env cb2.const_type in
check_conv conv_leq env arity1 typ2
@@ -319,7 +326,7 @@ let check_constant env mp1 l info1 cb2 spec2 subst1 subst2 =
"constructor and give a definition to map the old name to the new " ^
"name.")));
if constant_has_body cb2 then error () ;
- let u1 = inductive_instance mind1 in
+ let u1 = inductive_polymorphic_instance mind1 in
let ty1 = type_of_constructor (cstr,u1) (mind1,mind1.mind_packets.(i)) in
let ty2 = Typeops.type_of_constant_type env cb2.const_type in
check_conv conv env ty1 ty2
diff --git a/checker/typeops.ml b/checker/typeops.ml
index 0163db3347..543f9acced 100644
--- a/checker/typeops.ml
+++ b/checker/typeops.ml
@@ -329,7 +329,6 @@ let rec execute env cstr =
let pj = execute env p in
let lfj = execute_array env lf in
judge_of_case env ci (p,pj) (c,cj) lfj
-
| Fix ((_,i as vni),recdef) ->
let fix_ty = execute_recdef env recdef i in
let fix = (vni,recdef) in
diff --git a/checker/univ.ml b/checker/univ.ml
index 92b6a9e867..0ee4686c1a 100644
--- a/checker/univ.ml
+++ b/checker/univ.ml
@@ -1184,7 +1184,11 @@ end
type universe_context = UContext.t
-module UInfoInd =
+module AUContext = UContext
+
+type abstract_universe_context = AUContext.t
+
+module CumulativityInfo =
struct
type t = universe_context * universe_context
@@ -1223,7 +1227,10 @@ struct
end
-type universe_info_ind = UInfoInd.t
+type cumulativity_info = CumulativityInfo.t
+
+module ACumulativityInfo = CumulativityInfo
+type abstract_cumulativity_info = ACumulativityInfo.t
module ContextSet =
struct
@@ -1281,7 +1288,10 @@ let subst_instance_constraint s (u,d,v as c) =
let subst_instance_constraints s csts =
Constraint.fold
(fun c csts -> Constraint.add (subst_instance_constraint s c) csts)
- csts Constraint.empty
+ csts Constraint.empty
+
+let subst_instance_context inst (inner_inst, inner_constr) =
+ (inner_inst, subst_instance_constraints inst inner_constr)
let make_abstract_instance (ctx, _) =
Array.mapi (fun i l -> Level.var i) ctx
@@ -1290,8 +1300,8 @@ let make_abstract_instance (ctx, _) =
let instantiate_univ_context (ctx, csts) =
(ctx, subst_instance_constraints ctx csts)
-let instantiate_univ_constraints u (_, csts) =
- subst_instance_constraints u csts
+let instantiate_cumulativity_info (ctx, ctx') =
+ (instantiate_univ_context ctx, instantiate_univ_context ctx')
(** With level to universe substitutions. *)
type universe_subst_fn = universe_level -> universe
diff --git a/checker/univ.mli b/checker/univ.mli
index 018f8aee2e..a503924708 100644
--- a/checker/univ.mli
+++ b/checker/univ.mli
@@ -204,7 +204,17 @@ end
type universe_context = UContext.t
-module UInfoInd :
+module AUContext :
+sig
+ type t
+
+ val instance : t -> Instance.t
+
+end
+
+type abstract_universe_context = AUContext.t
+
+module CumulativityInfo :
sig
type t
@@ -223,7 +233,18 @@ sig
end
-type universe_info_ind = UInfoInd.t
+type cumulativity_info = CumulativityInfo.t
+
+module ACumulativityInfo :
+sig
+ type t
+
+ val univ_context : t -> abstract_universe_context
+ val subtyp_context : t -> abstract_universe_context
+
+end
+
+type abstract_cumulativity_info = ACumulativityInfo.t
module ContextSet :
sig
@@ -255,17 +276,17 @@ val subst_univs_universe : universe_subst_fn -> universe -> universe
(** Substitution of instances *)
val subst_instance_instance : universe_instance -> universe_instance -> universe_instance
val subst_instance_universe : universe_instance -> universe -> universe
-val subst_instance_constraints : universe_instance -> constraints -> constraints
+val subst_instance_context : universe_instance -> abstract_universe_context -> universe_context
(* val make_instance_subst : universe_instance -> universe_level_subst *)
(* val make_inverse_instance_subst : universe_instance -> universe_level_subst *)
(** Get the instantiated graph. *)
-val instantiate_univ_context : universe_context -> universe_context
-val instantiate_univ_constraints : universe_instance -> universe_context -> constraints
+val instantiate_univ_context : abstract_universe_context -> universe_context
+val instantiate_cumulativity_info : abstract_cumulativity_info -> cumulativity_info
(** Build the relative instance corresponding to the context *)
-val make_abstract_instance : universe_context -> universe_instance
+val make_abstract_instance : abstract_universe_context -> universe_instance
(** {6 Pretty-printing of universes. } *)
diff --git a/checker/values.ml b/checker/values.ml
index c58f56a9bd..422729ed55 100644
--- a/checker/values.ml
+++ b/checker/values.ml
@@ -13,7 +13,7 @@
To ensure this file is up-to-date, 'make' now compares the md5 of cic.mli
with a copy we maintain here:
-MD5 6153d4f8fb414a8f14797636ab10f55e checker/cic.mli
+MD5 6950230ca9e99e9cc3a70488d8ab824c checker/cic.mli
*)
@@ -109,6 +109,8 @@ let v_cstrs =
let v_instance = Annot ("instance", Array v_level)
let v_context = v_tuple "universe_context" [|v_instance;v_cstrs|]
+let v_abs_context = v_context (* only for clarity *)
+let v_abs_cum_info = v_tuple "cumulativity_info" [|v_abs_context; v_context|]
let v_context_set = v_tuple "universe_context_set" [|v_hset v_level;v_cstrs|]
(** kernel/term *)
@@ -215,13 +217,14 @@ let v_projbody =
let v_typing_flags =
v_tuple "typing_flags" [|v_bool; v_bool|]
+let v_const_univs = v_sum "constant_universes" 0 [|[|v_context|]; [|v_abs_context|]|]
+
let v_cb = v_tuple "constant_body"
[|v_section_ctxt;
v_cst_def;
v_cst_type;
Any;
- v_bool;
- v_context;
+ v_const_univs;
Opt v_projbody;
v_bool;
v_typing_flags|]
@@ -262,6 +265,10 @@ let v_finite = v_enum "recursivity_kind" 3
let v_mind_record = Annot ("mind_record",
Opt (Opt (v_tuple "record" [| v_id; Array v_cst; Array v_projbody |])))
+let v_ind_pack_univs =
+ v_sum "abstract_inductive_universes" 0
+ [|[|v_context|]; [|v_abs_context|]; [|v_abs_cum_info|]|]
+
let v_ind_pack = v_tuple "mutual_inductive_body"
[|Array v_one_ind;
v_mind_record;
@@ -271,9 +278,7 @@ let v_ind_pack = v_tuple "mutual_inductive_body"
Int;
Int;
v_rctxt;
- v_bool;
- v_bool;
- v_tuple "universes" [|v_context; v_context|];
+ v_ind_pack_univs; (* universes *)
Opt v_bool;
v_typing_flags|]
diff --git a/dev/base_include b/dev/base_include
index f9af0696b1..98cf67256f 100644
--- a/dev/base_include
+++ b/dev/base_include
@@ -196,7 +196,7 @@ let qid = Libnames.qualid_of_string;;
(* parsing of terms *)
let parse_constr = Pcoq.parse_string Pcoq.Constr.constr;;
-let parse_tac = Pcoq.parse_string Ltac_plugin.Pltac.tactic;;
+(*let parse_tac = Pcoq.parse_string Ltac_plugin.Pltac.tactic;;*)
let parse_vernac = Pcoq.parse_string Pcoq.Vernac_.vernac;;
(* build a term of type glob_constr without type-checking or resolution of
diff --git a/dev/include b/dev/include
index 4835b360db..1d87456de7 100644
--- a/dev/include
+++ b/dev/include
@@ -41,7 +41,7 @@
#install_printer (* univ context *) ppuniverse_context;;
#install_printer (* univ context future *) ppuniverse_context_future;;
#install_printer (* univ context set *) ppuniverse_context_set;;
-#install_printer (* univ info *) ppuniverse_info;;
+#install_printer (* univ info *) ppcumulativity_info;;
#install_printer (* univ set *) ppuniverse_set;;
#install_printer (* univ instance *) ppuniverse_instance;;
#install_printer (* univ subst *) ppuniverse_subst;;
diff --git a/dev/top_printers.ml b/dev/top_printers.ml
index e902da0b19..abf6db1b7f 100644
--- a/dev/top_printers.ml
+++ b/dev/top_printers.ml
@@ -215,7 +215,7 @@ let ppuniverseconstraints c = pp (Universes.Constraints.pr c)
let ppuniverse_context_future c =
let ctx = Future.force c in
ppuniverse_context ctx
-let ppuniverse_info c = pp (Univ.pr_universe_info_ind Univ.Level.pr c)
+let ppcumulativity_info c = pp (Univ.pr_cumulativity_info Univ.Level.pr c)
let ppuniverses u = pp (UGraph.pr_universes Level.pr u)
let ppnamedcontextval e =
pp (pr_named_context (Global.env ()) Evd.empty (named_context_of_val e))
diff --git a/engine/universes.ml b/engine/universes.ml
index a12b42ab17..bd4d75930c 100644
--- a/engine/universes.ml
+++ b/engine/universes.ml
@@ -283,11 +283,11 @@ let new_Type_sort dp = Type (new_univ dp)
let fresh_universe_instance ctx =
Instance.subst_fn (fun _ -> new_univ_level (Global.current_dirpath ()))
- (UContext.instance ctx)
+ (AUContext.instance ctx)
let fresh_instance_from_context ctx =
let inst = fresh_universe_instance ctx in
- let constraints = instantiate_univ_constraints inst ctx in
+ let constraints = UContext.constraints (subst_instance_context inst ctx) in
inst, constraints
let fresh_instance ctx =
@@ -296,13 +296,13 @@ let fresh_instance ctx =
Instance.subst_fn (fun v ->
let u = new_univ_level (Global.current_dirpath ()) in
ctx' := LSet.add u !ctx'; u)
- (UContext.instance ctx)
+ (AUContext.instance ctx)
in !ctx', inst
let existing_instance ctx inst =
let () =
let a1 = Instance.to_array inst
- and a2 = Instance.to_array (UContext.instance ctx) in
+ and a2 = Instance.to_array (AUContext.instance ctx) in
let len1 = Array.length a1 and len2 = Array.length a2 in
if not (len1 == len2) then
CErrors.user_err ~hdr:"Universes"
@@ -317,59 +317,75 @@ let fresh_instance_from ctx inst =
| Some inst -> existing_instance ctx inst
| None -> fresh_instance ctx
in
- let constraints = instantiate_univ_constraints inst ctx in
+ let constraints = UContext.constraints (subst_instance_context inst ctx) in
inst, (ctx', constraints)
let unsafe_instance_from ctx =
- (Univ.UContext.instance ctx, ctx)
+ (Univ.AUContext.instance ctx, Univ.instantiate_univ_context ctx)
(** Fresh universe polymorphic construction *)
let fresh_constant_instance env c inst =
let cb = lookup_constant c env in
- if cb.Declarations.const_polymorphic then
- let inst, ctx =
- fresh_instance_from
- (Declareops.universes_of_constant (Environ.opaque_tables env) cb) inst
- in
- ((c, inst), ctx)
- else ((c,Instance.empty), ContextSet.empty)
+ match cb.Declarations.const_universes with
+ | Declarations.Monomorphic_const _ -> ((c,Instance.empty), ContextSet.empty)
+ | Declarations.Polymorphic_const auctx ->
+ let inst, ctx =
+ fresh_instance_from auctx inst
+ in
+ ((c, inst), ctx)
let fresh_inductive_instance env ind inst =
let mib, mip = Inductive.lookup_mind_specif env ind in
- if mib.Declarations.mind_polymorphic then
- let inst, ctx = fresh_instance_from (Univ.UInfoInd.univ_context mib.Declarations.mind_universes) inst in
- ((ind,inst), ctx)
- else ((ind,Instance.empty), ContextSet.empty)
+ match mib.Declarations.mind_universes with
+ | Declarations.Monomorphic_ind _ ->
+ ((ind,Instance.empty), ContextSet.empty)
+ | Declarations.Polymorphic_ind uactx ->
+ let inst, ctx = (fresh_instance_from uactx) inst in
+ ((ind,inst), ctx)
+ | Declarations.Cumulative_ind acumi ->
+ let inst, ctx =
+ fresh_instance_from (Univ.ACumulativityInfo.univ_context acumi) inst
+ in ((ind,inst), ctx)
let fresh_constructor_instance env (ind,i) inst =
let mib, mip = Inductive.lookup_mind_specif env ind in
- if mib.Declarations.mind_polymorphic then
- let inst, ctx = fresh_instance_from (Univ.UInfoInd.univ_context mib.Declarations.mind_universes) inst in
+ match mib.Declarations.mind_universes with
+ | Declarations.Monomorphic_ind _ -> (((ind,i),Instance.empty), ContextSet.empty)
+ | Declarations.Polymorphic_ind auctx ->
+ let inst, ctx = fresh_instance_from auctx inst in
(((ind,i),inst), ctx)
- else (((ind,i),Instance.empty), ContextSet.empty)
+ | Declarations.Cumulative_ind acumi ->
+ let inst, ctx = fresh_instance_from (ACumulativityInfo.univ_context acumi) inst in
+ (((ind,i),inst), ctx)
let unsafe_constant_instance env c =
let cb = lookup_constant c env in
- if cb.Declarations.const_polymorphic then
- let inst, ctx = unsafe_instance_from
- (Declareops.universes_of_constant (Environ.opaque_tables env) cb) in
- ((c, inst), ctx)
- else ((c,Instance.empty), UContext.empty)
+ match cb.Declarations.const_universes with
+ | Declarations.Monomorphic_const _ ->
+ ((c,Instance.empty), UContext.empty)
+ | Declarations.Polymorphic_const auctx ->
+ let inst, ctx = unsafe_instance_from auctx in ((c, inst), ctx)
let unsafe_inductive_instance env ind =
let mib, mip = Inductive.lookup_mind_specif env ind in
- if mib.Declarations.mind_polymorphic then
- let inst, ctx = unsafe_instance_from (Univ.UInfoInd.univ_context mib.Declarations.mind_universes) in
- ((ind,inst), ctx)
- else ((ind,Instance.empty), UContext.empty)
+ match mib.Declarations.mind_universes with
+ | Declarations.Monomorphic_ind _ -> ((ind,Instance.empty), UContext.empty)
+ | Declarations.Polymorphic_ind auctx ->
+ let inst, ctx = unsafe_instance_from auctx in ((ind,inst), ctx)
+ | Declarations.Cumulative_ind acumi ->
+ let inst, ctx = unsafe_instance_from (ACumulativityInfo.univ_context acumi) in
+ ((ind,inst), ctx)
let unsafe_constructor_instance env (ind,i) =
let mib, mip = Inductive.lookup_mind_specif env ind in
- if mib.Declarations.mind_polymorphic then
- let inst, ctx = unsafe_instance_from (Univ.UInfoInd.univ_context mib.Declarations.mind_universes) in
- (((ind,i),inst), ctx)
- else (((ind,i),Instance.empty), UContext.empty)
+ match mib.Declarations.mind_universes with
+ | Declarations.Monomorphic_ind _ -> (((ind, i),Instance.empty), UContext.empty)
+ | Declarations.Polymorphic_ind auctx ->
+ let inst, ctx = unsafe_instance_from auctx in (((ind, i),inst), ctx)
+ | Declarations.Cumulative_ind acumi ->
+ let inst, ctx = unsafe_instance_from (ACumulativityInfo.univ_context acumi) in
+ (((ind, i),inst), ctx)
open Globnames
@@ -452,26 +468,49 @@ let type_of_reference env r =
| ConstRef c ->
let cb = Environ.lookup_constant c env in
let ty = Typeops.type_of_constant_type env cb.const_type in
- if cb.const_polymorphic then
- let inst, ctx = fresh_instance_from (Declareops.universes_of_constant (Environ.opaque_tables env) cb) None in
- Vars.subst_instance_constr inst ty, ctx
- else ty, ContextSet.empty
-
+ begin
+ match cb.const_universes with
+ | Monomorphic_const _ -> ty, ContextSet.empty
+ | Polymorphic_const auctx ->
+ let inst, ctx = fresh_instance_from auctx None in
+ Vars.subst_instance_constr inst ty, ctx
+ end
| IndRef ind ->
let (mib, oib as specif) = Inductive.lookup_mind_specif env ind in
- if mib.mind_polymorphic then
- let inst, ctx = fresh_instance_from (Univ.UInfoInd.univ_context mib.mind_universes) None in
+ begin
+ match mib.mind_universes with
+ | Monomorphic_ind _ ->
+ let ty = Inductive.type_of_inductive env (specif, Univ.Instance.empty) in
+ ty, ContextSet.empty
+ | Polymorphic_ind auctx ->
+ let inst, ctx = fresh_instance_from auctx None in
let ty = Inductive.type_of_inductive env (specif, inst) in
- ty, ctx
- else
- let ty = Inductive.type_of_inductive env (specif, Univ.Instance.empty) in
- ty, ContextSet.empty
+ ty, ctx
+ | Cumulative_ind cumi ->
+ let inst, ctx =
+ fresh_instance_from (ACumulativityInfo.univ_context cumi) None
+ in
+ let ty = Inductive.type_of_inductive env (specif, inst) in
+ ty, ctx
+ end
+
| ConstructRef cstr ->
- let (mib,oib as specif) = Inductive.lookup_mind_specif env (inductive_of_constructor cstr) in
- if mib.mind_polymorphic then
- let inst, ctx = fresh_instance_from (Univ.UInfoInd.univ_context mib.mind_universes) None in
- Inductive.type_of_constructor (cstr,inst) specif, ctx
- else Inductive.type_of_constructor (cstr,Instance.empty) specif, ContextSet.empty
+ let (mib,oib as specif) =
+ Inductive.lookup_mind_specif env (inductive_of_constructor cstr)
+ in
+ begin
+ match mib.mind_universes with
+ | Monomorphic_ind _ ->
+ Inductive.type_of_constructor (cstr,Instance.empty) specif, ContextSet.empty
+ | Polymorphic_ind auctx ->
+ let inst, ctx = fresh_instance_from auctx None in
+ Inductive.type_of_constructor (cstr,inst) specif, ctx
+ | Cumulative_ind cumi ->
+ let inst, ctx =
+ fresh_instance_from (ACumulativityInfo.univ_context cumi) None
+ in
+ Inductive.type_of_constructor (cstr,inst) specif, ctx
+ end
let type_of_global t = type_of_reference (Global.env ()) t
@@ -1098,4 +1137,4 @@ let univ_inf_ind_from_universe_context univcst =
let freshunivs = Instance.of_array
(Array.map (fun _ -> new_univ_level ())
(Instance.to_array (UContext.instance univcst)))
- in UInfoInd.from_universe_context univcst freshunivs
+ in CumulativityInfo.from_universe_context univcst freshunivs
diff --git a/engine/universes.mli b/engine/universes.mli
index c600f4af61..5ce5e4a42a 100644
--- a/engine/universes.mli
+++ b/engine/universes.mli
@@ -101,10 +101,10 @@ val eq_constr_universes_proj : env -> constr -> constr -> bool universe_constrai
(** Build a fresh instance for a given context, its associated substitution and
the instantiated constraints. *)
-val fresh_instance_from_context : universe_context ->
+val fresh_instance_from_context : abstract_universe_context ->
universe_instance constrained
-val fresh_instance_from : universe_context -> universe_instance option ->
+val fresh_instance_from : abstract_universe_context -> universe_instance option ->
universe_instance in_universe_context_set
val fresh_sort_in_family : env -> sorts_family ->
@@ -228,4 +228,4 @@ val solve_constraints_system : universe option array -> universe array -> univer
(** Given a universe context representing constraints of an inductive
this function produces a UInfoInd.t that with the trivial subtyping relation. *)
-val univ_inf_ind_from_universe_context : universe_context -> universe_info_ind
+val univ_inf_ind_from_universe_context : universe_context -> cumulativity_info
diff --git a/kernel/cbytegen.ml b/kernel/cbytegen.ml
index 57b397e6f8..02c6a2c715 100644
--- a/kernel/cbytegen.ml
+++ b/kernel/cbytegen.ml
@@ -992,8 +992,8 @@ let compile_constant_body fail_on_error env univs = function
let body = Mod_subst.force_constr sb in
let instance_size =
match univs with
- | None -> 0
- | Some univ -> Univ.UContext.size univ
+ | Monomorphic_const _ -> 0
+ | Polymorphic_const univ -> Univ.AUContext.size univ
in
match kind_of_term body with
| Const (kn',u) when is_univ_copy instance_size u ->
diff --git a/kernel/cbytegen.mli b/kernel/cbytegen.mli
index c0f48641ce..48c2e45332 100644
--- a/kernel/cbytegen.mli
+++ b/kernel/cbytegen.mli
@@ -10,7 +10,7 @@ val compile : bool -> (* Fail on error with a nice user message, otherwise simpl
(** init, fun, fv *)
val compile_constant_body : bool ->
- env -> constant_universes option -> constant_def -> body_code option
+ env -> constant_universes -> constant_def -> body_code option
(** Shortcut of the previous function used during module strengthening *)
diff --git a/kernel/cooking.ml b/kernel/cooking.ml
index 4deadff0a7..0008653644 100644
--- a/kernel/cooking.ml
+++ b/kernel/cooking.ml
@@ -153,8 +153,7 @@ type inline = bool
type result =
constant_def * constant_type * projection_body option *
- bool * constant_universes * inline
- * Context.Named.t option
+ constant_universes * inline * Context.Named.t option
let on_body ml hy f = function
| Undef _ as x -> x
@@ -179,17 +178,21 @@ let cook_constr { Opaqueproof.modlist ; abstract } c =
abstract_constant_body (expmod c) hyps
let lift_univs cb subst =
- if cb.const_polymorphic && not (Univ.LMap.is_empty subst) then
- let inst = Univ.UContext.instance cb.const_universes in
- let cstrs = Univ.UContext.constraints cb.const_universes in
- let len = Univ.LMap.cardinal subst in
- let subst =
- Array.fold_left_i (fun i acc v -> Univ.LMap.add (Level.var i) (Level.var (i + len)) acc)
- subst (Univ.Instance.to_array inst)
- in
- let cstrs' = Univ.subst_univs_level_constraints subst cstrs in
- subst, Univ.UContext.make (inst,cstrs')
- else subst, cb.const_universes
+ match cb.const_universes with
+ | Monomorphic_const ctx -> subst, (Monomorphic_const ctx)
+ | Polymorphic_const auctx ->
+ if (Univ.LMap.is_empty subst) then
+ subst, (Polymorphic_const auctx)
+ else
+ let inst = Univ.AUContext.instance auctx in
+ let len = Univ.LMap.cardinal subst in
+ let subst =
+ Array.fold_left_i
+ (fun i acc v -> Univ.LMap.add (Level.var i) (Level.var (i + len)) acc)
+ subst (Univ.Instance.to_array inst)
+ in
+ let auctx' = Univ.subst_univs_level_abstract_universe_context subst auctx in
+ subst, (Polymorphic_const auctx')
let cook_constant ~hcons env { from = cb; info } =
let { Opaqueproof.modlist; abstract } = info in
@@ -243,15 +246,15 @@ let cook_constant ~hcons env { from = cb; info } =
proj_eta = etab, etat;
proj_type = ty'; proj_body = c' }
in
- let univs =
- let abs' =
- if cb.const_polymorphic then abs_ctx
- else instantiate_univ_context abs_ctx
- in
- UContext.union abs' univs
+ let univs =
+ match univs with
+ | Monomorphic_const ctx ->
+ Monomorphic_const (UContext.union (instantiate_univ_context abs_ctx) ctx)
+ | Polymorphic_const auctx ->
+ Polymorphic_const (AUContext.union abs_ctx auctx)
in
(body, typ, Option.map projection cb.const_proj,
- cb.const_polymorphic, univs, cb.const_inline_code,
+ univs, cb.const_inline_code,
Some const_hyps)
(* let cook_constant_key = Profile.declare_profile "cook_constant" *)
diff --git a/kernel/cooking.mli b/kernel/cooking.mli
index 7d47eba23e..9db85a4a11 100644
--- a/kernel/cooking.mli
+++ b/kernel/cooking.mli
@@ -18,8 +18,7 @@ type inline = bool
type result =
constant_def * constant_type * projection_body option *
- bool * constant_universes * inline
- * Context.Named.t option
+ constant_universes * inline * Context.Named.t option
val cook_constant : hcons:bool -> env -> recipe -> result
val cook_constr : Opaqueproof.cooking_info -> Term.constr -> Term.constr
diff --git a/kernel/declarations.ml b/kernel/declarations.ml
index ae47324560..f3b7ae2b24 100644
--- a/kernel/declarations.ml
+++ b/kernel/declarations.ml
@@ -64,7 +64,9 @@ type constant_def =
| Def of constr Mod_subst.substituted (** or a transparent global definition *)
| OpaqueDef of Opaqueproof.opaque (** or an opaque global definition *)
-type constant_universes = Univ.universe_context
+type constant_universes =
+ | Monomorphic_const of Univ.universe_context
+ | Polymorphic_const of Univ.abstract_universe_context
(** The [typing_flags] are instructions to the type-checker which
modify its behaviour. The typing flags used in the type-checking
@@ -83,7 +85,6 @@ type constant_body = {
const_body : constant_def;
const_type : constant_type;
const_body_code : Cemitcodes.to_patch_substituted option;
- const_polymorphic : bool; (** Is it polymorphic or not *)
const_universes : constant_universes;
const_proj : projection_body option;
const_inline_code : bool;
@@ -168,6 +169,11 @@ type one_inductive_body = {
mind_reloc_tbl : Cbytecodes.reloc_table;
}
+type abstrac_inductive_universes =
+ | Monomorphic_ind of Univ.universe_context
+ | Polymorphic_ind of Univ.abstract_universe_context
+ | Cumulative_ind of Univ.abstract_cumulativity_info
+
type mutual_inductive_body = {
mind_packets : one_inductive_body array; (** The component of the mutual inductive block *)
@@ -186,11 +192,7 @@ type mutual_inductive_body = {
mind_params_ctxt : Context.Rel.t; (** The context of parameters (includes let-in declaration) *)
- mind_polymorphic : bool; (** Is it polymorphic or not *)
-
- mind_cumulative : bool; (** Is it cumulative or not *)
-
- mind_universes : Univ.universe_info_ind; (** Local universe variables and constraints together with subtyping constraints *)
+ mind_universes : abstrac_inductive_universes; (** Information about monomorphic/polymorphic/cumulative inductives and their universes *)
mind_private : bool option; (** allow pattern-matching: Some true ok, Some false blocked *)
diff --git a/kernel/declareops.ml b/kernel/declareops.ml
index 1d91b2d414..72b4907680 100644
--- a/kernel/declareops.ml
+++ b/kernel/declareops.ml
@@ -45,14 +45,15 @@ let hcons_template_arity ar =
(** {6 Constants } *)
let instantiate cb c =
- if cb.const_polymorphic then
- Vars.subst_instance_constr (Univ.UContext.instance cb.const_universes) c
- else c
+ match cb.const_universes with
+ | Monomorphic_const _ -> c
+ | Polymorphic_const ctx ->
+ Vars.subst_instance_constr (Univ.AUContext.instance ctx) c
-let instantiate_constraints cb cst =
- if cb.const_polymorphic then
- Univ.subst_instance_constraints (Univ.UContext.instance cb.const_universes) cst
- else cst
+let constant_is_polymorphic cb =
+ match cb.const_universes with
+ | Monomorphic_const _ -> false
+ | Polymorphic_const _ -> true
let body_of_constant otab cb = match cb.const_body with
| Undef _ -> None
@@ -67,34 +68,55 @@ let type_of_constant cb =
| TemplateArity _ as x -> x
let constraints_of_constant otab cb =
- let cst = Univ.Constraint.union
- (Univ.UContext.constraints cb.const_universes)
- (match cb.const_body with
- | Undef _ -> Univ.empty_constraint
- | Def c -> Univ.empty_constraint
- | OpaqueDef o ->
- Univ.ContextSet.constraints (Opaqueproof.force_constraints otab o))
- in instantiate_constraints cb cst
+ match cb.const_universes with
+ | Polymorphic_const ctx ->
+ Univ.UContext.constraints (Univ.instantiate_univ_context ctx)
+ | Monomorphic_const ctx ->
+ Univ.Constraint.union
+ (Univ.UContext.constraints ctx)
+ (match cb.const_body with
+ | Undef _ -> Univ.empty_constraint
+ | Def c -> Univ.empty_constraint
+ | OpaqueDef o ->
+ Univ.ContextSet.constraints (Opaqueproof.force_constraints otab o))
let universes_of_constant otab cb =
match cb.const_body with
- | Undef _ | Def _ -> cb.const_universes
+ | Undef _ | Def _ ->
+ begin
+ match cb.const_universes with
+ | Monomorphic_const ctx -> ctx
+ | Polymorphic_const ctx -> Univ.instantiate_univ_context ctx
+ end
| OpaqueDef o ->
- let body_uctxs = Opaqueproof.force_constraints otab o in
- assert(not cb.const_polymorphic || Univ.ContextSet.is_empty body_uctxs);
- let uctxs = Univ.ContextSet.of_context cb.const_universes in
- Univ.ContextSet.to_context (Univ.ContextSet.union body_uctxs uctxs)
+ let body_uctxs = Opaqueproof.force_constraints otab o in
+ match cb.const_universes with
+ | Monomorphic_const ctx ->
+ let uctxs = Univ.ContextSet.of_context ctx in
+ Univ.ContextSet.to_context (Univ.ContextSet.union body_uctxs uctxs)
+ | Polymorphic_const ctx ->
+ assert(Univ.ContextSet.is_empty body_uctxs);
+ Univ.instantiate_univ_context ctx
let universes_of_polymorphic_constant otab cb =
- if cb.const_polymorphic then
- let univs = universes_of_constant otab cb in
- Univ.instantiate_univ_context univs
- else Univ.UContext.empty
+ match cb.const_universes with
+ | Monomorphic_const _ -> Univ.UContext.empty
+ | Polymorphic_const ctx -> Univ.instantiate_univ_context ctx
let constant_has_body cb = match cb.const_body with
| Undef _ -> false
| Def _ | OpaqueDef _ -> true
+let constant_polymorphic_instance cb =
+ match cb.const_universes with
+ | Monomorphic_const _ -> Univ.Instance.empty
+ | Polymorphic_const ctx -> Univ.AUContext.instance ctx
+
+let constant_polymorphic_context cb =
+ match cb.const_universes with
+ | Monomorphic_const _ -> Univ.UContext.empty
+ | Polymorphic_const ctx -> Univ.instantiate_univ_context ctx
+
let is_opaque cb = match cb.const_body with
| OpaqueDef _ -> true
| Undef _ | Def _ -> false
@@ -142,7 +164,6 @@ let subst_const_body sub cb =
const_proj = proj';
const_body_code =
Option.map (Cemitcodes.subst_to_patch_subst sub) cb.const_body_code;
- const_polymorphic = cb.const_polymorphic;
const_universes = cb.const_universes;
const_inline_code = cb.const_inline_code;
const_typing_flags = cb.const_typing_flags }
@@ -173,11 +194,18 @@ let hcons_const_def = function
Def (from_val (Term.hcons_constr constr))
| OpaqueDef _ as x -> x (* hashconsed when turned indirect *)
+let hcons_const_universes cbu =
+ match cbu with
+ | Monomorphic_const ctx ->
+ Monomorphic_const (Univ.hcons_universe_context ctx)
+ | Polymorphic_const ctx ->
+ Polymorphic_const (Univ.hcons_abstract_universe_context ctx)
+
let hcons_const_body cb =
{ cb with
const_body = hcons_const_def cb.const_body;
const_type = hcons_const_type cb.const_type;
- const_universes = Univ.hcons_universe_context cb.const_universes }
+ const_universes = hcons_const_universes cb.const_universes }
(** {6 Inductive types } *)
@@ -266,22 +294,36 @@ let subst_mind_body sub mib =
mind_params_ctxt =
Context.Rel.map (subst_mps sub) mib.mind_params_ctxt;
mind_packets = Array.smartmap (subst_mind_packet sub) mib.mind_packets ;
- mind_polymorphic = mib.mind_polymorphic;
- mind_cumulative = mib.mind_cumulative;
mind_universes = mib.mind_universes;
mind_private = mib.mind_private;
mind_typing_flags = mib.mind_typing_flags;
}
-let inductive_instance mib =
- if mib.mind_polymorphic then
- Univ.UContext.instance (Univ.UInfoInd.univ_context mib.mind_universes)
- else Univ.Instance.empty
-
-let inductive_context mib =
- if mib.mind_polymorphic then
- Univ.instantiate_univ_context (Univ.UInfoInd.univ_context mib.mind_universes)
- else Univ.UContext.empty
+let inductive_polymorphic_instance mib =
+ match mib.mind_universes with
+ | Monomorphic_ind _ -> Univ.Instance.empty
+ | Polymorphic_ind ctx -> Univ.AUContext.instance ctx
+ | Cumulative_ind cumi ->
+ Univ.AUContext.instance (Univ.ACumulativityInfo.univ_context cumi)
+
+let inductive_polymorphic_context mib =
+ match mib.mind_universes with
+ | Monomorphic_ind _ -> Univ.UContext.empty
+ | Polymorphic_ind ctx -> Univ.instantiate_univ_context ctx
+ | Cumulative_ind cumi ->
+ Univ.instantiate_univ_context (Univ.ACumulativityInfo.univ_context cumi)
+
+let inductive_is_polymorphic mib =
+ match mib.mind_universes with
+ | Monomorphic_ind _ -> false
+ | Polymorphic_ind ctx -> true
+ | Cumulative_ind cumi -> true
+
+let inductive_is_cumulative mib =
+ match mib.mind_universes with
+ | Monomorphic_ind _ -> false
+ | Polymorphic_ind ctx -> false
+ | Cumulative_ind cumi -> true
(** {6 Hash-consing of inductive declarations } *)
@@ -309,11 +351,17 @@ let hcons_mind_packet oib =
mind_user_lc = user;
mind_nf_lc = nf }
+let hcons_mind_universes miu =
+ match miu with
+ | Monomorphic_ind ctx -> Monomorphic_ind (Univ.hcons_universe_context ctx)
+ | Polymorphic_ind ctx -> Polymorphic_ind (Univ.hcons_abstract_universe_context ctx)
+ | Cumulative_ind cui -> Cumulative_ind (Univ.hcons_abstract_cumulativity_info cui)
+
let hcons_mind mib =
{ mib with
mind_packets = Array.smartmap hcons_mind_packet mib.mind_packets;
mind_params_ctxt = hcons_rel_context mib.mind_params_ctxt;
- mind_universes = Univ.hcons_universe_info_ind mib.mind_universes }
+ mind_universes = hcons_mind_universes mib.mind_universes }
(** {6 Stm machinery } *)
diff --git a/kernel/declareops.mli b/kernel/declareops.mli
index 6650b6b7b0..811a28aa65 100644
--- a/kernel/declareops.mli
+++ b/kernel/declareops.mli
@@ -27,6 +27,12 @@ val subst_const_body : substitution -> constant_body -> constant_body
val constant_has_body : constant_body -> bool
+val constant_polymorphic_instance : constant_body -> universe_instance
+val constant_polymorphic_context : constant_body -> universe_context
+
+(** Is the constant polymorphic? *)
+val constant_is_polymorphic : constant_body -> bool
+
(** Accessing const_body, forcing access to opaque proof term if needed.
Only use this function if you know what you're doing. *)
@@ -66,8 +72,13 @@ val subst_wf_paths : substitution -> wf_paths -> wf_paths
val subst_mind_body : substitution -> mutual_inductive_body -> mutual_inductive_body
-val inductive_instance : mutual_inductive_body -> universe_instance
-val inductive_context : mutual_inductive_body -> universe_context
+val inductive_polymorphic_instance : mutual_inductive_body -> universe_instance
+val inductive_polymorphic_context : mutual_inductive_body -> universe_context
+
+(** Is the inductive polymorphic? *)
+val inductive_is_polymorphic : mutual_inductive_body -> bool
+(** Is the inductive cumulative? *)
+val inductive_is_cumulative : mutual_inductive_body -> bool
(** {6 Kernel flags} *)
diff --git a/kernel/entries.mli b/kernel/entries.mli
index 9c17346f22..f133587c16 100644
--- a/kernel/entries.mli
+++ b/kernel/entries.mli
@@ -34,6 +34,11 @@ then, in i{^ th} block, [mind_entry_params] is [xn:Xn;...;x1:X1];
[mind_entry_lc] is [Ti1;...;Tini], defined in context [[A'1;...;A'p;x1:X1;...;xn:Xn]] where [A'i] is [Ai] generalized over [[x1:X1;...;xn:Xn]].
*)
+type inductive_universes =
+ | Monomorphic_ind_entry of Univ.universe_context
+ | Polymorphic_ind_entry of Univ.universe_context
+ | Cumulative_ind_entry of Univ.cumulativity_info
+
type one_inductive_entry = {
mind_entry_typename : Id.t;
mind_entry_arity : constr;
@@ -49,9 +54,7 @@ type mutual_inductive_entry = {
mind_entry_finite : Decl_kinds.recursivity_kind;
mind_entry_params : (Id.t * local_entry) list;
mind_entry_inds : one_inductive_entry list;
- mind_entry_polymorphic : bool;
- mind_entry_cumulative : bool;
- mind_entry_universes : Univ.universe_info_ind;
+ mind_entry_universes : inductive_universes;
(* universe constraints and the constraints for subtyping of
inductive types in the block. *)
mind_entry_private : bool option;
diff --git a/kernel/environ.ml b/kernel/environ.ml
index 5727bf2ea1..1ab5b7a8d1 100644
--- a/kernel/environ.ml
+++ b/kernel/environ.ml
@@ -228,8 +228,10 @@ let add_constant kn cb env =
add_constant_key kn cb no_link_info env
let constraints_of cb u =
- let univs = cb.const_universes in
- Univ.subst_instance_constraints u (Univ.UContext.constraints univs)
+ match cb.const_universes with
+ | Monomorphic_const _ -> Univ.Constraint.empty
+ | Polymorphic_const ctx ->
+ Univ.UContext.constraints (Univ.subst_instance_context u ctx)
let map_regular_arity f = function
| RegularArity a as ar ->
@@ -240,15 +242,23 @@ let map_regular_arity f = function
(* constant_type gives the type of a constant *)
let constant_type env (kn,u) =
let cb = lookup_constant kn env in
- if cb.const_polymorphic then
- let csts = constraints_of cb u in
- (map_regular_arity (subst_instance_constr u) cb.const_type, csts)
- else cb.const_type, Univ.Constraint.empty
+ match cb.const_universes with
+ | Monomorphic_const _ -> cb.const_type, Univ.Constraint.empty
+ | Polymorphic_const ctx ->
+ let csts = constraints_of cb u in
+ (map_regular_arity (subst_instance_constr u) cb.const_type, csts)
+
+let constant_instance env kn =
+ let cb = lookup_constant kn env in
+ match cb.const_universes with
+ | Monomorphic_const _ -> Univ.Instance.empty
+ | Polymorphic_const ctx -> Univ.AUContext.instance ctx
let constant_context env kn =
let cb = lookup_constant kn env in
- if cb.const_polymorphic then cb.const_universes
- else Univ.UContext.empty
+ match cb.const_universes with
+ | Monomorphic_const _ -> Univ.UContext.empty
+ | Polymorphic_const ctx -> Univ.instantiate_univ_context ctx
type const_evaluation_result = NoBody | Opaque | IsProj
@@ -259,10 +269,14 @@ let constant_value env (kn,u) =
if cb.const_proj = None then
match cb.const_body with
| Def l_body ->
- if cb.const_polymorphic then
- let csts = constraints_of cb u in
- (subst_instance_constr u (Mod_subst.force_constr l_body), csts)
- else Mod_subst.force_constr l_body, Univ.Constraint.empty
+ begin
+ match cb.const_universes with
+ | Monomorphic_const _ ->
+ (Mod_subst.force_constr l_body, Univ.Constraint.empty)
+ | Polymorphic_const _ ->
+ let csts = constraints_of cb u in
+ (subst_instance_constr u (Mod_subst.force_constr l_body), csts)
+ end
| OpaqueDef _ -> raise (NotEvaluableConst Opaque)
| Undef _ -> raise (NotEvaluableConst NoBody)
else raise (NotEvaluableConst IsProj)
@@ -273,7 +287,7 @@ let constant_opt_value env cst =
let constant_value_and_type env (kn, u) =
let cb = lookup_constant kn env in
- if cb.const_polymorphic then
+ if Declareops.constant_is_polymorphic cb then
let cst = constraints_of cb u in
let b' = match cb.const_body with
| Def l_body -> Some (subst_instance_constr u (Mod_subst.force_constr l_body))
@@ -295,7 +309,7 @@ let constant_value_and_type env (kn, u) =
(* constant_type gives the type of a constant *)
let constant_type_in env (kn,u) =
let cb = lookup_constant kn env in
- if cb.const_polymorphic then
+ if Declareops.constant_is_polymorphic cb then
map_regular_arity (subst_instance_constr u) cb.const_type
else cb.const_type
@@ -321,7 +335,7 @@ let evaluable_constant kn env =
| Undef _ -> false
let polymorphic_constant cst env =
- (lookup_constant cst env).const_polymorphic
+ Declareops.constant_is_polymorphic (lookup_constant cst env)
let polymorphic_pconstant (cst,u) env =
if Univ.Instance.is_empty u then false
@@ -353,7 +367,7 @@ let is_projection cst env =
let lookup_mind = lookup_mind
let polymorphic_ind (mind,i) env =
- (lookup_mind mind env).mind_polymorphic
+ Declareops.inductive_is_polymorphic (lookup_mind mind env)
let polymorphic_pind (ind,u) env =
if Univ.Instance.is_empty u then false
diff --git a/kernel/environ.mli b/kernel/environ.mli
index b7431dbe5f..ae3afcb355 100644
--- a/kernel/environ.mli
+++ b/kernel/environ.mli
@@ -161,6 +161,9 @@ val constant_value_and_type : env -> constant puniverses ->
(** The universe context associated to the constant, empty if not
polymorphic *)
val constant_context : env -> constant -> Univ.universe_context
+(** The universe isntance associated to the constant, empty if not
+ polymorphic *)
+val constant_instance : env -> constant -> Univ.universe_instance
(* These functions should be called under the invariant that [env]
already contains the constraints corresponding to the constant
@@ -256,7 +259,7 @@ type unsafe_type_judgment = types punsafe_type_judgment
(** {6 Compilation of global declaration } *)
-val compile_constant_body : env -> constant_universes option -> constant_def -> Cemitcodes.body_code option
+val compile_constant_body : env -> constant_universes -> constant_def -> Cemitcodes.body_code option
exception Hyp_not_found
diff --git a/kernel/indtypes.ml b/kernel/indtypes.ml
index 5cfcbba606..00fbe27a70 100644
--- a/kernel/indtypes.ml
+++ b/kernel/indtypes.ml
@@ -231,23 +231,23 @@ let check_subtyping_arity_constructor env (subst : constr -> constr) (arcn : Ter
(* Check that the subtyping information inferred for inductive types in the block is correct. *)
(* This check produces a value of the unit type if successful or raises an anomaly if check fails. *)
-let check_subtyping mie paramsctxt env_ar inds =
+let check_subtyping cumi paramsctxt env_ar inds =
let numparams = Context.Rel.nhyps paramsctxt in
- let sbsubst = UInfoInd.subtyping_susbst mie.mind_entry_universes in
+ let sbsubst = CumulativityInfo.subtyping_susbst cumi in
let dosubst = subst_univs_level_constr sbsubst in
- let uctx = UInfoInd.univ_context mie.mind_entry_universes in
+ let uctx = CumulativityInfo.univ_context cumi in
let instance_other = Univ.subst_univs_level_instance sbsubst (Univ.UContext.instance uctx) in
let constraints_other = Univ.subst_univs_level_constraints sbsubst (Univ.UContext.constraints uctx) in
let uctx_other = Univ.UContext.make (instance_other, constraints_other) in
- let env' = Environ.push_context uctx env_ar in
- let env'' = Environ.push_context uctx_other env' in
- let envsb = push_context (UInfoInd.subtyp_context mie.mind_entry_universes) env'' in
+ let env = Environ.push_context uctx env_ar in
+ let env = Environ.push_context uctx_other env in
+ let env = push_context (CumulativityInfo.subtyp_context cumi) env in
(* process individual inductive types: *)
Array.iter (fun (id,cn,lc,(sign,arity)) ->
match arity with
| RegularArity (_, full_arity, _) ->
- check_subtyping_arity_constructor envsb dosubst full_arity numparams true;
- Array.iter (fun cnt -> check_subtyping_arity_constructor envsb dosubst cnt numparams false) lc
+ check_subtyping_arity_constructor env dosubst full_arity numparams true;
+ Array.iter (fun cnt -> check_subtyping_arity_constructor env dosubst cnt numparams false) lc
| TemplateArity _ -> ()
) inds
@@ -264,7 +264,13 @@ let typecheck_inductive env mie =
(* Check unicity of names *)
mind_check_names mie;
(* Params are typed-checked here *)
- let env' = push_context (Univ.UInfoInd.univ_context mie.mind_entry_universes) env in
+ let univctx =
+ match mie.mind_entry_universes with
+ | Monomorphic_ind_entry ctx -> ctx
+ | Polymorphic_ind_entry ctx -> ctx
+ | Cumulative_ind_entry cumi -> Univ.CumulativityInfo.univ_context cumi
+ in
+ let env' = push_context univctx env in
let (env_params,paramsctxt) = infer_local_decls env' mie.mind_entry_params in
(* We first type arity of each inductive definition *)
(* This allows building the environment of arities and to share *)
@@ -383,16 +389,21 @@ let typecheck_inductive env mie =
| _ (* Not an explicit occurrence of Type *) ->
full_polymorphic ()
in
- let arity =
- if mie.mind_entry_polymorphic then full_polymorphic ()
- else template_polymorphic ()
+ let arity =
+ match mie.mind_entry_universes with
+ | Monomorphic_ind_entry _ -> template_polymorphic ()
+ | Polymorphic_ind_entry _ | Cumulative_ind_entry _ -> full_polymorphic ()
in
(id,cn,lc,(sign,arity)))
inds
in
(* Check that the subtyping information inferred for inductive types in the block is correct. *)
(* This check produces a value of the unit type if successful or raises an anomaly if check fails. *)
- let () = if mie.mind_entry_cumulative then check_subtyping mie paramsctxt env_arities inds
+ let () =
+ match mie.mind_entry_universes with
+ | Monomorphic_ind_entry _ -> ()
+ | Polymorphic_ind_entry _ -> ()
+ | Cumulative_ind_entry cumi -> check_subtyping cumi paramsctxt env_arities inds
in (env_arities, env_ar_par, paramsctxt, inds)
(************************************************************************)
@@ -864,14 +875,21 @@ let compute_projections ((kn, _ as ind), u as indu) n x nparamargs params
Array.of_list (List.rev kns),
Array.of_list (List.rev pbs)
-let build_inductive env cum p prv ctx env_ar paramsctxt kn isrecord isfinite inds nmr recargs =
+let abstract_inductive_universes iu =
+ match iu with
+ | Monomorphic_ind_entry ctx -> (Univ.empty_level_subst, Monomorphic_ind ctx)
+ | Polymorphic_ind_entry ctx ->
+ let (inst, auctx) = Univ.abstract_universes ctx in (inst, Polymorphic_ind auctx)
+ | Cumulative_ind_entry cumi ->
+ let (inst, acumi) = Univ.abstract_cumulativity_info cumi in (inst, Cumulative_ind acumi)
+
+let build_inductive env prv iu env_ar paramsctxt kn isrecord isfinite inds nmr recargs =
let ntypes = Array.length inds in
(* Compute the set of used section variables *)
let hyps = used_section_variables env inds in
let nparamargs = Context.Rel.nhyps paramsctxt in
let nparamsctxt = Context.Rel.length paramsctxt in
- let substunivs, ctxunivs = Univ.abstract_universes p (Univ.UInfoInd.univ_context ctx) in
- let substsubtyp, ctxsubtyp = Univ.abstract_universes p (Univ.UInfoInd.subtyp_context ctx) in
+ let substunivs, aiu = abstract_inductive_universes iu in
let paramsctxt = Vars.subst_univs_level_context substunivs paramsctxt in
let env_ar =
let ctxunivs = Environ.rel_context env_ar in
@@ -942,10 +960,14 @@ let build_inductive env cum p prv ctx env_ar paramsctxt kn isrecord isfinite ind
&& Array.length pkt.mind_consnames == 1
&& pkt.mind_consnrealargs.(0) > 0 ->
(** The elimination criterion ensures that all projections can be defined. *)
- let u =
- if p then
- subst_univs_level_instance substunivs (Univ.UContext.instance ctxunivs)
- else Univ.Instance.empty
+ let u =
+ let process auctx =
+ subst_univs_level_instance substunivs (Univ.AUContext.instance auctx)
+ in
+ match aiu with
+ | Monomorphic_ind _ -> Univ.Instance.empty
+ | Polymorphic_ind auctx -> process auctx
+ | Cumulative_ind acumi -> process (Univ.ACumulativityInfo.univ_context acumi)
in
let indsp = ((kn, 0), u) in
let rctx, indty = decompose_prod_assum (subst1 (mkIndU indsp) pkt.mind_nf_lc.(0)) in
@@ -968,9 +990,7 @@ let build_inductive env cum p prv ctx env_ar paramsctxt kn isrecord isfinite ind
mind_nparams_rec = nmr;
mind_params_ctxt = paramsctxt;
mind_packets = packets;
- mind_polymorphic = p;
- mind_cumulative = cum;
- mind_universes = Univ.UInfoInd.make (ctxunivs, ctxsubtyp);
+ mind_universes = aiu;
mind_private = prv;
mind_typing_flags = Environ.typing_flags env;
}
@@ -985,7 +1005,6 @@ let check_inductive env kn mie =
let chkpos = (Environ.typing_flags env).check_guarded in
let (nmr,recargs) = check_positivity ~chkpos kn env_ar_par paramsctxt mie.mind_entry_finite inds in
(* Build the inductive packets *)
- build_inductive env mie.mind_entry_cumulative mie.mind_entry_polymorphic mie.mind_entry_private
- mie.mind_entry_universes
+ build_inductive env mie.mind_entry_private mie.mind_entry_universes
env_ar paramsctxt kn mie.mind_entry_record mie.mind_entry_finite
inds nmr recargs
diff --git a/kernel/indtypes.mli b/kernel/indtypes.mli
index 7b0f017941..5b4615399d 100644
--- a/kernel/indtypes.mli
+++ b/kernel/indtypes.mli
@@ -32,17 +32,6 @@ type inductive_error =
exception InductiveError of inductive_error
-val check_subtyping_arity_constructor : Environ.env ->
-(Term.constr -> Term.constr) -> Term.types -> int -> bool -> unit
-
-(* This needs not be exposed. Exposing for debugging purposes! *)
-val check_subtyping : Entries.mutual_inductive_entry ->
-Context.Rel.t ->
-Environ.env ->
-('b * 'c * Term.types array *
- ('d * ('e * Term.types * 'f, 'g) Declarations.declaration_arity))
-array -> unit
-
(** The following function does checks on inductive declarations. *)
val check_inductive : env -> mutual_inductive -> mutual_inductive_entry -> mutual_inductive_body
diff --git a/kernel/inductive.ml b/kernel/inductive.ml
index 0f0dc0d607..e81a1cb587 100644
--- a/kernel/inductive.ml
+++ b/kernel/inductive.ml
@@ -54,9 +54,13 @@ let inductive_paramdecls (mib,u) =
Vars.subst_instance_context u mib.mind_params_ctxt
let instantiate_inductive_constraints mib u =
- if mib.mind_polymorphic then
- Univ.subst_instance_constraints u (Univ.UContext.constraints (Univ.UInfoInd.univ_context mib.mind_universes))
- else Univ.Constraint.empty
+ let process auctx =
+ Univ.UContext.constraints (Univ.subst_instance_context u auctx)
+ in
+ match mib.mind_universes with
+ | Monomorphic_ind _ -> Univ.Constraint.empty
+ | Polymorphic_ind auctx -> process auctx
+ | Cumulative_ind cumi -> process (Univ.ACumulativityInfo.univ_context cumi)
(************************************************************************)
diff --git a/kernel/mod_typing.ml b/kernel/mod_typing.ml
index ff44f0f540..79016735bc 100644
--- a/kernel/mod_typing.ml
+++ b/kernel/mod_typing.ml
@@ -74,12 +74,13 @@ let rec check_with_def env struc (idl,(c,ctx)) mp equiv =
as long as they have the right type *)
let uctx = Declareops.universes_of_constant (opaque_tables env) cb in
let uctx = (* Context of the spec *)
- if cb.const_polymorphic then
- Univ.instantiate_univ_context uctx
- else uctx
+ match cb.const_universes with
+ | Monomorphic_const _ -> uctx
+ | Polymorphic_const auctx ->
+ Univ.instantiate_univ_context auctx
in
let c', univs, ctx' =
- if not cb.const_polymorphic then
+ if not (Declareops.constant_is_polymorphic cb) then
let env' = Environ.push_context ~strict:true uctx env' in
let env' = Environ.push_context ~strict:true ctx env' in
let c',cst = match cb.const_body with
@@ -92,7 +93,7 @@ let rec check_with_def env struc (idl,(c,ctx)) mp equiv =
| Def cs ->
let c' = Mod_subst.force_constr cs in
c, Reduction.infer_conv env' (Environ.universes env') c c'
- in c', ctx, Univ.ContextSet.add_constraints cst (Univ.ContextSet.of_context ctx)
+ in c', Monomorphic_const ctx, Univ.ContextSet.add_constraints cst (Univ.ContextSet.of_context ctx)
else
let cus, ccst = Univ.UContext.dest uctx in
let newus, cst = Univ.UContext.dest ctx in
@@ -122,21 +123,17 @@ let rec check_with_def env struc (idl,(c,ctx)) mp equiv =
in
if not (Univ.Constraint.is_empty cst) then
error_incorrect_with_constraint lab;
- let subst, ctx = Univ.abstract_universes true ctx in
- Vars.subst_univs_level_constr subst c, ctx, Univ.ContextSet.empty
+ let subst, ctx = Univ.abstract_universes ctx in
+ Vars.subst_univs_level_constr subst c, Polymorphic_const ctx, Univ.ContextSet.empty
in
let def = Def (Mod_subst.from_val c') in
(* let ctx' = Univ.UContext.make (newus, cst) in *)
- let univs =
- if cb.const_polymorphic then Some cb.const_universes
- else None
- in
let cb' =
{ cb with
const_body = def;
- const_universes = ctx ;
+ const_universes = univs ;
const_body_code = Option.map Cemitcodes.from_val
- (compile_constant_body env' univs def) }
+ (compile_constant_body env' cb.const_universes def) }
in
before@(lab,SFBconst(cb'))::after, c', ctx'
else
diff --git a/kernel/modops.ml b/kernel/modops.ml
index 1f8b97ae6a..33d13f1ba0 100644
--- a/kernel/modops.ml
+++ b/kernel/modops.ml
@@ -35,6 +35,7 @@ type signature_mismatch_error =
| NotConvertibleConstructorField of Id.t
| NotConvertibleBodyField
| NotConvertibleTypeField of env * types * types
+ | CumulativeStatusExpected of bool
| PolymorphicStatusExpected of bool
| NotSameConstructorNamesField
| NotSameInductiveNameInBlockField
@@ -327,12 +328,10 @@ let strengthen_const mp_from l cb resolver =
|_ ->
let kn = KerName.make2 mp_from l in
let con = constant_of_delta_kn resolver kn in
- let u =
- if cb.const_polymorphic then
- let u = Univ.UContext.instance cb.const_universes in
- let s = Univ.make_instance_subst u in
- Univ.subst_univs_level_instance s u
- else Univ.Instance.empty
+ let u =
+ match cb.const_universes with
+ | Monomorphic_const _ -> Univ.Instance.empty
+ | Polymorphic_const ctx -> Univ.make_abstract_instance ctx
in
{ cb with
const_body = Def (Mod_subst.from_val (mkConstU (con,u)));
diff --git a/kernel/modops.mli b/kernel/modops.mli
index e9f3db6e91..4b533c7efd 100644
--- a/kernel/modops.mli
+++ b/kernel/modops.mli
@@ -94,6 +94,7 @@ type signature_mismatch_error =
| NotConvertibleConstructorField of Id.t
| NotConvertibleBodyField
| NotConvertibleTypeField of env * types * types
+ | CumulativeStatusExpected of bool
| PolymorphicStatusExpected of bool
| NotSameConstructorNamesField
| NotSameInductiveNameInBlockField
diff --git a/kernel/nativecode.ml b/kernel/nativecode.ml
index d3cd6b62a5..4941d64d82 100644
--- a/kernel/nativecode.ml
+++ b/kernel/nativecode.ml
@@ -1863,8 +1863,9 @@ let compile_constant env sigma prefix ~interactive con cb =
match cb.const_proj with
| None ->
let u =
- if cb.const_polymorphic then Univ.UContext.instance cb.const_universes
- else Univ.Instance.empty
+ match cb.const_universes with
+ | Monomorphic_const _ -> Univ.Instance.empty
+ | Polymorphic_const ctx -> Univ.AUContext.instance ctx
in
begin match cb.const_body with
| Def t ->
@@ -1960,7 +1961,7 @@ let param_name = Name (id_of_string "params")
let arg_name = Name (id_of_string "arg")
let compile_mind prefix ~interactive mb mind stack =
- let u = Declareops.inductive_instance mb in
+ let u = Declareops.inductive_polymorphic_instance mb in
let f i stack ob =
let gtype = Gtype((mind, i), Array.map snd ob.mind_reloc_tbl) in
let j = push_symbol (SymbInd (mind,i)) in
diff --git a/kernel/opaqueproof.ml b/kernel/opaqueproof.ml
index 59e90ca2e9..3e15ff7401 100644
--- a/kernel/opaqueproof.ml
+++ b/kernel/opaqueproof.ml
@@ -16,7 +16,7 @@ type work_list = (Instance.t * Id.t array) Cmap.t *
type cooking_info = {
modlist : work_list;
- abstract : Context.Named.t * Univ.universe_level_subst * Univ.UContext.t }
+ abstract : Context.Named.t * Univ.universe_level_subst * Univ.AUContext.t }
type proofterm = (constr * Univ.universe_context_set) Future.computation
type opaque =
| Indirect of substitution list * DirPath.t * int (* subst, lib, index *)
diff --git a/kernel/opaqueproof.mli b/kernel/opaqueproof.mli
index 3897d5e51e..be1f4b13f0 100644
--- a/kernel/opaqueproof.mli
+++ b/kernel/opaqueproof.mli
@@ -49,7 +49,7 @@ type work_list = (Univ.Instance.t * Id.t array) Cmap.t *
type cooking_info = {
modlist : work_list;
- abstract : Context.Named.t * Univ.universe_level_subst * Univ.UContext.t }
+ abstract : Context.Named.t * Univ.universe_level_subst * Univ.AUContext.t }
(* The type has two caveats:
1) cook_constr is defined after
diff --git a/kernel/reduction.ml b/kernel/reduction.ml
index ea583fdac8..8bf95e5de9 100644
--- a/kernel/reduction.ml
+++ b/kernel/reduction.ml
@@ -497,11 +497,12 @@ and eqappr env cv_pb l2r infos (lft1,st1) (lft2,st2) cuniv =
if eq_ind ind1 ind2 then
let mind = Environ.lookup_mind (fst ind1) env in
let cuniv =
- if mind.Declarations.mind_polymorphic && mind.Declarations.mind_cumulative then
+ match mind.Declarations.mind_universes with
+ | Declarations.Monomorphic_ind _ | Declarations.Polymorphic_ind _ ->
+ convert_instances ~flex:false u1 u2 cuniv
+ | Declarations.Cumulative_ind cumi ->
convert_inductives cv_pb (mind, snd ind1) u1 (CClosure.stack_args_size v1)
u2 (CClosure.stack_args_size v2) cuniv
- else
- convert_instances ~flex:false u1 u2 cuniv
in
convert_stacks env l2r infos lft1 lft2 v1 v2 cuniv
else raise NotConvertible
@@ -510,12 +511,13 @@ and eqappr env cv_pb l2r infos (lft1,st1) (lft2,st2) cuniv =
if Int.equal j1 j2 && eq_ind ind1 ind2 then
let mind = Environ.lookup_mind (fst ind1) env in
let cuniv =
- if mind.Declarations.mind_polymorphic && mind.Declarations.mind_cumulative then
+ match mind.Declarations.mind_universes with
+ | Declarations.Monomorphic_ind _ | Declarations.Polymorphic_ind _ ->
+ convert_instances ~flex:false u1 u2 cuniv
+ | Declarations.Cumulative_ind _ ->
convert_constructors
(mind, snd ind1, j1) u1 (CClosure.stack_args_size v1)
u2 (CClosure.stack_args_size v2) cuniv
- else
- convert_instances ~flex:false u1 u2 cuniv
in
convert_stacks env l2r infos lft1 lft2 v1 v2 cuniv
else raise NotConvertible
@@ -637,22 +639,26 @@ let infer_check_conv_inductives
infer_check_convert_instances
infer_check_inductive_instances
cv_pb (mind, ind) u1 sv1 u2 sv2 univs =
- if mind.Declarations.mind_polymorphic then
+ match mind.Declarations.mind_universes with
+ | Declarations.Monomorphic_ind _ | Declarations.Polymorphic_ind _ ->
+ infer_check_convert_instances ~flex:false u1 u2 univs
+ | Declarations.Cumulative_ind cumi ->
let num_param_arity =
mind.Declarations.mind_nparams + mind.Declarations.mind_packets.(ind).Declarations.mind_nrealargs
in
if not (num_param_arity = sv1 && num_param_arity = sv2) then
infer_check_convert_instances ~flex:false u1 u2 univs
else
- let uinfind = mind.Declarations.mind_universes in
- infer_check_inductive_instances cv_pb uinfind u1 u2 univs
- else infer_check_convert_instances ~flex:false u1 u2 univs
+ infer_check_inductive_instances cv_pb cumi u1 u2 univs
let infer_check_conv_constructors
infer_check_convert_instances
infer_check_inductive_instances
(mind, ind, cns) u1 sv1 u2 sv2 univs =
- if mind.Declarations.mind_polymorphic then
+ match mind.Declarations.mind_universes with
+ | Declarations.Monomorphic_ind _ | Declarations.Polymorphic_ind _ ->
+ infer_check_convert_instances ~flex:false u1 u2 univs
+ | Declarations.Cumulative_ind cumi ->
let num_cnstr_args =
let nparamsctxt =
mind.Declarations.mind_nparams + mind.Declarations.mind_packets.(ind).Declarations.mind_nrealargs
@@ -662,26 +668,30 @@ let infer_check_conv_constructors
if not (num_cnstr_args = sv1 && num_cnstr_args = sv2) then
infer_check_convert_instances ~flex:false u1 u2 univs
else
- let uinfind = mind.Declarations.mind_universes in
- infer_check_inductive_instances CONV uinfind u1 u2 univs
- else infer_check_convert_instances ~flex:false u1 u2 univs
+ infer_check_inductive_instances CONV cumi u1 u2 univs
-let check_inductive_instances cv_pb uinfind u u' univs =
- let ind_instance = Univ.UContext.instance (Univ.UInfoInd.univ_context uinfind) in
- let ind_sbcst = Univ.UContext.constraints (Univ.UInfoInd.subtyp_context uinfind) in
+let check_inductive_instances cv_pb cumi u u' univs =
+ let ind_instance =
+ Univ.AUContext.instance (Univ.ACumulativityInfo.univ_context cumi)
+ in
+ let ind_subtypctx = Univ.ACumulativityInfo.subtyp_context cumi in
if not ((Univ.Instance.length ind_instance = Univ.Instance.length u) &&
(Univ.Instance.length ind_instance = Univ.Instance.length u')) then
anomaly (Pp.str "Invalid inductive subtyping encountered!")
else
let comp_cst =
let comp_subst = (Univ.Instance.append u u') in
- Univ.subst_instance_constraints comp_subst ind_sbcst
+ Univ.UContext.constraints
+ (Univ.subst_instance_context comp_subst ind_subtypctx)
in
let comp_cst =
match cv_pb with
CONV ->
- let comp_subst = (Univ.Instance.append u' u) in
- let comp_cst' = (Univ.subst_instance_constraints comp_subst ind_sbcst) in
+ let comp_cst' =
+ let comp_subst = (Univ.Instance.append u' u) in
+ Univ.UContext.constraints
+ (Univ.subst_instance_context comp_subst ind_subtypctx)
+ in
Univ.Constraint.union comp_cst comp_cst'
| CUMUL -> comp_cst
in
@@ -746,22 +756,27 @@ let infer_convert_instances ~flex u u' (univs,cstrs) =
else Univ.enforce_eq_instances u u' cstrs
in (univs, cstrs')
-let infer_inductive_instances cv_pb uinfind u u' (univs, cstrs) =
- let ind_instance = Univ.UContext.instance (Univ.UInfoInd.univ_context uinfind) in
- let ind_sbcst = Univ.UContext.constraints (Univ.UInfoInd.subtyp_context uinfind) in
+let infer_inductive_instances cv_pb cumi u u' (univs, cstrs) =
+ let ind_instance =
+ Univ.AUContext.instance (Univ.ACumulativityInfo.subtyp_context cumi)
+ in
+ let ind_subtypctx = Univ.ACumulativityInfo.subtyp_context cumi in
if not ((Univ.Instance.length ind_instance = Univ.Instance.length u) &&
(Univ.Instance.length ind_instance = Univ.Instance.length u')) then
anomaly (Pp.str "Invalid inductive subtyping encountered!")
else
let comp_cst =
let comp_subst = (Univ.Instance.append u u') in
- Univ.subst_instance_constraints comp_subst ind_sbcst
+ Univ.UContext.constraints
+ (Univ.subst_instance_context comp_subst ind_subtypctx)
in
let comp_cst =
match cv_pb with
CONV ->
- let comp_subst = (Univ.Instance.append u' u) in
- let comp_cst' = (Univ.subst_instance_constraints comp_subst ind_sbcst) in
+ let comp_cst' =
+ let comp_subst = (Univ.Instance.append u' u) in
+ Univ.UContext.constraints
+ (Univ.subst_instance_context comp_subst ind_subtypctx) in
Univ.Constraint.union comp_cst comp_cst'
| CUMUL -> comp_cst
in
diff --git a/kernel/safe_typing.ml b/kernel/safe_typing.ml
index 1568fe0bf2..946222ef2f 100644
--- a/kernel/safe_typing.ml
+++ b/kernel/safe_typing.ml
@@ -237,20 +237,29 @@ let private_con_of_scheme ~kind env cl =
let universes_of_private eff =
let open Declarations in
- List.fold_left (fun acc { Entries.eff } ->
- match eff with
- | Entries.SEscheme (l,s) ->
- List.fold_left (fun acc (_,_,cb,c) ->
- let acc = match c with
- | `Nothing -> acc
- | `Opaque (_, ctx) -> ctx :: acc in
- if cb.const_polymorphic then acc
- else (Univ.ContextSet.of_context cb.const_universes) :: acc)
- acc l
- | Entries.SEsubproof (c, cb, e) ->
- if cb.const_polymorphic then acc
- else Univ.ContextSet.of_context cb.const_universes :: acc)
- [] (Term_typing.uniq_seff eff)
+ List.fold_left
+ (fun acc { Entries.eff } ->
+ match eff with
+ | Entries.SEscheme (l,s) ->
+ List.fold_left
+ (fun acc (_,_,cb,c) ->
+ let acc = match c with
+ | `Nothing -> acc
+ | `Opaque (_, ctx) -> ctx :: acc
+ in
+ match cb.const_universes with
+ | Monomorphic_const ctx ->
+ (Univ.ContextSet.of_context ctx) :: acc
+ | Polymorphic_const _ -> acc
+ )
+ acc l
+ | Entries.SEsubproof (c, cb, e) ->
+ match cb.const_universes with
+ | Monomorphic_const ctx ->
+ (Univ.ContextSet.of_context ctx) :: acc
+ | Polymorphic_const _ -> acc
+ )
+ [] (Term_typing.uniq_seff eff)
let env_of_safe_env senv = senv.env
let env_of_senv = env_of_safe_env
@@ -373,7 +382,11 @@ let safe_push_named d env =
let push_named_def (id,de) senv =
- let c,typ,univs = Term_typing.translate_local_def senv.revstruct senv.env id de in
+ let c,typ,univs =
+ match Term_typing.translate_local_def senv.revstruct senv.env id de with
+ | c, typ, Monomorphic_const ctx -> c, typ, ctx
+ | _, _, Polymorphic_const _ -> assert false
+ in
let poly = de.Entries.const_entry_polymorphic in
let univs = Univ.ContextSet.of_context univs in
let c, univs = match c with
@@ -410,26 +423,28 @@ let labels_of_mib mib =
get ()
let globalize_constant_universes env cb =
- if cb.const_polymorphic then
- [Now (true, Univ.ContextSet.empty)]
- else
- let cstrs = Univ.ContextSet.of_context cb.const_universes in
- Now (false, cstrs) ::
- (match cb.const_body with
- | (Undef _ | Def _) -> []
- | OpaqueDef lc ->
- match Opaqueproof.get_constraints (Environ.opaque_tables env) lc with
- | None -> []
- | Some fc ->
+ match cb.const_universes with
+ | Monomorphic_const ctx ->
+ let cstrs = Univ.ContextSet.of_context ctx in
+ Now (false, cstrs) ::
+ (match cb.const_body with
+ | (Undef _ | Def _) -> []
+ | OpaqueDef lc ->
+ match Opaqueproof.get_constraints (Environ.opaque_tables env) lc with
+ | None -> []
+ | Some fc ->
match Future.peek_val fc with
- | None -> [Later fc]
- | Some c -> [Now (false, c)])
+ | None -> [Later fc]
+ | Some c -> [Now (false, c)])
+ | Polymorphic_const _ ->
+ [Now (true, Univ.ContextSet.empty)]
let globalize_mind_universes mb =
- if mb.mind_polymorphic then
- [Now (true, Univ.ContextSet.empty)]
- else
- [Now (false, Univ.ContextSet.of_context (Univ.UInfoInd.univ_context mb.mind_universes))]
+ match mb.mind_universes with
+ | Monomorphic_ind ctx ->
+ [Now (false, Univ.ContextSet.of_context ctx)]
+ | Polymorphic_ind _ -> [Now (true, Univ.ContextSet.empty)]
+ | Cumulative_ind _ -> [Now (true, Univ.ContextSet.empty)]
let constraints_of_sfb env sfb =
match sfb with
diff --git a/kernel/subtyping.ml b/kernel/subtyping.ml
index 60e630a6db..1bd9d6e495 100644
--- a/kernel/subtyping.ml
+++ b/kernel/subtyping.ml
@@ -104,15 +104,21 @@ let check_inductive cst env mp1 l info1 mp2 mib2 spec2 subst1 subst2 reso1 reso2
| IndType ((_,0), mib) -> Declareops.subst_mind_body subst1 mib
| _ -> error (InductiveFieldExpected mib2)
in
- let poly =
- if not (mib1.mind_polymorphic == mib2.mind_polymorphic) then
- error (PolymorphicStatusExpected mib2.mind_polymorphic)
- else mib2.mind_polymorphic
- in
- let u =
- if poly then
- CErrors.user_err Pp.(str "Checking of subtyping of polymorphic inductive types not implemented")
- else Instance.empty
+ let u =
+ let process inst inst' =
+ if Univ.Instance.equal inst inst' then inst else error IncompatibleInstances
+ in
+ match mib1.mind_universes, mib2.mind_universes with
+ | Monomorphic_ind _, Monomorphic_ind _ -> Univ.Instance.empty
+ | Polymorphic_ind auctx, Polymorphic_ind auctx' ->
+ process
+ (Univ.AUContext.instance auctx) (Univ.AUContext.instance auctx')
+ | Cumulative_ind cumi, Cumulative_ind cumi' ->
+ process
+ (Univ.AUContext.instance (Univ.ACumulativityInfo.univ_context cumi))
+ (Univ.AUContext.instance (Univ.ACumulativityInfo.univ_context cumi'))
+ | _ -> error
+ (CumulativeStatusExpected (Declareops.inductive_is_cumulative mib2))
in
let mib2 = Declareops.subst_mind_body subst2 mib2 in
let check_inductive_type cst name env t1 t2 =
@@ -148,7 +154,7 @@ let check_inductive cst env mp1 l info1 mp2 mib2 spec2 subst1 subst2 reso1 reso2
error (NotConvertibleInductiveField name)
| _ -> (s1, s2) in
check_conv (NotConvertibleInductiveField name)
- cst poly u infer_conv_leq env (mkArity (ctx1,s1)) (mkArity (ctx2,s2))
+ cst (inductive_is_polymorphic mib1) u infer_conv_leq env (mkArity (ctx1,s1)) (mkArity (ctx2,s2))
in
let check_packet cst p1 p2 =
@@ -176,7 +182,7 @@ let check_inductive cst env mp1 l info1 mp2 mib2 spec2 subst1 subst2 reso1 reso2
let check_cons_types i cst p1 p2 =
Array.fold_left3
(fun cst id t1 t2 -> check_conv (NotConvertibleConstructorField id) cst
- poly u infer_conv env t1 t2)
+ (inductive_is_polymorphic mib1) u infer_conv env t1 t2)
cst
p2.mind_consnames
(arities_of_specif (mind,u) (mib1,p1))
@@ -293,37 +299,42 @@ let check_constant cst env mp1 l info1 cb2 spec2 subst1 subst2 =
let cb2 = Declareops.subst_const_body subst2 cb2 in
(* Start by checking universes *)
let poly =
- if not (cb1.const_polymorphic == cb2.const_polymorphic) then
- error (PolymorphicStatusExpected cb2.const_polymorphic)
- else cb2.const_polymorphic
+ if not (Declareops.constant_is_polymorphic cb1
+ == Declareops.constant_is_polymorphic cb2) then
+ error (PolymorphicStatusExpected (Declareops.constant_is_polymorphic cb2))
+ else Declareops.constant_is_polymorphic cb2
in
- let cst', env', u =
- if poly then
- let ctx1 = Univ.instantiate_univ_context cb1.const_universes in
- let ctx2 = Univ.instantiate_univ_context cb2.const_universes in
- let inst1, ctx1 = Univ.UContext.dest ctx1 in
- let inst2, ctx2 = Univ.UContext.dest ctx2 in
+ let cst', env', u =
+ match cb1.const_universes, cb2.const_universes with
+ | Monomorphic_const _, Monomorphic_const _ ->
+ cst, env, Univ.Instance.empty
+ | Polymorphic_const auctx1, Polymorphic_const auctx2 ->
+ begin
+ let ctx1 = Univ.instantiate_univ_context auctx1 in
+ let ctx2 = Univ.instantiate_univ_context auctx2 in
+ let inst1, ctx1 = Univ.UContext.dest ctx1 in
+ let inst2, ctx2 = Univ.UContext.dest ctx2 in
if not (Univ.Instance.length inst1 == Univ.Instance.length inst2) then
error IncompatibleInstances
else
let cstrs = Univ.enforce_eq_instances inst1 inst2 cst in
let cstrs = Univ.Constraint.union cstrs ctx2 in
- try
- (* The environment with the expected universes plus equality
- of the body instances with the expected instance *)
- let ctxi = Univ.Instance.append inst1 inst2 in
- let ctx = Univ.UContext.make (ctxi, cstrs) in
- let env = Environ.push_context ctx env in
- (* Check that the given definition does not add any constraint over
- the expected ones, so that it can be used in place of
- the original. *)
- if UGraph.check_constraints ctx1 (Environ.universes env) then
- cstrs, env, inst2
- else error (IncompatibleConstraints ctx1)
- with Univ.UniverseInconsistency incon ->
- error (IncompatibleUniverses incon)
- else
- cst, env, Univ.Instance.empty
+ try
+ (* The environment with the expected universes plus equality
+ of the body instances with the expected instance *)
+ let ctxi = Univ.Instance.append inst1 inst2 in
+ let ctx = Univ.UContext.make (ctxi, cstrs) in
+ let env = Environ.push_context ctx env in
+ (* Check that the given definition does not add any constraint over
+ the expected ones, so that it can be used in place of
+ the original. *)
+ if UGraph.check_constraints ctx1 (Environ.universes env) then
+ cstrs, env, inst2
+ else error (IncompatibleConstraints ctx1)
+ with Univ.UniverseInconsistency incon ->
+ error (IncompatibleUniverses incon)
+ end
+ | _ -> assert false
in
(* Now check types *)
let typ1 = Typeops.type_of_constant_type env' cb1.const_type in
@@ -354,7 +365,7 @@ let check_constant cst env mp1 l info1 cb2 spec2 subst1 subst2 =
"name."));
let () = assert (List.is_empty mind1.mind_hyps && List.is_empty cb2.const_hyps) in
if Declareops.constant_has_body cb2 then error DefinitionFieldExpected;
- let u1 = inductive_instance mind1 in
+ let u1 = inductive_polymorphic_instance mind1 in
let arity1,cst1 = constrained_type_of_inductive env
((mind1,mind1.mind_packets.(i)),u1) in
let cst2 =
@@ -371,7 +382,7 @@ let check_constant cst env mp1 l info1 cb2 spec2 subst1 subst2 =
"name."));
let () = assert (List.is_empty mind1.mind_hyps && List.is_empty cb2.const_hyps) in
if Declareops.constant_has_body cb2 then error DefinitionFieldExpected;
- let u1 = inductive_instance mind1 in
+ let u1 = inductive_polymorphic_instance mind1 in
let ty1,cst1 = constrained_type_of_constructor (cstr,u1) (mind1,mind1.mind_packets.(i)) in
let cst2 =
Declareops.constraints_of_constant (Environ.opaque_tables env) cb2 in
diff --git a/kernel/term_typing.ml b/kernel/term_typing.ml
index 3cf2299d83..5370bcea43 100644
--- a/kernel/term_typing.ml
+++ b/kernel/term_typing.ml
@@ -121,18 +121,19 @@ let inline_side_effects env body ctx side_eff =
| OpaqueDef _, `Opaque (b,_) -> (b, true)
| _ -> assert false
in
- if cb.const_polymorphic then
- (** Inline the term to emulate universe polymorphism *)
- let data = (Univ.UContext.instance cb.const_universes, b) in
- let subst = Cmap_env.add c (Inl data) subst in
- (subst, var, ctx, args)
- else
+ match cb.const_universes with
+ | Monomorphic_const cnstctx ->
(** Abstract over the term at the top of the proof *)
let ty = Typeops.type_of_constant_type env cb.const_type in
let subst = Cmap_env.add c (Inr var) subst in
- let univs = Univ.ContextSet.of_context cb.const_universes in
+ let univs = Univ.ContextSet.of_context cnstctx in
let ctx = Univ.ContextSet.union ctx univs in
(subst, var + 1, ctx, (cname c, b, ty, opaque) :: args)
+ | Polymorphic_const auctx ->
+ (** Inline the term to emulate universe polymorphism *)
+ let data = (Univ.AUContext.instance auctx, b) in
+ let subst = Cmap_env.add c (Inl data) subst in
+ (subst, var, ctx, args)
in
let (subst, len, ctx, args) = List.fold_left fold (Cmap_env.empty, 1, ctx, []) side_eff in
(** Third step: inline the definitions *)
@@ -225,16 +226,25 @@ let feedback_completion_typecheck =
Option.iter (fun state_id ->
feedback ~id:state_id Feedback.Complete)
+let abstract_constant_universes abstract uctx =
+ if not abstract then
+ Univ.empty_level_subst, Monomorphic_const uctx
+ else
+ let sbst, auctx = Univ.abstract_universes uctx in
+ sbst, Polymorphic_const auctx
+
let infer_declaration ~trust env kn dcl =
match dcl with
| ParameterEntry (ctx,poly,(t,uctx),nl) ->
let env = push_context ~strict:(not poly) uctx env in
let j = infer env t in
let abstract = poly && not (Option.is_empty kn) in
- let usubst, univs = Univ.abstract_universes abstract uctx in
+ let usubst, univs =
+ abstract_constant_universes abstract uctx
+ in
let c = Typeops.assumption_of_judgment env j in
let t = hcons_constr (Vars.subst_univs_level_constr usubst c) in
- Undef nl, RegularArity t, None, poly, univs, false, ctx
+ Undef nl, RegularArity t, None, univs, false, ctx
(** Definition [c] is opaque (Qed), non polymorphic and with a specified type,
so we delay the typing and hash consing of its body.
@@ -264,9 +274,9 @@ let infer_declaration ~trust env kn dcl =
feedback_completion_typecheck feedback_id;
c, uctx) in
let def = OpaqueDef (Opaqueproof.create proofterm) in
- def, RegularArity typ, None, c.const_entry_polymorphic,
- c.const_entry_universes,
- c.const_entry_inline_code, c.const_entry_secctx
+ def, RegularArity typ, None,
+ (Monomorphic_const c.const_entry_universes),
+ c.const_entry_inline_code, c.const_entry_secctx
(** Other definitions have to be processed immediately. *)
| DefinitionEntry c ->
@@ -279,7 +289,8 @@ let infer_declaration ~trust env kn dcl =
let env = push_context_set ~strict:(not c.const_entry_polymorphic) ctx env in
let abstract = c.const_entry_polymorphic && not (Option.is_empty kn) in
let usubst, univs =
- Univ.abstract_universes abstract (Univ.ContextSet.to_context ctx) in
+ abstract_constant_universes abstract (Univ.ContextSet.to_context ctx)
+ in
let j = infer env body in
let typ = match typ with
| None ->
@@ -298,8 +309,7 @@ let infer_declaration ~trust env kn dcl =
else Def (Mod_subst.from_val def)
in
feedback_completion_typecheck feedback_id;
- def, typ, None, c.const_entry_polymorphic,
- univs, c.const_entry_inline_code, c.const_entry_secctx
+ def, typ, None, univs, c.const_entry_inline_code, c.const_entry_secctx
| ProjectionEntry {proj_entry_ind = ind; proj_entry_arg = i} ->
let mib, _ = Inductive.lookup_mind_specif env (ind,0) in
@@ -311,9 +321,16 @@ let infer_declaration ~trust env kn dcl =
else assert false
| _ -> assert false
in
+ let univs =
+ match mib.mind_universes with
+ | Monomorphic_ind ctx -> Monomorphic_const ctx
+ | Polymorphic_ind auctx -> Polymorphic_const auctx
+ | Cumulative_ind acumi ->
+ Polymorphic_const (Univ.ACumulativityInfo.univ_context acumi)
+ in
let term, typ = pb.proj_eta in
Def (Mod_subst.from_val (hcons_constr term)), RegularArity typ, Some pb,
- mib.mind_polymorphic, Univ.UInfoInd.univ_context mib.mind_universes, false, None
+ univs, false, None
let global_vars_set_constant_type env = function
| RegularArity t -> global_vars_set env t
@@ -337,7 +354,7 @@ let record_aux env s_ty s_bo suggested_expr =
let suggest_proof_using = ref (fun _ _ _ _ _ -> "")
let set_suggest_proof_using f = suggest_proof_using := f
-let build_constant_declaration kn env (def,typ,proj,poly,univs,inline_code,ctx) =
+let build_constant_declaration kn env (def,typ,proj,univs,inline_code,ctx) =
let check declared inferred =
let mk_set l = List.fold_right Id.Set.add (List.map NamedDecl.get_id l) Id.Set.empty in
let inferred_set, declared_set = mk_set inferred, mk_set declared in
@@ -409,9 +426,8 @@ let build_constant_declaration kn env (def,typ,proj,poly,univs,inline_code,ctx)
check declared inferred) lc) in
let tps =
let res =
- let comp_univs = if poly then Some univs else None in
match proj with
- | None -> compile_constant_body env comp_univs def
+ | None -> compile_constant_body env univs def
| Some pb ->
(* The compilation of primitive projections is a bit tricky, because
they refer to themselves (the body of p looks like fun c =>
@@ -425,14 +441,13 @@ let build_constant_declaration kn env (def,typ,proj,poly,univs,inline_code,ctx)
const_type = typ;
const_proj = proj;
const_body_code = None;
- const_polymorphic = poly;
const_universes = univs;
const_inline_code = inline_code;
const_typing_flags = Environ.typing_flags env;
}
in
let env = add_constant kn cb env in
- compile_constant_body env comp_univs def
+ compile_constant_body env univs def
in Option.map Cemitcodes.from_val res
in
{ const_hyps = hyps;
@@ -440,7 +455,6 @@ let build_constant_declaration kn env (def,typ,proj,poly,univs,inline_code,ctx)
const_type = typ;
const_proj = proj;
const_body_code = tps;
- const_polymorphic = poly;
const_universes = univs;
const_inline_code = inline_code;
const_typing_flags = Environ.typing_flags env }
@@ -452,6 +466,12 @@ let translate_constant mb env kn ce =
(infer_declaration ~trust:mb env (Some kn) ce)
let constant_entry_of_side_effect cb u =
+ let poly, univs =
+ match cb.const_universes with
+ | Monomorphic_const ctx -> false, ctx
+ | Polymorphic_const auctx ->
+ true, Univ.instantiate_univ_context auctx
+ in
let pt =
match cb.const_body, u with
| OpaqueDef _, `Opaque (b, c) -> b, c
@@ -463,8 +483,8 @@ let constant_entry_of_side_effect cb u =
const_entry_feedback = None;
const_entry_type =
(match cb.const_type with RegularArity t -> Some t | _ -> None);
- const_entry_polymorphic = cb.const_polymorphic;
- const_entry_universes = cb.const_universes;
+ const_entry_polymorphic = poly;
+ const_entry_universes = univs;
const_entry_opaque = Declareops.is_opaque cb;
const_entry_inline_code = cb.const_inline_code }
;;
@@ -508,16 +528,23 @@ let export_side_effects mb env ce =
let trusted = check_signatures mb signatures in
let push_seff env = function
| kn, cb, `Nothing, _ ->
- let env = Environ.add_constant kn cb env in
- if not cb.const_polymorphic then
- Environ.push_context ~strict:true cb.const_universes env
- else env
- | kn, cb, `Opaque(_, ctx), _ ->
- let env = Environ.add_constant kn cb env in
- if not cb.const_polymorphic then
- let env = Environ.push_context ~strict:true cb.const_universes env in
- Environ.push_context_set ~strict:true ctx env
- else env in
+ begin
+ let env = Environ.add_constant kn cb env in
+ match cb.const_universes with
+ | Monomorphic_const ctx ->
+ Environ.push_context ~strict:true ctx env
+ | Polymorphic_const _ -> env
+ end
+ | kn, cb, `Opaque(_, ctx), _ ->
+ begin
+ let env = Environ.add_constant kn cb env in
+ match cb.const_universes with
+ | Monomorphic_const cstctx ->
+ let env = Environ.push_context ~strict:true cstctx env in
+ Environ.push_context_set ~strict:true ctx env
+ | Polymorphic_const _ -> env
+ end
+ in
let rec translate_seff sl seff acc env =
match sl, seff with
| _, [] -> List.rev acc, ce
@@ -553,7 +580,7 @@ let translate_recipe env kn r =
build_constant_declaration kn env (Cooking.cook_constant ~hcons env r)
let translate_local_def mb env id centry =
- let def,typ,proj,poly,univs,inline_code,ctx =
+ let def,typ,proj,univs,inline_code,ctx =
infer_declaration ~trust:mb env None (DefinitionEntry centry) in
let typ = type_of_constant_type env typ in
if ctx = None && !Flags.compilation_mode = Flags.BuildVo then begin
diff --git a/kernel/typeops.ml b/kernel/typeops.ml
index 1a07bb2fc6..e08f3362db 100644
--- a/kernel/typeops.ml
+++ b/kernel/typeops.ml
@@ -555,7 +555,7 @@ let type_of_projection_constant env (p,u) =
let cb = lookup_constant cst env in
match cb.const_proj with
| Some pb ->
- if cb.const_polymorphic then
+ if Declareops.constant_is_polymorphic cb then
Vars.subst_instance_constr u pb.proj_type
else pb.proj_type
| None -> raise (Invalid_argument "type_of_projection: not a projection")
diff --git a/kernel/univ.ml b/kernel/univ.ml
index eb45f022e9..8cbb20a051 100644
--- a/kernel/univ.ml
+++ b/kernel/univ.ml
@@ -1031,7 +1031,13 @@ end
type universe_context = UContext.t
let hcons_universe_context = UContext.hcons
-(** Universe info for inductive types: A context of universe levels
+module AUContext = UContext
+
+type abstract_universe_context = AUContext.t
+let hcons_abstract_universe_context = AUContext.hcons
+
+(** Universe info for cumulative inductive types:
+ A context of universe levels
with universe constraints, representing local universe variables
and constraints, together with a context of universe levels with
universe constraints, representing conditions for subtyping used
@@ -1040,7 +1046,7 @@ let hcons_universe_context = UContext.hcons
This data structure maintains the invariant that the context for
subtyping constraints is exactly twice as big as the context for
universe constraints. *)
-module UInfoInd =
+module CumulativityInfo =
struct
type t = universe_context * universe_context
@@ -1093,8 +1099,13 @@ struct
end
-type universe_info_ind = UInfoInd.t
-let hcons_universe_info_ind = UInfoInd.hcons
+type cumulativity_info = CumulativityInfo.t
+let hcons_cumulativity_info = CumulativityInfo.hcons
+
+module ACumulativityInfo = CumulativityInfo
+
+type abstract_cumulativity_info = ACumulativityInfo.t
+let hcons_abstract_cumulativity_info = ACumulativityInfo.hcons
(** A set of universes with universe constraints.
We linearize the set to a list after typechecking.
@@ -1200,6 +1211,9 @@ let subst_univs_level_constraints subst csts =
(fun c -> Option.fold_right Constraint.add (subst_univs_level_constraint subst c))
csts Constraint.empty
+let subst_univs_level_abstract_universe_context subst (inst, csts) =
+ inst, subst_univs_level_constraints subst csts
+
(** With level to universe substitutions. *)
type universe_subst_fn = universe_level -> universe
@@ -1272,12 +1286,9 @@ let instantiate_univ_context (ctx, csts) =
(ctx, subst_instance_constraints ctx csts)
(** Substitute instance inst for ctx in universe constraints and subtyping constraints *)
-let instantiate_univ_info_ind (univcst, subtpcst) =
+let instantiate_cumulativity_info (univcst, subtpcst) =
(instantiate_univ_context univcst, instantiate_univ_context subtpcst)
-let instantiate_univ_constraints u (_, csts) =
- subst_instance_constraints u csts
-
let make_instance_subst i =
let arr = Instance.to_array i in
Array.fold_left_i (fun i acc l ->
@@ -1290,16 +1301,22 @@ let make_inverse_instance_subst i =
LMap.add (Level.var i) l acc)
LMap.empty arr
-let abstract_universes poly ctx =
+let make_abstract_instance (ctx, _) =
+ Array.mapi (fun i l -> Level.var i) ctx
+
+let abstract_universes ctx =
let instance = UContext.instance ctx in
- if poly then
- let subst = make_instance_subst instance in
- let cstrs = subst_univs_level_constraints subst
- (UContext.constraints ctx)
- in
- let ctx = UContext.make (instance, cstrs) in
- subst, ctx
- else empty_level_subst, ctx
+ let subst = make_instance_subst instance in
+ let cstrs = subst_univs_level_constraints subst
+ (UContext.constraints ctx)
+ in
+ let ctx = UContext.make (instance, cstrs) in
+ subst, ctx
+
+let abstract_cumulativity_info (univcst, substcst) =
+ let instance, univcst = abstract_universes univcst in
+ let _, substcst = abstract_universes substcst in
+ (instance, (univcst, substcst))
(** Pretty-printing *)
@@ -1307,7 +1324,11 @@ let pr_constraints prl = Constraint.pr prl
let pr_universe_context = UContext.pr
-let pr_universe_info_ind = UInfoInd.pr
+let pr_cumulativity_info = CumulativityInfo.pr
+
+let pr_abstract_universe_context = AUContext.pr
+
+let pr_abstract_cumulativity_info = ACumulativityInfo.pr
let pr_universe_context_set = ContextSet.pr
@@ -1364,3 +1385,12 @@ let subst_instance_constraints =
let key = Profile.declare_profile "subst_instance_constraints" in
Profile.profile2 key subst_instance_constraints
else subst_instance_constraints
+
+let subst_instance_context =
+ let subst_instance_context_body inst (inner_inst, inner_constr) =
+ (inner_inst, subst_instance_constraints inst inner_constr)
+ in
+ if Flags.profile then
+ let key = Profile.declare_profile "subst_instance_constraints" in
+ Profile.profile2 key subst_instance_context_body
+ else subst_instance_context_body
diff --git a/kernel/univ.mli b/kernel/univ.mli
index 53af804488..ecc72701d4 100644
--- a/kernel/univ.mli
+++ b/kernel/univ.mli
@@ -315,6 +315,23 @@ end
type universe_context = UContext.t
+module AUContext :
+sig
+ type t
+
+ val empty : t
+
+ val instance : t -> Instance.t
+
+ val size : t -> int
+
+ (** Keeps the order of the instances *)
+ val union : t -> t -> t
+
+end
+
+type abstract_universe_context = AUContext.t
+
(** Universe info for inductive types: A context of universe levels
with universe constraints, representing local universe variables
and constraints, together with a context of universe levels with
@@ -324,7 +341,7 @@ type universe_context = UContext.t
This data structure maintains the invariant that the context for
subtyping constraints is exactly twice as big as the context for
universe constraints. *)
-module UInfoInd :
+module CumulativityInfo :
sig
type t
@@ -347,7 +364,17 @@ sig
end
-type universe_info_ind = UInfoInd.t
+type cumulativity_info = CumulativityInfo.t
+
+module ACumulativityInfo :
+sig
+ type t
+
+ val univ_context : t -> abstract_universe_context
+ val subtyp_context : t -> abstract_universe_context
+end
+
+type abstract_cumulativity_info = ACumulativityInfo.t
(** Universe contexts (as sets) *)
@@ -399,6 +426,8 @@ val is_empty_level_subst : universe_level_subst -> bool
val subst_univs_level_level : universe_level_subst -> universe_level -> universe_level
val subst_univs_level_universe : universe_level_subst -> universe -> universe
val subst_univs_level_constraints : universe_level_subst -> constraints -> constraints
+val subst_univs_level_abstract_universe_context :
+ universe_level_subst -> abstract_universe_context -> abstract_universe_context
val subst_univs_level_instance : universe_level_subst -> universe_instance -> universe_instance
(** Level to universe substitutions. *)
@@ -413,27 +442,31 @@ val subst_univs_constraints : universe_subst_fn -> constraints -> constraints
(** Substitution of instances *)
val subst_instance_instance : universe_instance -> universe_instance -> universe_instance
val subst_instance_universe : universe_instance -> universe -> universe
-val subst_instance_constraints : universe_instance -> constraints -> constraints
+val subst_instance_context : universe_instance -> abstract_universe_context -> universe_context
val make_instance_subst : universe_instance -> universe_level_subst
val make_inverse_instance_subst : universe_instance -> universe_level_subst
-val abstract_universes : bool -> universe_context -> universe_level_subst * universe_context
+val abstract_universes : universe_context -> universe_level_subst * abstract_universe_context
+
+val abstract_cumulativity_info : cumulativity_info -> universe_level_subst * abstract_cumulativity_info
+
+val make_abstract_instance : abstract_universe_context -> universe_instance
(** Get the instantiated graph. *)
-val instantiate_univ_context : universe_context -> universe_context
+val instantiate_univ_context : abstract_universe_context -> universe_context
(** Get the instantiated graphs for both universe constraints and subtyping constraints. *)
-val instantiate_univ_info_ind : universe_info_ind -> universe_info_ind
-
-val instantiate_univ_constraints : universe_instance -> universe_context -> constraints
+val instantiate_cumulativity_info : abstract_cumulativity_info -> cumulativity_info
(** {6 Pretty-printing of universes. } *)
val pr_constraint_type : constraint_type -> Pp.std_ppcmds
val pr_constraints : (Level.t -> Pp.std_ppcmds) -> constraints -> Pp.std_ppcmds
val pr_universe_context : (Level.t -> Pp.std_ppcmds) -> universe_context -> Pp.std_ppcmds
-val pr_universe_info_ind : (Level.t -> Pp.std_ppcmds) -> universe_info_ind -> Pp.std_ppcmds
+val pr_cumulativity_info : (Level.t -> Pp.std_ppcmds) -> cumulativity_info -> Pp.std_ppcmds
+val pr_abstract_universe_context : (Level.t -> Pp.std_ppcmds) -> abstract_universe_context -> Pp.std_ppcmds
+val pr_abstract_cumulativity_info : (Level.t -> Pp.std_ppcmds) -> abstract_cumulativity_info -> Pp.std_ppcmds
val pr_universe_context_set : (Level.t -> Pp.std_ppcmds) -> universe_context_set -> Pp.std_ppcmds
val explain_universe_inconsistency : (Level.t -> Pp.std_ppcmds) ->
univ_inconsistency -> Pp.std_ppcmds
@@ -447,8 +480,10 @@ val hcons_univ : universe -> universe
val hcons_constraints : constraints -> constraints
val hcons_universe_set : universe_set -> universe_set
val hcons_universe_context : universe_context -> universe_context
+val hcons_abstract_universe_context : abstract_universe_context -> abstract_universe_context
val hcons_universe_context_set : universe_context_set -> universe_context_set
-val hcons_universe_info_ind : universe_info_ind -> universe_info_ind
+val hcons_cumulativity_info : cumulativity_info -> cumulativity_info
+val hcons_abstract_cumulativity_info : abstract_cumulativity_info -> abstract_cumulativity_info
(******)
diff --git a/kernel/vconv.ml b/kernel/vconv.ml
index fa16622702..0e452621c8 100644
--- a/kernel/vconv.ml
+++ b/kernel/vconv.ml
@@ -88,30 +88,34 @@ and conv_atom env pb k a1 stk1 a2 stk2 cu =
(* Pp.(msg_debug (str "conv_atom(" ++ pr_atom a1 ++ str ", " ++ pr_atom a2 ++ str ")")) ; *)
match a1, a2 with
| Aind ((mi,i) as ind1) , Aind ind2 ->
- if eq_ind ind1 ind2 && compare_stack stk1 stk2
- then
- if Environ.polymorphic_ind ind1 env
- then
- let mib = Environ.lookup_mind mi env in
- let ulen = Univ.UContext.size (Univ.UInfoInd.univ_context mib.Declarations.mind_universes) in
- match stk1 , stk2 with
- | [], [] -> assert (Int.equal ulen 0); cu
- | Zapp args1 :: stk1' , Zapp args2 :: stk2' ->
- assert (ulen <= nargs args1);
- assert (ulen <= nargs args2);
- let u1 = Array.init ulen (fun i -> uni_lvl_val (arg args1 i)) in
- let u2 = Array.init ulen (fun i -> uni_lvl_val (arg args2 i)) in
- let u1 = Univ.Instance.of_array u1 in
- let u2 = Univ.Instance.of_array u2 in
- let cu = convert_instances ~flex:false u1 u2 cu in
- conv_arguments env ~from:ulen k args1 args2
- (conv_stack env k stk1' stk2' cu)
- | _, _ -> assert false (* Should not happen if problem is well typed *)
- else
- conv_stack env k stk1 stk2 cu
- else raise NotConvertible
+ if eq_ind ind1 ind2 && compare_stack stk1 stk2 then
+ if Environ.polymorphic_ind ind1 env then
+ let mib = Environ.lookup_mind mi env in
+ let ulen =
+ match mib.Declarations.mind_universes with
+ | Declarations.Monomorphic_ind ctx -> Univ.UContext.size ctx
+ | Declarations.Polymorphic_ind auctx -> Univ.AUContext.size auctx
+ | Declarations.Cumulative_ind cumi ->
+ Univ.AUContext.size (Univ.ACumulativityInfo.univ_context cumi)
+ in
+ match stk1 , stk2 with
+ | [], [] -> assert (Int.equal ulen 0); cu
+ | Zapp args1 :: stk1' , Zapp args2 :: stk2' ->
+ assert (ulen <= nargs args1);
+ assert (ulen <= nargs args2);
+ let u1 = Array.init ulen (fun i -> uni_lvl_val (arg args1 i)) in
+ let u2 = Array.init ulen (fun i -> uni_lvl_val (arg args2 i)) in
+ let u1 = Univ.Instance.of_array u1 in
+ let u2 = Univ.Instance.of_array u2 in
+ let cu = convert_instances ~flex:false u1 u2 cu in
+ conv_arguments env ~from:ulen k args1 args2
+ (conv_stack env k stk1' stk2' cu)
+ | _, _ -> assert false (* Should not happen if problem is well typed *)
+ else
+ conv_stack env k stk1 stk2 cu
+ else raise NotConvertible
| Aid ik1, Aid ik2 ->
- if Vars.eq_id_key ik1 ik2 && compare_stack stk1 stk2 then
+ if Vars.eq_id_key ik1 ik2 && compare_stack stk1 stk2 then
conv_stack env k stk1 stk2 cu
else raise NotConvertible
| Atype _ , _ | _, Atype _ -> assert false
diff --git a/library/declare.ml b/library/declare.ml
index e2b726f457..db3dbcbd92 100644
--- a/library/declare.ml
+++ b/library/declare.ml
@@ -158,7 +158,7 @@ let cache_constant ((sp,kn), obj) =
assert (eq_constant kn' (constant_of_kn kn));
Nametab.push (Nametab.Until 1) sp (ConstRef (constant_of_kn kn));
let cst = Global.lookup_constant kn' in
- add_section_constant cst.const_polymorphic kn' cst.const_hyps;
+ add_section_constant (Declareops.constant_is_polymorphic cst) kn' cst.const_hyps;
Dischargedhypsmap.set_discharged_hyps sp obj.cst_hyps;
add_constant_kind (constant_of_kn kn) obj.cst_kind
@@ -325,7 +325,7 @@ let cache_inductive ((sp,kn),(dhyps,mie)) =
let kn' = Global.add_mind dir id mie in
assert (eq_mind kn' (mind_of_kn kn));
let mind = Global.lookup_mind kn' in
- add_section_kn mind.mind_polymorphic kn' mind.mind_hyps;
+ add_section_kn (Declareops.inductive_is_polymorphic mind) kn' mind.mind_hyps;
Dischargedhypsmap.set_discharged_hyps sp dhyps;
List.iter (fun (sp, ref) -> Nametab.push (Nametab.Until 1) sp ref) names
@@ -351,25 +351,26 @@ let dummy_inductive_entry (_,m) = ([],{
mind_entry_record = None;
mind_entry_finite = Decl_kinds.BiFinite;
mind_entry_inds = List.map dummy_one_inductive_entry m.mind_entry_inds;
- mind_entry_polymorphic = false;
- mind_entry_cumulative = false;
- mind_entry_universes = Univ.UInfoInd.empty;
+ mind_entry_universes = Monomorphic_ind_entry Univ.UContext.empty;
mind_entry_private = None;
})
(* reinfer subtyping constraints for inductive after section is dischared. *)
-let infer_inductive_subtyping (pth, mind_ent) =
- if mind_ent.mind_entry_polymorphic && mind_ent.mind_entry_cumulative then
+let infer_inductive_subtyping (pth, mind_ent) =
+ match mind_ent.mind_entry_universes with
+ | Monomorphic_ind_entry _ | Polymorphic_ind_entry _ ->
+ (pth, mind_ent)
+ | Cumulative_ind_entry cumi ->
begin
let env = Global.env () in
let env' =
- Environ.push_context (Univ.UInfoInd.univ_context mind_ent.mind_entry_universes) env
+ Environ.push_context
+ (Univ.CumulativityInfo.univ_context cumi) env
in
(* let (env'', typed_params) = Typeops.infer_local_decls env' (mind_ent.mind_entry_params) in *)
let evd = Evd.from_env env' in
(pth, Inductiveops.infer_inductive_subtyping env' evd mind_ent)
end
- else (pth, mind_ent)
type inductive_obj = Dischargedhypsmap.discharged_hyps * mutual_inductive_entry
diff --git a/library/global.ml b/library/global.ml
index a459983849..6d80012f47 100644
--- a/library/global.ml
+++ b/library/global.ml
@@ -176,19 +176,14 @@ let type_of_global_unsafe r =
Vars.subst_instance_constr (Univ.UContext.instance univs) ty
| IndRef ind ->
let (mib, oib as specif) = Inductive.lookup_mind_specif env ind in
- let inst =
- if mib.Declarations.mind_polymorphic then
- Univ.UContext.instance (Univ.UInfoInd.univ_context mib.Declarations.mind_universes)
- else Univ.Instance.empty
- in
+ let inst = Declareops.inductive_polymorphic_instance mib in
Inductive.type_of_inductive env (specif, inst)
| ConstructRef cstr ->
let (mib,oib as specif) = Inductive.lookup_mind_specif env (inductive_of_constructor cstr) in
- let inst = Univ.UContext.instance (Univ.UInfoInd.univ_context mib.Declarations.mind_universes) in
- Inductive.type_of_constructor (cstr,inst) specif
+ let inst = Declareops.inductive_polymorphic_instance mib in
+ Inductive.type_of_constructor (cstr,inst) specif
let type_of_global_in_context env r =
- let open Declarations in
match r with
| VarRef id -> Environ.named_type id env, Univ.UContext.empty
| ConstRef c ->
@@ -199,21 +194,17 @@ let type_of_global_in_context env r =
Typeops.type_of_constant_type env cb.Declarations.const_type, univs
| IndRef ind ->
let (mib, oib as specif) = Inductive.lookup_mind_specif env ind in
- let univs =
- if mib.mind_polymorphic then Univ.instantiate_univ_context (Univ.UInfoInd.univ_context mib.mind_universes)
- else Univ.UContext.empty
- in Inductive.type_of_inductive env (specif, Univ.UContext.instance univs), univs
+ let univs = Declareops.inductive_polymorphic_context mib in
+ Inductive.type_of_inductive env (specif, Univ.UContext.instance univs), univs
| ConstructRef cstr ->
- let (mib,oib as specif) = Inductive.lookup_mind_specif env (inductive_of_constructor cstr) in
- let univs =
- if mib.mind_polymorphic then Univ.instantiate_univ_context (Univ.UInfoInd.univ_context mib.mind_universes)
- else Univ.UContext.empty
- in
- let inst = Univ.UContext.instance univs in
- Inductive.type_of_constructor (cstr,inst) specif, univs
+ let (mib,oib as specif) =
+ Inductive.lookup_mind_specif env (inductive_of_constructor cstr)
+ in
+ let univs = Declareops.inductive_polymorphic_context mib in
+ let inst = Univ.UContext.instance univs in
+ Inductive.type_of_constructor (cstr,inst) specif, univs
let universes_of_global env r =
- let open Declarations in
match r with
| VarRef id -> Univ.UContext.empty
| ConstRef c ->
@@ -222,10 +213,11 @@ let universes_of_global env r =
(Environ.opaque_tables env) cb
| IndRef ind ->
let (mib, oib) = Inductive.lookup_mind_specif env ind in
- Univ.instantiate_univ_context (Univ.UInfoInd.univ_context mib.mind_universes)
+ Declareops.inductive_polymorphic_context mib
| ConstructRef cstr ->
- let (mib,oib) = Inductive.lookup_mind_specif env (inductive_of_constructor cstr) in
- Univ.instantiate_univ_context (Univ.UInfoInd.univ_context mib.mind_universes)
+ let (mib,oib) =
+ Inductive.lookup_mind_specif env (inductive_of_constructor cstr) in
+ Declareops.inductive_polymorphic_context mib
let universes_of_global gr =
universes_of_global (env ()) gr
diff --git a/library/lib.ml b/library/lib.ml
index f22f53eadf..8127316d73 100644
--- a/library/lib.ml
+++ b/library/lib.ml
@@ -402,7 +402,7 @@ let find_opening_node id =
type variable_info = Context.Named.Declaration.t * Decl_kinds.binding_kind
type variable_context = variable_info list
-type abstr_info = variable_context * Univ.universe_level_subst * Univ.UContext.t
+type abstr_info = variable_context * Univ.universe_level_subst * Univ.AUContext.t
type abstr_list = abstr_info Names.Cmap.t * abstr_info Names.Mindmap.t
@@ -465,9 +465,9 @@ let add_section_replacement f g poly hyps =
let () = check_same_poly poly vars in
let sechyps,ctx = extract_hyps (vars,hyps) in
let ctx = Univ.ContextSet.to_context ctx in
- let subst, ctx = Univ.abstract_universes true ctx in
+ let subst, ctx = Univ.abstract_universes ctx in
let args = instance_from_variable_context (List.rev sechyps) in
- sectab := (vars,f (Univ.UContext.instance ctx,args) exps,
+ sectab := (vars,f (Univ.AUContext.instance ctx,args) exps,
g (sechyps,subst,ctx) abs)::sl
let add_section_kn poly kn =
diff --git a/library/lib.mli b/library/lib.mli
index f47d6e1a58..284d339801 100644
--- a/library/lib.mli
+++ b/library/lib.mli
@@ -157,7 +157,7 @@ val xml_close_section : (Names.Id.t -> unit) Hook.t
(** {6 Section management for discharge } *)
type variable_info = Context.Named.Declaration.t * Decl_kinds.binding_kind
type variable_context = variable_info list
-type abstr_info = variable_context * Univ.universe_level_subst * Univ.UContext.t
+type abstr_info = variable_context * Univ.universe_level_subst * Univ.AUContext.t
val instance_from_variable_context : variable_context -> Names.Id.t array
val named_of_variable_context : variable_context -> Context.Named.t
diff --git a/library/univops.ml b/library/univops.ml
index e9383c6d9f..60c12f0d81 100644
--- a/library/univops.ml
+++ b/library/univops.ml
@@ -22,9 +22,8 @@ let universes_of_constr c =
in aux LSet.empty c
let universes_of_inductive mind =
- if mind.mind_polymorphic then
- begin
- let u = Univ.UContext.instance (Univ.UInfoInd.univ_context mind.mind_universes) in
+ let process auctx =
+ let u = Univ.AUContext.instance auctx in
let univ_of_one_ind oind =
let arity_univs =
Context.Rel.fold_outside
@@ -43,12 +42,22 @@ let universes_of_inductive mind =
Univ.LSet.union (universes_of_constr cns) unvs) arity_univs
oind.mind_nf_lc
in
- let univs = Array.fold_left (fun unvs pk -> Univ.LSet.union (univ_of_one_ind pk) unvs) Univ.LSet.empty mind.mind_packets in
- let mindcnt = Univ.UContext.constraints (Univ.instantiate_univ_context (Univ.UInfoInd.univ_context mind.mind_universes)) in
+ let univs =
+ Array.fold_left
+ (fun unvs pk ->
+ Univ.LSet.union
+ (univ_of_one_ind pk) unvs
+ )
+ Univ.LSet.empty mind.mind_packets
+ in
+ let mindcnt = Univ.UContext.constraints (Univ.instantiate_univ_context auctx) in
let univs = Univ.LSet.union univs (Univ.universes_of_constraints mindcnt) in
univs
- end
- else LSet.empty
+ in
+ match mind.mind_universes with
+ | Monomorphic_ind _ -> LSet.empty
+ | Polymorphic_ind auctx -> process auctx
+ | Cumulative_ind cumi -> process (Univ.ACumulativityInfo.univ_context cumi)
let restrict_universe_context (univs,csts) s =
(* Universes that are not necessary to typecheck the term.
diff --git a/pretyping/arguments_renaming.ml b/pretyping/arguments_renaming.ml
index 1bd03491a7..c7b37aba5c 100644
--- a/pretyping/arguments_renaming.ml
+++ b/pretyping/arguments_renaming.ml
@@ -43,7 +43,7 @@ let section_segment_of_reference = function
| ConstRef con -> Lib.section_segment_of_constant con
| IndRef (kn,_) | ConstructRef ((kn,_),_) ->
Lib.section_segment_of_mutual_inductive kn
- | _ -> [], Univ.LMap.empty, Univ.UContext.empty
+ | _ -> [], Univ.LMap.empty, Univ.AUContext.empty
let discharge_rename_args = function
| _, (ReqGlobal (c, names), _ as req) ->
diff --git a/pretyping/evarconv.ml b/pretyping/evarconv.ml
index be2fd81290..b15dde5d79 100644
--- a/pretyping/evarconv.ml
+++ b/pretyping/evarconv.ml
@@ -350,18 +350,22 @@ let exact_ise_stack2 env evd f sk1 sk2 =
ise_stack2 evd (List.rev sk1) (List.rev sk2)
else UnifFailure (evd, (* Dummy *) NotSameHead)
-let check_leq_inductives evd uinfind u u' =
+let check_leq_inductives evd cumi u u' =
let u = EConstr.EInstance.kind evd u in
let u' = EConstr.EInstance.kind evd u' in
- let ind_instance = Univ.UContext.instance (Univ.UInfoInd.univ_context uinfind) in
- let ind_sbcst = Univ.UContext.constraints (Univ.UInfoInd.subtyp_context uinfind) in
+ let ind_instance =
+ Univ.AUContext.instance (Univ.ACumulativityInfo.univ_context cumi)
+ in
+ let ind_sbcst = Univ.ACumulativityInfo.subtyp_context cumi in
if not ((Univ.Instance.length ind_instance = Univ.Instance.length u) &&
(Univ.Instance.length ind_instance = Univ.Instance.length u')) then
anomaly (Pp.str "Invalid inductive subtyping encountered!")
else
begin
let comp_subst = (Univ.Instance.append u u') in
- let comp_cst = Univ.subst_instance_constraints comp_subst ind_sbcst in
+ let comp_cst =
+ Univ.UContext.constraints (Univ.subst_instance_context comp_subst ind_sbcst)
+ in
Evd.add_constraints evd comp_cst
end
@@ -491,23 +495,24 @@ and evar_eqappr_x ?(rhs_is_already_stuck = false) ts env evd pbty
let nparamsaplied' = Stack.args_size sk' in
begin
let mind = Environ.lookup_mind (fst ind) env in
- if mind.Declarations.mind_polymorphic then
+ match mind.Declarations.mind_universes with
+ | Declarations.Monomorphic_ind _ | Declarations.Polymorphic_ind _ ->
+ UnifFailure (evd, NotSameHead)
+ | Declarations.Cumulative_ind cumi ->
begin
let num_param_arity =
- (* Context.Rel.length (mind.Declarations.mind_packets.(snd ind).Declarations.mind_arity_ctxt) *)
- mind.Declarations.mind_nparams + mind.Declarations.mind_packets.(snd ind).Declarations.mind_nrealargs
+ mind.Declarations.mind_nparams +
+ mind.Declarations.mind_packets.(snd ind).Declarations.mind_nrealargs
in
- if not (num_param_arity = nparamsaplied && num_param_arity = nparamsaplied') then
+ if not (num_param_arity = nparamsaplied
+ && num_param_arity = nparamsaplied') then
UnifFailure (evd, NotSameHead)
else
begin
- let uinfind = mind.Declarations.mind_universes in
- let evd' = check_leq_inductives evd uinfind u u' in
- Success (check_leq_inductives evd' uinfind u' u)
+ let evd' = check_leq_inductives evd cumi u u' in
+ Success (check_leq_inductives evd' cumi u' u)
end
end
- else
- UnifFailure (evd, NotSameHead)
end
in
first_try_strict_check (Names.eq_ind ind ind') u u' check_subtyping_constraints
@@ -518,26 +523,29 @@ and evar_eqappr_x ?(rhs_is_already_stuck = false) ts env evd pbty
let nparamsaplied = Stack.args_size sk in
let nparamsaplied' = Stack.args_size sk' in
let mind = Environ.lookup_mind (fst ind) env in
- if mind.Declarations.mind_polymorphic then
+ match mind.Declarations.mind_universes with
+ | Declarations.Monomorphic_ind _ | Declarations.Polymorphic_ind _ ->
+ UnifFailure (evd, NotSameHead)
+ | Declarations.Cumulative_ind cumi ->
begin
let num_cnstr_args =
let nparamsctxt =
- (* Context.Rel.length mind.Declarations.mind_params_ctxt *)
- mind.Declarations.mind_nparams + mind.Declarations.mind_packets.(snd ind).Declarations.mind_nrealargs
+ mind.Declarations.mind_nparams +
+ mind.Declarations.mind_packets.(snd ind).Declarations.mind_nrealargs
in
- nparamsctxt + mind.Declarations.mind_packets.(snd ind).Declarations.mind_consnrealargs.(j - 1)
+ nparamsctxt +
+ mind.Declarations.mind_packets.(snd ind).
+ Declarations.mind_consnrealargs.(j - 1)
in
- if not (num_cnstr_args = nparamsaplied && num_cnstr_args = nparamsaplied') then
+ if not (num_cnstr_args = nparamsaplied
+ && num_cnstr_args = nparamsaplied') then
UnifFailure (evd, NotSameHead)
else
begin
- let uinfind = mind.Declarations.mind_universes in
- let evd' = check_leq_inductives evd uinfind u u' in
- Success (check_leq_inductives evd' uinfind u' u)
+ let evd' = check_leq_inductives evd cumi u u' in
+ Success (check_leq_inductives evd' cumi u' u)
end
end
- else
- UnifFailure (evd, NotSameHead)
in
first_try_strict_check (Names.eq_constructor cons cons') u u' check_subtyping_constraints
| _, _ -> anomaly (Pp.str "")
@@ -546,7 +554,6 @@ and evar_eqappr_x ?(rhs_is_already_stuck = false) ts env evd pbty
try compare_heads i
with Univ.UniverseInconsistency p -> UnifFailure (i, UnifUnivInconsistency p));
(fun i -> exact_ise_stack2 env i (evar_conv_x ts) sk sk')]
-(* >>>>>>> Make unification use subtyping info of inductives *)
in
let flex_maybeflex on_left ev ((termF,skF as apprF),cstsF) ((termM, skM as apprM),cstsM) vM =
let switch f a b = if on_left then f a b else f b a in
diff --git a/pretyping/inductiveops.ml b/pretyping/inductiveops.ml
index 1ef4a9f5e7..2ae7c0f809 100644
--- a/pretyping/inductiveops.ml
+++ b/pretyping/inductiveops.ml
@@ -696,39 +696,52 @@ let infer_inductive_subtyping_arity_constructor
let infer_inductive_subtyping env evd mind_ent =
let { Entries.mind_entry_params = params;
Entries.mind_entry_inds = entries;
- Entries.mind_entry_polymorphic = poly;
- Entries.mind_entry_cumulative = cum;
- Entries.mind_entry_universes = ground_uinfind;
+ Entries.mind_entry_universes = ground_univs;
} = mind_ent
in
let uinfind =
- if poly && cum then
- begin
- let uctx = Univ.UInfoInd.univ_context ground_uinfind in
- let sbsubst = Univ.UInfoInd.subtyping_susbst ground_uinfind in
- let dosubst = subst_univs_level_constr sbsubst in
- let instance_other = Univ.subst_univs_level_instance sbsubst (Univ.UContext.instance uctx) in
- let constraints_other = Univ.subst_univs_level_constraints sbsubst (Univ.UContext.constraints uctx) in
- let uctx_other = Univ.UContext.make (instance_other, constraints_other) in
- let env = Environ.push_context uctx env in
- let env = Environ.push_context uctx_other env in
- let evd = Evd.merge_universe_context evd (UState.of_context_set (Univ.ContextSet.of_context uctx_other)) in
- let (_, _, subtyp_constraints) =
- List.fold_left
- (fun ctxs indentry ->
- let _, params = Typeops.infer_local_decls env params in
- let ctxs' = infer_inductive_subtyping_arity_constructor
- ctxs dosubst indentry.Entries.mind_entry_arity true params
- in
- List.fold_left
- (fun ctxs cons ->
- infer_inductive_subtyping_arity_constructor ctxs dosubst cons false params)
- ctxs' indentry.Entries.mind_entry_lc
- ) (env, evd, Univ.Constraint.empty) entries
- in Univ.UInfoInd.make (Univ.UInfoInd.univ_context ground_uinfind,
- Univ.UContext.make
- (Univ.UContext.instance (Univ.UInfoInd.subtyp_context ground_uinfind),
- subtyp_constraints))
- end
- else ground_uinfind
+ match ground_univs with
+ | Entries.Monomorphic_ind_entry _
+ | Entries.Polymorphic_ind_entry _ -> ground_univs
+ | Entries.Cumulative_ind_entry cumi ->
+ begin
+ let uctx = Univ.CumulativityInfo.univ_context cumi in
+ let sbsubst = Univ.CumulativityInfo.subtyping_susbst cumi in
+ let dosubst = subst_univs_level_constr sbsubst in
+ let instance_other =
+ Univ.subst_univs_level_instance sbsubst (Univ.UContext.instance uctx)
+ in
+ let constraints_other =
+ Univ.subst_univs_level_constraints
+ sbsubst (Univ.UContext.constraints uctx)
+ in
+ let uctx_other = Univ.UContext.make (instance_other, constraints_other) in
+ let env = Environ.push_context uctx env in
+ let env = Environ.push_context uctx_other env in
+ let evd =
+ Evd.merge_universe_context
+ evd (UState.of_context_set (Univ.ContextSet.of_context uctx_other))
+ in
+ let (_, _, subtyp_constraints) =
+ List.fold_left
+ (fun ctxs indentry ->
+ let _, params = Typeops.infer_local_decls env params in
+ let ctxs' = infer_inductive_subtyping_arity_constructor
+ ctxs dosubst indentry.Entries.mind_entry_arity true params
+ in
+ List.fold_left
+ (fun ctxs cons ->
+ infer_inductive_subtyping_arity_constructor
+ ctxs dosubst cons false params
+ )
+ ctxs' indentry.Entries.mind_entry_lc
+ ) (env, evd, Univ.Constraint.empty) entries
+ in
+ Entries.Cumulative_ind_entry
+ (Univ.CumulativityInfo.make
+ (Univ.CumulativityInfo.univ_context cumi,
+ Univ.UContext.make
+ (Univ.UContext.instance (Univ.CumulativityInfo.subtyp_context cumi),
+ subtyp_constraints)))
+ end
in {mind_ent with Entries.mind_entry_universes = uinfind;}
diff --git a/pretyping/recordops.ml b/pretyping/recordops.ml
index bc9e3a1f46..283a1dcd18 100644
--- a/pretyping/recordops.ml
+++ b/pretyping/recordops.ml
@@ -197,7 +197,7 @@ let warn_projection_no_head_constant =
(* Intended to always succeed *)
let compute_canonical_projections warn (con,ind) =
let env = Global.env () in
- let ctx = Univ.instantiate_univ_context (Environ.constant_context env con) in
+ let ctx = Environ.constant_context env con in
let u = Univ.UContext.instance ctx in
let v = (mkConstU (con,u)) in
let ctx = Univ.ContextSet.of_context ctx in
@@ -298,8 +298,7 @@ let error_not_structure ref =
let check_and_decompose_canonical_structure ref =
let sp = match ref with ConstRef sp -> sp | _ -> error_not_structure ref in
let env = Global.env () in
- let ctx = Environ.constant_context env sp in
- let u = Univ.UContext.instance ctx in
+ let u = Environ.constant_instance env sp in
let vc = match Environ.constant_opt_value_in env (sp, u) with
| Some vc -> vc
| None -> error_not_structure ref in
diff --git a/pretyping/reductionops.ml b/pretyping/reductionops.ml
index 2040acba79..123c610166 100644
--- a/pretyping/reductionops.ml
+++ b/pretyping/reductionops.ml
@@ -1362,21 +1362,25 @@ let sigma_compare_instances ~flex i0 i1 sigma =
raise Reduction.NotConvertible
let sigma_check_inductive_instances cv_pb uinfind u u' sigma =
- let ind_instance = Univ.UContext.instance (Univ.UInfoInd.univ_context uinfind) in
- let ind_sbcst = Univ.UContext.constraints (Univ.UInfoInd.subtyp_context uinfind) in
+ let ind_instance =
+ Univ.AUContext.instance (Univ.ACumulativityInfo.univ_context uinfind)
+ in
+ let ind_sbctx = Univ.ACumulativityInfo.subtyp_context uinfind in
if not ((Univ.Instance.length ind_instance = Univ.Instance.length u) &&
(Univ.Instance.length ind_instance = Univ.Instance.length u')) then
anomaly (Pp.str "Invalid inductive subtyping encountered!")
else
let comp_cst =
let comp_subst = (Univ.Instance.append u u') in
- Univ.subst_instance_constraints comp_subst ind_sbcst
+ Univ.UContext.constraints (Univ.subst_instance_context comp_subst ind_sbctx)
in
let comp_cst =
match cv_pb with
Reduction.CONV ->
let comp_subst = (Univ.Instance.append u' u) in
- let comp_cst' = (Univ.subst_instance_constraints comp_subst ind_sbcst) in
+ let comp_cst' =
+ Univ.UContext.constraints(Univ.subst_instance_context comp_subst ind_sbctx)
+ in
Univ.Constraint.union comp_cst comp_cst'
| Reduction.CUMUL -> comp_cst
in
@@ -1389,34 +1393,43 @@ let sigma_conv_inductives
cv_pb (mind, ind) u1 sv1 u2 sv2 sigma =
try sigma_compare_instances ~flex:false u1 u2 sigma with
Reduction.NotConvertible ->
- if mind.Declarations.mind_polymorphic then
+ match mind.Declarations.mind_universes with
+ | Declarations.Monomorphic_ind _ ->
+ raise Reduction.NotConvertible
+ | Declarations.Polymorphic_ind _ ->
+ raise Reduction.NotConvertible
+ | Declarations.Cumulative_ind cumi ->
let num_param_arity =
- mind.Declarations.mind_nparams + mind.Declarations.mind_packets.(ind).Declarations.mind_nrealargs
+ mind.Declarations.mind_nparams +
+ mind.Declarations.mind_packets.(ind).Declarations.mind_nrealargs
in
if not (num_param_arity = sv1 && num_param_arity = sv2) then
raise Reduction.NotConvertible
else
- let uinfind = mind.Declarations.mind_universes in
- sigma_check_inductive_instances cv_pb uinfind u1 u2 sigma
- else raise Reduction.NotConvertible
+ sigma_check_inductive_instances cv_pb cumi u1 u2 sigma
let sigma_conv_constructors
(mind, ind, cns) u1 sv1 u2 sv2 sigma =
try sigma_compare_instances ~flex:false u1 u2 sigma with
Reduction.NotConvertible ->
- if mind.Declarations.mind_polymorphic then
+ match mind.Declarations.mind_universes with
+ | Declarations.Monomorphic_ind _ ->
+ raise Reduction.NotConvertible
+ | Declarations.Polymorphic_ind _ ->
+ raise Reduction.NotConvertible
+ | Declarations.Cumulative_ind cumi ->
let num_cnstr_args =
let nparamsctxt =
- mind.Declarations.mind_nparams + mind.Declarations.mind_packets.(ind).Declarations.mind_nrealargs
- (* Context.Rel.length mind.Declarations.mind_params_ctxt *) in
- nparamsctxt + mind.Declarations.mind_packets.(ind).Declarations.mind_consnrealargs.(cns - 1)
+ mind.Declarations.mind_nparams +
+ mind.Declarations.mind_packets.(ind).Declarations.mind_nrealargs
+ in
+ nparamsctxt +
+ mind.Declarations.mind_packets.(ind).Declarations.mind_consnrealargs.(cns - 1)
in
if not (num_cnstr_args = sv1 && num_cnstr_args = sv2) then
raise Reduction.NotConvertible
else
- let uinfind = mind.Declarations.mind_universes in
- sigma_check_inductive_instances Reduction.CONV uinfind u1 u2 sigma
- else raise Reduction.NotConvertible
+ sigma_check_inductive_instances Reduction.CONV cumi u1 u2 sigma
let sigma_univ_state =
{ Reduction.compare = sigma_compare_sorts;
diff --git a/pretyping/typeclasses.ml b/pretyping/typeclasses.ml
index 152ccb0798..f883e647b5 100644
--- a/pretyping/typeclasses.ml
+++ b/pretyping/typeclasses.ml
@@ -111,20 +111,16 @@ let new_instance cl info glob poly impl =
let classes : typeclasses ref = Summary.ref Refmap.empty ~name:"classes"
let instances : instances ref = Summary.ref Refmap.empty ~name:"instances"
-open Declarations
-
let typeclass_univ_instance (cl,u') =
let subst =
let u =
match cl.cl_impl with
| ConstRef c ->
let cb = Global.lookup_constant c in
- if cb.const_polymorphic then Univ.UContext.instance cb.const_universes
- else Univ.Instance.empty
+ Declareops.constant_polymorphic_instance cb
| IndRef c ->
let mib,oib = Global.lookup_inductive c in
- if mib.mind_polymorphic then Univ.UContext.instance (Univ.UInfoInd.univ_context mib.mind_universes)
- else Univ.Instance.empty
+ Declareops.inductive_polymorphic_instance mib
| _ -> Univ.Instance.empty
in Array.fold_left2 (fun subst u u' -> Univ.LMap.add u u' subst)
Univ.LMap.empty (Univ.Instance.to_array u) (Univ.Instance.to_array u')
diff --git a/pretyping/vnorm.ml b/pretyping/vnorm.ml
index 074b7373c7..9e151fea25 100644
--- a/pretyping/vnorm.ml
+++ b/pretyping/vnorm.ml
@@ -174,8 +174,7 @@ and nf_whd env sigma whd typ =
| Vatom_stk(Aind ((mi,i) as ind), stk) ->
let mib = Environ.lookup_mind mi env in
let nb_univs =
- if mib.mind_polymorphic then Univ.UContext.size (Univ.UInfoInd.univ_context mib.mind_universes)
- else 0
+ Univ.Instance.length (Declareops.inductive_polymorphic_instance mib)
in
let mk u =
let pind = (ind, u) in (mkIndU pind, type_of_ind env pind)
@@ -204,8 +203,7 @@ and constr_type_of_idkey env sigma (idkey : Vars.id_key) stk =
| ConstKey cst ->
let cbody = Environ.lookup_constant cst env in
let nb_univs =
- if cbody.const_polymorphic then Univ.UContext.size cbody.const_universes
- else 0
+ Univ.Instance.length (Declareops.constant_polymorphic_instance cbody)
in
let mk u =
let pcst = (cst, u) in (mkConstU pcst, Typeops.type_of_constant_in env pcst)
diff --git a/printing/prettyp.ml b/printing/prettyp.ml
index 3ae7da8fc1..6d2bf6b73a 100644
--- a/printing/prettyp.ml
+++ b/printing/prettyp.ml
@@ -502,8 +502,8 @@ let ungeneralized_type_of_constant_type t =
Typeops.type_of_constant_type (Global.env ()) t
let print_instance sigma cb =
- if cb.const_polymorphic then
- pr_universe_instance sigma cb.const_universes
+ if Declareops.constant_is_polymorphic cb then
+ pr_universe_instance sigma (Declareops.constant_polymorphic_context cb)
else mt()
let print_constant with_values sep sp =
@@ -511,16 +511,14 @@ let print_constant with_values sep sp =
let val_0 = Global.body_of_constant_body cb in
let typ = Declareops.type_of_constant cb in
let typ = ungeneralized_type_of_constant_type typ in
- let univs = Univ.instantiate_univ_context
- (Global.universes_of_constant_body cb)
- in
+ let univs = Global.universes_of_constant_body cb in
let ctx =
Evd.evar_universe_context_of_binders
(Universes.universe_binders_of_global (ConstRef sp))
in
let env = Global.env () and sigma = Evd.from_ctx ctx in
let pr_ltype = pr_ltype_env env sigma in
- hov 0 (pr_polymorphic cb.const_polymorphic ++
+ hov 0 (pr_polymorphic (Declareops.constant_is_polymorphic cb) ++
match val_0 with
| None ->
str"*** [ " ++
diff --git a/printing/printer.ml b/printing/printer.ml
index 1d7b7cff0f..3b0b6d5d23 100644
--- a/printing/printer.ml
+++ b/printing/printer.ml
@@ -261,10 +261,11 @@ let pr_universe_ctx sigma c =
else
mt()
-let pr_universe_info_ind sigma uii =
- if !Detyping.print_universes && not (Univ.UInfoInd.is_empty uii) then
- fnl()++pr_in_comment (fun uii -> v 0
- (Univ.pr_universe_info_ind (Termops.pr_evd_level sigma) uii)) uii
+let pr_cumulativity_info sigma cumi =
+ if !Detyping.print_universes
+ && not (Univ.UContext.is_empty (Univ.CumulativityInfo.univ_context cumi)) then
+ fnl()++pr_in_comment (fun uii -> v 0
+ (Univ.pr_cumulativity_info (Termops.pr_evd_level sigma) uii)) cumi
else
mt()
@@ -998,10 +999,10 @@ let pr_assumptionset env s =
let xor a b =
(a && not b) || (not a && b)
-let pr_cumulative p b =
- if p then
- if b then str "Cumulative " else str "NonCumulative "
- else str ""
+let pr_cumulative poly cum =
+ if poly then
+ if cum then str "Cumulative " else str "NonCumulative "
+ else mt ()
let pr_polymorphic b =
let print = xor (Flags.is_universe_polymorphism ()) b in
diff --git a/printing/printer.mli b/printing/printer.mli
index 9f4ea23b74..f0a32bbbdf 100644
--- a/printing/printer.mli
+++ b/printing/printer.mli
@@ -98,7 +98,7 @@ val pr_polymorphic : bool -> std_ppcmds
val pr_cumulative : bool -> bool -> std_ppcmds
val pr_universe_instance : evar_map -> Univ.universe_context -> std_ppcmds
val pr_universe_ctx : evar_map -> Univ.universe_context -> std_ppcmds
-val pr_universe_info_ind : evar_map -> Univ.universe_info_ind -> std_ppcmds
+val pr_cumulativity_info : evar_map -> Univ.cumulativity_info -> std_ppcmds
(** Printing global references using names as short as possible *)
diff --git a/printing/printmod.ml b/printing/printmod.ml
index be8940b6ff..08d177f53e 100644
--- a/printing/printmod.ml
+++ b/printing/printmod.ml
@@ -88,8 +88,8 @@ let build_ind_type env mip =
Inductive.type_of_inductive env mip
let print_one_inductive env sigma mib ((_,i) as ind) =
- let u = if mib.mind_polymorphic then
- Univ.UContext.instance (Univ.UInfoInd.univ_context mib.mind_universes)
+ let u = if Declareops.inductive_is_polymorphic mib then
+ Declareops.inductive_polymorphic_instance mib
else Univ.Instance.empty in
let mip = mib.mind_packets.(i) in
let params = Inductive.inductive_paramdecls (mib,u) in
@@ -99,8 +99,8 @@ let print_one_inductive env sigma mib ((_,i) as ind) =
let cstrtypes = Array.map (fun c -> hnf_prod_applist env c args) cstrtypes in
let envpar = push_rel_context params env in
let inst =
- if mib.mind_polymorphic then
- Printer.pr_universe_instance sigma (Univ.UInfoInd.univ_context mib.mind_universes)
+ if Declareops.inductive_is_polymorphic mib then
+ Printer.pr_universe_instance sigma (Declareops.inductive_polymorphic_context mib)
else mt ()
in
hov 0 (
@@ -120,12 +120,18 @@ let print_mutual_inductive env mind mib =
in
let bl = Universes.universe_binders_of_global (IndRef (mind, 0)) in
let sigma = Evd.from_ctx (Evd.evar_universe_context_of_binders bl) in
- hov 0 (Printer.pr_polymorphic mib.mind_polymorphic ++
- Printer.pr_cumulative mib.mind_polymorphic mib.mind_cumulative ++
+ hov 0 (Printer.pr_polymorphic (Declareops.inductive_is_polymorphic mib) ++
+ Printer.pr_cumulative
+ (Declareops.inductive_is_polymorphic mib)
+ (Declareops.inductive_is_cumulative mib) ++
def keyword ++ spc () ++
prlist_with_sep (fun () -> fnl () ++ str" with ")
(print_one_inductive env sigma mib) inds ++
- Printer.pr_universe_info_ind sigma (Univ.instantiate_univ_info_ind mib.mind_universes))
+ match mib.mind_universes with
+ | Monomorphic_ind _ | Polymorphic_ind _ -> str ""
+ | Cumulative_ind cumi ->
+ Printer.pr_cumulativity_info
+ sigma (Univ.instantiate_cumulativity_info cumi))
let get_fields =
let rec prodec_rec l subst c =
@@ -142,8 +148,8 @@ let get_fields =
let print_record env mind mib =
let u =
- if mib.mind_polymorphic then
- Univ.UContext.instance (Univ.UInfoInd.univ_context mib.mind_universes)
+ if Declareops.inductive_is_polymorphic mib then
+ Declareops.inductive_polymorphic_instance mib
else Univ.Instance.empty
in
let mip = mib.mind_packets.(0) in
@@ -165,8 +171,10 @@ let print_record env mind mib =
in
hov 0 (
hov 0 (
- Printer.pr_polymorphic mib.mind_polymorphic ++
- Printer.pr_cumulative mib.mind_polymorphic mib.mind_cumulative ++
+ Printer.pr_polymorphic (Declareops.inductive_is_polymorphic mib) ++
+ Printer.pr_cumulative
+ (Declareops.inductive_is_polymorphic mib)
+ (Declareops.inductive_is_cumulative mib) ++
def keyword ++ spc () ++ pr_id mip.mind_typename ++ brk(1,4) ++
print_params env sigma params ++
str ": " ++ Printer.pr_lconstr_env envpar sigma arity ++ brk(1,2) ++
@@ -177,7 +185,12 @@ let print_record env mind mib =
(fun (id,b,c) ->
pr_id id ++ str (if b then " : " else " := ") ++
Printer.pr_lconstr_env envpar sigma c) fields) ++ str" }" ++
- Printer.pr_universe_info_ind sigma (Univ.instantiate_univ_info_ind mib.mind_universes))
+ match mib.mind_universes with
+ | Monomorphic_ind _ | Polymorphic_ind _ -> str ""
+ | Cumulative_ind cumi ->
+ Printer.pr_cumulativity_info
+ sigma (Univ.instantiate_cumulativity_info cumi)
+ )
let pr_mutual_inductive_body env mind mib =
if mib.mind_record <> None && not !Flags.raw_print then
@@ -280,7 +293,8 @@ let print_body is_impl env mp (l,body) =
| SFBmodtype _ -> keyword "Module Type" ++ spc () ++ name
| SFBconst cb ->
let u =
- if cb.const_polymorphic then Univ.UContext.instance cb.const_universes
+ if Declareops.constant_is_polymorphic cb then
+ Declareops.constant_polymorphic_instance cb
else Univ.Instance.empty
in
let sigma = Evd.empty in
@@ -302,7 +316,8 @@ let print_body is_impl env mp (l,body) =
Printer.pr_lconstr_env env sigma
(Vars.subst_instance_constr u (Mod_subst.force_constr l)))
| _ -> mt ()) ++ str "." ++
- Printer.pr_universe_ctx sigma (Univ.instantiate_univ_context cb.const_universes))
+ Printer.pr_universe_ctx sigma
+ (Declareops.constant_polymorphic_context cb))
| SFBmind mib ->
try
let env = Option.get env in
diff --git a/tactics/elimschemes.ml b/tactics/elimschemes.ml
index 8d8e198119..99761437eb 100644
--- a/tactics/elimschemes.ml
+++ b/tactics/elimschemes.ml
@@ -47,7 +47,7 @@ let optimize_non_type_induction_scheme kind dep sort _ ind =
(nf c', Evd.evar_universe_context sigma), eff
else
let mib,mip = Inductive.lookup_mind_specif env ind in
- let ctx = Declareops.inductive_context mib in
+ let ctx = Declareops.inductive_polymorphic_context mib in
let u = Univ.UContext.instance ctx in
let ctxset = Univ.ContextSet.of_context ctx in
let ectx = Evd.evar_universe_context_of ctxset in
@@ -60,7 +60,7 @@ let build_induction_scheme_in_type dep sort ind =
let sigma = Evd.from_env env in
let ctx =
let mib,mip = Inductive.lookup_mind_specif env ind in
- Declareops.inductive_context mib
+ Declareops.inductive_polymorphic_context mib
in
let u = Univ.UContext.instance ctx in
let ctxset = Univ.ContextSet.of_context ctx in
diff --git a/tactics/elimschemes.mli b/tactics/elimschemes.mli
index 77f927f2df..da432beadc 100644
--- a/tactics/elimschemes.mli
+++ b/tactics/elimschemes.mli
@@ -10,6 +10,14 @@ open Ind_tables
(** Induction/recursion schemes *)
+val optimize_non_type_induction_scheme :
+ 'a Ind_tables.scheme_kind ->
+ Indrec.dep_flag ->
+ Term.sorts_family ->
+ 'b ->
+ Names.inductive ->
+ (Constr.constr * Evd.evar_universe_context) * Safe_typing.private_constants
+
val rect_scheme_kind_from_prop : individual scheme_kind
val ind_scheme_kind_from_prop : individual scheme_kind
val rec_scheme_kind_from_prop : individual scheme_kind
diff --git a/tactics/hints.ml b/tactics/hints.ml
index 681db5d08e..2fc8baa895 100644
--- a/tactics/hints.ml
+++ b/tactics/hints.ml
@@ -1306,7 +1306,8 @@ let interp_hints poly =
List.init (nconstructors ind)
(fun i -> let c = (ind,i+1) in
let gr = ConstructRef c in
- empty_hint_info, mib.Declarations.mind_polymorphic, true,
+ empty_hint_info,
+ (Declareops.inductive_is_polymorphic mib), true,
PathHints [gr], IsGlobRef gr)
in HintsResolveEntry (List.flatten (List.map constr_hints_of_ind lqid))
| HintsExtern (pri, patcom, tacexp) ->
diff --git a/test-suite/coqchk/cumulativity.v b/test-suite/coqchk/cumulativity.v
index 84121ea925..a978f6b901 100644
--- a/test-suite/coqchk/cumulativity.v
+++ b/test-suite/coqchk/cumulativity.v
@@ -27,14 +27,13 @@ End ListLower.
Lemma LowerL_Lem@{i j} (A : Type@{j}) (l : List@{i} A) : l = LowerL l.
Proof. reflexivity. Qed.
-
-(* I disable these tests because cqochk can't process them when compiled with
+(*
+I disable these tests because cqochk can't process them when compiled with
ocaml-4.02.3+32bit and camlp5-4.16 which is the case for Travis!
I have added this file (including the commented parts below) in
test-suite/success/cumulativity.v which doesn't run coqchk on them.
*)
-
(* Inductive Tp := tp : Type -> Tp. *)
(* Section TpLift. *)
diff --git a/vernac/command.ml b/vernac/command.ml
index 2345cb4c51..4064773561 100644
--- a/vernac/command.ml
+++ b/vernac/command.ml
@@ -649,20 +649,25 @@ let interp_mutual_inductive (paramsl,indl) notations cum poly prv finite =
indimpls, List.map (fun impls ->
userimpls @ (lift_implicits len impls)) cimpls) indimpls constructors
in
- let ground_uinfind = Universes.univ_inf_ind_from_universe_context uctx in
+ let univs =
+ if poly then
+ if cum then
+ Cumulative_ind_entry (Universes.univ_inf_ind_from_universe_context uctx)
+ else Polymorphic_ind_entry uctx
+ else
+ Monomorphic_ind_entry uctx
+ in
(* Build the mutual inductive entry *)
- let mind_ent =
+ let mind_ent =
{ mind_entry_params = List.map prepare_param ctx_params;
mind_entry_record = None;
mind_entry_finite = finite;
mind_entry_inds = entries;
- mind_entry_polymorphic = poly;
- mind_entry_cumulative = cum;
mind_entry_private = if prv then Some false else None;
- mind_entry_universes = ground_uinfind;
+ mind_entry_universes = univs;
}
in
- (if poly then
+ (if poly && cum then
Inductiveops.infer_inductive_subtyping env_ar evd mind_ent
else mind_ent), pl, impls
diff --git a/vernac/discharge.ml b/vernac/discharge.ml
index 738e27f635..18f93334b1 100644
--- a/vernac/discharge.ml
+++ b/vernac/discharge.ml
@@ -79,12 +79,14 @@ let refresh_polymorphic_type_of_inductive (_,mip) =
let process_inductive (sechyps,abs_ctx) modlist mib =
let nparams = mib.mind_nparams in
- let subst, univs =
- if mib.mind_polymorphic then
- let inst = Univ.UContext.instance (Univ.UInfoInd.univ_context mib.mind_universes) in
- let cstrs = Univ.UContext.constraints (Univ.UInfoInd.univ_context mib.mind_universes) in
- inst, Univ.UContext.make (inst, Univ.subst_instance_constraints inst cstrs)
- else Univ.Instance.empty, (Univ.UInfoInd.univ_context mib.mind_universes)
+ let subst, univs =
+ match mib.mind_universes with
+ | Monomorphic_ind ctx -> Univ.Instance.empty, ctx
+ | Polymorphic_ind auctx ->
+ Univ.AUContext.instance auctx, Univ.instantiate_univ_context auctx
+ | Cumulative_ind cumi ->
+ let auctx = Univ.ACumulativityInfo.univ_context cumi in
+ Univ.AUContext.instance auctx, Univ.instantiate_univ_context auctx
in
let inds =
Array.map_to_list
@@ -105,7 +107,12 @@ let process_inductive (sechyps,abs_ctx) modlist mib =
let (params',inds') = abstract_inductive sechyps' nparams inds in
let abs_ctx = Univ.instantiate_univ_context abs_ctx in
let univs = Univ.UContext.union abs_ctx univs in
- let univ_info_ind = Universes.univ_inf_ind_from_universe_context univs in
+ let ind_univs =
+ match mib.mind_universes with
+ | Monomorphic_ind _ -> Monomorphic_ind_entry univs
+ | Polymorphic_ind _ -> Polymorphic_ind_entry univs
+ | Cumulative_ind _ ->
+ Cumulative_ind_entry (Universes.univ_inf_ind_from_universe_context univs) in
let record = match mib.mind_record with
| Some (Some (id, _, _)) -> Some (Some id)
| Some None -> Some None
@@ -115,9 +122,7 @@ let process_inductive (sechyps,abs_ctx) modlist mib =
mind_entry_finite = mib.mind_finite;
mind_entry_params = params';
mind_entry_inds = inds';
- mind_entry_polymorphic = mib.mind_polymorphic;
- mind_entry_cumulative = mib.mind_cumulative;
mind_entry_private = mib.mind_private;
- mind_entry_universes = univ_info_ind
+ mind_entry_universes = ind_univs
}
diff --git a/vernac/discharge.mli b/vernac/discharge.mli
index 18d1b67766..3845c04a11 100644
--- a/vernac/discharge.mli
+++ b/vernac/discharge.mli
@@ -11,4 +11,5 @@ open Entries
open Opaqueproof
val process_inductive :
- Context.Named.t Univ.in_universe_context -> work_list -> mutual_inductive_body -> mutual_inductive_entry
+ ((Term.constr, Term.constr) Context.Named.pt * Univ.abstract_universe_context)
+ -> work_list -> mutual_inductive_body -> mutual_inductive_entry
diff --git a/vernac/himsg.ml b/vernac/himsg.ml
index 6d8dd82ac6..ce91e1a09f 100644
--- a/vernac/himsg.ml
+++ b/vernac/himsg.ml
@@ -889,6 +889,10 @@ let explain_not_match_error = function
| NoTypeConstraintExpected ->
strbrk "a definition whose type is constrained can only be subtype " ++
strbrk "of a definition whose type is itself constrained"
+ | CumulativeStatusExpected b ->
+ let status b = if b then str"cumulative" else str"non-cumulative" in
+ str "a " ++ status b ++ str" declaration was expected, but a " ++
+ status (not b) ++ str" declaration was found"
| PolymorphicStatusExpected b ->
let status b = if b then str"polymorphic" else str"monomorphic" in
str "a " ++ status b ++ str" declaration was expected, but a " ++
diff --git a/vernac/ind_tables.ml b/vernac/ind_tables.ml
index f3259f1f3b..65d42b6267 100644
--- a/vernac/ind_tables.ml
+++ b/vernac/ind_tables.ml
@@ -148,7 +148,7 @@ let define_individual_scheme_base kind suff f mode idopt (mind,i as ind) =
let id = match idopt with
| Some id -> id
| None -> add_suffix mib.mind_packets.(i).mind_typename suff in
- let const = define mode id c mib.mind_polymorphic ctx in
+ let const = define mode id c (Declareops.inductive_is_polymorphic mib) ctx in
declare_scheme kind [|ind,const|];
const, Safe_typing.add_private
(Safe_typing.private_con_of_scheme ~kind (Global.safe_env()) [ind,const]) eff
@@ -166,7 +166,7 @@ let define_mutual_scheme_base kind suff f mode names mind =
try Int.List.assoc i names
with Not_found -> add_suffix mib.mind_packets.(i).mind_typename suff) in
let consts = Array.map2 (fun id cl ->
- define mode id cl mib.mind_polymorphic ctx) ids cl in
+ define mode id cl (Declareops.inductive_is_polymorphic mib) ctx) ids cl in
let schemes = Array.mapi (fun i cst -> ((mind,i),cst)) consts in
declare_scheme kind schemes;
consts,
diff --git a/vernac/obligations.ml b/vernac/obligations.ml
index e03e9b8039..135e4c63ab 100644
--- a/vernac/obligations.ml
+++ b/vernac/obligations.ml
@@ -365,8 +365,8 @@ let get_body obl =
match obl.obl_body with
| None -> None
| Some (DefinedObl c) ->
- let ctx = Environ.constant_context (Global.env ()) c in
- let pc = (c, Univ.UContext.instance ctx) in
+ let u = Environ.constant_instance (Global.env ()) c in
+ let pc = (c, u) in
Some (DefinedObl pc)
| Some (TermObl c) ->
Some (TermObl c)
diff --git a/vernac/record.ml b/vernac/record.ml
index b95131b724..7dd70d0133 100644
--- a/vernac/record.ml
+++ b/vernac/record.ml
@@ -265,10 +265,16 @@ let warn_non_primitive_record =
let declare_projections indsp ?(kind=StructureComponent) binder_name coers fieldimpls fields =
let env = Global.env() in
let (mib,mip) = Global.lookup_inductive indsp in
- let u = Declareops.inductive_instance mib in
+ let u = Declareops.inductive_polymorphic_instance mib in
let paramdecls = Inductive.inductive_paramdecls (mib, u) in
- let poly = mib.mind_polymorphic in
- let ctx = Univ.instantiate_univ_context (Univ.UInfoInd.univ_context mib.mind_universes) in
+ let poly = Declareops.inductive_is_polymorphic mib in
+ let ctx =
+ match mib.mind_universes with
+ | Monomorphic_ind ctx -> ctx
+ | Polymorphic_ind auctx -> Univ.instantiate_univ_context auctx
+ | Cumulative_ind cumi ->
+ Univ.instantiate_univ_context (Univ.ACumulativityInfo.univ_context cumi)
+ in
let indu = indsp, u in
let r = mkIndU (indsp,u) in
let rp = applist (r, Context.Rel.to_extended_list mkRel 0 paramdecls) in
@@ -377,12 +383,18 @@ let structure_signature ctx =
open Typeclasses
-let declare_structure finite cum poly ctx id idbuild paramimpls params arity template
+let declare_structure finite univs id idbuild paramimpls params arity template
fieldimpls fields ?(kind=StructureComponent) ?name is_coe coers sign =
let nparams = List.length params and nfields = List.length fields in
let args = Context.Rel.to_extended_list mkRel nfields params in
let ind = applist (mkRel (1+nparams+nfields), args) in
let type_constructor = it_mkProd_or_LetIn ind fields in
+ let poly, ctx =
+ match univs with
+ | Monomorphic_ind_entry ctx -> false, ctx
+ | Polymorphic_ind_entry ctx -> true, ctx
+ | Cumulative_ind_entry cumi -> true, (Univ.CumulativityInfo.univ_context cumi)
+ in
let binder_name =
match name with
| None -> Id.of_string (Unicode.lowercase_first_char (Id.to_string id))
@@ -400,17 +412,15 @@ let declare_structure finite cum poly ctx id idbuild paramimpls params arity tem
mind_entry_record = Some (if !primitive_flag then Some binder_name else None);
mind_entry_finite = finite;
mind_entry_inds = [mie_ind];
- mind_entry_polymorphic = poly;
- mind_entry_cumulative = cum;
mind_entry_private = None;
- mind_entry_universes = ctx;
+ mind_entry_universes = univs;
}
in
let mie =
if poly then
begin
let env = Global.env () in
- let env' = Environ.push_context (Univ.UInfoInd.univ_context ctx) env in
+ let env' = Environ.push_context ctx env in
(* let env'' = Environ.push_rel_context params env' in *)
let evd = Evd.from_env env' in
Inductiveops.infer_inductive_subtyping env' evd mie
@@ -479,7 +489,16 @@ let declare_class finite def cum poly ctx id idbuild paramimpls params arity
in
cref, [Name proj_name, sub, Some proj_cst]
| _ ->
- let ind = declare_structure BiFinite cum poly (Universes.univ_inf_ind_from_universe_context ctx) (snd id) idbuild paramimpls
+ let univs =
+ if poly then
+ if cum then
+ Cumulative_ind_entry (Universes.univ_inf_ind_from_universe_context ctx)
+ else
+ Polymorphic_ind_entry ctx
+ else
+ Monomorphic_ind_entry ctx
+ in
+ let ind = declare_structure BiFinite univs (snd id) idbuild paramimpls
params arity template fieldimpls fields
~kind:Method ~name:binder_name false (List.map (fun _ -> false) fields) sign
in
@@ -528,7 +547,7 @@ let add_inductive_class ind =
let mind, oneind = Global.lookup_inductive ind in
let k =
let ctx = oneind.mind_arity_ctxt in
- let inst = Univ.UContext.instance (Univ.UInfoInd.univ_context mind.mind_universes) in
+ let inst = Declareops.inductive_polymorphic_instance mind in
let ty = Inductive.type_of_inductive
(push_rel_context ctx (Global.env ()))
((mind,oneind),inst)
@@ -581,10 +600,20 @@ let definition_structure (kind,cum,poly,finite,(is_coe,((loc,idstruc),pl)),ps,cf
implpars params arity template implfs fields is_coe coers priorities sign in
gr
| _ ->
- let implfs = List.map
+ let implfs = List.map
(fun impls -> implpars @ Impargs.lift_implicits
- (succ (List.length params)) impls) implfs in
- let ind = declare_structure finite cum poly (Universes.univ_inf_ind_from_universe_context ctx) idstruc
+ (succ (List.length params)) impls) implfs
+ in
+ let univs =
+ if poly then
+ if cum then
+ Cumulative_ind_entry (Universes.univ_inf_ind_from_universe_context ctx)
+ else
+ Polymorphic_ind_entry ctx
+ else
+ Monomorphic_ind_entry ctx
+ in
+ let ind = declare_structure finite univs idstruc
idbuild implpars params arity template implfs
fields is_coe (List.map (fun coe -> not (Option.is_empty coe)) coers) sign in
IndRef ind
diff --git a/vernac/record.mli b/vernac/record.mli
index c43d833b0b..aa530fd61a 100644
--- a/vernac/record.mli
+++ b/vernac/record.mli
@@ -26,9 +26,7 @@ val declare_projections :
val declare_structure :
Decl_kinds.recursivity_kind ->
- Decl_kinds.cumulative_inductive_flag ->
- Decl_kinds.polymorphic ->
- Univ.universe_info_ind (** universe and subtyping constraints *) ->
+ Entries.inductive_universes ->
Id.t -> Id.t ->
manual_explicitation list -> Context.Rel.t -> (** params *) constr -> (** arity *)
bool (** template arity ? *) ->
diff --git a/vernac/search.ml b/vernac/search.ml
index 0ff78f439d..5e56ada8ad 100644
--- a/vernac/search.ml
+++ b/vernac/search.ml
@@ -85,7 +85,7 @@ let iter_declarations (fn : global_reference -> env -> constr -> unit) =
let mib = Global.lookup_mind mind in
let iter_packet i mip =
let ind = (mind, i) in
- let u = Declareops.inductive_instance mib in
+ let u = Declareops.inductive_polymorphic_instance mib in
let i = (ind, u) in
let typ = Inductiveops.type_of_inductive env i in
let () = fn (IndRef ind) env typ in
--
cgit v1.2.3
From 49e4acab949da9861adcd37b8511a89c221ae129 Mon Sep 17 00:00:00 2001
From: Amin Timany
Date: Thu, 1 Jun 2017 17:05:52 +0200
Subject: Use a smart map_constr
---
checker/term.ml | 44 ++++++++++++--------------------------------
kernel/vars.ml | 44 ++++++++++++--------------------------------
2 files changed, 24 insertions(+), 64 deletions(-)
diff --git a/checker/term.ml b/checker/term.ml
index f604ac4bd3..c0f8e0106c 100644
--- a/checker/term.ml
+++ b/checker/term.ml
@@ -413,38 +413,18 @@ let eq_constr m n = eq_constr m n (* to avoid tracing a recursive fun *)
let map_constr f c = map_constr_with_binders (fun x -> x) (fun _ c -> f c) 0 c
let subst_instance_constr subst c =
- if Univ.Instance.is_empty subst then c
- else
- let f u = Univ.subst_instance_instance subst u in
- let changed = ref false in
- let rec aux t =
- match t with
- | Const (c, u) ->
- if Univ.Instance.is_empty u then t
- else
- let u' = f u in
- if u' == u then t
- else (changed := true; Const (c, u'))
- | Ind (i, u) ->
- if Univ.Instance.is_empty u then t
- else
- let u' = f u in
- if u' == u then t
- else (changed := true; Ind (i, u'))
- | Construct (c, u) ->
- if Univ.Instance.is_empty u then t
- else
- let u' = f u in
- if u' == u then t
- else (changed := true; Construct (c, u'))
- | Sort (Type u) ->
- let u' = Univ.subst_instance_universe subst u in
- if u' == u then t else
- (changed := true; Sort (sort_of_univ u'))
- | _ -> map_constr aux t
- in
- let c' = aux c in
- if !changed then c' else c
+ let f u = Univ.subst_instance_instance subst u in
+ let rec aux t =
+ match t with
+ | Const (c, u) -> Const (c, f u)
+ | Ind (i, u) -> Ind (i, f u)
+ | Construct (c, u) -> Construct (c, f u)
+ | Sort (Type u) ->
+ let u' = Univ.subst_instance_universe subst u in
+ Sort (sort_of_univ u')
+ | _ -> map_constr aux t
+ in
+ aux c
let subst_instance_context s ctx =
if Univ.Instance.is_empty s then ctx
diff --git a/kernel/vars.ml b/kernel/vars.ml
index 629de80f7c..89c17b850e 100644
--- a/kernel/vars.ml
+++ b/kernel/vars.ml
@@ -316,38 +316,18 @@ let subst_univs_level_context s =
Context.Rel.map (subst_univs_level_constr s)
let subst_instance_constr subst c =
- if Univ.Instance.is_empty subst then c
- else
- let f u = Univ.subst_instance_instance subst u in
- let changed = ref false in
- let rec aux t =
- match kind t with
- | Const (c, u) ->
- if Univ.Instance.is_empty u then t
- else
- let u' = f u in
- if u' == u then t
- else (changed := true; mkConstU (c, u'))
- | Ind (i, u) ->
- if Univ.Instance.is_empty u then t
- else
- let u' = f u in
- if u' == u then t
- else (changed := true; mkIndU (i, u'))
- | Construct (c, u) ->
- if Univ.Instance.is_empty u then t
- else
- let u' = f u in
- if u' == u then t
- else (changed := true; mkConstructU (c, u'))
- | Sort (Sorts.Type u) ->
- let u' = Univ.subst_instance_universe subst u in
- if u' == u then t else
- (changed := true; mkSort (Sorts.sort_of_univ u'))
- | _ -> Constr.map aux t
- in
- let c' = aux c in
- if !changed then c' else c
+ let f u = Univ.subst_instance_instance subst u in
+ let rec aux t =
+ match kind t with
+ | Const (c, u) -> mkConstU (c, f u)
+ | Ind (i, u) -> mkIndU (i, f u)
+ | Construct (c, u) -> mkConstructU (c, f u)
+ | Sort (Sorts.Type u) ->
+ let u' = Univ.subst_instance_universe subst u in
+ mkSort (Sorts.sort_of_univ u')
+ | _ -> Constr.map aux t
+ in
+ aux c
(* let substkey = Profile.declare_profile "subst_instance_constr";; *)
(* let subst_instance_constr inst c = Profile.profile2 substkey subst_instance_constr inst c;; *)
--
cgit v1.2.3
From ab0c49baa8d57ed92a79e7d0b0737267042210f8 Mon Sep 17 00:00:00 2001
From: Amin Timany
Date: Thu, 1 Jun 2017 17:46:16 +0200
Subject: Optimization
Only try using cumulativity in conversion/subtyping if the universe
instances are non-empty
---
checker/reduction.ml | 38 +++++++++++++++++++++++++-------------
kernel/reduction.ml | 50 +++++++++++++++++++++++++++++---------------------
2 files changed, 54 insertions(+), 34 deletions(-)
diff --git a/checker/reduction.ml b/checker/reduction.ml
index 5010920bcb..95dc93f5d2 100644
--- a/checker/reduction.ml
+++ b/checker/reduction.ml
@@ -431,23 +431,35 @@ and eqappr univ cv_pb infos (lft1,st1) (lft2,st2) =
| (FInd (ind1,u1), FInd (ind2,u2)) ->
if mind_equiv_infos infos ind1 ind2 then
- let mind = Environ.lookup_mind (fst ind1) (infos_env infos) in
- let () =
- convert_inductives cv_pb (mind, snd ind1) u1 (stack_args_size v1)
- u2 (stack_args_size v2) univ
- in
- convert_stacks univ infos lft1 lft2 v1 v2
+ if Univ.Instance.length u1 = 0 || Univ.Instance.length u2 = 0 then
+ begin
+ convert_universes univ u1 u2;
+ convert_stacks univ infos lft1 lft2 v1 v2
+ end
+ else
+ let mind = Environ.lookup_mind (fst ind1) (infos_env infos) in
+ let () =
+ convert_inductives cv_pb (mind, snd ind1) u1 (stack_args_size v1)
+ u2 (stack_args_size v2) univ
+ in
+ convert_stacks univ infos lft1 lft2 v1 v2
else raise NotConvertible
| (FConstruct ((ind1,j1),u1), FConstruct ((ind2,j2),u2)) ->
if Int.equal j1 j2 && mind_equiv_infos infos ind1 ind2 then
- let mind = Environ.lookup_mind (fst ind1) (infos_env infos) in
- let () =
- convert_constructors
- (mind, snd ind1, j1) u1 (stack_args_size v1)
- u2 (stack_args_size v2) univ
- in
- convert_stacks univ infos lft1 lft2 v1 v2
+ if Univ.Instance.length u1 = 0 || Univ.Instance.length u2 = 0 then
+ begin
+ convert_universes univ u1 u2;
+ convert_stacks univ infos lft1 lft2 v1 v2
+ end
+ else
+ let mind = Environ.lookup_mind (fst ind1) (infos_env infos) in
+ let () =
+ convert_constructors
+ (mind, snd ind1, j1) u1 (stack_args_size v1)
+ u2 (stack_args_size v2) univ
+ in
+ convert_stacks univ infos lft1 lft2 v1 v2
else raise NotConvertible
(* Eta expansion of records *)
diff --git a/kernel/reduction.ml b/kernel/reduction.ml
index 8bf95e5de9..a9e2ce78c7 100644
--- a/kernel/reduction.ml
+++ b/kernel/reduction.ml
@@ -495,31 +495,39 @@ and eqappr env cv_pb l2r infos (lft1,st1) (lft2,st2) cuniv =
(* Inductive types: MutInd MutConstruct Fix Cofix *)
| (FInd (ind1,u1), FInd (ind2,u2)) ->
if eq_ind ind1 ind2 then
- let mind = Environ.lookup_mind (fst ind1) env in
- let cuniv =
- match mind.Declarations.mind_universes with
- | Declarations.Monomorphic_ind _ | Declarations.Polymorphic_ind _ ->
- convert_instances ~flex:false u1 u2 cuniv
- | Declarations.Cumulative_ind cumi ->
- convert_inductives cv_pb (mind, snd ind1) u1 (CClosure.stack_args_size v1)
- u2 (CClosure.stack_args_size v2) cuniv
- in
- convert_stacks env l2r infos lft1 lft2 v1 v2 cuniv
+ if Univ.Instance.length u1 = 0 || Univ.Instance.length u2 = 0 then
+ let cuniv = convert_instances ~flex:false u1 u2 cuniv in
+ convert_stacks env l2r infos lft1 lft2 v1 v2 cuniv
+ else
+ let mind = Environ.lookup_mind (fst ind1) env in
+ let cuniv =
+ match mind.Declarations.mind_universes with
+ | Declarations.Monomorphic_ind _ | Declarations.Polymorphic_ind _ ->
+ convert_instances ~flex:false u1 u2 cuniv
+ | Declarations.Cumulative_ind cumi ->
+ convert_inductives cv_pb (mind, snd ind1) u1 (CClosure.stack_args_size v1)
+ u2 (CClosure.stack_args_size v2) cuniv
+ in
+ convert_stacks env l2r infos lft1 lft2 v1 v2 cuniv
else raise NotConvertible
| (FConstruct ((ind1,j1),u1), FConstruct ((ind2,j2),u2)) ->
if Int.equal j1 j2 && eq_ind ind1 ind2 then
- let mind = Environ.lookup_mind (fst ind1) env in
- let cuniv =
- match mind.Declarations.mind_universes with
- | Declarations.Monomorphic_ind _ | Declarations.Polymorphic_ind _ ->
- convert_instances ~flex:false u1 u2 cuniv
- | Declarations.Cumulative_ind _ ->
- convert_constructors
- (mind, snd ind1, j1) u1 (CClosure.stack_args_size v1)
- u2 (CClosure.stack_args_size v2) cuniv
- in
- convert_stacks env l2r infos lft1 lft2 v1 v2 cuniv
+ if Univ.Instance.length u1 = 0 || Univ.Instance.length u2 = 0 then
+ let cuniv = convert_instances ~flex:false u1 u2 cuniv in
+ convert_stacks env l2r infos lft1 lft2 v1 v2 cuniv
+ else
+ let mind = Environ.lookup_mind (fst ind1) env in
+ let cuniv =
+ match mind.Declarations.mind_universes with
+ | Declarations.Monomorphic_ind _ | Declarations.Polymorphic_ind _ ->
+ convert_instances ~flex:false u1 u2 cuniv
+ | Declarations.Cumulative_ind _ ->
+ convert_constructors
+ (mind, snd ind1, j1) u1 (CClosure.stack_args_size v1)
+ u2 (CClosure.stack_args_size v2) cuniv
+ in
+ convert_stacks env l2r infos lft1 lft2 v1 v2 cuniv
else raise NotConvertible
(* Eta expansion of records *)
--
cgit v1.2.3
From 5fb30d6c06d47a8e6c4200cdd0ba9067be7cfe2f Mon Sep 17 00:00:00 2001
From: Amin Timany
Date: Mon, 12 Jun 2017 17:44:29 +0200
Subject: use map_constr more efficiently
---
checker/term.ml | 42 ++++++++++++++++++++++++++++++------------
kernel/vars.ml | 42 ++++++++++++++++++++++++++++++------------
2 files changed, 60 insertions(+), 24 deletions(-)
diff --git a/checker/term.ml b/checker/term.ml
index c0f8e0106c..dea3d3e659 100644
--- a/checker/term.ml
+++ b/checker/term.ml
@@ -413,18 +413,36 @@ let eq_constr m n = eq_constr m n (* to avoid tracing a recursive fun *)
let map_constr f c = map_constr_with_binders (fun x -> x) (fun _ c -> f c) 0 c
let subst_instance_constr subst c =
- let f u = Univ.subst_instance_instance subst u in
- let rec aux t =
- match t with
- | Const (c, u) -> Const (c, f u)
- | Ind (i, u) -> Ind (i, f u)
- | Construct (c, u) -> Construct (c, f u)
- | Sort (Type u) ->
- let u' = Univ.subst_instance_universe subst u in
- Sort (sort_of_univ u')
- | _ -> map_constr aux t
- in
- aux c
+ if Univ.Instance.is_empty subst then c
+ else
+ let f u = Univ.subst_instance_instance subst u in
+ let rec aux t =
+ match t with
+ | Const (c, u) ->
+ if Univ.Instance.is_empty u then t
+ else
+ let u' = f u in
+ if u' == u then t
+ else (Const (c, u'))
+ | Ind (i, u) ->
+ if Univ.Instance.is_empty u then t
+ else
+ let u' = f u in
+ if u' == u then t
+ else (Ind (i, u'))
+ | Construct (c, u) ->
+ if Univ.Instance.is_empty u then t
+ else
+ let u' = f u in
+ if u' == u then t
+ else (Construct (c, u'))
+ | Sort (Type u) ->
+ let u' = Univ.subst_instance_universe subst u in
+ if u' == u then t else
+ (Sort (sort_of_univ u'))
+ | _ -> map_constr aux t
+ in
+ aux c
let subst_instance_context s ctx =
if Univ.Instance.is_empty s then ctx
diff --git a/kernel/vars.ml b/kernel/vars.ml
index 89c17b850e..baf8fa31f6 100644
--- a/kernel/vars.ml
+++ b/kernel/vars.ml
@@ -316,18 +316,36 @@ let subst_univs_level_context s =
Context.Rel.map (subst_univs_level_constr s)
let subst_instance_constr subst c =
- let f u = Univ.subst_instance_instance subst u in
- let rec aux t =
- match kind t with
- | Const (c, u) -> mkConstU (c, f u)
- | Ind (i, u) -> mkIndU (i, f u)
- | Construct (c, u) -> mkConstructU (c, f u)
- | Sort (Sorts.Type u) ->
- let u' = Univ.subst_instance_universe subst u in
- mkSort (Sorts.sort_of_univ u')
- | _ -> Constr.map aux t
- in
- aux c
+ if Univ.Instance.is_empty subst then c
+ else
+ let f u = Univ.subst_instance_instance subst u in
+ let rec aux t =
+ match kind t with
+ | Const (c, u) ->
+ if Univ.Instance.is_empty u then t
+ else
+ let u' = f u in
+ if u' == u then t
+ else (mkConstU (c, u'))
+ | Ind (i, u) ->
+ if Univ.Instance.is_empty u then t
+ else
+ let u' = f u in
+ if u' == u then t
+ else (mkIndU (i, u'))
+ | Construct (c, u) ->
+ if Univ.Instance.is_empty u then t
+ else
+ let u' = f u in
+ if u' == u then t
+ else (mkConstructU (c, u'))
+ | Sort (Sorts.Type u) ->
+ let u' = Univ.subst_instance_universe subst u in
+ if u' == u then t else
+ (mkSort (Sorts.sort_of_univ u'))
+ | _ -> Constr.map aux t
+ in
+ aux c
(* let substkey = Profile.declare_profile "subst_instance_constr";; *)
(* let subst_instance_constr inst c = Profile.profile2 substkey subst_instance_constr inst c;; *)
--
cgit v1.2.3
From a4969591f391d857a9efd038338e1a80fc68950b Mon Sep 17 00:00:00 2001
From: Amin Timany
Date: Wed, 14 Jun 2017 16:32:47 +0200
Subject: A short cleanup
---
API/API.mli | 5 ++---
checker/cic.mli | 4 ++--
checker/values.ml | 2 +-
dev/base_include | 2 +-
kernel/declarations.ml | 4 ++--
5 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/API/API.mli b/API/API.mli
index ecce22c1de..899bafa1fd 100644
--- a/API/API.mli
+++ b/API/API.mli
@@ -1088,12 +1088,11 @@ sig
| MEapply of module_alg_expr * Names.ModPath.t
| MEwith of module_alg_expr * with_declaration
- type abstrac_inductive_universes = Declarations.abstrac_inductive_universes =
+ type abstract_inductive_universes = Declarations.abstract_inductive_universes =
| Monomorphic_ind of Univ.UContext.t
| Polymorphic_ind of Univ.abstract_universe_context
| Cumulative_ind of Univ.abstract_cumulativity_info
-
type mutual_inductive_body = Declarations.mutual_inductive_body = {
mind_packets : one_inductive_body array;
mind_record : Declarations.record_body option;
@@ -1103,7 +1102,7 @@ sig
mind_nparams : int;
mind_nparams_rec : int;
mind_params_ctxt : Context.Rel.t;
- mind_universes : abstrac_inductive_universes;
+ mind_universes : Declarations.abstract_inductive_universes;
mind_private : bool option;
mind_typing_flags : Declarations.typing_flags;
}
diff --git a/checker/cic.mli b/checker/cic.mli
index bbddb678bc..e298c41cf1 100644
--- a/checker/cic.mli
+++ b/checker/cic.mli
@@ -304,7 +304,7 @@ type one_inductive_body = {
mind_reloc_tbl : reloc_table;
}
-type abstrac_inductive_universes =
+type abstract_inductive_universes =
| Monomorphic_ind of Univ.universe_context
| Polymorphic_ind of Univ.abstract_universe_context
| Cumulative_ind of Univ.abstract_cumulativity_info
@@ -327,7 +327,7 @@ type mutual_inductive_body = {
mind_params_ctxt : rel_context; (** The context of parameters (includes let-in declaration) *)
- mind_universes : abstrac_inductive_universes; (** Local universe variables and constraints together with subtyping constraints *)
+ mind_universes : abstract_inductive_universes; (** Local universe variables and constraints together with subtyping constraints *)
mind_private : bool option; (** allow pattern-matching: Some true ok, Some false blocked *)
diff --git a/checker/values.ml b/checker/values.ml
index 422729ed55..b8b395aaf7 100644
--- a/checker/values.ml
+++ b/checker/values.ml
@@ -13,7 +13,7 @@
To ensure this file is up-to-date, 'make' now compares the md5 of cic.mli
with a copy we maintain here:
-MD5 6950230ca9e99e9cc3a70488d8ab824c checker/cic.mli
+MD5 b132075590daf5e202de0d9cc34e6003 checker/cic.mli
*)
diff --git a/dev/base_include b/dev/base_include
index 98cf67256f..f9af0696b1 100644
--- a/dev/base_include
+++ b/dev/base_include
@@ -196,7 +196,7 @@ let qid = Libnames.qualid_of_string;;
(* parsing of terms *)
let parse_constr = Pcoq.parse_string Pcoq.Constr.constr;;
-(*let parse_tac = Pcoq.parse_string Ltac_plugin.Pltac.tactic;;*)
+let parse_tac = Pcoq.parse_string Ltac_plugin.Pltac.tactic;;
let parse_vernac = Pcoq.parse_string Pcoq.Vernac_.vernac;;
(* build a term of type glob_constr without type-checking or resolution of
diff --git a/kernel/declarations.ml b/kernel/declarations.ml
index f3b7ae2b24..21651b3e21 100644
--- a/kernel/declarations.ml
+++ b/kernel/declarations.ml
@@ -169,7 +169,7 @@ type one_inductive_body = {
mind_reloc_tbl : Cbytecodes.reloc_table;
}
-type abstrac_inductive_universes =
+type abstract_inductive_universes =
| Monomorphic_ind of Univ.universe_context
| Polymorphic_ind of Univ.abstract_universe_context
| Cumulative_ind of Univ.abstract_cumulativity_info
@@ -192,7 +192,7 @@ type mutual_inductive_body = {
mind_params_ctxt : Context.Rel.t; (** The context of parameters (includes let-in declaration) *)
- mind_universes : abstrac_inductive_universes; (** Information about monomorphic/polymorphic/cumulative inductives and their universes *)
+ mind_universes : abstract_inductive_universes; (** Information about monomorphic/polymorphic/cumulative inductives and their universes *)
mind_private : bool option; (** allow pattern-matching: Some true ok, Some false blocked *)
--
cgit v1.2.3
From 15b1856edd593b39d63d23584a4f5acec0eeb592 Mon Sep 17 00:00:00 2001
From: Amin Timany
Date: Thu, 15 Jun 2017 16:50:05 +0200
Subject: Fix a bug in cumulativity
---
dev/base_include | 2 --
dev/include | 3 ++-
dev/top_printers.ml | 1 -
dev/vm_printers.ml | 1 -
kernel/reduction.ml | 20 +++++++++++---------
pretyping/evarconv.ml | 9 +++++----
pretyping/reductionops.mli | 1 -
test-suite/success/cumulativity.v | 6 +++++-
8 files changed, 23 insertions(+), 20 deletions(-)
diff --git a/dev/base_include b/dev/base_include
index f9af0696b1..8ee1cceb23 100644
--- a/dev/base_include
+++ b/dev/base_include
@@ -58,8 +58,6 @@
(* Open main files *)
-open API
-open Grammar_API
open Names
open Term
open Vars
diff --git a/dev/include b/dev/include
index 1d87456de7..31ae5da71a 100644
--- a/dev/include
+++ b/dev/include
@@ -41,7 +41,8 @@
#install_printer (* univ context *) ppuniverse_context;;
#install_printer (* univ context future *) ppuniverse_context_future;;
#install_printer (* univ context set *) ppuniverse_context_set;;
-#install_printer (* univ info *) ppcumulativity_info;;
+#install_printer (* cumulativity info *) ppcumulativity_info;;
+#install_printer (* abstract cumulativity info *) ppabstract_cumulativity_info;;
#install_printer (* univ set *) ppuniverse_set;;
#install_printer (* univ instance *) ppuniverse_instance;;
#install_printer (* univ subst *) ppuniverse_subst;;
diff --git a/dev/top_printers.ml b/dev/top_printers.ml
index abf6db1b7f..ff575e432c 100644
--- a/dev/top_printers.ml
+++ b/dev/top_printers.ml
@@ -8,7 +8,6 @@
(* Printers for the ocaml toplevel. *)
-open API
open Util
open Pp
open Names
diff --git a/dev/vm_printers.ml b/dev/vm_printers.ml
index be6b914b6b..afa94a63e0 100644
--- a/dev/vm_printers.ml
+++ b/dev/vm_printers.ml
@@ -1,4 +1,3 @@
-open API
open Format
open Term
open Names
diff --git a/kernel/reduction.ml b/kernel/reduction.ml
index a9e2ce78c7..605e9f314c 100644
--- a/kernel/reduction.ml
+++ b/kernel/reduction.ml
@@ -679,12 +679,13 @@ let infer_check_conv_constructors
infer_check_inductive_instances CONV cumi u1 u2 univs
let check_inductive_instances cv_pb cumi u u' univs =
- let ind_instance =
- Univ.AUContext.instance (Univ.ACumulativityInfo.univ_context cumi)
+ let length_ind_instance =
+ Univ.Instance.length
+ (Univ.AUContext.instance (Univ.ACumulativityInfo.univ_context cumi))
in
let ind_subtypctx = Univ.ACumulativityInfo.subtyp_context cumi in
- if not ((Univ.Instance.length ind_instance = Univ.Instance.length u) &&
- (Univ.Instance.length ind_instance = Univ.Instance.length u')) then
+ if not ((length_ind_instance = Univ.Instance.length u) &&
+ (length_ind_instance = Univ.Instance.length u')) then
anomaly (Pp.str "Invalid inductive subtyping encountered!")
else
let comp_cst =
@@ -765,13 +766,14 @@ let infer_convert_instances ~flex u u' (univs,cstrs) =
in (univs, cstrs')
let infer_inductive_instances cv_pb cumi u u' (univs, cstrs) =
- let ind_instance =
- Univ.AUContext.instance (Univ.ACumulativityInfo.subtyp_context cumi)
+ let length_ind_instance =
+ Univ.Instance.length
+ (Univ.AUContext.instance (Univ.ACumulativityInfo.univ_context cumi))
in
let ind_subtypctx = Univ.ACumulativityInfo.subtyp_context cumi in
- if not ((Univ.Instance.length ind_instance = Univ.Instance.length u) &&
- (Univ.Instance.length ind_instance = Univ.Instance.length u')) then
- anomaly (Pp.str "Invalid inductive subtyping encountered!")
+ if not ((length_ind_instance = Univ.Instance.length u) &&
+ (length_ind_instance = Univ.Instance.length u')) then
+ anomaly (Pp.str "Invalid inductive subtyping encountered!")
else
let comp_cst =
let comp_subst = (Univ.Instance.append u u') in
diff --git a/pretyping/evarconv.ml b/pretyping/evarconv.ml
index b15dde5d79..d84363089d 100644
--- a/pretyping/evarconv.ml
+++ b/pretyping/evarconv.ml
@@ -353,12 +353,13 @@ let exact_ise_stack2 env evd f sk1 sk2 =
let check_leq_inductives evd cumi u u' =
let u = EConstr.EInstance.kind evd u in
let u' = EConstr.EInstance.kind evd u' in
- let ind_instance =
- Univ.AUContext.instance (Univ.ACumulativityInfo.univ_context cumi)
+ let length_ind_instance =
+ Univ.Instance.length
+ (Univ.AUContext.instance (Univ.ACumulativityInfo.univ_context cumi))
in
let ind_sbcst = Univ.ACumulativityInfo.subtyp_context cumi in
- if not ((Univ.Instance.length ind_instance = Univ.Instance.length u) &&
- (Univ.Instance.length ind_instance = Univ.Instance.length u')) then
+ if not ((length_ind_instance = Univ.Instance.length u) &&
+ (length_ind_instance = Univ.Instance.length u')) then
anomaly (Pp.str "Invalid inductive subtyping encountered!")
else
begin
diff --git a/pretyping/reductionops.mli b/pretyping/reductionops.mli
index af4ea3ac53..a4da19de75 100644
--- a/pretyping/reductionops.mli
+++ b/pretyping/reductionops.mli
@@ -66,7 +66,6 @@ module Cst_stack : sig
val pr : t -> Pp.std_ppcmds
end
-
module Stack : sig
type 'a app_node
diff --git a/test-suite/success/cumulativity.v b/test-suite/success/cumulativity.v
index ecf9035bfe..ebf817cfc5 100644
--- a/test-suite/success/cumulativity.v
+++ b/test-suite/success/cumulativity.v
@@ -58,4 +58,8 @@ Section subtyping_test.
Inductive TP2 := tp2 : Type@{i} -> Type@{j} -> TP2.
-End subtyping_test.
\ No newline at end of file
+End subtyping_test.
+
+Record A : Type := { a :> Type; }.
+
+Record B (X : A) : Type := { b : X; }.
\ No newline at end of file
--
cgit v1.2.3
From 4f6fd16c06b9e11bc2619a34c1629bd71aba76de Mon Sep 17 00:00:00 2001
From: Pierre-Marie Pédrot
Date: Thu, 15 Jun 2017 16:38:15 +0200
Subject: Remove the last use of the low-level Proof_type API in ssr.
---
plugins/ssr/ssrcommon.ml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plugins/ssr/ssrcommon.ml b/plugins/ssr/ssrcommon.ml
index 490ded9d4d..ded9fa66be 100644
--- a/plugins/ssr/ssrcommon.ml
+++ b/plugins/ssr/ssrcommon.ml
@@ -960,7 +960,7 @@ let applyn ~with_evars ?beta ?(with_shelve=false) n t gl =
| _ -> assert false
in loop sigma t [] n in
pp(lazy(str"Refiner.refiner " ++ Printer.pr_econstr t));
- Refiner.refiner (Proof_type.Refine (EConstr.Unsafe.to_constr t)) gl
+ Tacmach.refine_no_check (EConstr.Unsafe.to_constr t) gl
let refine_with ?(first_goes_last=false) ?beta ?(with_evars=true) oc gl =
let rec mkRels = function 1 -> [] | n -> mkRel n :: mkRels (n-1) in
--
cgit v1.2.3
From 0437339ccac602d692b5b8c071b77ac756805520 Mon Sep 17 00:00:00 2001
From: Pierre-Marie Pédrot
Date: Thu, 15 Jun 2017 16:41:09 +0200
Subject: Removing Proof_type from the API.
Unluckily, this forces replacing a lot of code in plugins, because the API
defined the type of goals and tactics in Proof_type, and by the no-alias rule,
this was the only one. But Proof_type was already implicitly deprecated, so
that the API should have relied on Tacmach instead.
---
API/API.ml | 13 ---
API/API.mli | 101 ++++++++++------------
plugins/cc/ccalgo.ml | 2 +-
plugins/cc/ccalgo.mli | 2 +-
plugins/funind/functional_principles_proofs.ml | 3 +-
plugins/funind/functional_principles_proofs.mli | 4 +-
plugins/funind/functional_principles_types.mli | 2 +-
plugins/funind/indfun.ml | 4 +-
plugins/funind/indfun.mli | 2 +-
plugins/funind/indfun_common.mli | 4 +-
plugins/funind/invfun.ml | 10 +--
plugins/funind/recdef.ml | 2 +-
plugins/funind/recdef.mli | 4 +-
plugins/rtauto/refl_tauto.mli | 6 +-
plugins/ssr/ssrast.mli | 4 +-
plugins/ssr/ssrbwd.mli | 4 +-
plugins/ssr/ssrcommon.ml | 2 +-
plugins/ssr/ssrcommon.mli | 106 ++++++++++++------------
plugins/ssr/ssrelim.mli | 16 ++--
plugins/ssr/ssrequality.mli | 12 +--
plugins/ssr/ssrfwd.mli | 6 +-
plugins/ssr/ssripats.ml | 6 +-
plugins/ssr/ssripats.mli | 16 ++--
plugins/ssr/ssrprinters.mli | 2 +-
plugins/ssr/ssrtacticals.mli | 6 +-
plugins/ssr/ssrview.ml | 2 +-
plugins/ssrmatching/ssrmatching.mli | 2 +-
27 files changed, 158 insertions(+), 185 deletions(-)
diff --git a/API/API.ml b/API/API.ml
index 2b7bbd561b..60703e1fa8 100644
--- a/API/API.ml
+++ b/API/API.ml
@@ -200,16 +200,3 @@ module Entries =
| ParameterEntry of parameter_entry
| ProjectionEntry of projection_entry
end
-
-(* NOTE: It does not make sense to replace the following "module expression"
- simply with "module Proof_type = Proof_type" because
- there is only "proofs/proof_type.mli";
- there is no "proofs/proof_type.ml" file *)
-module Proof_type =
- struct
- type goal = Goal.goal
- type tactic = goal Evd.sigma -> goal list Evd.sigma
- type rule = Proof_type.prim_rule =
- | Cut of bool * bool * Names.Id.t * Term.types
- | Refine of Term.constr
- end
diff --git a/API/API.mli b/API/API.mli
index 69278e7c9f..9ed952dc2f 100644
--- a/API/API.mli
+++ b/API/API.mli
@@ -3310,17 +3310,6 @@ sig
val module_is_known : string -> bool
end
-(* All items in the Proof_type module are deprecated. *)
-module Proof_type :
-sig
- type goal = Evar.t
- type rule = Proof_type.prim_rule =
- | Cut of bool * bool * Names.Id.t * Term.types
- | Refine of Term.constr
-
- type tactic = goal Evd.sigma -> goal list Evd.sigma
-end
-
module Redexpr :
sig
type red_expr =
@@ -3332,61 +3321,61 @@ end
module Tacmach :
sig
- type tactic = Proof_type.tactic
- [@@ocaml.deprecated "alias for API.Proof_type.tactic"]
+ type tactic = Goal.goal Evd.sigma -> Goal.goal list Evd.sigma
type 'a sigma = 'a Evd.sigma
[@@ocaml.deprecated "alias of API.Evd.sigma"]
val re_sig : 'a -> Evd.evar_map -> 'a Evd.sigma
- val pf_reduction_of_red_expr : Proof_type.goal Evd.sigma -> Redexpr.red_expr -> EConstr.constr -> Evd.evar_map * EConstr.constr
+ val pf_reduction_of_red_expr : Goal.goal Evd.sigma -> Redexpr.red_expr -> EConstr.constr -> Evd.evar_map * EConstr.constr
- val pf_unsafe_type_of : Proof_type.goal Evd.sigma -> EConstr.constr -> EConstr.types
+ val pf_unsafe_type_of : Goal.goal Evd.sigma -> EConstr.constr -> EConstr.types
- val pf_get_new_id : Names.Id.t -> Proof_type.goal Evd.sigma -> Names.Id.t
+ val pf_get_new_id : Names.Id.t -> Goal.goal Evd.sigma -> Names.Id.t
- val pf_env : Proof_type.goal Evd.sigma -> Environ.env
+ val pf_env : Goal.goal Evd.sigma -> Environ.env
- val pf_concl : Proof_type.goal Evd.sigma -> EConstr.types
+ val pf_concl : Goal.goal Evd.sigma -> EConstr.types
- val pf_apply : (Environ.env -> Evd.evar_map -> 'a) -> Proof_type.goal Evd.sigma -> 'a
+ val pf_apply : (Environ.env -> Evd.evar_map -> 'a) -> Goal.goal Evd.sigma -> 'a
- val pf_get_hyp : Proof_type.goal Evd.sigma -> Names.Id.t -> EConstr.named_declaration
- val pf_get_hyp_typ : Proof_type.goal Evd.sigma -> Names.Id.t -> EConstr.types
- val project : Proof_type.goal Evd.sigma -> Evd.evar_map
- val refine : EConstr.constr -> Proof_type.tactic
- val pf_type_of : Proof_type.goal Evd.sigma -> EConstr.constr -> Evd.evar_map * EConstr.types
+ val pf_get_hyp : Goal.goal Evd.sigma -> Names.Id.t -> EConstr.named_declaration
+ val pf_get_hyp_typ : Goal.goal Evd.sigma -> Names.Id.t -> EConstr.types
+ val project : Goal.goal Evd.sigma -> Evd.evar_map
+ val refine : EConstr.constr -> tactic
+ val refine_no_check : EConstr.constr -> tactic
+ val pf_type_of : Goal.goal Evd.sigma -> EConstr.constr -> Evd.evar_map * EConstr.types
- val pf_hyps : Proof_type.goal Evd.sigma -> EConstr.named_context
+ val pf_hyps : Goal.goal Evd.sigma -> EConstr.named_context
- val pf_ids_of_hyps : Proof_type.goal Evd.sigma -> Names.Id.t list
+ val pf_ids_of_hyps : Goal.goal Evd.sigma -> Names.Id.t list
- val pf_reduce_to_atomic_ind : Proof_type.goal Evd.sigma -> EConstr.types -> (Names.inductive * EConstr.EInstance.t) * EConstr.types
+ val pf_reduce_to_atomic_ind : Goal.goal Evd.sigma -> EConstr.types -> (Names.inductive * EConstr.EInstance.t) * EConstr.types
- val pf_reduce_to_quantified_ind : Proof_type.goal Evd.sigma -> EConstr.types -> (Names.inductive * EConstr.EInstance.t) * EConstr.types
+ val pf_reduce_to_quantified_ind : Goal.goal Evd.sigma -> EConstr.types -> (Names.inductive * EConstr.EInstance.t) * EConstr.types
val pf_eapply : (Environ.env -> Evd.evar_map -> 'a -> Evd.evar_map * 'b) ->
Evar.t Evd.sigma -> 'a -> Evar.t Evd.sigma * 'b
val pf_unfoldn : (Locus.occurrences * Names.evaluable_global_reference) list
- -> Proof_type.goal Evd.sigma -> EConstr.constr -> EConstr.constr
+ -> Goal.goal Evd.sigma -> EConstr.constr -> EConstr.constr
- val pf_reduce : (Environ.env -> Evd.evar_map -> EConstr.constr -> EConstr.constr) -> Proof_type.goal Evd.sigma -> EConstr.constr -> EConstr.constr
+ val pf_reduce : (Environ.env -> Evd.evar_map -> EConstr.constr -> EConstr.constr) -> Goal.goal Evd.sigma -> EConstr.constr -> EConstr.constr
- val pf_conv_x : Proof_type.goal Evd.sigma -> EConstr.constr -> EConstr.constr -> bool
+ val pf_conv_x : Goal.goal Evd.sigma -> EConstr.constr -> EConstr.constr -> bool
- val pf_is_matching : Proof_type.goal Evd.sigma -> Pattern.constr_pattern -> EConstr.constr -> bool
+ val pf_is_matching : Goal.goal Evd.sigma -> Pattern.constr_pattern -> EConstr.constr -> bool
- val pf_hyps_types : Proof_type.goal Evd.sigma -> (Names.Id.t * EConstr.types) list
+ val pf_hyps_types : Goal.goal Evd.sigma -> (Names.Id.t * EConstr.types) list
- val pr_gls : Proof_type.goal Evd.sigma -> Pp.std_ppcmds
+ val pr_gls : Goal.goal Evd.sigma -> Pp.std_ppcmds
- val pf_nf_betaiota : Proof_type.goal Evd.sigma -> EConstr.constr -> EConstr.constr
+ val pf_nf_betaiota : Goal.goal Evd.sigma -> EConstr.constr -> EConstr.constr
- val pf_last_hyp : Proof_type.goal Evd.sigma -> EConstr.named_declaration
+ val pf_last_hyp : Goal.goal Evd.sigma -> EConstr.named_declaration
- val pf_nth_hyp_id : Proof_type.goal Evd.sigma -> int -> Names.Id.t
+ val pf_nth_hyp_id : Goal.goal Evd.sigma -> int -> Names.Id.t
val sig_it : 'a Evd.sigma -> 'a
@@ -3395,7 +3384,7 @@ sig
val pf_apply : (Environ.env -> Evd.evar_map -> 'a) -> 'b Proofview.Goal.t -> 'a
val project : 'a Proofview.Goal.t -> Evd.evar_map
val pf_unsafe_type_of : 'a Proofview.Goal.t -> EConstr.constr -> EConstr.types
- val of_old : (Proof_type.goal Evd.sigma -> 'a) -> [ `NF ] Proofview.Goal.t -> 'a
+ val of_old : (Goal.goal Evd.sigma -> 'a) -> [ `NF ] Proofview.Goal.t -> 'a
val pf_env : 'a Proofview.Goal.t -> Environ.env
val pf_ids_of_hyps : 'a Proofview.Goal.t -> Names.Id.t list
@@ -3516,21 +3505,19 @@ sig
val repackage : Evd.evar_map ref -> 'a -> 'a Evd.sigma
- val refiner : Proof_type.rule -> Proof_type.tactic
-
- val tclSHOWHYPS : Proof_type.tactic -> Proof_type.tactic
+ val tclSHOWHYPS : Tacmach.tactic -> Tacmach.tactic
exception FailError of int * Pp.std_ppcmds Lazy.t
- val tclEVARS : Evd.evar_map -> Proof_type.tactic
- val tclMAP : ('a -> Proof_type.tactic) -> 'a list -> Proof_type.tactic
- val tclREPEAT : Proof_type.tactic -> Proof_type.tactic
- val tclORELSE : Proof_type.tactic -> Proof_type.tactic -> Proof_type.tactic
- val tclFAIL : int -> Pp.std_ppcmds -> Proof_type.tactic
- val tclIDTAC : Proof_type.tactic
- val tclTHEN : Proof_type.tactic -> Proof_type.tactic -> Proof_type.tactic
- val tclTHENLIST : Proof_type.tactic list -> Proof_type.tactic
- val tclTRY : Proof_type.tactic -> Proof_type.tactic
- val tclAT_LEAST_ONCE : Proof_type.tactic -> Proof_type.tactic
+ val tclEVARS : Evd.evar_map -> Tacmach.tactic
+ val tclMAP : ('a -> Tacmach.tactic) -> 'a list -> Tacmach.tactic
+ val tclREPEAT : Tacmach.tactic -> Tacmach.tactic
+ val tclORELSE : Tacmach.tactic -> Tacmach.tactic -> Tacmach.tactic
+ val tclFAIL : int -> Pp.std_ppcmds -> Tacmach.tactic
+ val tclIDTAC : Tacmach.tactic
+ val tclTHEN : Tacmach.tactic -> Tacmach.tactic -> Tacmach.tactic
+ val tclTHENLIST : Tacmach.tactic list -> Tacmach.tactic
+ val tclTRY : Tacmach.tactic -> Tacmach.tactic
+ val tclAT_LEAST_ONCE : Tacmach.tactic -> Tacmach.tactic
end
module Termops :
@@ -3668,7 +3655,7 @@ module Printer :
sig
val pr_named_context : Environ.env -> Evd.evar_map -> Context.Named.t -> Pp.std_ppcmds
val pr_rel_context : Environ.env -> Evd.evar_map -> Context.Rel.t -> Pp.std_ppcmds
- val pr_goal : Proof_type.goal Evd.sigma -> Pp.std_ppcmds
+ val pr_goal : Goal.goal Evd.sigma -> Pp.std_ppcmds
val pr_constr_env : Prelude.env -> Prelude.evar_map -> Term.constr -> Pp.std_ppcmds
val pr_lconstr_env : Prelude.env -> Prelude.evar_map -> Term.constr -> Pp.std_ppcmds
@@ -4124,7 +4111,7 @@ end
module Tacticals :
sig
- open Proof_type
+ open Tacmach
val tclORELSE : tactic -> tactic -> tactic
val tclDO : int -> tactic -> tactic
val tclIDTAC : tactic
@@ -4132,7 +4119,7 @@ sig
val tclTHEN : tactic -> tactic -> tactic
val tclTHENLIST : tactic list -> tactic
val pf_constr_of_global :
- Globnames.global_reference -> (EConstr.constr -> Proof_type.tactic) -> Proof_type.tactic
+ Globnames.global_reference -> (EConstr.constr -> Tacmach.tactic) -> Tacmach.tactic
val tclMAP : ('a -> tactic) -> 'a list -> tactic
val tclTRY : tactic -> tactic
val tclCOMPLETE : tactic -> tactic
@@ -4153,13 +4140,13 @@ sig
val tclTHENSEQ : tactic list -> tactic
[@@ocaml.deprecated "alias of API.Tacticals.tclTHENLIST"]
- val nLastDecls : int -> Proof_type.goal Evd.sigma -> EConstr.named_context
+ val nLastDecls : int -> Goal.goal Evd.sigma -> EConstr.named_context
val tclTHEN_i : tactic -> (int -> tactic) -> tactic
val tclPROGRESS : tactic -> tactic
- val elimination_sort_of_goal : Proof_type.goal Evd.sigma -> Sorts.family
+ val elimination_sort_of_goal : Goal.goal Evd.sigma -> Sorts.family
module New :
sig
@@ -4539,7 +4526,7 @@ sig
val autounfold_tac : Hints.hint_db_name list option -> Locus.clause -> unit Proofview.tactic
val autounfold_one : Hints.hint_db_name list -> Locus.hyp_location option -> unit Proofview.tactic
val eauto_with_bases :
- ?debug:Hints.debug -> bool * int -> Tactypes.delayed_open_constr list -> Hints.hint_db list -> Proof_type.tactic
+ ?debug:Hints.debug -> bool * int -> Tactypes.delayed_open_constr list -> Hints.hint_db list -> Tacmach.tactic
end
module Class_tactics :
diff --git a/plugins/cc/ccalgo.ml b/plugins/cc/ccalgo.ml
index 5c7cad7ff5..39fb8feeb8 100644
--- a/plugins/cc/ccalgo.ml
+++ b/plugins/cc/ccalgo.ml
@@ -270,7 +270,7 @@ type state =
mutable rew_depth:int;
mutable changed:bool;
by_type: Int.Set.t Typehash.t;
- mutable gls:Proof_type.goal Evd.sigma}
+ mutable gls:Goal.goal Evd.sigma}
let dummy_node =
{
diff --git a/plugins/cc/ccalgo.mli b/plugins/cc/ccalgo.mli
index 505029992a..51e2301fe6 100644
--- a/plugins/cc/ccalgo.mli
+++ b/plugins/cc/ccalgo.mli
@@ -129,7 +129,7 @@ val axioms : forest -> (term * term) Constrhash.t
val epsilons : forest -> pa_constructor list
-val empty : int -> Proof_type.goal Evd.sigma -> state
+val empty : int -> Goal.goal Evd.sigma -> state
val add_term : state -> term -> int
diff --git a/plugins/funind/functional_principles_proofs.ml b/plugins/funind/functional_principles_proofs.ml
index ef894b2395..ba46f78aa8 100644
--- a/plugins/funind/functional_principles_proofs.ml
+++ b/plugins/funind/functional_principles_proofs.ml
@@ -10,7 +10,6 @@ open Names
open Pp
open Tacmach
open Termops
-open Proof_type
open Tacticals
open Tactics
open Indfun_common
@@ -106,7 +105,7 @@ let make_refl_eq constructor type_of_t t =
type pte_info =
{
- proving_tac : (Id.t list -> Proof_type.tactic);
+ proving_tac : (Id.t list -> Tacmach.tactic);
is_valid : constr -> bool
}
diff --git a/plugins/funind/functional_principles_proofs.mli b/plugins/funind/functional_principles_proofs.mli
index 5bb288678d..d03fc475e0 100644
--- a/plugins/funind/functional_principles_proofs.mli
+++ b/plugins/funind/functional_principles_proofs.mli
@@ -4,7 +4,7 @@ open Names
val prove_princ_for_struct :
Evd.evar_map ref ->
bool ->
- int -> Constant.t array -> EConstr.constr array -> int -> Proof_type.tactic
+ int -> Constant.t array -> EConstr.constr array -> int -> Tacmach.tactic
val prove_principle_for_gen :
@@ -14,7 +14,7 @@ val prove_principle_for_gen :
int -> (* the number of recursive argument *)
EConstr.types -> (* the type of the recursive argument *)
EConstr.constr -> (* the wf relation used to prove the function *)
- Proof_type.tactic
+ Tacmach.tactic
(* val is_pte : rel_declaration -> bool *)
diff --git a/plugins/funind/functional_principles_types.mli b/plugins/funind/functional_principles_types.mli
index bb2b2d9186..e70ef23656 100644
--- a/plugins/funind/functional_principles_types.mli
+++ b/plugins/funind/functional_principles_types.mli
@@ -28,7 +28,7 @@ val generate_functional_principle :
(* The tactic to use to make the proof w.r
the number of params
*)
- (EConstr.constr array -> int -> Proof_type.tactic) ->
+ (EConstr.constr array -> int -> Tacmach.tactic) ->
unit
val compute_new_princ_type_from_rel : constr array -> Sorts.t array ->
diff --git a/plugins/funind/indfun.ml b/plugins/funind/indfun.ml
index d12aa7f425..ad04e430cd 100644
--- a/plugins/funind/indfun.ml
+++ b/plugins/funind/indfun.ml
@@ -343,7 +343,7 @@ let error_error names e =
let generate_principle (evd:Evd.evar_map ref) pconstants on_error
is_general do_built (fix_rec_l:(Vernacexpr.fixpoint_expr * Vernacexpr.decl_notation list) list) recdefs interactive_proof
(continue_proof : int -> Names.Constant.t array -> EConstr.constr array -> int ->
- Proof_type.tactic) : unit =
+ Tacmach.tactic) : unit =
let names = List.map (function (((_, name),_),_,_,_,_),_ -> name) fix_rec_l in
let fun_bodies = List.map2 prepare_body fix_rec_l recdefs in
let funs_args = List.map fst fun_bodies in
@@ -446,7 +446,7 @@ let register_struct is_rec (fixpoint_exprl:(Vernacexpr.fixpoint_expr * Vernacexp
let generate_correction_proof_wf f_ref tcc_lemma_ref
is_mes functional_ref eq_ref rec_arg_num rec_arg_type nb_args relation
- (_: int) (_:Names.Constant.t array) (_:EConstr.constr array) (_:int) : Proof_type.tactic =
+ (_: int) (_:Names.Constant.t array) (_:EConstr.constr array) (_:int) : Tacmach.tactic =
Functional_principles_proofs.prove_principle_for_gen
(f_ref,functional_ref,eq_ref)
tcc_lemma_ref is_mes rec_arg_num rec_arg_type relation
diff --git a/plugins/funind/indfun.mli b/plugins/funind/indfun.mli
index 33420d8132..fc7da6a338 100644
--- a/plugins/funind/indfun.mli
+++ b/plugins/funind/indfun.mli
@@ -16,7 +16,7 @@ val functional_induction :
EConstr.constr ->
(EConstr.constr * EConstr.constr bindings) option ->
Tacexpr.or_and_intro_pattern option ->
- Proof_type.goal Evd.sigma -> Proof_type.goal list Evd.sigma
+ Goal.goal Evd.sigma -> Goal.goal list Evd.sigma
val make_graph : Globnames.global_reference -> unit
diff --git a/plugins/funind/indfun_common.mli b/plugins/funind/indfun_common.mli
index 6b40c91713..f7a9cedd73 100644
--- a/plugins/funind/indfun_common.mli
+++ b/plugins/funind/indfun_common.mli
@@ -105,7 +105,7 @@ exception ToShow of exn
val is_strict_tcc : unit -> bool
-val h_intros: Names.Id.t list -> Proof_type.tactic
+val h_intros: Names.Id.t list -> Tacmach.tactic
val h_id : Names.Id.t
val hrec_id : Names.Id.t
val acc_inv_id : EConstr.constr Util.delayed
@@ -114,7 +114,7 @@ val well_founded_ltof : EConstr.constr Util.delayed
val acc_rel : EConstr.constr Util.delayed
val well_founded : EConstr.constr Util.delayed
val evaluable_of_global_reference : Globnames.global_reference -> Names.evaluable_global_reference
-val list_rewrite : bool -> (EConstr.constr*bool) list -> Proof_type.tactic
+val list_rewrite : bool -> (EConstr.constr*bool) list -> Tacmach.tactic
val decompose_lam_n : Evd.evar_map -> int -> EConstr.t ->
(Names.Name.t * EConstr.t) list * EConstr.t
diff --git a/plugins/funind/invfun.ml b/plugins/funind/invfun.ml
index ebdb490e37..94ef2590c8 100644
--- a/plugins/funind/invfun.ml
+++ b/plugins/funind/invfun.ml
@@ -218,7 +218,7 @@ let rec generate_fresh_id x avoid i =
\end{enumerate}
*)
-let prove_fun_correct evd functional_induction funs_constr graphs_constr schemes lemmas_types_infos i : Proof_type.tactic =
+let prove_fun_correct evd functional_induction funs_constr graphs_constr schemes lemmas_types_infos i : Tacmach.tactic =
fun g ->
(* first of all we recreate the lemmas types to be used as predicates of the induction principle
that is~:
@@ -468,7 +468,7 @@ let tauto =
let rec intros_with_rewrite g =
observe_tac "intros_with_rewrite" intros_with_rewrite_aux g
-and intros_with_rewrite_aux : Proof_type.tactic =
+and intros_with_rewrite_aux : Tacmach.tactic =
fun g ->
let eq_ind = make_eq () in
let sigma = project g in
@@ -629,7 +629,7 @@ let rec reflexivity_with_destruct_cases g =
*)
-let prove_fun_complete funcs graphs schemes lemmas_types_infos i : Proof_type.tactic =
+let prove_fun_complete funcs graphs schemes lemmas_types_infos i : Tacmach.tactic =
fun g ->
(* We compute the types of the different mutually recursive lemmas
in $\zeta$ normal form
@@ -673,7 +673,7 @@ let prove_fun_complete funcs graphs schemes lemmas_types_infos i : Proof_type.ta
using [f_equation] if it is recursive (that is the graph is infinite
or unfold if the graph is finite
*)
- let rewrite_tac j ids : Proof_type.tactic =
+ let rewrite_tac j ids : Tacmach.tactic =
let graph_def = graphs.(j) in
let infos =
try find_Function_infos (fst (destConst (project g) funcs.(j)))
@@ -953,7 +953,7 @@ let revert_graph kn post_tac hid g =
\end{enumerate}
*)
-let functional_inversion kn hid fconst f_correct : Proof_type.tactic =
+let functional_inversion kn hid fconst f_correct : Tacmach.tactic =
fun g ->
let old_ids = List.fold_right Id.Set.add (pf_ids_of_hyps g) Id.Set.empty in
let sigma = project g in
diff --git a/plugins/funind/recdef.ml b/plugins/funind/recdef.ml
index 3cd20a9507..8e12b239e8 100644
--- a/plugins/funind/recdef.ml
+++ b/plugins/funind/recdef.ml
@@ -30,7 +30,7 @@ open Nametab
open Declare
open Decl_kinds
open Tacred
-open Proof_type
+open Goal
open Pfedit
open Glob_term
open Pretyping
diff --git a/plugins/funind/recdef.mli b/plugins/funind/recdef.mli
index e1a072799e..f3d5e73320 100644
--- a/plugins/funind/recdef.mli
+++ b/plugins/funind/recdef.mli
@@ -2,10 +2,10 @@ open API
(* val evaluable_of_global_reference : Libnames.global_reference -> Names.evaluable_global_reference *)
val tclUSER_if_not_mes :
- Proof_type.tactic ->
+ Tacmach.tactic ->
bool ->
Names.Id.t list option ->
- Proof_type.tactic
+ Tacmach.tactic
val recursive_definition :
bool ->
Names.Id.t ->
diff --git a/plugins/rtauto/refl_tauto.mli b/plugins/rtauto/refl_tauto.mli
index ac260e51ac..801fc46067 100644
--- a/plugins/rtauto/refl_tauto.mli
+++ b/plugins/rtauto/refl_tauto.mli
@@ -14,13 +14,13 @@ type atom_env=
mutable env:(Term.constr*int) list}
val make_form : atom_env ->
- Proof_type.goal Evd.sigma -> EConstr.types -> Proof_search.form
+ Goal.goal Evd.sigma -> EConstr.types -> Proof_search.form
val make_hyps :
atom_env ->
- Proof_type.goal Evd.sigma ->
+ Goal.goal Evd.sigma ->
EConstr.types list ->
EConstr.named_context ->
(Names.Id.t * Proof_search.form) list
-val rtauto_tac : Proof_type.tactic
+val rtauto_tac : Tacmach.tactic
diff --git a/plugins/ssr/ssrast.mli b/plugins/ssr/ssrast.mli
index 0f4b86d10d..94eaa1d6aa 100644
--- a/plugins/ssr/ssrast.mli
+++ b/plugins/ssr/ssrast.mli
@@ -145,6 +145,6 @@ type 'a ssrseqarg = ssrindex * ('a ssrhint * 'a option)
(* OOP : these are general shortcuts *)
type gist = Tacintern.glob_sign
type ist = Tacinterp.interp_sign
-type goal = Proof_type.goal
+type goal = Goal.goal
type 'a sigma = 'a Evd.sigma
-type v82tac = Proof_type.tactic
+type v82tac = Tacmach.tactic
diff --git a/plugins/ssr/ssrbwd.mli b/plugins/ssr/ssrbwd.mli
index b0e98bdb47..20a1263d24 100644
--- a/plugins/ssr/ssrbwd.mli
+++ b/plugins/ssr/ssrbwd.mli
@@ -10,7 +10,7 @@
open API
-val apply_top_tac : Proof_type.goal Evd.sigma -> Proof_type.goal list Evd.sigma
+val apply_top_tac : Goal.goal Evd.sigma -> Goal.goal list Evd.sigma
val inner_ssrapplytac :
Ssrast.ssrterm list ->
@@ -19,4 +19,4 @@ val inner_ssrapplytac :
list list ->
Ssrast.ssrhyps ->
Ssrast.ist ->
- Proof_type.goal Evd.sigma -> Proof_type.goal list Evd.sigma
+ Goal.goal Evd.sigma -> Goal.goal list Evd.sigma
diff --git a/plugins/ssr/ssrcommon.ml b/plugins/ssr/ssrcommon.ml
index ded9fa66be..411ce6853c 100644
--- a/plugins/ssr/ssrcommon.ml
+++ b/plugins/ssr/ssrcommon.ml
@@ -960,7 +960,7 @@ let applyn ~with_evars ?beta ?(with_shelve=false) n t gl =
| _ -> assert false
in loop sigma t [] n in
pp(lazy(str"Refiner.refiner " ++ Printer.pr_econstr t));
- Tacmach.refine_no_check (EConstr.Unsafe.to_constr t) gl
+ Tacmach.refine_no_check t gl
let refine_with ?(first_goes_last=false) ?beta ?(with_evars=true) oc gl =
let rec mkRels = function 1 -> [] | n -> mkRel n :: mkRels (n-1) in
diff --git a/plugins/ssr/ssrcommon.mli b/plugins/ssr/ssrcommon.mli
index 7a4b47a462..f611685769 100644
--- a/plugins/ssr/ssrcommon.mli
+++ b/plugins/ssr/ssrcommon.mli
@@ -9,9 +9,9 @@
(* This file is (C) Copyright 2006-2015 Microsoft Corporation and Inria. *)
open API
+open Tacmach
open Names
open Environ
-open Proof_type
open Evd
open Constrexpr
open Ssrast
@@ -122,11 +122,11 @@ val intern_term :
ssrterm -> Glob_term.glob_constr
val pf_intern_term :
- Tacinterp.interp_sign -> Proof_type.goal Evd.sigma ->
+ Tacinterp.interp_sign -> Goal.goal Evd.sigma ->
ssrterm -> Glob_term.glob_constr
val interp_term :
- Tacinterp.interp_sign -> Proof_type.goal Evd.sigma ->
+ Tacinterp.interp_sign -> Goal.goal Evd.sigma ->
ssrterm -> evar_map * EConstr.t
val interp_wit :
@@ -136,28 +136,28 @@ val interp_hyp : ist -> goal sigma -> ssrhyp -> evar_map * ssrhyp
val interp_hyps : ist -> goal sigma -> ssrhyps -> evar_map * ssrhyps
val interp_refine :
- Tacinterp.interp_sign -> Proof_type.goal Evd.sigma ->
+ Tacinterp.interp_sign -> Goal.goal Evd.sigma ->
Glob_term.glob_constr -> evar_map * (evar_map * EConstr.constr)
val interp_open_constr :
- Tacinterp.interp_sign -> Proof_type.goal Evd.sigma ->
+ Tacinterp.interp_sign -> Goal.goal Evd.sigma ->
Tacexpr.glob_constr_and_expr -> evar_map * (evar_map * EConstr.t)
val pf_e_type_of :
- Proof_type.goal Evd.sigma ->
- EConstr.constr -> Proof_type.goal Evd.sigma * EConstr.types
+ Goal.goal Evd.sigma ->
+ EConstr.constr -> Goal.goal Evd.sigma * EConstr.types
val splay_open_constr :
- Proof_type.goal Evd.sigma ->
+ Goal.goal Evd.sigma ->
evar_map * EConstr.t ->
(Names.Name.t * EConstr.t) list * EConstr.t
-val isAppInd : Proof_type.goal Evd.sigma -> EConstr.types -> bool
+val isAppInd : Goal.goal Evd.sigma -> EConstr.types -> bool
val interp_view_nbimps :
Tacinterp.interp_sign ->
- Proof_type.goal Evd.sigma -> Glob_term.glob_constr -> int
+ Goal.goal Evd.sigma -> Glob_term.glob_constr -> int
val interp_nbargs :
Tacinterp.interp_sign ->
- Proof_type.goal Evd.sigma -> Glob_term.glob_constr -> int
+ Goal.goal Evd.sigma -> Glob_term.glob_constr -> int
val mk_term : ssrtermkind -> 'b -> ssrtermkind * (Glob_term.glob_constr * 'b option)
@@ -169,20 +169,20 @@ val mk_internal_id : string -> Id.t
val mk_tagged_id : string -> int -> Id.t
val mk_evar_name : int -> Name.t
val ssr_anon_hyp : string
-val pf_type_id : Proof_type.goal Evd.sigma -> EConstr.types -> Id.t
+val pf_type_id : Goal.goal Evd.sigma -> EConstr.types -> Id.t
val pf_abs_evars :
- Proof_type.goal Evd.sigma ->
+ Goal.goal Evd.sigma ->
evar_map * EConstr.t ->
int * EConstr.t * Evar.t list *
UState.t
val pf_abs_evars2 : (* ssr2 *)
- Proof_type.goal Evd.sigma -> Evar.t list ->
+ Goal.goal Evd.sigma -> Evar.t list ->
evar_map * EConstr.t ->
int * EConstr.t * Evar.t list *
UState.t
val pf_abs_cterm :
- Proof_type.goal Evd.sigma -> int -> EConstr.t -> EConstr.t
+ Goal.goal Evd.sigma -> int -> EConstr.t -> EConstr.t
val pf_merge_uc :
UState.t -> 'a Evd.sigma -> 'a Evd.sigma
@@ -190,21 +190,21 @@ val pf_merge_uc_of :
evar_map -> 'a Evd.sigma -> 'a Evd.sigma
val constr_name : evar_map -> EConstr.t -> Name.t
val pf_type_of :
- Proof_type.goal Evd.sigma ->
- Term.constr -> Proof_type.goal Evd.sigma * Term.types
+ Goal.goal Evd.sigma ->
+ Term.constr -> Goal.goal Evd.sigma * Term.types
val pfe_type_of :
- Proof_type.goal Evd.sigma ->
- EConstr.t -> Proof_type.goal Evd.sigma * EConstr.types
+ Goal.goal Evd.sigma ->
+ EConstr.t -> Goal.goal Evd.sigma * EConstr.types
val pf_abs_prod :
Name.t ->
- Proof_type.goal Evd.sigma ->
+ Goal.goal Evd.sigma ->
EConstr.t ->
- EConstr.t -> Proof_type.goal Evd.sigma * EConstr.types
+ EConstr.t -> Goal.goal Evd.sigma * EConstr.types
val pf_mkprod :
- Proof_type.goal Evd.sigma ->
+ Goal.goal Evd.sigma ->
EConstr.t ->
?name:Name.t ->
- EConstr.t -> Proof_type.goal Evd.sigma * EConstr.types
+ EConstr.t -> Goal.goal Evd.sigma * EConstr.types
val mkSsrRRef : string -> Glob_term.glob_constr * 'a option
val mkSsrRef : string -> Globnames.global_reference
@@ -213,15 +213,15 @@ val mkSsrConst :
env -> evar_map -> evar_map * EConstr.t
val pf_mkSsrConst :
string ->
- Proof_type.goal Evd.sigma ->
- EConstr.t * Proof_type.goal Evd.sigma
+ Goal.goal Evd.sigma ->
+ EConstr.t * Goal.goal Evd.sigma
val new_wild_id : tac_ctx -> Names.Id.t * tac_ctx
val pf_fresh_global :
Globnames.global_reference ->
- Proof_type.goal Evd.sigma ->
- Term.constr * Proof_type.goal Evd.sigma
+ Goal.goal Evd.sigma ->
+ Term.constr * Goal.goal Evd.sigma
val is_discharged_id : Id.t -> bool
val mk_discharged_id : Id.t -> Id.t
@@ -230,15 +230,15 @@ val has_discharged_tag : string -> bool
val ssrqid : string -> Libnames.qualid
val new_tmp_id :
tac_ctx -> (Names.Id.t * Name.t ref) * tac_ctx
-val mk_anon_id : string -> Proof_type.goal Evd.sigma -> Id.t
+val mk_anon_id : string -> Goal.goal Evd.sigma -> Id.t
val pf_abs_evars_pirrel :
- Proof_type.goal Evd.sigma ->
+ Goal.goal Evd.sigma ->
evar_map * Term.constr -> int * Term.constr
-val pf_nbargs : Proof_type.goal Evd.sigma -> EConstr.t -> int
+val pf_nbargs : Goal.goal Evd.sigma -> EConstr.t -> int
val gen_tmp_ids :
?ist:Geninterp.interp_sign ->
- (Proof_type.goal * tac_ctx) Evd.sigma ->
- (Proof_type.goal * tac_ctx) list Evd.sigma
+ (Goal.goal * tac_ctx) Evd.sigma ->
+ (Goal.goal * tac_ctx) list Evd.sigma
val ssrevaltac : Tacinterp.interp_sign -> Tacinterp.Value.t -> Proofview.V82.tac
@@ -258,23 +258,23 @@ val ssrautoprop_tac :
val mkProt :
EConstr.t ->
EConstr.t ->
- Proof_type.goal Evd.sigma ->
- EConstr.t * Proof_type.goal Evd.sigma
+ Goal.goal Evd.sigma ->
+ EConstr.t * Goal.goal Evd.sigma
val mkEtaApp : EConstr.t -> int -> int -> EConstr.t
val mkRefl :
EConstr.t ->
EConstr.t ->
- Proof_type.goal Evd.sigma -> EConstr.t * Proof_type.goal Evd.sigma
+ Goal.goal Evd.sigma -> EConstr.t * Goal.goal Evd.sigma
val discharge_hyp :
Id.t * (Id.t * string) ->
- Proof_type.goal Evd.sigma -> Evar.t list Evd.sigma
+ Goal.goal Evd.sigma -> Evar.t list Evd.sigma
val clear_wilds_and_tmp_and_delayed_ids :
- (Proof_type.goal * tac_ctx) Evd.sigma ->
- (Proof_type.goal * tac_ctx) list Evd.sigma
+ (Goal.goal * tac_ctx) Evd.sigma ->
+ (Goal.goal * tac_ctx) list Evd.sigma
val view_error : string -> ssrterm -> 'a
@@ -284,14 +284,14 @@ val top_id : Id.t
val pf_abs_ssrterm :
?resolve_typeclasses:bool ->
ist ->
- Proof_type.goal Evd.sigma ->
+ Goal.goal Evd.sigma ->
ssrterm ->
evar_map * EConstr.t * UState.t * int
val pf_interp_ty :
?resolve_typeclasses:bool ->
Tacinterp.interp_sign ->
- Proof_type.goal Evd.sigma ->
+ Goal.goal Evd.sigma ->
Ssrast.ssrtermkind *
(Glob_term.glob_constr * Constrexpr.constr_expr option) ->
int * EConstr.t * EConstr.t * UState.t
@@ -309,12 +309,12 @@ exception NotEnoughProducts
val pf_saturate :
?beta:bool ->
?bi_types:bool ->
- Proof_type.goal Evd.sigma ->
+ Goal.goal Evd.sigma ->
EConstr.constr ->
?ty:EConstr.types ->
int ->
EConstr.constr * EConstr.types * (int * EConstr.constr) list *
- Proof_type.goal Evd.sigma
+ Goal.goal Evd.sigma
val saturate :
?beta:bool ->
?bi_types:bool ->
@@ -338,32 +338,32 @@ type name_hint = (int * EConstr.types array) option ref
val gentac :
(Geninterp.interp_sign ->
(Ssrast.ssrdocc) *
- Ssrmatching_plugin.Ssrmatching.cpattern -> Proof_type.tactic)
+ Ssrmatching_plugin.Ssrmatching.cpattern -> Tacmach.tactic)
val genstac :
((Ssrast.ssrhyp list option * Ssrmatching_plugin.Ssrmatching.occ) *
Ssrmatching_plugin.Ssrmatching.cpattern)
list * Ssrast.ssrhyp list ->
- Tacinterp.interp_sign -> Proof_type.tactic
+ Tacinterp.interp_sign -> Tacmach.tactic
val pf_interp_gen :
Tacinterp.interp_sign ->
- Proof_type.goal Evd.sigma ->
+ Goal.goal Evd.sigma ->
bool ->
(Ssrast.ssrhyp list option * Ssrmatching_plugin.Ssrmatching.occ) *
Ssrmatching_plugin.Ssrmatching.cpattern ->
EConstr.t * EConstr.t * Ssrast.ssrhyp list *
- Proof_type.goal Evd.sigma
+ Goal.goal Evd.sigma
val pf_interp_gen_aux :
Tacinterp.interp_sign ->
- Proof_type.goal Evd.sigma ->
+ Goal.goal Evd.sigma ->
bool ->
(Ssrast.ssrhyp list option * Ssrmatching_plugin.Ssrmatching.occ) *
Ssrmatching_plugin.Ssrmatching.cpattern ->
bool * Ssrmatching_plugin.Ssrmatching.pattern * EConstr.t *
EConstr.t * Ssrast.ssrhyp list * UState.t *
- Proof_type.goal Evd.sigma
+ Goal.goal Evd.sigma
val is_name_in_ipats :
Id.t -> ssripats -> bool
@@ -386,12 +386,12 @@ val interp_clr :
val genclrtac :
EConstr.constr ->
- EConstr.constr list -> Ssrast.ssrhyp list -> Proof_type.tactic
+ EConstr.constr list -> Ssrast.ssrhyp list -> Tacmach.tactic
val cleartac : ssrhyps -> v82tac
-val tclMULT : int * ssrmmod -> Proof_type.tactic -> Proof_type.tactic
+val tclMULT : int * ssrmmod -> Tacmach.tactic -> Tacmach.tactic
-val unprotecttac : Proof_type.goal Evd.sigma -> Proof_type.goal list Evd.sigma
+val unprotecttac : Goal.goal Evd.sigma -> Goal.goal list Evd.sigma
val abs_wgen :
bool ->
@@ -401,8 +401,8 @@ val abs_wgen :
((Ssrast.ssrhyp_or_id * string) *
Ssrmatching_plugin.Ssrmatching.cpattern option)
option ->
- Proof_type.goal Evd.sigma * EConstr.t list * EConstr.t ->
- Proof_type.goal Evd.sigma * EConstr.t list * EConstr.t
+ Goal.goal Evd.sigma * EConstr.t list * EConstr.t ->
+ Goal.goal Evd.sigma * EConstr.t list * EConstr.t
val clr_of_wgen :
ssrhyps * ((ssrhyp_or_id * 'a) * 'b option) option ->
diff --git a/plugins/ssr/ssrelim.mli b/plugins/ssr/ssrelim.mli
index 8dc28d8b75..825b4758e3 100644
--- a/plugins/ssr/ssrelim.mli
+++ b/plugins/ssr/ssrelim.mli
@@ -32,23 +32,23 @@ val ssrelim :
(?ist:Ltac_plugin.Tacinterp.interp_sign ->
'a ->
Ssrast.ssripat option ->
- (Proof_type.goal Evd.sigma -> Proof_type.goal list Evd.sigma) ->
- bool -> Ssrast.ssrhyp list -> Proof_type.tactic) ->
- Proof_type.goal Evd.sigma -> Proof_type.goal list Evd.sigma
+ (Goal.goal Evd.sigma -> Goal.goal list Evd.sigma) ->
+ bool -> Ssrast.ssrhyp list -> Tacmach.tactic) ->
+ Goal.goal Evd.sigma -> Goal.goal list Evd.sigma
val elimtac :
EConstr.constr ->
- Proof_type.goal Evd.sigma -> Proof_type.goal list Evd.sigma
+ Goal.goal Evd.sigma -> Goal.goal list Evd.sigma
val casetac :
EConstr.constr ->
- Proof_type.goal Evd.sigma -> Proof_type.goal list Evd.sigma
+ Goal.goal Evd.sigma -> Goal.goal list Evd.sigma
-val is_injection_case : EConstr.t -> Proof_type.goal Evd.sigma -> bool
+val is_injection_case : EConstr.t -> Goal.goal Evd.sigma -> bool
val perform_injection :
EConstr.constr ->
- Proof_type.goal Evd.sigma -> Proof_type.goal list Evd.sigma
+ Goal.goal Evd.sigma -> Goal.goal list Evd.sigma
val ssrscasetac :
bool ->
EConstr.constr ->
- Proof_type.goal Evd.sigma -> Proof_type.goal list Evd.sigma
+ Goal.goal Evd.sigma -> Goal.goal list Evd.sigma
diff --git a/plugins/ssr/ssrequality.mli b/plugins/ssr/ssrequality.mli
index f712002c1f..f9ab5d74fe 100644
--- a/plugins/ssr/ssrequality.mli
+++ b/plugins/ssr/ssrequality.mli
@@ -25,12 +25,12 @@ val mkclr : ssrclear -> ssrdocc
val nodocc : ssrdocc
val noclr : ssrdocc
-val simpltac : Ssrast.ssrsimpl -> Proof_type.tactic
+val simpltac : Ssrast.ssrsimpl -> Tacmach.tactic
val newssrcongrtac :
int * Ssrast.ssrterm ->
Ltac_plugin.Tacinterp.interp_sign ->
- Proof_type.goal Evd.sigma -> Proof_type.goal list Evd.sigma
+ Goal.goal Evd.sigma -> Goal.goal list Evd.sigma
val mk_rwarg :
@@ -45,7 +45,7 @@ val ssrinstancesofrule :
Ltac_plugin.Tacinterp.interp_sign ->
Ssrast.ssrdir ->
Ssrast.ssrterm ->
- Proof_type.goal Evd.sigma -> Proof_type.goal list Evd.sigma
+ Goal.goal Evd.sigma -> Goal.goal list Evd.sigma
val ssrrewritetac :
Ltac_plugin.Tacinterp.interp_sign ->
@@ -53,11 +53,11 @@ val ssrrewritetac :
(((Ssrast.ssrhyps option * Ssrmatching.occ) *
Ssrmatching.rpattern option) *
(ssrwkind * Ssrast.ssrterm)))
- list -> Proof_type.tactic
+ list -> Tacmach.tactic
-val ipat_rewrite : ssrocc -> ssrdir -> EConstr.t -> Proof_type.tactic
+val ipat_rewrite : ssrocc -> ssrdir -> EConstr.t -> Tacmach.tactic
val unlocktac :
Ltac_plugin.Tacinterp.interp_sign ->
(Ssrmatching.occ * Ssrast.ssrterm) list ->
- Proof_type.goal Evd.sigma -> Proof_type.goal list Evd.sigma
+ Goal.goal Evd.sigma -> Goal.goal list Evd.sigma
diff --git a/plugins/ssr/ssrfwd.mli b/plugins/ssr/ssrfwd.mli
index ead361745d..7f254074c7 100644
--- a/plugins/ssr/ssrfwd.mli
+++ b/plugins/ssr/ssrfwd.mli
@@ -36,7 +36,7 @@ val ssrabstract :
val basecuttac :
string ->
- EConstr.t -> Proof_type.goal Evd.sigma -> Evar.t list Evd.sigma
+ EConstr.t -> Goal.goal Evd.sigma -> Evar.t list Evd.sigma
val wlogtac :
Ltac_plugin.Tacinterp.interp_sign ->
@@ -52,7 +52,7 @@ val wlogtac :
Ltac_plugin.Tacinterp.Value.t Ssrast.ssrhint ->
bool ->
[< `Gen of Names.Id.t option option | `NoGen > `NoGen ] ->
- Proof_type.goal Evd.sigma -> Proof_type.goal list Evd.sigma
+ Goal.goal Evd.sigma -> Goal.goal list Evd.sigma
val sufftac :
Ssrast.ist ->
@@ -62,5 +62,5 @@ val sufftac :
(Ssrast.ssrtermkind *
(Glob_term.glob_constr * Constrexpr.constr_expr option))) *
(bool * Tacinterp.Value.t option list)) ->
- Proof_type.tactic
+ Tacmach.tactic
diff --git a/plugins/ssr/ssripats.ml b/plugins/ssr/ssripats.ml
index 7ae9e38248..06bbd749e6 100644
--- a/plugins/ssr/ssripats.ml
+++ b/plugins/ssr/ssripats.ml
@@ -175,10 +175,10 @@ let move_top_with_view ~next c r v =
type block_names = (int * EConstr.types array) option
-let (introstac : ?ist:Tacinterp.interp_sign -> ssripats -> Proof_type.tactic),
+let (introstac : ?ist:Tacinterp.interp_sign -> ssripats -> Tacmach.tactic),
(tclEQINTROS : ?ind:block_names ref -> ?ist:Tacinterp.interp_sign ->
- Proof_type.tactic -> Proof_type.tactic -> ssripats ->
- Proof_type.tactic)
+ Tacmach.tactic -> Tacmach.tactic -> ssripats ->
+ Tacmach.tactic)
=
let rec ipattac ?ist ~next p : tac_ctx tac_a = fun gl ->
diff --git a/plugins/ssr/ssripats.mli b/plugins/ssr/ssripats.mli
index 5f5c7f34a4..aefdc8e111 100644
--- a/plugins/ssr/ssripats.mli
+++ b/plugins/ssr/ssripats.mli
@@ -36,10 +36,10 @@ val elim_intro_tac :
?ist:Tacinterp.interp_sign ->
[> `EConstr of 'a * 'b * EConstr.t ] ->
Ssrast.ssripat option ->
- Proof_type.tactic ->
+ Tacmach.tactic ->
bool ->
Ssrast.ssrhyp list ->
- Proof_type.goal Evd.sigma -> Proof_type.goal list Evd.sigma
+ Goal.goal Evd.sigma -> Goal.goal list Evd.sigma
(* "move=> top; tac top; clear top" respecting the speed *)
val with_top : (EConstr.t -> v82tac) -> tac_ctx tac_a
@@ -51,17 +51,17 @@ val ssrmovetac :
(((Ssrast.ssrdocc * Ssrmatching.cpattern) list
list * Ssrast.ssrclear) *
Ssrast.ssripats)) ->
- Proof_type.tactic
+ Tacmach.tactic
-val movehnftac : Proof_type.goal Evd.sigma -> Proof_type.goal list Evd.sigma
+val movehnftac : Goal.goal Evd.sigma -> Goal.goal list Evd.sigma
val with_dgens :
(Ssrast.ssrdocc * Ssrmatching.cpattern) list
list * Ssrast.ssrclear ->
((Ssrast.ssrdocc * Ssrmatching.cpattern) list ->
Ssrast.ssrdocc * Ssrmatching.cpattern ->
- Ltac_plugin.Tacinterp.interp_sign -> Proof_type.tactic) ->
- Ltac_plugin.Tacinterp.interp_sign -> Proof_type.tactic
+ Ltac_plugin.Tacinterp.interp_sign -> Tacmach.tactic) ->
+ Ltac_plugin.Tacinterp.interp_sign -> Tacmach.tactic
val ssrcasetac :
Ltac_plugin.Tacinterp.interp_sign ->
@@ -69,7 +69,7 @@ val ssrcasetac :
(Ssrast.ssripat option *
(((Ssrast.ssrdocc * Ssrmatching.cpattern) list list * Ssrast.ssrclear) *
Ssrast.ssripats)) ->
- Proof_type.tactic
+ Tacmach.tactic
val ssrapplytac :
Tacinterp.interp_sign ->
@@ -79,5 +79,5 @@ val ssrapplytac :
(Ssrast.ssrtermkind * Tacexpr.glob_constr_and_expr))
list list * Ssrast.ssrhyps) *
Ssrast.ssripats)) ->
- Proof_type.tactic
+ Tacmach.tactic
diff --git a/plugins/ssr/ssrprinters.mli b/plugins/ssr/ssrprinters.mli
index 9207b9e437..8da9bc72bc 100644
--- a/plugins/ssr/ssrprinters.mli
+++ b/plugins/ssr/ssrprinters.mli
@@ -12,7 +12,7 @@ open API
open Ssrast
val pp_term :
- Proof_type.goal Evd.sigma -> EConstr.constr -> Pp.std_ppcmds
+ Goal.goal Evd.sigma -> EConstr.constr -> Pp.std_ppcmds
val pr_spc : unit -> Pp.std_ppcmds
val pr_bar : unit -> Pp.std_ppcmds
diff --git a/plugins/ssr/ssrtacticals.mli b/plugins/ssr/ssrtacticals.mli
index 1d18871387..297cfdfdc0 100644
--- a/plugins/ssr/ssrtacticals.mli
+++ b/plugins/ssr/ssrtacticals.mli
@@ -17,7 +17,7 @@ val tclSEQAT :
int Misctypes.or_var *
(('a * Ltac_plugin.Tacinterp.Value.t option list) *
Ltac_plugin.Tacinterp.Value.t option) ->
- Proof_type.tactic
+ Tacmach.tactic
val tclCLAUSES :
Ltac_plugin.Tacinterp.interp_sign ->
@@ -27,7 +27,7 @@ val tclCLAUSES :
Ssrmatching_plugin.Ssrmatching.cpattern option)
option)
list * Ssrast.ssrclseq ->
- Proof_type.goal Evd.sigma -> Proof_type.goal list Evd.sigma
+ Goal.goal Evd.sigma -> Goal.goal list Evd.sigma
val hinttac :
Tacinterp.interp_sign ->
@@ -42,5 +42,5 @@ val ssrdotac :
Ssrmatching_plugin.Ssrmatching.cpattern option)
option)
list * Ssrast.ssrclseq) ->
- Proof_type.goal Evd.sigma -> Proof_type.goal list Evd.sigma
+ Goal.goal Evd.sigma -> Goal.goal list Evd.sigma
diff --git a/plugins/ssr/ssrview.ml b/plugins/ssr/ssrview.ml
index 91e40f3684..cc142e091c 100644
--- a/plugins/ssr/ssrview.ml
+++ b/plugins/ssr/ssrview.ml
@@ -80,7 +80,7 @@ let interp_view ist si env sigma gv v rid =
snd (view_with (if view_nbimps < 0 then [] else viewtab.(0)))
-let with_view ist ~next si env (gl0 : (Proof_type.goal * tac_ctx) Evd.sigma) c name cl prune (conclude : EConstr.t -> EConstr.t -> tac_ctx tac_a) clr =
+let with_view ist ~next si env (gl0 : (Goal.goal * tac_ctx) Evd.sigma) c name cl prune (conclude : EConstr.t -> EConstr.t -> tac_ctx tac_a) clr =
let c2r ist x = { ist with lfun =
Id.Map.add top_id (Value.of_constr x) ist.lfun } in
let terminate (sigma, c') =
diff --git a/plugins/ssrmatching/ssrmatching.mli b/plugins/ssrmatching/ssrmatching.mli
index c2bf12cb63..1853bc35dc 100644
--- a/plugins/ssrmatching/ssrmatching.mli
+++ b/plugins/ssrmatching/ssrmatching.mli
@@ -3,11 +3,11 @@
open API
open Grammar_API
+open Goal
open Genarg
open Tacexpr
open Environ
open Evd
-open Proof_type
open Term
(** ******** Small Scale Reflection pattern matching facilities ************* *)
--
cgit v1.2.3
From d06af26e6cd93c6bb819b38573603a5e1121ed68 Mon Sep 17 00:00:00 2001
From: Théo Zimmermann
Date: Tue, 13 Jun 2017 18:24:45 +0200
Subject: Each user overlay goes into its own file.
This will avoid stupid merge conflicts in the future.
---
dev/ci/ci-common.sh | 4 +-
dev/ci/ci-user-overlay.sh | 58 ----------------------
.../user-overlays/00669-maximedenes-ssr-merge.sh | 4 ++
dev/ci/user-overlays/README.md | 14 ++++++
4 files changed, 21 insertions(+), 59 deletions(-)
delete mode 100644 dev/ci/ci-user-overlay.sh
create mode 100644 dev/ci/user-overlays/00669-maximedenes-ssr-merge.sh
create mode 100644 dev/ci/user-overlays/README.md
diff --git a/dev/ci/ci-common.sh b/dev/ci/ci-common.sh
index f1e1515d41..5435e95885 100644
--- a/dev/ci/ci-common.sh
+++ b/dev/ci/ci-common.sh
@@ -18,7 +18,9 @@ ls "$COQBIN"
# Where we clone and build external developments
CI_BUILD_DIR=`pwd`/_build_ci
-source ${ci_dir}/ci-user-overlay.sh
+for overlay in ${ci_dir}/user-overlays/*.sh; do
+ source ${overlay}
+done
source ${ci_dir}/ci-basic-overlay.sh
mathcomp_CI_DIR=${CI_BUILD_DIR}/math-comp
diff --git a/dev/ci/ci-user-overlay.sh b/dev/ci/ci-user-overlay.sh
deleted file mode 100644
index 2ecd40416f..0000000000
--- a/dev/ci/ci-user-overlay.sh
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/usr/bin/env bash
-
-# Add user overlays here. You can use some logic to detect if you are
-# in your travis branch and conditionally enable the overlay.
-
-# Some useful Travis variables:
-# (https://docs.travis-ci.com/user/environment-variables/#Default-Environment-Variables)
-#
-# - TRAVIS_BRANCH: For builds not triggered by a pull request this is
-# the name of the branch currently being built; whereas for builds
-# triggered by a pull request this is the name of the branch
-# targeted by the pull request (in many cases this will be master).
-#
-# - TRAVIS_COMMIT: The commit that the current build is testing.
-#
-# - TRAVIS_PULL_REQUEST: The pull request number if the current job is
-# a pull request, “false” if it’s not a pull request.
-#
-# - TRAVIS_PULL_REQUEST_BRANCH: If the current job is a pull request,
-# the name of the branch from which the PR originated. "" if the
-# current job is a push build.
-
-echo $TRAVIS_PULL_REQUEST_BRANCH
-echo $TRAVIS_PULL_REQUEST
-echo $TRAVIS_BRANCH
-echo $TRAVIS_COMMIT
-
-if [ $TRAVIS_PULL_REQUEST == "669" ] || [ $TRAVIS_BRANCH == "ssr-merge" ]; then
- mathcomp_CI_BRANCH=ssr-merge
- mathcomp_CI_GITURL=https://github.com/maximedenes/math-comp.git
-fi
-
-echo "DEBUG: ci-user-overlay.sh 0"
-if [ $TRAVIS_PULL_REQUEST = "707" ] || [ $TRAVIS_BRANCH == "trunk__API__coq_makefile" ]; then
- echo "DEBUG: ci-user-overlay.sh 1"
- bedrock_src_CI_BRANCH=trunk__API
- bedrock_src_CI_GITURL=https://github.com/matejkosik/bedrock.git
- bedrock_facade_CI_BRANCH=trunk__API
- bedrock_facade_CI_GITURL=https://github.com/matejkosik/bedrock.git
- fiat_parsers_CI_BRANCH=trunk__API
- fiat_parsers_CI_GITURL=https://github.com/matejkosik/fiat.git
-fi
-
-if [ $TRAVIS_PULL_REQUEST == "498" ] || [ $TRAVIS_BRANCH == "outsource-bignums" ]; then
- math_classes_CI_BRANCH=external-bignums
- math_classes_CI_GITURL=https://github.com/letouzey/math-classes.git
- Corn_CI_BRANCH=external-bignums
- Corn_CI_GITURL=https://github.com/letouzey/corn.git
-fi
-
-if [ $TRAVIS_PULL_REQUEST == "220" ] || [ $TRAVIS_BRANCH == "less_init_plugins" ]; then
- CompCert_CI_BRANCH=less_init_plugins
- CompCert_CI_GITURL=https://github.com/letouzey/CompCert.git
- VST_CI_BRANCH=less_init_plugins
- VST_CI_GITURL=https://github.com/letouzey/VST.git
- fiat_crypto_CI_BRANCH=less_init_plugins
- fiat_crypto_CI_GITURL=https://github.com/letouzey/fiat-crypto.git
-fi
diff --git a/dev/ci/user-overlays/00669-maximedenes-ssr-merge.sh b/dev/ci/user-overlays/00669-maximedenes-ssr-merge.sh
new file mode 100644
index 0000000000..af4a96f4ae
--- /dev/null
+++ b/dev/ci/user-overlays/00669-maximedenes-ssr-merge.sh
@@ -0,0 +1,4 @@
+if [ "$TRAVIS_PULL_REQUEST" = "669" ] || [ "$TRAVIS_BRANCH" = "ssr-merge" ]; then
+ mathcomp_CI_BRANCH=ssr-merge
+ mathcomp_CI_GITURL=https://github.com/maximedenes/math-comp.git
+fi
diff --git a/dev/ci/user-overlays/README.md b/dev/ci/user-overlays/README.md
new file mode 100644
index 0000000000..9146d3d521
--- /dev/null
+++ b/dev/ci/user-overlays/README.md
@@ -0,0 +1,14 @@
+# Add overlays for your pull requests in this directory
+
+An overlay is a file containing very simple logic to test whether we are currently building a specific pull request or git branch (useful so that overlays work on your own fork) and which changes some of the variables whose default can be found in [`ci-basic-overlay.sh`](/dev/ci/ci-basic-overlay.sh).
+
+The name of your overlay file should be of the form `five_digit_PR_number-GitHub_handle-branch_name.sh`.
+
+Example: `00669-maximedenes-ssr-merge.sh` containing
+
+```
+if [ "$TRAVIS_PULL_REQUEST" = "669" ] || [ "$TRAVIS_BRANCH" = "ssr-merge" ]; then
+ mathcomp_CI_BRANCH=ssr-merge
+ mathcomp_CI_GITURL=https://github.com/maximedenes/math-comp.git
+fi
+```
--
cgit v1.2.3
From f70f12b56e44abd9df4ad6941ee4941a761302fa Mon Sep 17 00:00:00 2001
From: Gaëtan Gilbert
Date: Fri, 16 Jun 2017 11:07:23 +0200
Subject: Increase the time limit on 4366.v to make gitlab work better.
---
test-suite/bugs/closed/4366.v | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test-suite/bugs/closed/4366.v b/test-suite/bugs/closed/4366.v
index 6a5e9a4023..403c2d2026 100644
--- a/test-suite/bugs/closed/4366.v
+++ b/test-suite/bugs/closed/4366.v
@@ -10,6 +10,6 @@ end.
Goal True.
Proof.
pose (v := stupid 24).
-Timeout 2 vm_compute in v.
+Timeout 4 vm_compute in v.
exact I.
Qed.
--
cgit v1.2.3
From e4f0651516ee7c8bdfd9832aa3afa74e61f9fa81 Mon Sep 17 00:00:00 2001
From: Théo Zimmermann
Date: Fri, 9 Jun 2017 15:42:50 +0200
Subject: "There are pending proofs" error message now lists the name of the
proofs.
This closes https://coq.inria.fr/bugs/show_bug.cgi?id=5275
---
toplevel/vernac.ml | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/toplevel/vernac.ml b/toplevel/vernac.ml
index 92730c14d0..74c7663ca5 100644
--- a/toplevel/vernac.ml
+++ b/toplevel/vernac.ml
@@ -286,7 +286,12 @@ let ensure_exists f =
let compile verbosely f =
let check_pending_proofs () =
let pfs = Proof_global.get_all_proof_names () in
- if not (List.is_empty pfs) then vernac_error (str "There are pending proofs")
+ if not (List.is_empty pfs) then
+ vernac_error (str "There are pending proofs: "
+ ++ (pfs
+ |> List.rev
+ |> prlist_with_sep pr_comma Names.Id.print)
+ ++ str ".")
in
match !Flags.compilation_mode with
| BuildVo ->
--
cgit v1.2.3
From 7eed898a0418fba38821594efe8f98a458d8bb10 Mon Sep 17 00:00:00 2001
From: Gaëtan Gilbert
Date: Fri, 16 Jun 2017 11:02:25 +0200
Subject: Add coq-dpdgraph to gitlab CI
---
.gitlab-ci.yml | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index d5351f5738..92243b7573 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -259,6 +259,14 @@ ci-color:
ci-compcert:
<<: *ci-template
+ci-coq-dpdgraph:
+ <<: *ci-template
+ variables:
+ <<: *ci-template-vars
+ EXTRA_OPAM: "ocamlgraph"
+ EXTRA_PACKAGES: "autoconf"
+ allow_failure: true
+
ci-coquelicot:
<<: *ci-template
variables:
--
cgit v1.2.3
From d7e85f575fe6a41a700da9cd50236bef8ab03cf8 Mon Sep 17 00:00:00 2001
From: Pierre Letouzey
Date: Mon, 12 Jun 2017 17:50:18 +0200
Subject: romega: avoid potential slowdown when changing concl by reified
version
On some benchmarks provided by Chantal Keller a long time ago,
romega was abnormally slow compared to omega (or lia).
It turned out that the change of concl by reified version was
triggering unnecessary unfolds of Z.add, instead of unfolding
ReflOmegaCore.Z_as_Int.plus into Z.add. This is now fixed by
the various Parameter Inline : no more indirections, Z_as_Int.plus
is directly Z.add.
Also use Tactics.convert_concl_no_check for this "change", as
recommended by PMP.
---
plugins/romega/ReflOmegaCore.v | 20 ++++++++++----------
plugins/romega/refl_omega.ml | 2 +-
test-suite/success/ROmega3.v | 31 +++++++++++++++++++++++++++++++
3 files changed, 42 insertions(+), 11 deletions(-)
create mode 100644 test-suite/success/ROmega3.v
diff --git a/plugins/romega/ReflOmegaCore.v b/plugins/romega/ReflOmegaCore.v
index d242264a91..51b99b9935 100644
--- a/plugins/romega/ReflOmegaCore.v
+++ b/plugins/romega/ReflOmegaCore.v
@@ -18,12 +18,12 @@ Module Type Int.
Bind Scope Int_scope with t.
- Parameter zero : t.
- Parameter one : t.
- Parameter plus : t -> t -> t.
- Parameter opp : t -> t.
- Parameter minus : t -> t -> t.
- Parameter mult : t -> t -> t.
+ Parameter Inline zero : t.
+ Parameter Inline one : t.
+ Parameter Inline plus : t -> t -> t.
+ Parameter Inline opp : t -> t.
+ Parameter Inline minus : t -> t -> t.
+ Parameter Inline mult : t -> t -> t.
Notation "0" := zero : Int_scope.
Notation "1" := one : Int_scope.
@@ -39,10 +39,10 @@ Module Type Int.
(** Int should also be ordered: *)
- Parameter le : t -> t -> Prop.
- Parameter lt : t -> t -> Prop.
- Parameter ge : t -> t -> Prop.
- Parameter gt : t -> t -> Prop.
+ Parameter Inline le : t -> t -> Prop.
+ Parameter Inline lt : t -> t -> Prop.
+ Parameter Inline ge : t -> t -> Prop.
+ Parameter Inline gt : t -> t -> Prop.
Notation "x <= y" := (le x y): Int_scope.
Notation "x < y" := (lt x y) : Int_scope.
Notation "x >= y" := (ge x y) : Int_scope.
diff --git a/plugins/romega/refl_omega.ml b/plugins/romega/refl_omega.ml
index 1a53862ec4..60e6e7de79 100644
--- a/plugins/romega/refl_omega.ml
+++ b/plugins/romega/refl_omega.ml
@@ -1016,7 +1016,7 @@ let resolution unsafe env (reified_concl,reified_hyps) systems_list =
Tactics.generalize
(l_generalize_arg @ List.map EConstr.mkVar useful_hypnames) >>
- Tactics.change_concl (EConstr.of_constr reified) >>
+ Tactics.convert_concl_no_check (EConstr.of_constr reified) Term.DEFAULTcast >>
Tactics.apply (EConstr.of_constr (app coq_do_omega [|decompose_tactic|])) >>
show_goal >>
(if unsafe then
diff --git a/test-suite/success/ROmega3.v b/test-suite/success/ROmega3.v
new file mode 100644
index 0000000000..fd4ff260b5
--- /dev/null
+++ b/test-suite/success/ROmega3.v
@@ -0,0 +1,31 @@
+
+Require Import ZArith ROmega.
+Local Open Scope Z_scope.
+
+(** Benchmark provided by Chantal Keller, that romega used to
+ solve far too slowly (compared to omega or lia). *)
+
+Parameter v4 : Z.
+Parameter v3 : Z.
+Parameter o4 : Z.
+Parameter s5 : Z.
+Parameter v2 : Z.
+Parameter o5 : Z.
+Parameter s6 : Z.
+Parameter v1 : Z.
+Parameter o6 : Z.
+Parameter s7 : Z.
+Parameter v0 : Z.
+Parameter o7 : Z.
+
+Lemma lemma_5833 :
+ ~ 16 * v4 + (8 * v3 + (-8192 * o4 + (-4096 * s5 + (4 * v2 +
+ (-4096 * o5 + (-2048 * s6 + (2 * v1 + (-2048 * o6 +
+ (-1024 * s7 + (v0 + -1024 * o7)))))))))) >= 8192
+\/
+ 16 * v4 + (8 * v3 + (-8192 * o4 + (-4096 * s5 + (4 * v2 +
+ (-4096 * o5 + (-2048 * s6 + (2 * v1 + (-2048 * o6 +
+ (-1024 * s7 + (v0 + -1024 * o7)))))))))) >= 1024.
+Proof.
+Timeout 1 romega. (* should take a few milliseconds, not seconds *)
+Timeout 1 Qed. (* ditto *)
--
cgit v1.2.3
From 11c52f0882b39afe853473f7a9289e62d1ca843a Mon Sep 17 00:00:00 2001
From: Emilio Jesus Gallego Arias
Date: Thu, 15 Jun 2017 12:36:54 +0200
Subject: [ide] Better exn printing. [fixes BZ#5524]
Due to the situation explained in bug 5360, error printing in
ide_slave results in an anomaly. We fix that by properly processing
the error.
This fixes BZ#5524, however BZ#5525 , still applies.
---
ide/ide_slave.ml | 1 +
1 file changed, 1 insertion(+)
diff --git a/ide/ide_slave.ml b/ide/ide_slave.ml
index 9c771cbef1..6298d9f093 100644
--- a/ide/ide_slave.ml
+++ b/ide/ide_slave.ml
@@ -341,6 +341,7 @@ let about () = {
}
let handle_exn (e, info) =
+ let (e, info) = ExplainErr.process_vernac_interp_error (e, info) in
let dummy = Stateid.dummy in
let loc_of e = match Loc.get_loc e with
| Some loc -> Some (Loc.unloc loc)
--
cgit v1.2.3
From d8874dd855d748aaaf504890487ab15ffd7a677d Mon Sep 17 00:00:00 2001
From: Emilio Jesus Gallego Arias
Date: Mon, 12 Jun 2017 11:41:40 +0200
Subject: [ide] Add route_id parameter to query call.
This is necessary in order for clients to identify the results of
queries. This is a minor breaking change of the protocol, affecting
only this particular call.
This change is necessary in order to fix bug ####.
---
API/API.mli | 3 +--
CHANGES | 6 ++++++
dev/doc/changes.txt | 4 ++++
dev/doc/xml-protocol.md | 9 +++++++--
ide/coqOps.ml | 10 +++++-----
ide/ide_slave.ml | 4 ++--
ide/interface.mli | 5 +++--
ide/xmlprotocol.ml | 20 +++++++++++++++++---
intf/vernacexpr.ml | 3 +--
stm/stm.ml | 23 +++++++++++++----------
stm/stm.mli | 2 +-
stm/vernac_classifier.ml | 10 +++-------
tools/fake_ide.ml | 8 ++++----
13 files changed, 67 insertions(+), 40 deletions(-)
diff --git a/API/API.mli b/API/API.mli
index 69278e7c9f..b5928c023d 100644
--- a/API/API.mli
+++ b/API/API.mli
@@ -2266,10 +2266,9 @@ sig
| VtQed of vernac_qed_type
| VtProofStep of proof_step
| VtProofMode of string
- | VtQuery of vernac_part_of_script * report_with
+ | VtQuery of vernac_part_of_script * Feedback.route_id
| VtStm of vernac_control * vernac_part_of_script
| VtUnknown
- and report_with = Stateid.t * Feedback.route_id
and vernac_qed_type = Vernacexpr.vernac_qed_type =
| VtKeep
| VtKeepAsAxiom
diff --git a/CHANGES b/CHANGES
index b5aaad725e..c6228e55ee 100644
--- a/CHANGES
+++ b/CHANGES
@@ -94,6 +94,12 @@ Build Infrastructure
access to the same .cmi files. In short, use "make -j && make -j byte"
instead of "make -j world byte".
+XML Protocol
+
+- The `query` call has been modified, now it carries a mandatory
+ "route_id" integer parameter, that associated the result of such
+ query with its generated feedback.
+
Changes from V8.6beta1 to V8.6
==============================
diff --git a/dev/doc/changes.txt b/dev/doc/changes.txt
index 0728608f31..159be9a582 100644
--- a/dev/doc/changes.txt
+++ b/dev/doc/changes.txt
@@ -288,6 +288,10 @@ document type". This allows for a more uniform handling of printing
- The legacy `Interp` call has been turned into a noop.
+- The `query` call has been modified, now it carries a mandatory
+ "route_id" integer parameter, that associated the result of such
+ query with its generated feedback.
+
=========================================
= CHANGES BETWEEN COQ V8.5 AND COQ V8.6 =
=========================================
diff --git a/dev/doc/xml-protocol.md b/dev/doc/xml-protocol.md
index 2ff82c6888..127b4a6d2d 100644
--- a/dev/doc/xml-protocol.md
+++ b/dev/doc/xml-protocol.md
@@ -308,15 +308,20 @@ CoqIDE typically sets `force` to `false`.
-------------------------------
+### **Query(route_id: integer, query: string, stateId: integer)**
+
+`routeId` can be used to distinguish the result of a particular query,
+`stateId` should be set to the state the query should be run.
-### **Query(query: string, stateId: integer)**
-In practice, `stateId` is 0, but the effect is to perform the query on the currently-focused state.
```html
+
+
${query}
+
```
#### *Returns*
diff --git a/ide/coqOps.ml b/ide/coqOps.ml
index d30d7ab5e0..3a869f69af 100644
--- a/ide/coqOps.ml
+++ b/ide/coqOps.ml
@@ -373,7 +373,8 @@ object(self)
else messages#add s;
in
let query =
- Coq.query (phrase,sid) in
+ let route_id = 0 in
+ Coq.query (route_id,(phrase,sid)) in
let next = function
| Fail (_, _, err) -> display_error err; Coq.return ()
| Good msg -> Coq.return ()
@@ -841,15 +842,14 @@ object(self)
in
let try_phrase phrase stop more =
let action = log "Sending to coq now" in
- let query = Coq.query (phrase,Stateid.dummy) in
+ let route_id = 0 in
+ let query = Coq.query (route_id,(phrase,Stateid.dummy)) in
let next = function
| Fail (_, l, str) -> (* FIXME: check *)
display_error (l, str);
messages#add (Pp.str ("Unsuccessfully tried: "^phrase));
more
- | Good msg ->
- messages#add_string msg;
- stop Tags.Script.processed
+ | Good () -> stop Tags.Script.processed
in
Coq.bind (Coq.seq action query) next
in
diff --git a/ide/ide_slave.ml b/ide/ide_slave.ml
index 9c771cbef1..7cb22aa33f 100644
--- a/ide/ide_slave.ml
+++ b/ide/ide_slave.ml
@@ -109,9 +109,9 @@ let edit_at id =
* as not to break the core protocol for this minor change, but it should
* be removed in the next version of the protocol.
*)
-let query (s,id) =
+let query (route, (s,id)) =
let pa = Pcoq.Gram.parsable (Stream.of_string s) in
- Stm.query ~at:id pa; ""
+ Stm.query ~at:id ~route pa
let annotate phrase =
let (loc, ast) =
diff --git a/ide/interface.mli b/ide/interface.mli
index 62f63aefb9..1a4d6c0ecb 100644
--- a/ide/interface.mli
+++ b/ide/interface.mli
@@ -112,6 +112,7 @@ type coq_info = {
type location = (int * int) option (* start and end of the error *)
type state_id = Stateid.t
+type route_id = Feedback.route_id
(* Obsolete *)
type edit_id = int
@@ -154,8 +155,8 @@ type edit_at_rty = (unit, state_id * (state_id * state_id)) union
has been deprecated in favor of sending the query answers as
feedback. It will be removed in a future version of the protocol.
*)
-type query_sty = string * state_id
-type query_rty = string
+type query_sty = route_id * (string * state_id)
+type query_rty = unit
(** Fetching the list of current goals. Return [None] if no proof is in
progress, [Some gl] otherwise. *)
diff --git a/ide/xmlprotocol.ml b/ide/xmlprotocol.ml
index 53eb1a95ff..d42bfe43dd 100644
--- a/ide/xmlprotocol.ml
+++ b/ide/xmlprotocol.ml
@@ -10,7 +10,7 @@
(** WARNING: TO BE UPDATED WHEN MODIFIED! *)
-let protocol_version = "20150913"
+let protocol_version = "20170413"
type msg_format = Richpp of int | Ppcmds
let msg_format = ref (Richpp 72)
@@ -95,6 +95,13 @@ let to_stateid = function
let of_stateid i = Element ("state_id",["val",string_of_int (Stateid.to_int i)],[])
+let to_routeid = function
+ | Element ("route_id",["val",i],[]) ->
+ let id = int_of_string i in id
+ | _ -> raise (Invalid_argument "to_route_id")
+
+let of_routeid i = Element ("route_id",["val",string_of_int i],[])
+
let of_box (ppb : Pp.block_type) = let open Pp in match ppb with
| Pp_hbox i -> constructor "ppbox" "hbox" [of_int i]
| Pp_vbox i -> constructor "ppbox" "vbox" [of_int i]
@@ -269,6 +276,7 @@ module ReifType : sig
val coq_info_t : coq_info val_t
val coq_object_t : 'a val_t -> 'a coq_object val_t
val state_id_t : state_id val_t
+ val route_id_t : route_id val_t
val search_cst_t : search_constraint val_t
val of_value_type : 'a val_t -> 'a -> xml
@@ -304,6 +312,7 @@ end = struct
| Coq_info : coq_info val_t
| Coq_object : 'a val_t -> 'a coq_object val_t
| State_id : state_id val_t
+ | Route_id : route_id val_t
| Search_cst : search_constraint val_t
type value_type = Value_type : 'a val_t -> value_type
@@ -329,6 +338,7 @@ end = struct
let coq_info_t = Coq_info
let coq_object_t x = Coq_object x
let state_id_t = State_id
+ let route_id_t = Route_id
let search_cst_t = Search_cst
let of_value_type (ty : 'a val_t) : 'a -> xml =
@@ -350,6 +360,7 @@ end = struct
| Pair (t1,t2) -> (of_pair (convert t1) (convert t2))
| Union (t1,t2) -> (of_union (convert t1) (convert t2))
| State_id -> of_stateid
+ | Route_id -> of_routeid
| Search_cst -> of_search_cst
in
convert ty
@@ -373,6 +384,7 @@ end = struct
| Pair (t1,t2) -> (to_pair (convert t1) (convert t2))
| Union (t1,t2) -> (to_union (convert t1) (convert t2))
| State_id -> to_stateid
+ | Route_id -> to_routeid
| Search_cst -> to_search_cst
in
convert ty
@@ -450,6 +462,7 @@ end = struct
| Pair (t1,t2) -> (pr_pair (print t1) (print t2))
| Union (t1,t2) -> (pr_union (print t1) (print t2))
| State_id -> pr_state_id
+ | Route_id -> pr_int
(* This is to break if a rename/refactoring makes the strings below outdated *)
type 'a exists = bool
@@ -475,6 +488,7 @@ end = struct
| Union (t1,t2) -> assert(true : ('a,'b) CSig.union exists);
Printf.sprintf "((%s, %s) CSig.union)" (print_val_t t1) (print_val_t t2)
| State_id -> assert(true : Stateid.t exists); "Stateid.t"
+ | Route_id -> assert(true : route_id exists); "route_id"
let print_type = function Value_type ty -> print_val_t ty
@@ -506,7 +520,7 @@ open ReifType
let add_sty_t : add_sty val_t =
pair_t (pair_t string_t int_t) (pair_t state_id_t bool_t)
let edit_at_sty_t : edit_at_sty val_t = state_id_t
-let query_sty_t : query_sty val_t = pair_t string_t state_id_t
+let query_sty_t : query_sty val_t = pair_t route_id_t (pair_t string_t state_id_t)
let goals_sty_t : goals_sty val_t = unit_t
let evars_sty_t : evars_sty val_t = unit_t
let hints_sty_t : hints_sty val_t = unit_t
@@ -528,7 +542,7 @@ let add_rty_t : add_rty val_t =
pair_t state_id_t (pair_t (union_t unit_t state_id_t) string_t)
let edit_at_rty_t : edit_at_rty val_t =
union_t unit_t (pair_t state_id_t (pair_t state_id_t state_id_t))
-let query_rty_t : query_rty val_t = string_t
+let query_rty_t : query_rty val_t = unit_t
let goals_rty_t : goals_rty val_t = option_t goals_t
let evars_rty_t : evars_rty val_t = option_t (list_t evar_t)
let hints_rty_t : hints_rty val_t =
diff --git a/intf/vernacexpr.ml b/intf/vernacexpr.ml
index cabd06735f..538135f98e 100644
--- a/intf/vernacexpr.ml
+++ b/intf/vernacexpr.ml
@@ -495,10 +495,9 @@ type vernac_type =
| VtQed of vernac_qed_type
| VtProofStep of proof_step
| VtProofMode of string
- | VtQuery of vernac_part_of_script * report_with
+ | VtQuery of vernac_part_of_script * Feedback.route_id
| VtStm of vernac_control * vernac_part_of_script
| VtUnknown
-and report_with = Stateid.t * Feedback.route_id (* feedback on id/route *)
and vernac_qed_type = VtKeep | VtKeepAsAxiom | VtDrop (* Qed/Admitted, Abort *)
and vernac_start = string * opacity_guarantee * Id.t list
and vernac_sideff_type = Id.t list
diff --git a/stm/stm.ml b/stm/stm.ml
index 8ca50e2d54..071d2edf98 100644
--- a/stm/stm.ml
+++ b/stm/stm.ml
@@ -2520,23 +2520,26 @@ let process_transaction ?(newtip=Stateid.fresh ())
anomaly(str"classifier: VtBack + VtLater must imply part_of_script.")
(* Query *)
- | VtQuery (false,(report_id,route)), VtNow ->
- (try stm_vernac_interp report_id ~route x
- with e ->
- let e = CErrors.push e in
- Exninfo.iraise (State.exn_on ~valid:Stateid.dummy report_id e)); `Ok
- | VtQuery (true,(report_id,_)), w ->
- assert(Stateid.equal report_id Stateid.dummy);
+ | VtQuery (false, route), VtNow ->
+ begin
+ let query_sid = VCS.cur_tip () in
+ try stm_vernac_interp (VCS.cur_tip ()) x
+ with e ->
+ let e = CErrors.push e in
+ Exninfo.iraise (State.exn_on ~valid:Stateid.dummy query_sid e)
+ end; `Ok
+ | VtQuery (true, _route), w ->
let id = VCS.new_node ~id:newtip () in
let queue =
if !Flags.async_proofs_full then `QueryQueue (ref false)
else if Flags.(!compilation_mode = BuildVio) &&
VCS.((get_branch head).kind = `Master) &&
may_pierce_opaque x
- then `SkipQueue
+ then `SkipQueue
else `MainQueue in
VCS.commit id (mkTransCmd x [] false queue);
Backtrack.record (); if w == VtNow then finish (); `Ok
+
| VtQuery (false,_), VtLater ->
anomaly(str"classifier: VtQuery + VtLater must imply part_of_script.")
@@ -2766,7 +2769,7 @@ type focus = {
tip : Stateid.t
}
-let query ~at ?(report_with=(Stateid.dummy,default_route)) s =
+let query ~at ~route s =
Future.purify (fun s ->
if Stateid.equal at Stateid.dummy then finish ()
else Reach.known_state ~cache:`Yes at;
@@ -2779,7 +2782,7 @@ let query ~at ?(report_with=(Stateid.dummy,default_route)) s =
| VtStm (w,_), _ ->
ignore(process_transaction aast (VtStm (w,false), VtNow))
| _ ->
- ignore(process_transaction aast (VtQuery (false,report_with), VtNow)))
+ ignore(process_transaction aast (VtQuery (false, route), VtNow)))
s
let edit_at id =
diff --git a/stm/stm.mli b/stm/stm.mli
index b150f97489..188b176bab 100644
--- a/stm/stm.mli
+++ b/stm/stm.mli
@@ -34,7 +34,7 @@ val add : ontop:Stateid.t -> ?newtip:Stateid.t ->
throwing away side effects except messages. Feedback will
be sent with [report_with], which defaults to the dummy state id *)
val query :
- at:Stateid.t -> ?report_with:(Stateid.t * Feedback.route_id) -> Pcoq.Gram.coq_parsable -> unit
+ at:Stateid.t -> route:Feedback.route_id -> Pcoq.Gram.coq_parsable -> unit
(* [edit_at id] is issued to change the editing zone. [`NewTip] is returned if
the requested id is the new document tip hence the document portion following
diff --git a/stm/vernac_classifier.ml b/stm/vernac_classifier.ml
index 471e05e458..d25861d5a6 100644
--- a/stm/vernac_classifier.ml
+++ b/stm/vernac_classifier.ml
@@ -30,9 +30,7 @@ let string_of_vernac_type = function
"ProofStep " ^ string_of_parallel parallel ^
Option.default "" proof_block_detection
| VtProofMode s -> "ProofMode " ^ s
- | VtQuery (b,(id,route)) ->
- "Query " ^ string_of_in_script b ^ " report " ^ Stateid.to_string id ^
- " route " ^ string_of_int route
+ | VtQuery (b, route) -> "Query " ^ string_of_in_script b ^ " route " ^ string_of_int route
| VtStm ((VtJoinDocument|VtWait), b) -> "Stm " ^ string_of_in_script b
| VtStm (VtBack _, b) -> "Stm Back " ^ string_of_in_script b
@@ -92,8 +90,7 @@ let rec classify_vernac e =
| VernacEndProof _ | VernacExactProof _ -> VtQed VtKeep, VtLater
(* Query *)
| VernacShow _ | VernacPrint _ | VernacSearch _ | VernacLocate _
- | VernacCheckMayEval _ ->
- VtQuery (true,(Stateid.dummy,Feedback.default_route)), VtLater
+ | VernacCheckMayEval _ -> VtQuery (true,Feedback.default_route), VtLater
(* ProofStep *)
| VernacProof _
| VernacFocus _ | VernacUnfocus
@@ -213,7 +210,6 @@ let rec classify_vernac e =
make_polymorphic res
else res
-let classify_as_query =
- VtQuery (true,(Stateid.dummy,Feedback.default_route)), VtLater
+let classify_as_query = VtQuery (true,Feedback.default_route), VtLater
let classify_as_sideeff = VtSideff [], VtLater
let classify_as_proofstep = VtProofStep { parallel = `No; proof_block_detection = None}, VtLater
diff --git a/tools/fake_ide.ml b/tools/fake_ide.ml
index 932097607b..4dad16fd8c 100644
--- a/tools/fake_ide.ml
+++ b/tools/fake_ide.ml
@@ -247,16 +247,16 @@ let eval_print l coq =
let to_id, need_unfocus = get_id id in
after_edit_at (to_id, need_unfocus) (base_eval_call (edit_at to_id) coq)
| [ Tok(_,"QUERY"); Top []; Tok(_,phrase) ] ->
- eval_call (query (phrase,tip_id())) coq
+ eval_call (query (0,(phrase,tip_id()))) coq
| [ Tok(_,"QUERY"); Top [Tok(_,id)]; Tok(_,phrase) ] ->
let to_id, _ = get_id id in
- eval_call (query (phrase, to_id)) coq
+ eval_call (query (0,(phrase, to_id))) coq
| [ Tok(_,"WAIT") ] ->
let phrase = "Stm Wait." in
- eval_call (query (phrase,tip_id())) coq
+ eval_call (query (0,(phrase,tip_id()))) coq
| [ Tok(_,"JOIN") ] ->
let phrase = "Stm JoinDocument." in
- eval_call (query (phrase,tip_id())) coq
+ eval_call (query (0,(phrase,tip_id()))) coq
| [ Tok(_,"ASSERT"); Tok(_,"TIP"); Tok(_,id) ] ->
let to_id, _ = get_id id in
if not(Stateid.equal (Document.tip doc) to_id) then error "Wrong tip"
--
cgit v1.2.3
From 9c6b492355d82b6346176d884f593bbbf5bde67f Mon Sep 17 00:00:00 2001
From: Maxime Dénès
Date: Mon, 19 Jun 2017 13:32:40 +0200
Subject: Fix typo in comment.
---
lib/envars.mli | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/envars.mli b/lib/envars.mli
index edd13447fc..18b7676ce7 100644
--- a/lib/envars.mli
+++ b/lib/envars.mli
@@ -53,7 +53,7 @@ val coqroot : string
the order it gets added to the search path. *)
val coqpath : string list
-(** [camlbin ()] is the path to the ocamlfind binary. *)
+(** [camlfind ()] is the path to the ocamlfind binary. *)
val ocamlfind : unit -> string
(** [camlp4bin ()] is the path to the camlp4 binary. *)
--
cgit v1.2.3
From 396c77feb0cced3965f90f65c681e48c528636d5 Mon Sep 17 00:00:00 2001
From: Maxime Dénès
Date: Mon, 19 Jun 2017 17:40:48 +0200
Subject: Test case for bug 5578.
---
test-suite/bugs/closed/5578.v | 57 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 57 insertions(+)
create mode 100644 test-suite/bugs/closed/5578.v
diff --git a/test-suite/bugs/closed/5578.v b/test-suite/bugs/closed/5578.v
new file mode 100644
index 0000000000..5bcdaa2f18
--- /dev/null
+++ b/test-suite/bugs/closed/5578.v
@@ -0,0 +1,57 @@
+(* File reduced by coq-bug-finder from original input, then from 1549 lines to 298 lines, then from 277 lines to 133 lines, then from 985 lines to 138 lines, then from 206 lines to 139 lines, then from 203 lines to 142 lines, then from 262 lines to 152 lines, then from 567 lines to 151 lines, then from 3746 lines to 151 lines, then from 577 lines to 151 lines, then from 187 lines to 151 lines, thenfrom 981 lines to 940 lines, then from 938 lines to 175 lines, then from 589 lines to 205 lines, then from 3797 lines to 205 lines, then from 628 lines to 206 lines, then from 238 lines to 205 lines, then from 1346 lines to 213 lines, then from 633 lines to 214 lines, then from 243 lines to 213 lines, then from 5656 lines to 245 lines, then from 661 lines to 272 lines, then from 3856 lines to 352 lines, then from 1266 lines to 407 lines, then from 421 lines to 406 lines, then from 424 lines to 91 lines, then from 105 lines to 91 lines, then from 85 lines to 55 lines, then from 69 lines to 55 lines *)
+(* coqc version trunk (May 2017) compiled on May 30 2017 13:28:59 with OCaml
+4.02.3
+ coqtop version jgross-Leopard-WS:/home/jgross/Downloads/coq/coq-trunk,trunk (fd36c0451c26e44b1b7e93299d3367ad2d35fee3) *)
+
+Class Proper {A} (R : A -> A -> Prop) (m : A) := mkp : R m m.
+Definition respectful {A B} (R : A -> A -> Prop) (R' : B -> B -> Prop) (f g : A -> B) := forall x y, R x y -> R' (f x) (g y).
+Set Implicit Arguments.
+
+Class EqDec (A : Set) := {
+ eqb : A -> A -> bool ;
+ eqb_leibniz : forall x y, eqb x y = true <-> x = y
+}.
+
+Infix "?=" := eqb (at level 70) : eq_scope.
+
+Inductive Comp : Set -> Type :=
+| Bind : forall (A B : Set), Comp B -> (B -> Comp A) -> Comp A.
+
+Open Scope eq_scope.
+
+Goal forall (Rat : Set) (PositiveMap_t : Set -> Set)
+ type (t : type) (interp_type_list_message interp_type_rand interp_type_message : nat -> Set),
+ (forall eta : nat, PositiveMap_t (interp_type_rand eta) -> interp_type_list_message eta -> interp_type_message eta) ->
+ ((nat -> Rat) -> Prop) ->
+ forall (interp_type_sbool : nat -> Set) (interp_type0 : type -> nat -> Set),
+ (forall eta : nat,
+ (interp_type_list_message eta -> interp_type_message eta) -> PositiveMap_t (interp_type_rand eta) -> interp_type0 t eta)
+ -> (forall (t0 : type) (eta : nat), EqDec (interp_type0 t0 eta))
+ -> (bool -> Comp bool) -> False.
+ clear.
+ intros Rat PositiveMap_t type t interp_type_list_message interp_type_rand interp_type_message adv negligible interp_type_sbool
+ interp_type interp_term_fixed_t_x
+ EqDec_interp_type ret_bool.
+ assert (forall f adv' k
+ (lem : forall (eta : nat) (evil_rands rands : PositiveMap_t
+(interp_type_rand eta)),
+ (interp_term_fixed_t_x eta (adv eta evil_rands) rands
+ ?= interp_term_fixed_t_x eta (adv eta evil_rands) rands) = true),
+ (forall (eta : nat), Proper (respectful eq eq) (f eta))
+ -> negligible
+ (fun eta : nat =>
+ f eta (
+ (Bind (k eta) (fun rands =>
+ ret_bool (interp_term_fixed_t_x eta (adv' eta) rands ?= interp_term_fixed_t_x eta (adv' eta) rands)))))).
+ Undo.
+ assert (forall f adv' k
+ (lem : forall (eta : nat) (rands : PositiveMap_t
+(interp_type_rand eta)),
+ (interp_term_fixed_t_x eta (adv' eta) rands ?= interp_term_fixed_t_x eta (adv' eta) rands) = true),
+ (forall (eta : nat), Proper (respectful eq eq) (f eta))
+ -> negligible
+ (fun eta : nat =>
+ f eta (
+ (Bind (k eta) (fun rands =>
+ ret_bool (interp_term_fixed_t_x eta (adv' eta) rands ?= interp_term_fixed_t_x eta (adv' eta) rands)))))).
+ (* Error: Anomaly "Signature and its instance do not match." Please report at http://coq.inria.fr/bugs/. *)
\ No newline at end of file
--
cgit v1.2.3
From 21f8312738f324d1c55e4ed7c451b642c9da70e6 Mon Sep 17 00:00:00 2001
From: Emilio Jesus Gallego Arias
Date: Sun, 11 Jun 2017 06:40:29 +0200
Subject: [vernac] Remove unused hooks.
These hooks are not used (leftovers?) and IMHO they should not be.
---
vernac/command.ml | 5 -----
vernac/command.mli | 5 -----
2 files changed, 10 deletions(-)
diff --git a/vernac/command.ml b/vernac/command.ml
index 4064773561..68fa8ab888 100644
--- a/vernac/command.ml
+++ b/vernac/command.ml
@@ -167,10 +167,6 @@ let declare_global_definition ident ce local k pl imps =
let () = definition_message ident in
gr
-let declare_definition_hook = ref ignore
-let set_declare_definition_hook = (:=) declare_definition_hook
-let get_declare_definition_hook () = !declare_definition_hook
-
let warn_definition_not_visible =
CWarnings.create ~name:"definition-not-visible" ~category:"implicits"
(fun ident ->
@@ -179,7 +175,6 @@ let warn_definition_not_visible =
let declare_definition ident (local, p, k) ce pl imps hook =
let fix_exn = Future.fix_exn_of ce.const_entry_body in
- let () = !declare_definition_hook ce in
let r = match local with
| Discharge when Lib.sections_are_opened () ->
let c = SectionLocalDef ce in
diff --git a/vernac/command.mli b/vernac/command.mli
index a636bc03c5..f7d90ce607 100644
--- a/vernac/command.mli
+++ b/vernac/command.mli
@@ -23,11 +23,6 @@ val do_universe : polymorphic -> Id.t Loc.located list -> unit
val do_constraint : polymorphic ->
(Misctypes.glob_level * Univ.constraint_type * Misctypes.glob_level) list -> unit
-(** {6 Hooks for Pcoq} *)
-
-val set_declare_definition_hook : (Safe_typing.private_constants definition_entry -> unit) -> unit
-val get_declare_definition_hook : unit -> (Safe_typing.private_constants definition_entry -> unit)
-
(** {6 Definitions/Let} *)
val interp_definition :
--
cgit v1.2.3
From ec8523065abfb68aff9bd3664869224419885385 Mon Sep 17 00:00:00 2001
From: Emilio Jesus Gallego Arias
Date: Sun, 11 Jun 2017 06:54:07 +0200
Subject: [vernac] Remove forward hooks from Obligations.
This was (once again) a spurious inter-dependency, that we solve by
introducing a new module with the proper functionality. This helps in
cleaning up the code. Note that no code was changed, other than
removing the setting of the references.
---
vernac/classes.ml | 2 +-
vernac/command.ml | 63 ++++---------------------------------------------
vernac/command.mli | 7 ------
vernac/declareDef.ml | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++
vernac/declareDef.mli | 19 +++++++++++++++
vernac/obligations.ml | 11 +++------
vernac/obligations.mli | 11 ---------
vernac/vernac.mllib | 1 +
8 files changed, 92 insertions(+), 86 deletions(-)
create mode 100644 vernac/declareDef.ml
create mode 100644 vernac/declareDef.mli
diff --git a/vernac/classes.ml b/vernac/classes.ml
index 007b70bc0f..2e8ebb8531 100644
--- a/vernac/classes.ml
+++ b/vernac/classes.ml
@@ -417,7 +417,7 @@ let context poly l =
let decl = (Discharge, poly, Definition) in
let entry = Declare.definition_entry ~poly ~univs:ctx ~types:t b in
let hook = Lemmas.mk_hook (fun _ gr -> gr) in
- let _ = Command.declare_definition id decl entry [] [] hook in
+ let _ = DeclareDef.declare_definition id decl entry [] [] hook in
Lib.sections_are_opened () || Lib.is_modtype_strict ()
in
status && nstatus
diff --git a/vernac/command.ml b/vernac/command.ml
index 68fa8ab888..fd49e53243 100644
--- a/vernac/command.ml
+++ b/vernac/command.ml
@@ -145,54 +145,6 @@ let check_definition (ce, evd, _, imps) =
check_evars_are_solved (Global.env ()) evd Evd.empty;
ce
-let warn_local_declaration =
- CWarnings.create ~name:"local-declaration" ~category:"scope"
- (fun (id,kind) ->
- pr_id id ++ strbrk " is declared as a local " ++ str kind)
-
-let get_locality id ~kind = function
-| Discharge ->
- (** If a Let is defined outside a section, then we consider it as a local definition *)
- warn_local_declaration (id,kind);
- true
-| Local -> true
-| Global -> false
-
-let declare_global_definition ident ce local k pl imps =
- let local = get_locality ident ~kind:"definition" local in
- let kn = declare_constant ident ~local (DefinitionEntry ce, IsDefinition k) in
- let gr = ConstRef kn in
- let () = maybe_declare_manual_implicits false gr imps in
- let () = Universes.register_universe_binders gr pl in
- let () = definition_message ident in
- gr
-
-let warn_definition_not_visible =
- CWarnings.create ~name:"definition-not-visible" ~category:"implicits"
- (fun ident ->
- strbrk "Section definition " ++
- pr_id ident ++ strbrk " is not visible from current goals")
-
-let declare_definition ident (local, p, k) ce pl imps hook =
- let fix_exn = Future.fix_exn_of ce.const_entry_body in
- let r = match local with
- | Discharge when Lib.sections_are_opened () ->
- let c = SectionLocalDef ce in
- let _ = declare_variable ident (Lib.cwd(), c, IsDefinition k) in
- let () = definition_message ident in
- let gr = VarRef ident in
- let () = maybe_declare_manual_implicits false gr imps in
- let () = if Proof_global.there_are_pending_proofs () then
- warn_definition_not_visible ident
- in
- gr
- | Discharge | Local | Global ->
- declare_global_definition ident ce local k pl imps in
- Lemmas.call_hook fix_exn hook local r
-
-let _ = Obligations.declare_definition_ref :=
- (fun i k c imps hook -> declare_definition i k c [] imps hook)
-
let do_definition ident k pl bl red_option c ctypopt hook =
let (ce, evd, pl', imps as def) =
interp_definition pl bl (pi2 k) red_option c ctypopt
@@ -215,7 +167,7 @@ let do_definition ident k pl bl red_option c ctypopt hook =
ignore(Obligations.add_definition
ident ~term:c cty ctx ?pl ~implicits:imps ~kind:k ~hook obls)
else let ce = check_definition def in
- ignore(declare_definition ident k ce pl' imps
+ ignore(DeclareDef.declare_definition ident k ce pl' imps
(Lemmas.mk_hook
(fun l r -> Lemmas.call_hook (fun exn -> exn) hook l r;r)))
@@ -238,7 +190,7 @@ match local with
(r,Univ.Instance.empty,true)
| Global | Local | Discharge ->
- let local = get_locality ident ~kind:"axiom" local in
+ let local = DeclareDef.get_locality ident ~kind:"axiom" local in
let inl = match nl with
| NoInline -> None
| DefaultInline -> Some (Flags.get_inline_level())
@@ -871,13 +823,6 @@ let interp_fix_body env_rec evdref impls (_,ctx) fix ccl =
let build_fix_type (_,ctx) ccl = EConstr.it_mkProd_or_LetIn ccl ctx
-let declare_fix ?(opaque = false) (_,poly,_ as kind) pl ctx f ((def,_),eff) t imps =
- let ce = definition_entry ~opaque ~types:t ~poly ~univs:ctx ~eff def in
- declare_definition f kind ce pl imps (Lemmas.mk_hook (fun _ r -> r))
-
-let _ = Obligations.declare_fix_ref :=
- (fun ?opaque k ctx f d t imps -> declare_fix ?opaque k [] ctx f d t imps)
-
let prepare_recursive_declaration fixnames fixtypes fixdefs =
let defs = List.map (subst_vars (List.rev fixnames)) fixdefs in
let names = List.map (fun id -> Name id) fixnames in
@@ -1221,7 +1166,7 @@ let declare_fixpoint local poly ((fixnames,fixdefs,fixtypes),pl,ctx,fiximps) ind
let evd = Evd.restrict_universe_context evd vars in
let fixdecls = List.map Safe_typing.mk_pure_proof fixdecls in
let pl, ctx = Evd.universe_context ?names:pl evd in
- ignore (List.map4 (declare_fix (local, poly, Fixpoint) pl ctx)
+ ignore (List.map4 (DeclareDef.declare_fix (local, poly, Fixpoint) pl ctx)
fixnames fixdecls fixtypes fiximps);
(* Declare the recursive definitions *)
fixpoint_message (Some indexes) fixnames;
@@ -1252,7 +1197,7 @@ let declare_cofixpoint local poly ((fixnames,fixdefs,fixtypes),pl,ctx,fiximps) n
let evd = Evd.from_ctx ctx in
let evd = Evd.restrict_universe_context evd vars in
let pl, ctx = Evd.universe_context ?names:pl evd in
- ignore (List.map4 (declare_fix (local, poly, CoFixpoint) pl ctx)
+ ignore (List.map4 (DeclareDef.declare_fix (local, poly, CoFixpoint) pl ctx)
fixnames fixdecls fixtypes fiximps);
(* Declare the recursive definitions *)
cofixpoint_message fixnames
diff --git a/vernac/command.mli b/vernac/command.mli
index f7d90ce607..1887885de9 100644
--- a/vernac/command.mli
+++ b/vernac/command.mli
@@ -30,10 +30,6 @@ val interp_definition :
constr_expr option -> Safe_typing.private_constants definition_entry * Evd.evar_map *
Universes.universe_binders * Impargs.manual_implicits
-val declare_definition : Id.t -> definition_kind ->
- Safe_typing.private_constants definition_entry -> Universes.universe_binders -> Impargs.manual_implicits ->
- Globnames.global_reference Lemmas.declaration_hook -> Globnames.global_reference
-
val do_definition : Id.t -> definition_kind -> lident list option ->
local_binder_expr list -> red_expr option -> constr_expr ->
constr_expr option -> unit Lemmas.declaration_hook -> unit
@@ -165,6 +161,3 @@ val do_cofixpoint :
(** Utils *)
val check_mutuality : Environ.env -> Evd.evar_map -> bool -> (Id.t * types) list -> unit
-
-val declare_fix : ?opaque:bool -> definition_kind -> Universes.universe_binders -> Univ.universe_context -> Id.t ->
- Safe_typing.private_constants Entries.proof_output -> types -> Impargs.manual_implicits -> global_reference
diff --git a/vernac/declareDef.ml b/vernac/declareDef.ml
new file mode 100644
index 0000000000..d7a4fcca3d
--- /dev/null
+++ b/vernac/declareDef.ml
@@ -0,0 +1,64 @@
+(************************************************************************)
+(* v * The Coq Proof Assistant / The Coq Development Team *)
+(*
+ strbrk "Section definition " ++
+ pr_id ident ++ strbrk " is not visible from current goals")
+
+let warn_local_declaration =
+ CWarnings.create ~name:"local-declaration" ~category:"scope"
+ Pp.(fun (id,kind) ->
+ pr_id id ++ strbrk " is declared as a local " ++ str kind)
+
+let get_locality id ~kind = function
+| Discharge ->
+ (** If a Let is defined outside a section, then we consider it as a local definition *)
+ warn_local_declaration (id,kind);
+ true
+| Local -> true
+| Global -> false
+
+let declare_global_definition ident ce local k pl imps =
+ let local = get_locality ident ~kind:"definition" local in
+ let kn = declare_constant ident ~local (DefinitionEntry ce, IsDefinition k) in
+ let gr = ConstRef kn in
+ let () = maybe_declare_manual_implicits false gr imps in
+ let () = Universes.register_universe_binders gr pl in
+ let () = definition_message ident in
+ gr
+
+let declare_definition ident (local, p, k) ce pl imps hook =
+ let fix_exn = Future.fix_exn_of ce.const_entry_body in
+ let r = match local with
+ | Discharge when Lib.sections_are_opened () ->
+ let c = SectionLocalDef ce in
+ let _ = declare_variable ident (Lib.cwd(), c, IsDefinition k) in
+ let () = definition_message ident in
+ let gr = VarRef ident in
+ let () = maybe_declare_manual_implicits false gr imps in
+ let () = if Proof_global.there_are_pending_proofs () then
+ warn_definition_not_visible ident
+ in
+ gr
+ | Discharge | Local | Global ->
+ declare_global_definition ident ce local k pl imps in
+ Lemmas.call_hook fix_exn hook local r
+
+let declare_fix ?(opaque = false) (_,poly,_ as kind) pl ctx f ((def,_),eff) t imps =
+ let ce = definition_entry ~opaque ~types:t ~poly ~univs:ctx ~eff def in
+ declare_definition f kind ce pl imps (Lemmas.mk_hook (fun _ r -> r))
+
diff --git a/vernac/declareDef.mli b/vernac/declareDef.mli
new file mode 100644
index 0000000000..5dea0ba272
--- /dev/null
+++ b/vernac/declareDef.mli
@@ -0,0 +1,19 @@
+(************************************************************************)
+(* v * The Coq Proof Assistant / The Coq Development Team *)
+(* kind:string -> Decl_kinds.locality -> bool
+
+val declare_definition : Id.t -> definition_kind ->
+ Safe_typing.private_constants Entries.definition_entry -> Universes.universe_binders -> Impargs.manual_implicits ->
+ Globnames.global_reference Lemmas.declaration_hook -> Globnames.global_reference
+
+val declare_fix : ?opaque:bool -> definition_kind -> Universes.universe_binders -> Univ.universe_context -> Id.t ->
+ Safe_typing.private_constants Entries.proof_output -> Constr.types -> Impargs.manual_implicits -> Globnames.global_reference
diff --git a/vernac/obligations.ml b/vernac/obligations.ml
index 135e4c63ab..c0acdaf57d 100644
--- a/vernac/obligations.ml
+++ b/vernac/obligations.ml
@@ -22,9 +22,6 @@ open Util
module NamedDecl = Context.Named.Declaration
-let declare_fix_ref = ref (fun ?opaque _ _ _ _ _ _ -> assert false)
-let declare_definition_ref = ref (fun _ _ _ _ _ -> assert false)
-
let get_fix_exn, stm_get_fix_exn = Hook.make ()
let succfix (depth, fixrels) =
@@ -496,14 +493,12 @@ let declare_definition prg =
in
let () = progmap_remove prg in
let cst =
- !declare_definition_ref prg.prg_name
- prg.prg_kind ce prg.prg_implicits
+ DeclareDef.declare_definition prg.prg_name
+ prg.prg_kind ce [] prg.prg_implicits
(Lemmas.mk_hook (fun l r -> Lemmas.call_hook fix_exn prg.prg_hook l r prg.prg_ctx; r))
in
Universes.register_universe_binders cst pl;
cst
-
-open Pp
let rec lam_index n t acc =
match kind_of_term t with
@@ -569,7 +564,7 @@ let declare_mutual_definition l =
(* Declare the recursive definitions *)
let ctx = Evd.evar_context_universe_context first.prg_ctx in
let fix_exn = Hook.get get_fix_exn () in
- let kns = List.map4 (!declare_fix_ref ~opaque (local, poly, kind) ctx)
+ let kns = List.map4 (DeclareDef.declare_fix ~opaque (local, poly, kind) [] ctx)
fixnames fixdecls fixtypes fiximps in
(* Declare notations *)
List.iter Metasyntax.add_notation_interpretation first.prg_notations;
diff --git a/vernac/obligations.mli b/vernac/obligations.mli
index a276f9f9a3..9cbbf6082c 100644
--- a/vernac/obligations.mli
+++ b/vernac/obligations.mli
@@ -12,23 +12,12 @@ open Evd
open Names
open Pp
open Globnames
-open Decl_kinds
-
-(** Forward declaration. *)
-val declare_fix_ref : (?opaque:bool -> definition_kind -> Univ.universe_context -> Id.t ->
- Safe_typing.private_constants Entries.proof_output -> types -> Impargs.manual_implicits -> global_reference) ref
-
-val declare_definition_ref :
- (Id.t -> definition_kind ->
- Safe_typing.private_constants Entries.definition_entry -> Impargs.manual_implicits
- -> global_reference Lemmas.declaration_hook -> global_reference) ref
(* This is a hack to make it possible for Obligations to craft a Qed
* behind the scenes. The fix_exn the Stm attaches to the Future proof
* is not available here, so we provide a side channel to get it *)
val stm_get_fix_exn : (unit -> Exninfo.iexn -> Exninfo.iexn) Hook.t
-
val check_evars : env -> evar_map -> unit
val evar_dependencies : evar_map -> Evar.t -> Evar.Set.t
diff --git a/vernac/vernac.mllib b/vernac/vernac.mllib
index d631fae8a8..f74073e1f7 100644
--- a/vernac/vernac.mllib
+++ b/vernac/vernac.mllib
@@ -8,6 +8,7 @@ Metasyntax
Auto_ind_decl
Search
Indschemes
+DeclareDef
Obligations
Command
Classes
--
cgit v1.2.3
From 2e99ed199cde9495bd0f7e3c1209986bcaf77947 Mon Sep 17 00:00:00 2001
From: Enrico Tassi
Date: Tue, 20 Jun 2017 15:18:40 +0200
Subject: STM: par: report no error to UIs in non-solve mode
Used to report to the UI an Error feedback message whenever a
worker was non making any progress. This is wrong since no-progress
is fine (as long as one does not specify "solve")
---
stm/stm.ml | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/stm/stm.ml b/stm/stm.ml
index 8ca50e2d54..90f977ddbb 100644
--- a/stm/stm.ml
+++ b/stm/stm.ml
@@ -1672,7 +1672,7 @@ end (* }}} *)
and TacTask : sig
- type output = Constr.constr * Evd.evar_universe_context
+ type output = (Constr.constr * Evd.evar_universe_context) option
type task = {
t_state : Stateid.t;
t_state_fb : Stateid.t;
@@ -1681,13 +1681,12 @@ and TacTask : sig
t_goal : Goal.goal;
t_kill : unit -> unit;
t_name : string }
- exception NoProgress
include AsyncTaskQueue.Task with type task := task
end = struct (* {{{ *)
- type output = Constr.constr * Evd.evar_universe_context
+ type output = (Constr.constr * Evd.evar_universe_context) option
let forward_feedback msg = Hooks.(call forward_feedback msg)
@@ -1709,10 +1708,9 @@ end = struct (* {{{ *)
r_name : string }
type response =
- | RespBuiltSubProof of output
+ | RespBuiltSubProof of (Constr.constr * Evd.evar_universe_context)
| RespError of Pp.std_ppcmds
| RespNoProgress
- exception NoProgress
let name = ref "tacworker"
let extra_env () = [||]
@@ -1734,10 +1732,9 @@ end = struct (* {{{ *)
let use_response _ { t_assign; t_state; t_state_fb; t_kill } resp =
match resp with
- | RespBuiltSubProof o -> t_assign (`Val o); `Stay ((),[])
+ | RespBuiltSubProof o -> t_assign (`Val (Some o)); `Stay ((),[])
| RespNoProgress ->
- let e = (NoProgress, Exninfo.null) in
- t_assign (`Exn e);
+ t_assign (`Val None);
t_kill ();
`Stay ((),[])
| RespError msg ->
@@ -1848,8 +1845,8 @@ end = struct (* {{{ *)
else tclUNIT ()
else
let open Notations in
- try
- let pt, uc = Future.join f in
+ match Future.join f with
+ | Some (pt, uc) ->
stm_pperr_endline (fun () -> hov 0 (
str"g=" ++ int (Evar.repr gid) ++ spc () ++
str"t=" ++ (Printer.pr_constr pt) ++ spc () ++
@@ -1857,7 +1854,7 @@ end = struct (* {{{ *)
(if abstract then Tactics.tclABSTRACT None else (fun x -> x))
(V82.tactic (Refiner.tclPUSHEVARUNIVCONTEXT uc) <*>
Tactics.exact_no_check (EConstr.of_constr pt))
- with TacTask.NoProgress ->
+ | None ->
if solve then Tacticals.New.tclSOLVE [] else tclUNIT ()
end)
in
--
cgit v1.2.3
From 64f0a3f014e423e4f7aa4fc1dc47cb70bc0e81fa Mon Sep 17 00:00:00 2001
From: Emilio Jesus Gallego Arias
Date: Tue, 20 Jun 2017 21:55:16 +0200
Subject: [stm] Fix route setting on VtQuery
This is a fix for a mistake in
d8874dd855d748aaaf504890487ab15ffd7a677d , where we forgot to
propagate the route parameter.
---
stm/stm.ml | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/stm/stm.ml b/stm/stm.ml
index 071d2edf98..a7ed84350b 100644
--- a/stm/stm.ml
+++ b/stm/stm.ml
@@ -2523,11 +2523,12 @@ let process_transaction ?(newtip=Stateid.fresh ())
| VtQuery (false, route), VtNow ->
begin
let query_sid = VCS.cur_tip () in
- try stm_vernac_interp (VCS.cur_tip ()) x
+ try stm_vernac_interp ~route (VCS.cur_tip ()) x
with e ->
let e = CErrors.push e in
Exninfo.iraise (State.exn_on ~valid:Stateid.dummy query_sid e)
end; `Ok
+ (* Part of the script commands don't set the query route *)
| VtQuery (true, _route), w ->
let id = VCS.new_node ~id:newtip () in
let queue =
--
cgit v1.2.3
From dbeb7210109f2e70e5fb55c65257ae2abd0bc3a0 Mon Sep 17 00:00:00 2001
From: Hugo Herbelin
Date: Mon, 19 Jun 2017 07:23:47 +0200
Subject: Should fix a false negative reported by deps-order.sh.
The files deps-order.sh and deps-checksum.sh were concurrently rm-ing
the files of the other.
Courtesy of Guillaume M.
---
test-suite/misc/deps-checksum.sh | 2 +-
test-suite/misc/deps-order.sh | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/test-suite/misc/deps-checksum.sh b/test-suite/misc/deps-checksum.sh
index 1e2afb7540..e07612b84c 100755
--- a/test-suite/misc/deps-checksum.sh
+++ b/test-suite/misc/deps-checksum.sh
@@ -1,4 +1,4 @@
-rm -f misc/deps/*/*.vo
+rm -f misc/deps/A/*.vo misc/deps/B/*.vo
$coqc -R misc/deps/A A misc/deps/A/A.v
$coqc -R misc/deps/B A misc/deps/B/A.v
$coqc -R misc/deps/B A misc/deps/B/B.v
diff --git a/test-suite/misc/deps-order.sh b/test-suite/misc/deps-order.sh
index 375b706f0a..00c5eb1bd5 100755
--- a/test-suite/misc/deps-order.sh
+++ b/test-suite/misc/deps-order.sh
@@ -1,7 +1,7 @@
# Check that both coqdep and coqtop/coqc supports -R
# Check that both coqdep and coqtop/coqc takes the later -R
# See bugs 2242, 2337, 2339
-rm -f misc/deps/*/*.vo
+rm -f misc/deps/lib/*.vo misc/deps/client/*.vo
tmpoutput=`mktemp /tmp/coqcheck.XXXXXX`
$coqdep -R misc/deps/lib lib -R misc/deps/client client misc/deps/client/bar.v 2>&1 | head -n 1 > $tmpoutput
diff -u misc/deps/deps.out $tmpoutput 2>&1
--
cgit v1.2.3
From fb09983542295dc31122fbad5e01799c1f48e498 Mon Sep 17 00:00:00 2001
From: Emilio Jesus Gallego Arias
Date: Wed, 21 Jun 2017 15:07:26 +0200
Subject: [ide] Correct more merging errors.
This file doesn't want to leave us.
---
ide/texmacspp.ml | 769 -------------------------------------------------------
1 file changed, 769 deletions(-)
delete mode 100644 ide/texmacspp.ml
diff --git a/ide/texmacspp.ml b/ide/texmacspp.ml
deleted file mode 100644
index 8409c75218..0000000000
--- a/ide/texmacspp.ml
+++ /dev/null
@@ -1,769 +0,0 @@
-(************************************************************************)
-(* v * The Coq Proof Assistant / The Coq Development Team *)
-(* (List.filter (fun (a,_) -> a = attr) attrs)
- | _ -> [])
- xml_list in
- match List.flatten attrs_list with
- | [] -> (attr, "")
- | l -> (List.hd l)
-
-let backstep_loc xmllist =
- let start_att = get_fst_attr_in_xml_list "begin" xmllist in
- let stop_att = get_fst_attr_in_xml_list "end" (List.rev xmllist) in
- [start_att ; stop_att]
-
-let compare_begin_att xml1 xml2 =
- let att1 = get_fst_attr_in_xml_list "begin" [xml1] in
- let att2 = get_fst_attr_in_xml_list "begin" [xml2] in
- match att1, att2 with
- | (_, s1), (_, s2) when s1 == "" || s2 == "" -> 0
- | (_, s1), (_, s2) when int_of_string s1 > int_of_string s2 -> 1
- | (_, s1), (_, s2) when int_of_string s1 < int_of_string s2 -> -1
- | _ -> 0
-
-let xmlBeginSection ?loc name = xmlWithLoc ?loc "beginsection" ["name", name] []
-
-let xmlEndSegment ?loc name = xmlWithLoc ?loc "endsegment" ["name", name] []
-
-let xmlThm ?loc typ name xml =
- xmlWithLoc ?loc "theorem" ["type", typ; "name", name] xml
-
-let xmlDef ?loc typ name xml =
- xmlWithLoc ?loc "definition" ["type", typ; "name", name] xml
-
-let xmlNotation ?loc attr name xml =
- xmlWithLoc ?loc "notation" (("name", name) :: attr) xml
-
-let xmlReservedNotation ?loc attr name =
- xmlWithLoc ?loc "reservednotation" (("name", name) :: attr) []
-
-let xmlCst ?loc ?(attr=[]) name =
- xmlWithLoc ?loc "constant" (("name", name) :: attr) []
-
-let xmlOperator ?loc ?(attr=[]) ?(pprules=[]) name =
- xmlWithLoc ?loc "operator"
- (("name", name) :: List.map (fun (a,b) -> "format"^a,b) pprules @ attr) []
-
-let xmlApply ?loc ?(attr=[]) xml = xmlWithLoc ?loc "apply" attr xml
-
-let xmlToken ?loc ?(attr=[]) xml = xmlWithLoc ?loc "token" attr xml
-
-let xmlTyped xml = Element("typed", (backstep_loc xml), xml)
-
-let xmlReturn ?(attr=[]) xml = Element("return", attr, xml)
-
-let xmlCase xml = Element("case", [], xml)
-
-let xmlScrutinee ?(attr=[]) xml = Element("scrutinee", attr, xml)
-
-let xmlWith xml = Element("with", [], xml)
-
-let xmlAssign id xml = Element("assign", ["target",string_of_id id], [xml])
-
-let xmlInductive ?loc kind xml = xmlWithLoc ?loc "inductive" ["kind",kind] xml
-
-let xmlCoFixpoint xml = Element("cofixpoint", [], xml)
-
-let xmlFixpoint xml = Element("fixpoint", [], xml)
-
-let xmlCheck ?loc xml = xmlWithLoc ?loc "check" [] xml
-
-let xmlAssumption ?loc kind xml = xmlWithLoc ?loc "assumption" ["kind",kind] xml
-
-let xmlComment ?loc xml = xmlWithLoc ?loc "comment" [] xml
-
-let xmlCanonicalStructure ?loc attr = xmlWithLoc ?loc "canonicalstructure" attr []
-
-let xmlQed ?loc ?(attr=[]) = xmlWithLoc ?loc "qed" attr []
-
-let xmlPatvar ?loc id = xmlWithLoc ?loc "patvar" ["id", id] []
-
-let xmlReference ref =
- let name = Libnames.string_of_reference ref in
- let i, j = Option.cata Loc.unloc (0,0) (Libnames.loc_of_reference ref) in
- let b, e = string_of_int i, string_of_int j in
- Element("reference",["name", name; "begin", b; "end", e] ,[])
-
-let xmlRequire ?loc ?(attr=[]) xml = xmlWithLoc ?loc "require" attr xml
-let xmlImport ?loc ?(attr=[]) xml = xmlWithLoc ?loc "import" attr xml
-
-let xmlAddLoadPath ?loc ?(attr=[]) xml = xmlWithLoc ?loc "addloadpath" attr xml
-let xmlRemoveLoadPath ?loc ?(attr=[]) = xmlWithLoc ?loc "removeloadpath" attr
-let xmlAddMLPath ?loc ?(attr=[]) = xmlWithLoc ?loc "addmlpath" attr
-
-let xmlExtend ?loc xml = xmlWithLoc ?loc "extend" [] xml
-
-let xmlScope ?loc ?(attr=[]) action name xml =
- xmlWithLoc ?loc "scope" (["name",name;"action",action] @ attr) xml
-
-let xmlProofMode ?loc name = xmlWithLoc ?loc "proofmode" ["name",name] []
-
-let xmlProof ?loc xml = xmlWithLoc ?loc "proof" [] xml
-
-let xmlSectionSubsetDescr name ssd =
- Element("sectionsubsetdescr",["name",name],
- [PCData (Proof_using.to_string ssd)])
-
-let xmlDeclareMLModule ?loc s =
- xmlWithLoc ?loc "declarexmlmodule" []
- (List.map (fun x -> Element("path",["value",x],[])) s)
-
-(* tactics *)
-let xmlLtac ?loc xml = xmlWithLoc ?loc "ltac" [] xml
-
-(* toplevel commands *)
-let xmlGallina ?loc xml = xmlWithLoc ?loc "gallina" [] xml
-
-let xmlTODO ?loc x =
- xmlWithLoc ?loc "todo" [] [PCData (Pp.string_of_ppcmds (Ppvernac.pr_vernac x))]
-
-let string_of_name n =
- match n with
- | Anonymous -> "_"
- | Name id -> Id.to_string id
-
-let string_of_glob_sort s =
- match s with
- | GProp -> "Prop"
- | GSet -> "Set"
- | GType _ -> "Type"
-
-let string_of_cast_sort c =
- match c with
- | CastConv _ -> "CastConv"
- | CastVM _ -> "CastVM"
- | CastNative _ -> "CastNative"
- | CastCoerce -> "CastCoerce"
-
-let string_of_case_style s =
- match s with
- | LetStyle -> "Let"
- | IfStyle -> "If"
- | LetPatternStyle -> "LetPattern"
- | MatchStyle -> "Match"
- | RegularStyle -> "Regular"
-
-let attribute_of_syntax_modifier sm =
-match sm with
- | SetItemLevel (sl, NumLevel n) ->
- List.map (fun s -> ("itemlevel", s)) sl @ ["level", string_of_int n]
- | SetItemLevel (sl, NextLevel) ->
- List.map (fun s -> ("itemlevel", s)) sl @ ["level", "next"]
- | SetLevel i -> ["level", string_of_int i]
- | SetAssoc a ->
- begin match a with
- | NonA -> ["",""]
- | RightA -> ["associativity", "right"]
- | LeftA -> ["associativity", "left"]
- end
- | SetEntryType (s, _) -> ["entrytype", s]
- | SetOnlyPrinting -> ["onlyprinting", ""]
- | SetOnlyParsing -> ["onlyparsing", ""]
- | SetCompatVersion v -> ["compat", Flags.pr_version v]
- | SetFormat (system, (loc, s)) ->
- let start, stop = unlock ?loc in
- ["format-"^system, s; "begin", start; "end", stop]
-
-let string_of_assumption_kind l a many =
- match l, a, many with
- | (Discharge, Logical, true) -> "Hypotheses"
- | (Discharge, Logical, false) -> "Hypothesis"
- | (Discharge, Definitional, true) -> "Variables"
- | (Discharge, Definitional, false) -> "Variable"
- | (Global, Logical, true) -> "Axioms"
- | (Global, Logical, false) -> "Axiom"
- | (Global, Definitional, true) -> "Parameters"
- | (Global, Definitional, false) -> "Parameter"
- | (Local, Logical, true) -> "Local Axioms"
- | (Local, Logical, false) -> "Local Axiom"
- | (Local, Definitional, true) -> "Local Parameters"
- | (Local, Definitional, false) -> "Local Parameter"
- | (Global, Conjectural, _) -> "Conjecture"
- | ((Discharge | Local), Conjectural, _) -> assert false
-
-let rec pp_bindlist bl =
- let tlist =
- List.flatten
- (List.map
- (fun (loc_names, _, e) ->
- let names =
- (List.map
- (fun (loc, name) ->
- xmlCst ?loc (string_of_name name)) loc_names) in
- match e.CAst.v with
- | CHole _ -> names
- | _ -> names @ [pp_expr e])
- bl) in
- match tlist with
- | [e] -> e
- | l -> xmlTyped l
-and pp_decl_notation ((_, s), ce, sc) = (* don't know what it is for now *)
- Element ("decl_notation", ["name", s], [pp_expr ce])
-and pp_local_binder lb = (* don't know what it is for now *)
- match lb with
- | CLocalDef ((loc, nam), ce, ty) ->
- let attrs = ["name", string_of_name nam] in
- let value = match ty with
- Some t -> CAst.make ?loc:(Loc.merge_opt (constr_loc ce) (constr_loc t)) @@ CCast (ce, CastConv t)
- | None -> ce in
- pp_expr ~attr:attrs value
- | CLocalAssum (namll, _, ce) ->
- let ppl =
- List.map (fun (loc, nam) -> (xmlCst ?loc (string_of_name nam))) namll in
- xmlTyped (ppl @ [pp_expr ce])
- | CLocalPattern _ ->
- assert false
-and pp_local_decl_expr lde = (* don't know what it is for now *)
- match lde with
- | AssumExpr (_, ce) -> pp_expr ce
- | DefExpr (_, ce, _) -> pp_expr ce
-and pp_inductive_expr ((_, ((l, id),_)), lbl, ceo, _, cl_or_rdexpr) =
- (* inductive_expr *)
- let b,e = Option.cata Loc.unloc (0,0) l in
- let location = ["begin", string_of_int b; "end", string_of_int e] in
- [Element ("lident", ["name", Id.to_string id] @ location, [])] @ (* inductive name *)
- begin match cl_or_rdexpr with
- | Constructors coel -> List.map (fun (_, (_, ce)) -> pp_expr ce) coel
- | RecordDecl (_, ldewwwl) ->
- List.map (fun (((_, x), _), _) -> pp_local_decl_expr x) ldewwwl
- end @
- begin match ceo with (* don't know what it is for now *)
- | Some ce -> [pp_expr ce]
- | None -> []
- end @
- (List.map pp_local_binder lbl)
-and pp_recursion_order_expr optid roe = (* don't know what it is for now *)
- let attrs =
- match optid with
- | None -> []
- | Some (loc, id) ->
- let start, stop = unlock ?loc in
- ["begin", start; "end", stop ; "name", Id.to_string id] in
- let kind, expr =
- match roe with
- | CStructRec -> "struct", []
- | CWfRec e -> "rec", [pp_expr e]
- | CMeasureRec (e, None) -> "mesrec", [pp_expr e]
- | CMeasureRec (e, Some rel) -> "mesrec", [pp_expr e] @ [pp_expr rel] in
- Element ("recursion_order", ["kind", kind] @ attrs, expr)
-and pp_fixpoint_expr (((loc, id), pl), (optid, roe), lbl, ce, ceo) =
- (* fixpoint_expr *)
- let start, stop = unlock ?loc in
- let id = Id.to_string id in
- [Element ("lident", ["begin", start; "end", stop ; "name", id], [])] @
- (* fixpoint name *)
- [pp_recursion_order_expr optid roe] @
- (List.map pp_local_binder lbl) @
- [pp_expr ce] @
- begin match ceo with (* don't know what it is for now *)
- | Some ce -> [pp_expr ce]
- | None -> []
- end
-and pp_cofixpoint_expr (((loc, id), pl), lbl, ce, ceo) = (* cofixpoint_expr *)
- (* Nota: it is like fixpoint_expr without (optid, roe)
- * so could be merged if there is no more differences *)
- let start, stop = unlock ?loc in
- let id = Id.to_string id in
- [Element ("lident", ["begin", start; "end", stop ; "name", id], [])] @
- (* cofixpoint name *)
- (List.map pp_local_binder lbl) @
- [pp_expr ce] @
- begin match ceo with (* don't know what it is for now *)
- | Some ce -> [pp_expr ce]
- | None -> []
- end
-and pp_lident (loc, id) = xmlCst ?loc (Id.to_string id)
-and pp_simple_binder (idl, ce) = List.map pp_lident idl @ [pp_expr ce]
-and pp_cases_pattern_expr {loc ; CAst.v = cpe} =
- match cpe with
- | CPatAlias (cpe, id) ->
- xmlApply ?loc
- (xmlOperator ?loc ~attr:["name", string_of_id id] "alias" ::
- [pp_cases_pattern_expr cpe])
- | CPatCstr (ref, None, cpel2) ->
- xmlApply ?loc
- (xmlOperator ?loc "reference"
- ~attr:["name", Libnames.string_of_reference ref] ::
- [Element ("impargs", [], []);
- Element ("args", [], (List.map pp_cases_pattern_expr cpel2))])
- | CPatCstr (ref, Some cpel1, cpel2) ->
- xmlApply ?loc
- (xmlOperator ?loc "reference"
- ~attr:["name", Libnames.string_of_reference ref] ::
- [Element ("impargs", [], (List.map pp_cases_pattern_expr cpel1));
- Element ("args", [], (List.map pp_cases_pattern_expr cpel2))])
- | CPatAtom optr ->
- let attrs = match optr with
- | None -> []
- | Some r -> ["name", Libnames.string_of_reference r] in
- xmlApply ?loc (xmlOperator ?loc "atom" ~attr:attrs :: [])
- | CPatOr cpel ->
- xmlApply ?loc (xmlOperator ?loc "or" :: List.map pp_cases_pattern_expr cpel)
- | CPatNotation (n, (subst_constr, subst_rec), cpel) ->
- xmlApply ?loc
- (xmlOperator ?loc "notation" ::
- [xmlOperator ?loc n;
- Element ("subst", [],
- [Element ("subterms", [],
- List.map pp_cases_pattern_expr subst_constr);
- Element ("recsubterms", [],
- List.map
- (fun (cpel) ->
- Element ("recsubterm", [],
- List.map pp_cases_pattern_expr cpel))
- subst_rec)]);
- Element ("args", [], (List.map pp_cases_pattern_expr cpel))])
- | CPatPrim tok -> pp_token ?loc tok
- | CPatRecord rcl ->
- xmlApply ?loc
- (xmlOperator ?loc "record" ::
- List.map (fun (r, cpe) ->
- Element ("field",
- ["reference", Libnames.string_of_reference r],
- [pp_cases_pattern_expr cpe]))
- rcl)
- | CPatDelimiters (delim, cpe) ->
- xmlApply ?loc
- (xmlOperator ?loc "delimiter" ~attr:["name", delim] ::
- [pp_cases_pattern_expr cpe])
- | CPatCast _ -> assert false
-and pp_case_expr (e, name, pat) =
- match name, pat with
- | None, None -> xmlScrutinee [pp_expr e]
- | Some (loc, name), None ->
- let start, stop= unlock ?loc in
- xmlScrutinee ~attr:["name", string_of_name name;
- "begin", start; "end", stop] [pp_expr e]
- | Some (loc, name), Some p ->
- let start, stop= unlock ?loc in
- xmlScrutinee ~attr:["name", string_of_name name;
- "begin", start; "end", stop]
- [Element ("in", [], [pp_cases_pattern_expr p]) ; pp_expr e]
- | None, Some p ->
- xmlScrutinee [Element ("in", [], [pp_cases_pattern_expr p]) ; pp_expr e]
-and pp_branch_expr_list bel =
- xmlWith
- (List.map
- (fun (_, (cpel, e)) ->
- let ppcepl =
- List.map pp_cases_pattern_expr (List.flatten (List.map snd cpel)) in
- let ppe = [pp_expr e] in
- xmlCase (ppcepl @ ppe))
- bel)
-and pp_token ?loc tok =
- let tokstr =
- match tok with
- | String s -> PCData s
- | Numeral n -> PCData (to_string n) in
- xmlToken ?loc [tokstr]
-and pp_local_binder_list lbl =
- let l = (List.map pp_local_binder lbl) in
- Element ("recurse", (backstep_loc l), l)
-and pp_const_expr_list cel =
- let l = List.map pp_expr cel in
- Element ("recurse", (backstep_loc l), l)
-and pp_expr ?(attr=[]) { loc; CAst.v = e } =
- match e with
- | CRef (r, _) ->
- xmlCst ?loc:(Libnames.loc_of_reference r) ~attr (Libnames.string_of_reference r)
- | CProdN (bl, e) ->
- xmlApply ?loc
- (xmlOperator ?loc "forall" :: [pp_bindlist bl] @ [pp_expr e])
- | CApp ((_, hd), args) ->
- xmlApply ?loc ~attr (pp_expr hd :: List.map (fun (e,_) -> pp_expr e) args)
- | CAppExpl ((_, r, _), args) ->
- xmlApply ?loc ~attr
- (xmlCst ?loc:(Libnames.loc_of_reference r) (Libnames.string_of_reference r)
- :: List.map pp_expr args)
- | CNotation (notation, ([],[],[])) ->
- xmlOperator ?loc notation
- | CNotation (notation, (args, cell, lbll)) ->
- let fmts = Notation.find_notation_extra_printing_rules notation in
- let oper = xmlOperator ?loc notation ~pprules:fmts in
- let cels = List.map pp_const_expr_list cell in
- let lbls = List.map pp_local_binder_list lbll in
- let args = List.map pp_expr args in
- xmlApply ?loc (oper :: (List.sort compare_begin_att (args @ cels @ lbls)))
- | CSort(s) ->
- xmlOperator ?loc (string_of_glob_sort s)
- | CDelimiters (scope, ce) ->
- xmlApply ?loc (xmlOperator ?loc "delimiter" ~attr:["name", scope] ::
- [pp_expr ce])
- | CPrim tok -> pp_token ?loc tok
- | CGeneralization (kind, _, e) ->
- let kind= match kind with
- | Explicit -> "explicit"
- | Implicit -> "implicit" in
- xmlApply ?loc
- (xmlOperator ?loc ~attr:["kind", kind] "generalization" :: [pp_expr e])
- | CCast (e, tc) ->
- begin match tc with
- | CastConv t | CastVM t |CastNative t ->
- xmlApply ?loc
- (xmlOperator ?loc ":" ~attr:["kind", (string_of_cast_sort tc)] ::
- [pp_expr e; pp_expr t])
- | CastCoerce ->
- xmlApply ?loc
- (xmlOperator ?loc ":" ~attr:["kind", "CastCoerce"] ::
- [pp_expr e])
- end
- | CEvar (ek, cel) ->
- let ppcel = List.map (fun (id,e) -> xmlAssign id (pp_expr e)) cel in
- xmlApply ?loc
- (xmlOperator ?loc "evar" ~attr:["id", string_of_id ek] ::
- ppcel)
- | CPatVar id -> xmlPatvar ?loc (string_of_id id)
- | CHole (_, _, _) -> xmlCst ?loc ~attr "_"
- | CIf (test, (_, ret), th, el) ->
- let return = match ret with
- | None -> []
- | Some r -> [xmlReturn [pp_expr r]] in
- xmlApply ?loc
- (xmlOperator ?loc "if" ::
- return @ [pp_expr th] @ [pp_expr el])
- | CLetTuple (names, (_, ret), value, body) ->
- let return = match ret with
- | None -> []
- | Some r -> [xmlReturn [pp_expr r]] in
- xmlApply ?loc
- (xmlOperator ?loc "lettuple" ::
- return @
- (List.map (fun (loc, var) -> xmlCst ?loc (string_of_name var)) names) @
- [pp_expr value; pp_expr body])
- | CCases (sty, ret, cel, bel) ->
- let return = match ret with
- | None -> []
- | Some r -> [xmlReturn [pp_expr r]] in
- xmlApply ?loc
- (xmlOperator ?loc ~attr:["style", (string_of_case_style sty)] "match" ::
- (return @
- [Element ("scrutinees", [], List.map pp_case_expr cel)] @
- [pp_branch_expr_list bel]))
- | CRecord _ -> assert false
- | CLetIn ((varloc, var), value, typ, body) ->
- let value = match typ with
- | Some t ->
- CAst.make ?loc:(Loc.merge_opt (constr_loc value) (constr_loc t)) (CCast (value, CastConv t))
- | None -> value in
- xmlApply ?loc
- (xmlOperator ?loc "let" ::
- [xmlCst ?loc:varloc (string_of_name var) ; pp_expr value; pp_expr body])
- | CLambdaN (bl, e) ->
- xmlApply ?loc
- (xmlOperator ?loc "lambda" :: [pp_bindlist bl] @ [pp_expr e])
- | CCoFix (_, _) -> assert false
- | CFix (lid, fel) ->
- xmlApply ?loc
- (xmlOperator ?loc "fix" ::
- List.flatten (List.map
- (fun (a,b,cl,c,d) -> pp_fixpoint_expr ((a,None),b,cl,c,Some d))
- fel))
-
-let pp_comment c =
- match c with
- | CommentConstr e -> [pp_expr e]
- | CommentString s -> [Element ("string", [], [PCData s])]
- | CommentInt i -> [PCData (string_of_int i)]
-
-let rec tmpp ?loc v =
- match v with
- (* Control *)
- | VernacLoad (verbose,f) ->
- xmlWithLoc ?loc "load" ["verbose",string_of_bool verbose;"file",f] []
- | VernacTime (loc,e) ->
- xmlApply ?loc (Element("time",[],[]) ::
- [tmpp ?loc e])
- | VernacRedirect (s, (loc,e)) ->
- xmlApply ?loc (Element("redirect",["path", s],[]) ::
- [tmpp ?loc e])
- | VernacTimeout (s,e) ->
- xmlApply ?loc (Element("timeout",["val",string_of_int s],[]) ::
- [tmpp ?loc e])
- | VernacFail e -> xmlApply ?loc (Element("fail",[],[]) :: [tmpp ?loc e])
-
- (* Syntax *)
- | VernacSyntaxExtension (_, ((_, name), sml)) ->
- let attrs = List.flatten (List.map attribute_of_syntax_modifier sml) in
- xmlReservedNotation ?loc attrs name
-
- | VernacOpenCloseScope (_,(true,name)) -> xmlScope ?loc "open" name []
- | VernacOpenCloseScope (_,(false,name)) -> xmlScope ?loc "close" name []
- | VernacDelimiters (name,Some tag) ->
- xmlScope ?loc "delimit" name ~attr:["delimiter",tag] []
- | VernacDelimiters (name,None) ->
- xmlScope ?loc "undelimit" name ~attr:[] []
- | VernacInfix (_,((_,name),sml),ce,sn) ->
- let attrs = List.flatten (List.map attribute_of_syntax_modifier sml) in
- let sc_attr =
- match sn with
- | Some scope -> ["scope", scope]
- | None -> [] in
- xmlNotation ?loc (sc_attr @ attrs) name [pp_expr ce]
- | VernacNotation (_, ce, (lstr, sml), sn) ->
- let name = snd lstr in
- let attrs = List.flatten (List.map attribute_of_syntax_modifier sml) in
- let sc_attr =
- match sn with
- | Some scope -> ["scope", scope]
- | None -> [] in
- xmlNotation ?loc (sc_attr @ attrs) name [pp_expr ce]
- | VernacBindScope _ as x -> xmlTODO ?loc x
- | VernacNotationAddFormat _ as x -> xmlTODO ?loc x
- | VernacUniverse _
- | VernacConstraint _
- | VernacPolymorphic (_, _) as x -> xmlTODO ?loc x
- (* Gallina *)
- | VernacDefinition (ldk, ((_,id),_), de) ->
- let l, dk =
- match ldk with
- | Some l, dk -> (l, dk)
- | None, dk -> (Global, dk) in (* Like in ppvernac.ml, l 585 *)
- let e =
- match de with
- | ProveBody (_, ce) -> ce
- | DefineBody (_, Some _, ce, None) -> ce
- | DefineBody (_, None , ce, None) -> ce
- | DefineBody (_, Some _, ce, Some _) -> ce
- | DefineBody (_, None , ce, Some _) -> ce in
- let str_dk = Kindops.string_of_definition_kind (l, false, dk) in
- let str_id = Id.to_string id in
- (xmlDef ?loc str_dk str_id [pp_expr e])
- | VernacStartTheoremProof (tk, [ Some ((_,id),_), ([], statement, None) ], b) ->
- let str_tk = Kindops.string_of_theorem_kind tk in
- let str_id = Id.to_string id in
- (xmlThm ?loc str_tk str_id [pp_expr statement])
- | VernacStartTheoremProof _ as x -> xmlTODO ?loc x
- | VernacEndProof pe ->
- begin
- match pe with
- | Admitted -> xmlQed ?loc ?attr:None
- | Proved (_, Some ((_, id), Some tk)) ->
- let nam = Id.to_string id in
- let typ = Kindops.string_of_theorem_kind tk in
- xmlQed ?loc ~attr:["name", nam; "type", typ]
- | Proved (_, Some ((_, id), None)) ->
- let nam = Id.to_string id in
- xmlQed ?loc ~attr:["name", nam]
- | Proved _ -> xmlQed ?loc ?attr:None
- end
- | VernacExactProof _ as x -> xmlTODO ?loc x
- | VernacAssumption ((l, a), _, sbwcl) ->
- let binders = List.map (fun (_, (id, c)) -> (List.map fst id, c)) sbwcl in
- let many =
- List.length (List.flatten (List.map fst binders)) > 1 in
- let exprs =
- List.flatten (List.map pp_simple_binder binders) in
- let l = match l with Some x -> x | None -> Decl_kinds.Global in
- let kind = string_of_assumption_kind l a many in
- xmlAssumption ?loc kind exprs
- | VernacInductive (_, _, _, iednll) ->
- let kind =
- let (_, _, _, k, _), _ = List.hd iednll in
- begin
- match k with
- | Record -> "Record"
- | Structure -> "Structure"
- | Inductive_kw -> "Inductive"
- | CoInductive -> "CoInductive"
- | Class _ -> "Class"
- | Variant -> "Variant"
- end in
- let exprs =
- List.flatten (* should probably not be flattened *)
- (List.map
- (fun (ie, dnl) -> (pp_inductive_expr ie) @
- (List.map pp_decl_notation dnl)) iednll) in
- xmlInductive ?loc kind exprs
- | VernacFixpoint (_, fednll) ->
- let exprs =
- List.flatten (* should probably not be flattened *)
- (List.map
- (fun (fe, dnl) -> (pp_fixpoint_expr fe) @
- (List.map pp_decl_notation dnl)) fednll) in
- xmlFixpoint exprs
- | VernacCoFixpoint (_, cfednll) ->
- (* Nota: it is like VernacFixpoint without so could be merged *)
- let exprs =
- List.flatten (* should probably not be flattened *)
- (List.map
- (fun (cfe, dnl) -> (pp_cofixpoint_expr cfe) @
- (List.map pp_decl_notation dnl)) cfednll) in
- xmlCoFixpoint exprs
- | VernacScheme _ as x -> xmlTODO ?loc x
- | VernacCombinedScheme _ as x -> xmlTODO ?loc x
-
- (* Gallina extensions *)
- | VernacBeginSection (_, id) -> xmlBeginSection ?loc (Id.to_string id)
- | VernacEndSegment (_, id) -> xmlEndSegment ?loc (Id.to_string id)
- | VernacNameSectionHypSet _ as x -> xmlTODO ?loc x
- | VernacRequire (from, import, l) ->
- let import = match import with
- | None -> []
- | Some true -> ["export","true"]
- | Some false -> ["import","true"]
- in
- let from = match from with
- | None -> []
- | Some r -> ["from", Libnames.string_of_reference r]
- in
- xmlRequire ?loc ~attr:(from @ import) (List.map (fun ref ->
- xmlReference ref) l)
- | VernacImport (true,l) ->
- xmlImport ?loc ~attr:["export","true"] (List.map (fun ref ->
- xmlReference ref) l)
- | VernacImport (false,l) ->
- xmlImport ?loc (List.map (fun ref -> xmlReference ref) l)
- | VernacCanonical r ->
- let attr =
- match r with
- | AN (Qualid (_, q)) -> ["qualid", string_of_qualid q]
- | AN (Ident (_, id)) -> ["id", Id.to_string id]
- | ByNotation (_, (s, _)) -> ["notation", s] in
- xmlCanonicalStructure ?loc attr
- | VernacCoercion _ as x -> xmlTODO ?loc x
- | VernacIdentityCoercion _ as x -> xmlTODO ?loc x
-
- (* Type classes *)
- | VernacInstance _ as x -> xmlTODO ?loc x
-
- | VernacContext _ as x -> xmlTODO ?loc x
-
- | VernacDeclareInstances _ as x -> xmlTODO ?loc x
-
- | VernacDeclareClass _ as x -> xmlTODO ?loc x
-
- (* Modules and Module Types *)
- | VernacDeclareModule _ as x -> xmlTODO ?loc x
- | VernacDefineModule _ as x -> xmlTODO ?loc x
- | VernacDeclareModuleType _ as x -> xmlTODO ?loc x
- | VernacInclude _ as x -> xmlTODO ?loc x
-
- (* Solving *)
-
- | (VernacSolveExistential _) as x ->
- xmlLtac ?loc [PCData (Pp.string_of_ppcmds (Ppvernac.pr_vernac x))]
-
- (* Auxiliary file and library management *)
- | VernacAddLoadPath (recf,name,None) ->
- xmlAddLoadPath ?loc ~attr:["rec",string_of_bool recf;"path",name] []
- | VernacAddLoadPath (recf,name,Some dp) ->
- xmlAddLoadPath ?loc ~attr:["rec",string_of_bool recf;"path",name]
- [PCData (Names.DirPath.to_string dp)]
- | VernacRemoveLoadPath name -> xmlRemoveLoadPath ?loc ~attr:["path",name] []
- | VernacAddMLPath (recf,name) ->
- xmlAddMLPath ?loc ~attr:["rec",string_of_bool recf;"path",name] []
- | VernacDeclareMLModule sl -> xmlDeclareMLModule ?loc sl
- | VernacChdir _ as x -> xmlTODO ?loc x
-
- (* State management *)
- | VernacWriteState _ as x -> xmlTODO ?loc x
- | VernacRestoreState _ as x -> xmlTODO ?loc x
-
- (* Resetting *)
- | VernacResetName _ as x -> xmlTODO ?loc x
- | VernacResetInitial as x -> xmlTODO ?loc x
- | VernacBack _ as x -> xmlTODO ?loc x
- | VernacBackTo _ -> PCData "VernacBackTo"
-
- (* Commands *)
- | VernacCreateHintDb _ as x -> xmlTODO ?loc x
- | VernacRemoveHints _ as x -> xmlTODO ?loc x
- | VernacHints _ as x -> xmlTODO ?loc x
- | VernacSyntacticDefinition ((_, name), (idl, ce), _, _) ->
- let name = Id.to_string name in
- let attrs = List.map (fun id -> ("id", Id.to_string id)) idl in
- xmlNotation ?loc attrs name [pp_expr ce]
- | VernacDeclareImplicits _ as x -> xmlTODO ?loc x
- | VernacArguments _ as x -> xmlTODO ?loc x
- | VernacArgumentsScope _ as x -> xmlTODO ?loc x
- | VernacReserve _ as x -> xmlTODO ?loc x
- | VernacGeneralizable _ as x -> xmlTODO ?loc x
- | VernacSetOpacity _ as x -> xmlTODO ?loc x
- | VernacSetStrategy _ as x -> xmlTODO ?loc x
- | VernacUnsetOption _ as x -> xmlTODO ?loc x
- | VernacSetOption _ as x -> xmlTODO ?loc x
- | VernacSetAppendOption _ as x -> xmlTODO ?loc x
- | VernacAddOption _ as x -> xmlTODO ?loc x
- | VernacRemoveOption _ as x -> xmlTODO ?loc x
- | VernacMemOption _ as x -> xmlTODO ?loc x
- | VernacPrintOption _ as x -> xmlTODO ?loc x
- | VernacCheckMayEval (_,_,e) -> xmlCheck ?loc [pp_expr e]
- | VernacGlobalCheck _ as x -> xmlTODO ?loc x
- | VernacDeclareReduction _ as x -> xmlTODO ?loc x
- | VernacPrint _ as x -> xmlTODO ?loc x
- | VernacSearch _ as x -> xmlTODO ?loc x
- | VernacLocate _ as x -> xmlTODO ?loc x
- | VernacRegister _ as x -> xmlTODO ?loc x
- | VernacComments (cl) ->
- xmlComment ?loc (List.flatten (List.map pp_comment cl))
-
- (* Stm backdoor *)
- | VernacStm _ as x -> xmlTODO ?loc x
-
- (* Proof management *)
- | VernacGoal _ as x -> xmlTODO ?loc x
- | VernacAbort _ as x -> xmlTODO ?loc x
- | VernacAbortAll -> PCData "VernacAbortAll"
- | VernacRestart as x -> xmlTODO ?loc x
- | VernacUndo _ as x -> xmlTODO ?loc x
- | VernacUndoTo _ as x -> xmlTODO ?loc x
- | VernacBacktrack _ as x -> xmlTODO ?loc x
- | VernacFocus _ as x -> xmlTODO ?loc x
- | VernacUnfocus as x -> xmlTODO ?loc x
- | VernacUnfocused as x -> xmlTODO ?loc x
- | VernacBullet _ as x -> xmlTODO ?loc x
- | VernacSubproof _ as x -> xmlTODO ?loc x
- | VernacEndSubproof as x -> xmlTODO ?loc x
- | VernacShow _ as x -> xmlTODO ?loc x
- | VernacCheckGuard as x -> xmlTODO ?loc x
- | VernacProof (tac,using) ->
- let tac = None (** FIXME *) in
- let using = Option.map (xmlSectionSubsetDescr "using") using in
- xmlProof ?loc (Option.List.(cons tac (cons using [])))
- | VernacProofMode name -> xmlProofMode ?loc name
-
- (* Toplevel control *)
- | VernacToplevelControl _ as x -> xmlTODO ?loc x
-
- (* For extension *)
- | VernacExtend _ as x ->
- xmlExtend ?loc [PCData (Pp.string_of_ppcmds (Ppvernac.pr_vernac x))]
-
- (* Flags *)
- | VernacProgram e -> xmlApply ?loc (Element("program",[],[]) :: [tmpp ?loc e])
- | VernacLocal (b,e) ->
- xmlApply ?loc (Element("local",["flag",string_of_bool b],[]) ::
- [tmpp ?loc e])
-
-let tmpp ?loc v =
- match tmpp ?loc v with
- | Element("ltac",_,_) as x -> x
- | xml -> xmlGallina ?loc [xml]
--
cgit v1.2.3
From 94e0cbc26718fe3fecc58f6f8673f5f8abb0ce31 Mon Sep 17 00:00:00 2001
From: Emilio Jesus Gallego Arias
Date: Wed, 21 Jun 2017 15:12:21 +0200
Subject: [vernac] Remove stale bool parameter from `VernacStartTheoremProof`
`VernacStartTheoremProof` contained a stale bool parameter from 15
years ago, which is unused today.
---
API/API.mli | 2 +-
intf/vernacexpr.ml | 2 +-
parsing/g_vernac.ml4 | 2 +-
printing/ppvernac.ml | 2 +-
stm/stm.ml | 2 +-
stm/vernac_classifier.ml | 2 +-
vernac/vernacentries.ml | 10 +++-------
7 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/API/API.mli b/API/API.mli
index 1e078bb77e..9f13f51fce 100644
--- a/API/API.mli
+++ b/API/API.mli
@@ -2407,7 +2407,7 @@ sig
| VernacNotationAddFormat of string * string * string
| VernacDefinition of
(Decl_kinds.locality option * Decl_kinds.definition_object_kind) * plident * definition_expr
- | VernacStartTheoremProof of Decl_kinds.theorem_kind * proof_expr list * bool
+ | VernacStartTheoremProof of Decl_kinds.theorem_kind * proof_expr list
| VernacEndProof of proof_end
| VernacExactProof of Constrexpr.constr_expr
| VernacAssumption of (Decl_kinds.locality option * Decl_kinds.assumption_object_kind) *
diff --git a/intf/vernacexpr.ml b/intf/vernacexpr.ml
index 7c12f9df5d..31ec444707 100644
--- a/intf/vernacexpr.ml
+++ b/intf/vernacexpr.ml
@@ -331,7 +331,7 @@ type vernac_expr =
(* Gallina *)
| VernacDefinition of
(locality option * definition_object_kind) * plident * definition_expr
- | VernacStartTheoremProof of theorem_kind * proof_expr list * bool
+ | VernacStartTheoremProof of theorem_kind * proof_expr list
| VernacEndProof of proof_end
| VernacExactProof of constr_expr
| VernacAssumption of (locality option * assumption_object_kind) *
diff --git a/parsing/g_vernac.ml4 b/parsing/g_vernac.ml4
index dbd2fc4016..fe8f517a73 100644
--- a/parsing/g_vernac.ml4
+++ b/parsing/g_vernac.ml4
@@ -151,7 +151,7 @@ GEXTEND Gram
l = LIST0
[ "with"; id = pidentref; bl = binders; ":"; c = lconstr ->
(Some id,(bl,c)) ] ->
- VernacStartTheoremProof (thm, (Some id,(bl,c))::l, false)
+ VernacStartTheoremProof (thm, (Some id,(bl,c))::l)
| stre = assumption_token; nl = inline; bl = assum_list ->
VernacAssumption (stre, nl, bl)
| (kwd,stre) = assumptions_token; nl = inline; bl = assum_list ->
diff --git a/printing/ppvernac.ml b/printing/ppvernac.ml
index 4a5cfe6301..d0536a1744 100644
--- a/printing/ppvernac.ml
+++ b/printing/ppvernac.ml
@@ -698,7 +698,7 @@ open Decl_kinds
| Some cc -> str" :=" ++ spc() ++ cc))
)
- | VernacStartTheoremProof (ki,l,_) ->
+ | VernacStartTheoremProof (ki,l) ->
return (
hov 1 (pr_statement (pr_thm_token ki) (List.hd l) ++
prlist (pr_statement (spc () ++ keyword "with")) (List.tl l))
diff --git a/stm/stm.ml b/stm/stm.ml
index 071d2edf98..81bac6a1f0 100644
--- a/stm/stm.ml
+++ b/stm/stm.ml
@@ -476,7 +476,7 @@ end = struct (* {{{ *)
let mk_branch_name { expr = x } = Branch.make
(let rec aux x = match x with
| VernacDefinition (_,((_,i),_),_) -> Names.string_of_id i
- | VernacStartTheoremProof (_,[Some ((_,i),_),_],_) -> Names.string_of_id i
+ | VernacStartTheoremProof (_,[Some ((_,i),_),_]) -> Names.string_of_id i
| VernacTime (_, e)
| VernacTimeout (_, e) -> aux e
| _ -> "branch" in aux x)
diff --git a/stm/vernac_classifier.ml b/stm/vernac_classifier.ml
index 1234e15afc..50e68852f8 100644
--- a/stm/vernac_classifier.ml
+++ b/stm/vernac_classifier.ml
@@ -115,7 +115,7 @@ let rec classify_vernac e =
VtStartProof(default_proof_mode (),Doesn'tGuaranteeOpacity,[i]), VtLater
| VernacDefinition (_,((_,i),_),ProveBody _) ->
VtStartProof(default_proof_mode (),GuaranteesOpacity,[i]), VtLater
- | VernacStartTheoremProof (_,l,_) ->
+ | VernacStartTheoremProof (_,l) ->
let ids =
CList.map_filter (function (Some ((_,i),pl), _) -> Some i | _ -> None) l in
VtStartProof (default_proof_mode (),GuaranteesOpacity,ids), VtLater
diff --git a/vernac/vernacentries.ml b/vernac/vernacentries.ml
index 21f053fb9b..acd2185365 100644
--- a/vernac/vernacentries.ml
+++ b/vernac/vernacentries.ml
@@ -490,17 +490,13 @@ let vernac_definition locality p (local,k) ((loc,id as lid),pl) def =
Some (snd (Hook.get f_interp_redexp env evc r)) in
do_definition id (local,p,k) pl bl red_option c typ_opt hook)
-let vernac_start_proof locality p kind l lettop =
+let vernac_start_proof locality p kind l =
let local = enforce_locality_exp locality None in
if Dumpglob.dump () then
List.iter (fun (id, _) ->
match id with
| Some (lid,_) -> Dumpglob.dump_definition lid false "prf"
| None -> ()) l;
- if not(Proof_global.there_are_pending_proofs ()) then
- if lettop then
- user_err ~hdr:"Vernacentries.StartProof"
- (str "Let declarations can only be used in proof editing mode.");
start_proof_and_print (local, p, Proof kind) l no_hook
let vernac_end_proof ?proof = function
@@ -1937,7 +1933,7 @@ let interp ?proof ?loc locality poly c =
(* Gallina *)
| VernacDefinition (k,lid,d) -> vernac_definition locality poly k lid d
- | VernacStartTheoremProof (k,l,top) -> vernac_start_proof locality poly k l top
+ | VernacStartTheoremProof (k,l) -> vernac_start_proof locality poly k l
| VernacEndProof e -> vernac_end_proof ?proof e
| VernacExactProof c -> vernac_exact_proof c
| VernacAssumption (stre,nl,l) -> vernac_assumption locality poly stre l nl
@@ -2025,7 +2021,7 @@ let interp ?proof ?loc locality poly c =
| VernacComments l -> if_verbose Feedback.msg_info (str "Comments ok\n")
(* Proof management *)
- | VernacGoal t -> vernac_start_proof locality poly Theorem [None,([],t)] false
+ | VernacGoal t -> vernac_start_proof locality poly Theorem [None,([],t)]
| VernacFocus n -> vernac_focus n
| VernacUnfocus -> vernac_unfocus ()
| VernacUnfocused -> vernac_unfocused ()
--
cgit v1.2.3
From e9e8420df7a1799d9fcc86430c31a68820dc90c3 Mon Sep 17 00:00:00 2001
From: Théo Zimmermann
Date: Thu, 22 Jun 2017 14:38:31 +0200
Subject: Add missing definition and fix #use include;; as suggested by
@amintimany.
---
dev/top_printers.ml | 1 +
1 file changed, 1 insertion(+)
diff --git a/dev/top_printers.ml b/dev/top_printers.ml
index ff575e432c..1be72759c9 100644
--- a/dev/top_printers.ml
+++ b/dev/top_printers.ml
@@ -215,6 +215,7 @@ let ppuniverse_context_future c =
let ctx = Future.force c in
ppuniverse_context ctx
let ppcumulativity_info c = pp (Univ.pr_cumulativity_info Univ.Level.pr c)
+let ppabstract_cumulativity_info c = pp (Univ.pr_abstract_cumulativity_info Univ.Level.pr c)
let ppuniverses u = pp (UGraph.pr_universes Level.pr u)
let ppnamedcontextval e =
pp (pr_named_context (Global.env ()) Evd.empty (named_context_of_val e))
--
cgit v1.2.3
From cdd6e87e0a8df4b6af4a08353f260fb035af48fb Mon Sep 17 00:00:00 2001
From: Théo Zimmermann
Date: Thu, 22 Jun 2017 16:33:13 +0200
Subject: Ignore all PDF files.
Rules for ignoring *some* PDF files had been added one by one to `.gitignore`
but some were still missing (for the corresponding latex files in `dev`).
This rule is actually better since we are not tracking any PDF file.
---
.gitignore | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/.gitignore b/.gitignore
index 58e1d346cf..acb1100bcf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,6 +12,7 @@
*.log
*.aux
*.dvi
+*.pdf
*.blg
*.bbl
*.idx
@@ -33,7 +34,6 @@
*.tacidx
*.tacind
*.v.tex
-*.v.pdf
*.v.ps
*.v.html
*.stamp
@@ -71,7 +71,6 @@ test-suite/coq-makefile/*/theories2
test-suite/coq-makefile/*/html
test-suite/coq-makefile/*/mlihtml
test-suite/coq-makefile/*/subdir/done
-test-suite/coq-makefile/latex1/all.pdf
test-suite/coq-makefile/merlin1/.merlin
test-suite/coq-makefile/plugin-reach-outside-API-and-fail/_CoqProject
test-suite/coq-makefile/plugin-reach-outside-API-and-succeed-by-bypassing-the-API/_CoqProject
@@ -82,12 +81,10 @@ doc/common/version.tex
doc/faq/html/
doc/faq/axioms.eps
doc/faq/axioms.eps_t
-doc/faq/axioms.pdf
doc/faq/axioms.pdf_t
doc/faq/axioms.png
doc/refman/.csdp.cache
doc/refman/trace
-doc/refman/Reference-Manual.pdf
doc/refman/Reference-Manual.ps
doc/refman/Reference-Manual.html
doc/refman/Reference-Manual.out
@@ -102,19 +99,15 @@ doc/refman/heapsort.ml
doc/refman/heapsort.mli
doc/refman/html/
doc/stdlib/Library.out
-doc/stdlib/Library.pdf
doc/stdlib/Library.ps
doc/stdlib/Library.coqdoc.tex
-doc/stdlib/FullLibrary.pdf
doc/stdlib/FullLibrary.ps
doc/stdlib/FullLibrary.coqdoc.tex
doc/stdlib/html/
doc/stdlib/index-body.html
doc/stdlib/index-list.html
doc/RecTutorial/RecTutorial.html
-doc/RecTutorial/RecTutorial.pdf
doc/RecTutorial/RecTutorial.ps
-dev/doc/naming-conventions.pdf
dev/ocamldoc/*.html
dev/ocamldoc/*.css
--
cgit v1.2.3
From ee8385ef39292fd03bdbae3a7a73726d9fb65e99 Mon Sep 17 00:00:00 2001
From: Jason Gross
Date: Thu, 15 Jun 2017 18:34:26 -0400
Subject: Put plugin exports in the right compatibility file
This closes [bug #5607](https://coq.inria.fr/bugs/show_bug.cgi?id=5607).
PR #220 put the exports in the wrong compat files, presumably because it
was originally targeted to version 8.6, and this wasn't updated when it
was retargeted to version 8.7.
---
theories/Compat/Coq85.v | 3 ---
theories/Compat/Coq86.v | 4 +++-
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/theories/Compat/Coq85.v b/theories/Compat/Coq85.v
index b30ad1af88..64ba6b1e30 100644
--- a/theories/Compat/Coq85.v
+++ b/theories/Compat/Coq85.v
@@ -34,6 +34,3 @@ Global Unset Typeclasses Filtered Unification.
(** Allow silently letting unification constraints float after a "." *)
Global Unset Solve Unification Constraints.
-
-Require Export Coq.extraction.Extraction.
-Require Export Coq.funind.FunInd.
diff --git a/theories/Compat/Coq86.v b/theories/Compat/Coq86.v
index 6952fdf199..4a511d6c48 100644
--- a/theories/Compat/Coq86.v
+++ b/theories/Compat/Coq86.v
@@ -6,4 +6,6 @@
(* * GNU Lesser General Public License Version 2.1 *)
(************************************************************************)
-(** Compatibility file for making Coq act similar to Coq v8.6 *)
\ No newline at end of file
+(** Compatibility file for making Coq act similar to Coq v8.6 *)
+Require Export Coq.extraction.Extraction.
+Require Export Coq.funind.FunInd.
--
cgit v1.2.3
From d4a0e0bcc7689457340af5a3007a541b92e12301 Mon Sep 17 00:00:00 2001
From: Jason Gross
Date: Thu, 22 Jun 2017 21:07:32 -0400
Subject: Add test-suite file for funind, extraction with compat 8.6
---
test-suite/success/FunindExtraction_compat86.v | 506 +++++++++++++++++++++++++
1 file changed, 506 insertions(+)
create mode 100644 test-suite/success/FunindExtraction_compat86.v
diff --git a/test-suite/success/FunindExtraction_compat86.v b/test-suite/success/FunindExtraction_compat86.v
new file mode 100644
index 0000000000..8912197d2f
--- /dev/null
+++ b/test-suite/success/FunindExtraction_compat86.v
@@ -0,0 +1,506 @@
+(* -*- coq-prog-args: ("-compat" "8.6") -*- *)
+
+Definition iszero (n : nat) : bool :=
+ match n with
+ | O => true
+ | _ => false
+ end.
+
+Functional Scheme iszero_ind := Induction for iszero Sort Prop.
+
+Lemma toto : forall n : nat, n = 0 -> iszero n = true.
+intros x eg.
+ functional induction iszero x; simpl.
+trivial.
+inversion eg.
+Qed.
+
+
+Function ftest (n m : nat) : nat :=
+ match n with
+ | O => match m with
+ | O => 0
+ | _ => 1
+ end
+ | S p => 0
+ end.
+(* MS: FIXME: apparently can't define R_ftest_complete. Rest of the file goes through. *)
+
+Lemma test1 : forall n m : nat, ftest n m <= 2.
+intros n m.
+ functional induction ftest n m; auto.
+Qed.
+
+Lemma test2 : forall m n, ~ 2 = ftest n m.
+Proof.
+intros n m;intro H.
+functional inversion H ftest.
+Qed.
+
+Lemma test3 : forall n m, ftest n m = 0 -> (n = 0 /\ m = 0) \/ n <> 0.
+Proof.
+functional inversion 1 ftest;auto.
+Qed.
+
+
+Require Import Arith.
+Lemma test11 : forall m : nat, ftest 0 m <= 2.
+intros m.
+ functional induction ftest 0 m.
+auto.
+auto.
+auto with *.
+Qed.
+
+Function lamfix (m n : nat) {struct n } : nat :=
+ match n with
+ | O => m
+ | S p => lamfix m p
+ end.
+
+(* Parameter v1 v2 : nat. *)
+
+Lemma lamfix_lem : forall v1 v2 : nat, lamfix v1 v2 = v1.
+intros v1 v2.
+ functional induction lamfix v1 v2.
+trivial.
+assumption.
+Defined.
+
+
+
+(* polymorphic function *)
+Require Import List.
+
+Functional Scheme app_ind := Induction for app Sort Prop.
+
+Lemma appnil : forall (A : Set) (l l' : list A), l' = nil -> l = l ++ l'.
+intros A l l'.
+ functional induction app A l l'; intuition.
+ rewrite <- H0; trivial.
+Qed.
+
+
+
+
+
+Require Export Arith.
+
+
+Function trivfun (n : nat) : nat :=
+ match n with
+ | O => 0
+ | S m => trivfun m
+ end.
+
+
+(* essaie de parametre variables non locaux:*)
+
+Parameter varessai : nat.
+
+Lemma first_try : trivfun varessai = 0.
+ functional induction trivfun varessai.
+trivial.
+assumption.
+Defined.
+
+
+ Functional Scheme triv_ind := Induction for trivfun Sort Prop.
+
+Lemma bisrepetita : forall n' : nat, trivfun n' = 0.
+intros n'.
+ functional induction trivfun n'.
+trivial.
+assumption.
+Qed.
+
+
+
+
+
+
+
+Function iseven (n : nat) : bool :=
+ match n with
+ | O => true
+ | S (S m) => iseven m
+ | _ => false
+ end.
+
+
+Function funex (n : nat) : nat :=
+ match iseven n with
+ | true => n
+ | false => match n with
+ | O => 0
+ | S r => funex r
+ end
+ end.
+
+
+Function nat_equal_bool (n m : nat) {struct n} : bool :=
+ match n with
+ | O => match m with
+ | O => true
+ | _ => false
+ end
+ | S p => match m with
+ | O => false
+ | S q => nat_equal_bool p q
+ end
+ end.
+
+
+Require Export Div2.
+Require Import Nat.
+Functional Scheme div2_ind := Induction for div2 Sort Prop.
+Lemma div2_inf : forall n : nat, div2 n <= n.
+intros n.
+ functional induction div2 n.
+auto.
+auto.
+
+apply le_S.
+apply le_n_S.
+exact IHn0.
+Qed.
+
+(* reuse this lemma as a scheme:*)
+
+Function nested_lam (n : nat) : nat -> nat :=
+ match n with
+ | O => fun m : nat => 0
+ | S n' => fun m : nat => m + nested_lam n' m
+ end.
+
+
+Lemma nest : forall n m : nat, nested_lam n m = n * m.
+intros n m.
+ functional induction nested_lam n m; simpl;auto.
+Qed.
+
+
+Function essai (x : nat) (p : nat * nat) {struct x} : nat :=
+ let (n, m) := (p: nat*nat) in
+ match n with
+ | O => 0
+ | S q => match x with
+ | O => 1
+ | S r => S (essai r (q, m))
+ end
+ end.
+
+Lemma essai_essai :
+ forall (x : nat) (p : nat * nat), let (n, m) := p in 0 < n -> 0 < essai x p.
+intros x p.
+ functional induction essai x p; intros.
+inversion H.
+auto with arith.
+ auto with arith.
+Qed.
+
+Function plus_x_not_five'' (n m : nat) {struct n} : nat :=
+ let x := nat_equal_bool m 5 in
+ let y := 0 in
+ match n with
+ | O => y
+ | S q =>
+ let recapp := plus_x_not_five'' q m in
+ match x with
+ | true => S recapp
+ | false => S recapp
+ end
+ end.
+
+Lemma notplusfive'' : forall x y : nat, y = 5 -> plus_x_not_five'' x y = x.
+intros a b.
+ functional induction plus_x_not_five'' a b; intros hyp; simpl; auto.
+Qed.
+
+Lemma iseq_eq : forall n m : nat, n = m -> nat_equal_bool n m = true.
+intros n m.
+ functional induction nat_equal_bool n m; simpl; intros hyp; auto.
+rewrite <- hyp in y; simpl in y;tauto.
+inversion hyp.
+Qed.
+
+Lemma iseq_eq' : forall n m : nat, nat_equal_bool n m = true -> n = m.
+intros n m.
+ functional induction nat_equal_bool n m; simpl; intros eg; auto.
+inversion eg.
+inversion eg.
+Qed.
+
+
+Inductive istrue : bool -> Prop :=
+ istrue0 : istrue true.
+
+Functional Scheme add_ind := Induction for add Sort Prop.
+
+Lemma inf_x_plusxy' : forall x y : nat, x <= x + y.
+intros n m.
+ functional induction add n m; intros.
+auto with arith.
+auto with arith.
+Qed.
+
+
+Lemma inf_x_plusxy'' : forall x : nat, x <= x + 0.
+intros n.
+unfold plus.
+ functional induction plus n 0; intros.
+auto with arith.
+apply le_n_S.
+assumption.
+Qed.
+
+Lemma inf_x_plusxy''' : forall x : nat, x <= 0 + x.
+intros n.
+ functional induction plus 0 n; intros; auto with arith.
+Qed.
+
+Function mod2 (n : nat) : nat :=
+ match n with
+ | O => 0
+ | S (S m) => S (mod2 m)
+ | _ => 0
+ end.
+
+Lemma princ_mod2 : forall n : nat, mod2 n <= n.
+intros n.
+ functional induction mod2 n; simpl; auto with arith.
+Qed.
+
+Function isfour (n : nat) : bool :=
+ match n with
+ | S (S (S (S O))) => true
+ | _ => false
+ end.
+
+Function isononeorfour (n : nat) : bool :=
+ match n with
+ | S O => true
+ | S (S (S (S O))) => true
+ | _ => false
+ end.
+
+Lemma toto'' : forall n : nat, istrue (isfour n) -> istrue (isononeorfour n).
+intros n.
+ functional induction isononeorfour n; intros istr; simpl;
+ inversion istr.
+apply istrue0.
+destruct n. inversion istr.
+destruct n. tauto.
+destruct n. inversion istr.
+destruct n. inversion istr.
+destruct n. tauto.
+simpl in *. inversion H0.
+Qed.
+
+Lemma toto' : forall n m : nat, n = 4 -> istrue (isononeorfour n).
+intros n.
+ functional induction isononeorfour n; intros m istr; inversion istr.
+apply istrue0.
+rewrite H in y; simpl in y;tauto.
+Qed.
+
+Function ftest4 (n m : nat) : nat :=
+ match n with
+ | O => match m with
+ | O => 0
+ | S q => 1
+ end
+ | S p => match m with
+ | O => 0
+ | S r => 1
+ end
+ end.
+
+Lemma test4 : forall n m : nat, ftest n m <= 2.
+intros n m.
+ functional induction ftest n m; auto with arith.
+Qed.
+
+Lemma test4' : forall n m : nat, ftest4 (S n) m <= 2.
+intros n m.
+assert ({n0 | n0 = S n}).
+exists (S n);reflexivity.
+destruct H as [n0 H1].
+rewrite <- H1;revert H1.
+ functional induction ftest4 n0 m.
+inversion 1.
+inversion 1.
+
+auto with arith.
+auto with arith.
+Qed.
+
+Function ftest44 (x : nat * nat) (n m : nat) : nat :=
+ let (p, q) := (x: nat*nat) in
+ match n with
+ | O => match m with
+ | O => 0
+ | S q => 1
+ end
+ | S p => match m with
+ | O => 0
+ | S r => 1
+ end
+ end.
+
+Lemma test44 :
+ forall (pq : nat * nat) (n m o r s : nat), ftest44 pq n (S m) <= 2.
+intros pq n m o r s.
+ functional induction ftest44 pq n (S m).
+auto with arith.
+auto with arith.
+auto with arith.
+auto with arith.
+Qed.
+
+Function ftest2 (n m : nat) {struct n} : nat :=
+ match n with
+ | O => match m with
+ | O => 0
+ | S q => 0
+ end
+ | S p => ftest2 p m
+ end.
+
+Lemma test2' : forall n m : nat, ftest2 n m <= 2.
+intros n m.
+ functional induction ftest2 n m; simpl; intros; auto.
+Qed.
+
+Function ftest3 (n m : nat) {struct n} : nat :=
+ match n with
+ | O => 0
+ | S p => match m with
+ | O => ftest3 p 0
+ | S r => 0
+ end
+ end.
+
+Lemma test3' : forall n m : nat, ftest3 n m <= 2.
+intros n m.
+ functional induction ftest3 n m.
+intros.
+auto.
+intros.
+auto.
+intros.
+simpl.
+auto.
+Qed.
+
+Function ftest5 (n m : nat) {struct n} : nat :=
+ match n with
+ | O => 0
+ | S p => match m with
+ | O => ftest5 p 0
+ | S r => ftest5 p r
+ end
+ end.
+
+Lemma test5 : forall n m : nat, ftest5 n m <= 2.
+intros n m.
+ functional induction ftest5 n m.
+intros.
+auto.
+intros.
+auto.
+intros.
+simpl.
+auto.
+Qed.
+
+Function ftest7 (n : nat) : nat :=
+ match ftest5 n 0 with
+ | O => 0
+ | S r => 0
+ end.
+
+Lemma essai7 :
+ forall (Hrec : forall n : nat, ftest5 n 0 = 0 -> ftest7 n <= 2)
+ (Hrec0 : forall n r : nat, ftest5 n 0 = S r -> ftest7 n <= 2)
+ (n : nat), ftest7 n <= 2.
+intros hyp1 hyp2 n.
+ functional induction ftest7 n; auto.
+Qed.
+
+Function ftest6 (n m : nat) {struct n} : nat :=
+ match n with
+ | O => 0
+ | S p => match ftest5 p 0 with
+ | O => ftest6 p 0
+ | S r => ftest6 p r
+ end
+ end.
+
+
+Lemma princ6 :
+ (forall n m : nat, n = 0 -> ftest6 0 m <= 2) ->
+ (forall n m p : nat,
+ ftest6 p 0 <= 2 -> ftest5 p 0 = 0 -> n = S p -> ftest6 (S p) m <= 2) ->
+ (forall n m p r : nat,
+ ftest6 p r <= 2 -> ftest5 p 0 = S r -> n = S p -> ftest6 (S p) m <= 2) ->
+ forall x y : nat, ftest6 x y <= 2.
+intros hyp1 hyp2 hyp3 n m.
+generalize hyp1 hyp2 hyp3.
+clear hyp1 hyp2 hyp3.
+ functional induction ftest6 n m; auto.
+Qed.
+
+Lemma essai6 : forall n m : nat, ftest6 n m <= 2.
+intros n m.
+ functional induction ftest6 n m; simpl; auto.
+Qed.
+
+(* Some tests with modules *)
+Module M.
+Function test_m (n:nat) : nat :=
+ match n with
+ | 0 => 0
+ | S n => S (S (test_m n))
+ end.
+
+Lemma test_m_is_double : forall n, div2 (test_m n) = n.
+Proof.
+intros n.
+functional induction (test_m n).
+reflexivity.
+simpl;rewrite IHn0;reflexivity.
+Qed.
+End M.
+(* We redefine a new Function with the same name *)
+Function test_m (n:nat) : nat :=
+ pred n.
+
+Lemma test_m_is_pred : forall n, test_m n = pred n.
+Proof.
+intro n.
+functional induction (test_m n). (* the test_m_ind to use is the last defined saying that test_m = pred*)
+reflexivity.
+Qed.
+
+(* Checks if the dot notation are correctly treated in infos *)
+Lemma M_test_m_is_double : forall n, div2 (M.test_m n) = n.
+intro n.
+(* here we should apply M.test_m_ind *)
+functional induction (M.test_m n).
+reflexivity.
+simpl;rewrite IHn0;reflexivity.
+Qed.
+
+Import M.
+(* Now test_m is the one which defines double *)
+
+Lemma test_m_is_double : forall n, div2 (M.test_m n) = n.
+intro n.
+(* here we should apply M.test_m_ind *)
+functional induction (test_m n).
+reflexivity.
+simpl;rewrite IHn0;reflexivity.
+Qed.
+
+Extraction iszero.
--
cgit v1.2.3
From 181cb78d09ba55c7a6d62b333b26595a4fbb360a Mon Sep 17 00:00:00 2001
From: Julien Forest
Date: Fri, 23 Jun 2017 15:06:49 +0200
Subject: closing bug #4250
---
plugins/funind/indfun.ml | 78 ++++++++++++++++++++-----------------------
test-suite/bugs/closed/4250.v | 11 ++++++
2 files changed, 47 insertions(+), 42 deletions(-)
create mode 100644 test-suite/bugs/closed/4250.v
diff --git a/plugins/funind/indfun.ml b/plugins/funind/indfun.ml
index ad04e430cd..35f0929587 100644
--- a/plugins/funind/indfun.ml
+++ b/plugins/funind/indfun.ml
@@ -576,50 +576,44 @@ let map_option f = function
| Some v -> Some (f v)
open Constrexpr
-open Topconstr
-let make_assoc assoc l1 l2 =
- let fold assoc a b = match a, b with
- | (_, Name na), (_, Name id) -> Id.Map.add na id assoc
- | _, _ -> assoc
- in
- List.fold_left2 fold assoc l1 l2
-
-let rec rebuild_bl (aux,assoc) bl typ =
- match bl,typ with
- | [], _ -> (List.rev aux,replace_vars_constr_expr assoc typ,assoc)
- | (Constrexpr.CLocalAssum(nal,bk,_))::bl',typ ->
- rebuild_nal (aux,assoc) bk bl' nal (List.length nal) typ
- | (Constrexpr.CLocalDef(na,_,_))::bl',{ CAst.v = Constrexpr.CLetIn(_,nat,ty,typ') } ->
- rebuild_bl ((Constrexpr.CLocalDef(na,replace_vars_constr_expr assoc nat,Option.map (replace_vars_constr_expr assoc) ty (* ??? *))::aux),assoc)
+let rec rebuild_bl aux bl typ =
+ match bl,typ with
+ | [], _ -> List.rev aux,typ
+ | (CLocalAssum(nal,bk,_))::bl',typ ->
+ rebuild_nal aux bk bl' nal typ
+ | (CLocalDef(na,_,_))::bl',{ CAst.v = CLetIn(_,nat,ty,typ') } ->
+ rebuild_bl (Constrexpr.CLocalDef(na,nat,ty)::aux)
bl' typ'
| _ -> assert false
- and rebuild_nal (aux,assoc) bk bl' nal lnal typ =
- match nal, typ.CAst.v with
- | [], _ -> rebuild_bl (aux,assoc) bl' typ
- | _,CProdN([],typ) -> rebuild_nal (aux,assoc) bk bl' nal lnal typ
- | _,CProdN((nal',bk',nal't)::rest,typ') ->
- let lnal' = List.length nal' in
- if lnal' >= lnal
- then
- let old_nal',new_nal' = List.chop lnal nal' in
- let nassoc = make_assoc assoc old_nal' nal in
- let assum = CLocalAssum(nal,bk,replace_vars_constr_expr assoc nal't) in
- rebuild_bl ((assum :: aux), nassoc) bl'
- (if List.is_empty new_nal' && List.is_empty rest
- then typ'
- else CAst.make @@ if List.is_empty new_nal'
- then CProdN(rest,typ')
- else CProdN(((new_nal',bk',nal't)::rest),typ'))
- else
- let captured_nal,non_captured_nal = List.chop lnal' nal in
- let nassoc = make_assoc assoc nal' captured_nal in
- let assum = CLocalAssum(captured_nal,bk,replace_vars_constr_expr assoc nal't) in
- rebuild_nal ((assum :: aux), nassoc)
- bk bl' non_captured_nal (lnal - lnal') (CAst.make @@ CProdN(rest,typ'))
- | _ -> assert false
-
-let rebuild_bl (aux,assoc) bl typ = rebuild_bl (aux,assoc) bl typ
+and rebuild_nal aux bk bl' nal typ =
+ match nal,typ with
+ | _,{ CAst.v = CProdN([],typ) } -> rebuild_nal aux bk bl' nal typ
+ | [], _ -> rebuild_bl aux bl' typ
+ | na::nal,{ CAst.v = CProdN((na'::nal',bk',nal't)::rest,typ') } ->
+ if Name.equal (snd na) (snd na') || Name.is_anonymous (snd na')
+ then
+ let assum = CLocalAssum([na],bk',nal't) in
+ let new_rest = if nal' = [] then rest else ((nal',bk',nal't)::rest) in
+ rebuild_nal
+ (assum::aux)
+ bk
+ bl'
+ nal
+ (CAst.make @@ CProdN(new_rest,typ'))
+ else
+ let assum = CLocalAssum([na'],bk',nal't) in
+ let new_rest = if nal' = [] then rest else ((nal',bk',nal't)::rest) in
+ rebuild_nal
+ (assum::aux)
+ bk
+ bl'
+ (na::nal)
+ (CAst.make @@ CProdN(new_rest,typ'))
+ | _ ->
+ assert false
+
+let rebuild_bl aux bl typ = rebuild_bl aux bl typ
let recompute_binder_list (fixpoint_exprl : (Vernacexpr.fixpoint_expr * Vernacexpr.decl_notation list) list) =
let fixl,ntns = Command.extract_fixpoint_components false fixpoint_exprl in
@@ -629,7 +623,7 @@ let recompute_binder_list (fixpoint_exprl : (Vernacexpr.fixpoint_expr * Vernacex
let fixpoint_exprl_with_new_bl =
List.map2 (fun ((lna,(rec_arg_opt,rec_order),bl,ret_typ,opt_body),notation_list) fix_typ ->
- let new_bl',new_ret_type,_ = rebuild_bl ([],Id.Map.empty) bl fix_typ in
+ let new_bl',new_ret_type = rebuild_bl [] bl fix_typ in
(((lna,(rec_arg_opt,rec_order),new_bl',new_ret_type,opt_body),notation_list):(Vernacexpr.fixpoint_expr * Vernacexpr.decl_notation list))
)
fixpoint_exprl constr_expr_typel
diff --git a/test-suite/bugs/closed/4250.v b/test-suite/bugs/closed/4250.v
new file mode 100644
index 0000000000..74cacf559a
--- /dev/null
+++ b/test-suite/bugs/closed/4250.v
@@ -0,0 +1,11 @@
+Require Import FunInd.
+Require Vector.
+Generalizable All Variables.
+
+Definition f `{n:nat , u:Vector.t A n} := n.
+
+Function f2 {A:Type} {n:nat} {v:Vector.t A n} : nat := n.
+
+(* fails with "The reference A was not found in the current environment." *)
+Function f3 `{n:nat , u:Vector.t A n} := u.
+Check R_f3_complete.
\ No newline at end of file
--
cgit v1.2.3
From 10c81e90a836c8abea32bc6157976b9adf7775fa Mon Sep 17 00:00:00 2001
From: Julien Forest
Date: Thu, 29 Jun 2017 17:27:04 +0200
Subject: closing bug #5618 introduce by PR 828
---
plugins/funind/indfun.ml | 4 ++--
test-suite/bugs/closed/5618.v | 9 +++++++++
2 files changed, 11 insertions(+), 2 deletions(-)
create mode 100644 test-suite/bugs/closed/5618.v
diff --git a/plugins/funind/indfun.ml b/plugins/funind/indfun.ml
index 35f0929587..2c5dae1cde 100644
--- a/plugins/funind/indfun.ml
+++ b/plugins/funind/indfun.ml
@@ -593,7 +593,7 @@ and rebuild_nal aux bk bl' nal typ =
| na::nal,{ CAst.v = CProdN((na'::nal',bk',nal't)::rest,typ') } ->
if Name.equal (snd na) (snd na') || Name.is_anonymous (snd na')
then
- let assum = CLocalAssum([na],bk',nal't) in
+ let assum = CLocalAssum([na],bk,nal't) in
let new_rest = if nal' = [] then rest else ((nal',bk',nal't)::rest) in
rebuild_nal
(assum::aux)
@@ -602,7 +602,7 @@ and rebuild_nal aux bk bl' nal typ =
nal
(CAst.make @@ CProdN(new_rest,typ'))
else
- let assum = CLocalAssum([na'],bk',nal't) in
+ let assum = CLocalAssum([na'],bk,nal't) in
let new_rest = if nal' = [] then rest else ((nal',bk',nal't)::rest) in
rebuild_nal
(assum::aux)
diff --git a/test-suite/bugs/closed/5618.v b/test-suite/bugs/closed/5618.v
new file mode 100644
index 0000000000..ab88a88f44
--- /dev/null
+++ b/test-suite/bugs/closed/5618.v
@@ -0,0 +1,9 @@
+Require Import FunInd.
+
+Function test {T} (v : T) (x : nat) : nat :=
+ match x with
+ | 0 => 0
+ | S x' => test v x'
+ end.
+
+Check R_test_complete.
\ No newline at end of file
--
cgit v1.2.3
From 178004b174a4920118479b59900066b681326492 Mon Sep 17 00:00:00 2001
From: Théo Zimmermann
Date: Fri, 30 Jun 2017 09:06:29 +0200
Subject: Fix OS X Travis by pinning OCaml version.
---
.travis.yml | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index e7082a9eeb..d2d779d8ba 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -139,8 +139,7 @@ matrix:
- os: osx
env:
- TEST_TARGET="test-suite"
- - COMPILER="system"
- - CAMLP5_VER="6.17"
+ - COMPILER="4.02.3"
- NATIVE_COMP="no"
before_install:
- brew update
--
cgit v1.2.3