aboutsummaryrefslogtreecommitdiffhomepage
path: root/library
diff options
context:
space:
mode:
authorGravatar Matthieu Sozeau <matthieu.sozeau@inria.fr>2015-10-01 18:42:38 +0200
committerGravatar Matthieu Sozeau <mattam@mattam.org>2015-10-02 15:54:13 +0200
commit4585baa53e7fa4c25e304b8136944748a7622e10 (patch)
treeb8a6b71eff51d1f1ef8367bdf420754597dcd8c3 /library
parentde648c72a79ae5ba35db166575669ca465b11770 (diff)
Univs: refined handling of assumptions
According to their polymorphic/non-polymorphic status, which imply that universe variables introduced with it are assumed to be >= or > Set respectively in the following definitions.
Diffstat (limited to 'library')
-rw-r--r--library/declare.ml11
-rw-r--r--library/global.ml6
-rw-r--r--library/global.mli6
-rw-r--r--library/lib.ml1
-rw-r--r--library/universes.ml32
5 files changed, 28 insertions, 28 deletions
diff --git a/library/declare.ml b/library/declare.ml
index 8908a2c91..ec0e1047e 100644
--- a/library/declare.ml
+++ b/library/declare.ml
@@ -42,7 +42,7 @@ type variable_declaration = DirPath.t * section_variable_entry * logical_kind
let cache_variable ((sp,_),o) =
match o with
- | Inl ctx -> Global.push_context_set ctx
+ | Inl ctx -> Global.push_context_set false ctx
| Inr (id,(p,d,mk)) ->
(* Constr raisonne sur les noms courts *)
if variable_exists id then
@@ -50,7 +50,7 @@ let cache_variable ((sp,_),o) =
let impl,opaq,poly,ctx = match d with (* Fails if not well-typed *)
| SectionLocalAssum ((ty,ctx),poly,impl) ->
- let () = Global.push_named_assum ((id,ty),ctx) in
+ let () = Global.push_named_assum ((id,ty,poly),ctx) in
let impl = if impl then Implicit else Explicit in
impl, true, poly, ctx
| SectionLocalDef (de) ->
@@ -116,8 +116,9 @@ let open_constant i ((sp,kn), obj) =
match (Global.lookup_constant con).const_body with
| (Def _ | Undef _) -> ()
| OpaqueDef lc ->
- match Opaqueproof.get_constraints (Global.opaque_tables ())lc with
- | Some f when Future.is_val f -> Global.push_context_set (Future.force f)
+ match Opaqueproof.get_constraints (Global.opaque_tables ()) lc with
+ | Some f when Future.is_val f ->
+ Global.push_context_set false (Future.force f)
| _ -> ()
let exists_name id =
@@ -462,7 +463,7 @@ let do_universe l =
Univ.ContextSet.add_universe lev ctx))
(glob, Univ.ContextSet.empty) l
in
- Global.push_context_set ctx;
+ Global.push_context_set false ctx;
Lib.add_anonymous_leaf (input_universes glob')
diff --git a/library/global.ml b/library/global.ml
index 0419799b6..382abb846 100644
--- a/library/global.ml
+++ b/library/global.ml
@@ -80,8 +80,8 @@ let i2l = Label.of_id
let push_named_assum a = globalize0 (Safe_typing.push_named_assum a)
let push_named_def d = globalize0 (Safe_typing.push_named_def d)
let add_constraints c = globalize0 (Safe_typing.add_constraints c)
-let push_context_set c = globalize0 (Safe_typing.push_context_set c)
-let push_context c = globalize0 (Safe_typing.push_context c)
+let push_context_set b c = globalize0 (Safe_typing.push_context_set b c)
+let push_context b c = globalize0 (Safe_typing.push_context b c)
let set_engagement c = globalize0 (Safe_typing.set_engagement c)
let add_constant dir id d = globalize (Safe_typing.add_constant dir (i2l id) d)
@@ -249,7 +249,7 @@ let current_dirpath () =
let with_global f =
let (a, ctx) = f (env ()) (current_dirpath ()) in
- push_context_set ctx; a
+ push_context_set false ctx; a
(* spiwack: register/unregister functions for retroknowledge *)
let register field value by_clause =
diff --git a/library/global.mli b/library/global.mli
index 363bb5789..e6b5c1cba 100644
--- a/library/global.mli
+++ b/library/global.mli
@@ -30,7 +30,7 @@ val set_engagement : Declarations.engagement -> unit
(** Variables, Local definitions, constants, inductive types *)
-val push_named_assum : (Id.t * Constr.types) Univ.in_universe_context_set -> unit
+val push_named_assum : (Id.t * Constr.types * bool) Univ.in_universe_context_set -> unit
val push_named_def : (Id.t * Entries.definition_entry) -> unit
val add_constant :
@@ -41,8 +41,8 @@ val add_mind :
(** Extra universe constraints *)
val add_constraints : Univ.constraints -> unit
-val push_context : Univ.universe_context -> unit
-val push_context_set : Univ.universe_context_set -> unit
+val push_context : bool -> Univ.universe_context -> unit
+val push_context_set : bool -> Univ.universe_context_set -> unit
(** Non-interactive modules and module types *)
diff --git a/library/lib.ml b/library/lib.ml
index 81db547ef..f4f52db53 100644
--- a/library/lib.ml
+++ b/library/lib.ml
@@ -420,6 +420,7 @@ let extract_hyps (secs,ohyps) =
in aux (secs,ohyps)
let instance_from_variable_context sign =
+
let rec inst_rec = function
| (id,b,None,_) :: sign -> id :: inst_rec sign
| _ :: sign -> inst_rec sign
diff --git a/library/universes.ml b/library/universes.ml
index 9bc21b0e5..bc42cc044 100644
--- a/library/universes.ml
+++ b/library/universes.ml
@@ -849,19 +849,20 @@ let normalize_context_set ctx us algs =
ctx Univ.empty_universes
in
let g =
- Univ.Constraint.fold (fun (l, d, r) g ->
- let g =
- if not (Level.is_small l || LSet.mem l ctx) then
- try Univ.add_universe l false g
- with Univ.AlreadyDeclared -> g
- else g
- in
- let g =
- if not (Level.is_small r || LSet.mem r ctx) then
- try Univ.add_universe r false g
- with Univ.AlreadyDeclared -> g
- else g
- in g) csts g
+ Univ.Constraint.fold
+ (fun (l, d, r) g ->
+ let g =
+ if not (Level.is_small l || LSet.mem l ctx) then
+ try Univ.add_universe l false g
+ with Univ.AlreadyDeclared -> g
+ else g
+ in
+ let g =
+ if not (Level.is_small r || LSet.mem r ctx) then
+ try Univ.add_universe r false g
+ with Univ.AlreadyDeclared -> g
+ else g
+ in g) csts g
in
let g = Univ.Constraint.fold Univ.enforce_constraint csts g in
Univ.constraints_of_universes g
@@ -870,10 +871,7 @@ let normalize_context_set ctx us algs =
Constraint.fold (fun (l,d,r as cstr) noneqs ->
if d == Eq then (UF.union l r uf; noneqs)
else (* We ignore the trivial Prop/Set <= i constraints. *)
- if d == Le && Univ.Level.is_small l then
- noneqs
- else if Level.is_small l && d == Lt && not (LSet.mem r ctx) then
- noneqs
+ if d == Le && Univ.Level.is_small l then noneqs
else Constraint.add cstr noneqs)
csts Constraint.empty
in