aboutsummaryrefslogtreecommitdiff
path: root/kernel/univ.ml
diff options
context:
space:
mode:
authorherbelin2008-05-12 10:19:32 +0000
committerherbelin2008-05-12 10:19:32 +0000
commitbba897d5fd964bef0aa10102ef41cee1ac5fc3bb (patch)
tree0eb8625ba79a6e2f482ed9f6eea5671dea9e95a0 /kernel/univ.ml
parent30443ddaba7a0cc996216b3d692b97e0b05907fe (diff)
Changement de stratégie vis à vis du commit 10859 sur la gestion des
univers, suite à discussion avec Bruno : on franchit le cap et on ajoute le sous-typage Prop <= Set. On n'a donc plus besoin d'utiliser l'image de Prop dans la hiérarchie en dehors de la zone de calcul de la sorte la plus basse d'un inductif polymorphe (au passage, nous avons décidé de renommer Type -1 en Type 0-, pour bien indiquer qu'il se trouve au même niveau que Type 0). Coq se retrouve donc avec la hiérarchie Prop <= Set <= Type i et avec une copie de Prop (Type 0-) et une copie de Set (Type 0) dans la hiérarchie Type. En théorie, on pourrait donc supprimer "Prop Null" et "Prop Pos" de l'implémentation et ne travailler qu'avec "Type". L'ajout de Prop <= Set vaut à la fois dans le cas Set prédicatif et dans le cas Set imprédicatif (Prop et Set étant en bas de la hiérarchie, il n'y a pas d'incohérence connue). Dans le modéle ensembliste, Prop et Type 0- sont interprétés par exemple comme {{},{o}}, où "o" est un objet particulier interprétant les preuves, et il n'y a pas de Set imprédicatif. Dans un modèle de réalisabilité, Set imprédicatif est interprétable et Prop peut au choix s'interpréter comme Set ou comme booléen (cf la thèse de Miquel). Le sous-typage du côté ensembliste s'obtient en mettant au moins l'ensemble {{},{o}} dans l'interprétation de Set (ce qu'on fait de la même manière que Prop <= Type 1, avec conversion typée), et du côté réalisabilité en mettant l'ensemble {Typ(vide),Typ(unit)} dans l'interprétation de Set ("Typ" étant la coercion faisant d'un ensemble un terme), ce qui est fait dans la section 6.2.4 de la thèse d'Alexandre Miquel (modèle du CC implicite sans types inductifs). Il reste un problème pratique. Lorsqu'on donne Inductive unit:Type := tt:unit. Coq dit que unit est dans Prop. C'est correct parce qu'il n'y a pas de contraintes d'univers mais un peu déroutant même si la coercion "unit : Set" reste valide. Une suggestion est de ne rendre polymorphe que les inductifs dont on ne donne pas la sorte explicitement, comme dans Inductive unit := tt:unit. mais alors, comment indiquer l'absence de sorte explicite si le type a des paramètres réels (comme "vect") ?? PS: modification de sort_cmp dans checker/inductive.ml faite. --This line, and those below, will be ignored-- M kernel/univ.ml M kernel/univ.mli M kernel/inductive.ml M kernel/reduction.ml M kernel/indtypes.ml M checker/inductive.ml M checker/reduction.ml M pretyping/reductionops.ml M pretyping/termops.ml git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@10920 85f007b7-540e-0410-9357-904b9bb8a0f7
Diffstat (limited to 'kernel/univ.ml')
-rw-r--r--kernel/univ.ml36
1 files changed, 17 insertions, 19 deletions
diff --git a/kernel/univ.ml b/kernel/univ.ml
index aa12f0a8bd..89b4a21124 100644
--- a/kernel/univ.ml
+++ b/kernel/univ.ml
@@ -40,8 +40,8 @@ open Util
*)
type universe_level =
- | PredicativeSet
- | PredicativeLevel of Names.dir_path * int
+ | Set
+ | Level of Names.dir_path * int
type universe =
| Atom of universe_level
@@ -53,10 +53,10 @@ module UniverseOrdered = struct
end
let string_of_univ_level = function
- | PredicativeSet -> "0"
- | PredicativeLevel (d,n) -> Names.string_of_dirpath d^"."^string_of_int n
+ | Set -> "0"
+ | Level (d,n) -> Names.string_of_dirpath d^"."^string_of_int n
-let make_univ (m,n) = Atom (PredicativeLevel (m,n))
+let make_univ (m,n) = Atom (Level (m,n))
let pr_uni_level u = str (string_of_univ_level u)
@@ -78,8 +78,6 @@ let pr_uni = function
let super = function
| Atom u ->
Max ([],[u])
- | Max ([],[]) -> (* Used for polym. inductive types at the lower level *)
- Max ([],[PredicativeSet])
| Max _ ->
anomaly ("Cannot take the successor of a non variable universe:\n"^
"(maybe a bugged tactic)")
@@ -128,28 +126,28 @@ let declare_univ u g =
(* The lower predicative level of the hierarchy that contains (impredicative)
Prop and singleton inductive types *)
-let lower_univ = Max ([],[])
+let type0m_univ = Max ([],[])
-let is_lower_univ = function
+let is_type0m_univ = function
| Max ([],[]) -> true
| _ -> false
(* The level of predicative Set *)
-let type0_univ = Atom PredicativeSet
+let type0_univ = Atom Set
let is_type0_univ = function
- | Atom PredicativeSet -> true
- | Max ([PredicativeSet],[]) -> warning "Non canonical Set"; true
+ | Atom Set -> true
+ | Max ([Set],[]) -> warning "Non canonical Set"; true
| u -> false
let is_univ_variable = function
- | Atom a when a<>PredicativeSet -> true
+ | Atom a when a<>Set -> true
| _ -> false
(* When typing [Prop] and [Set], there is no constraint on the level,
hence the definition of [type1_univ], the type of [Prop] *)
-let type1_univ = Max ([],[PredicativeSet])
+let type1_univ = Max ([],[Set])
let initial_universes = UniverseMap.empty
@@ -297,7 +295,7 @@ let check_eq g u v =
let compare_greater g strict u v =
let g = declare_univ u g in
let g = declare_univ v g in
- if not strict && compare_eq g v PredicativeSet then true else
+ if not strict && compare_eq g v Set then true else
match compare g v u with
| (EQ|LE) -> not strict
| LT -> true
@@ -461,7 +459,7 @@ type constraint_function =
universe -> universe -> constraints -> constraints
let constraint_add_leq v u c =
- if v = PredicativeSet then c else Constraint.add (v,Leq,u) c
+ if v = Set then c else Constraint.add (v,Leq,u) c
let enforce_geq u v c =
match u, v with
@@ -485,7 +483,7 @@ let merge_constraints c g =
(* Temporary inductive type levels *)
let fresh_level =
- let n = ref 0 in fun () -> incr n; PredicativeLevel (Names.make_dirpath [],!n)
+ let n = ref 0 in fun () -> incr n; Level (Names.make_dirpath [],!n)
let fresh_local_univ () = Atom (fresh_level ())
@@ -612,8 +610,8 @@ module Huniv =
type t = universe
type u = Names.dir_path -> Names.dir_path
let hash_aux hdir = function
- | PredicativeSet -> PredicativeSet
- | PredicativeLevel (d,n) -> PredicativeLevel (hdir d,n)
+ | Set -> Set
+ | Level (d,n) -> Level (hdir d,n)
let hash_sub hdir = function
| Atom u -> Atom (hash_aux hdir u)
| Max (gel,gtl) ->