Skip to content

Commit 3a488f5

Browse files
committed
Rename LevelAlg -> Universe.t -> Sort.t, equality takes conv_pb
1 parent e4a179c commit 3a488f5

File tree

121 files changed

+7113
-7802
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+7113
-7802
lines changed

common/theories/Environment.v

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Module Type Term.
99
Parameter Inline term : Type.
1010

1111
Parameter Inline tRel : nat -> term.
12-
Parameter Inline tSort : Universe.t -> term.
12+
Parameter Inline tSort : Sort.t -> term.
1313
Parameter Inline tProd : aname -> term -> term -> term.
1414
Parameter Inline tLambda : aname -> term -> term -> term.
1515
Parameter Inline tLetIn : aname -> term -> term -> term -> term.
@@ -129,7 +129,7 @@ Module Environment (T : Term).
129129
Import T.
130130
#[global] Existing Instance subst_instance_constr.
131131

132-
Definition judgment := judgment_ Universe.t term.
132+
Definition judgment := judgment_ Sort.t term.
133133

134134
(** ** Declarations *)
135135
Notation context_decl := (context_decl term).
@@ -344,7 +344,7 @@ Module Environment (T : Term).
344344
Record one_inductive_body := {
345345
ind_name : ident;
346346
ind_indices : context; (* Indices of the inductive types, under params *)
347-
ind_sort : Universe.t; (* Sort of the inductive. *)
347+
ind_sort : Sort.t; (* Sort of the inductive. *)
348348
ind_type : term; (* Closed arity = forall mind_params, ind_indices, tSort ind_sort *)
349349
ind_kelim : allowed_eliminations; (* Allowed eliminations *)
350350
ind_ctors : list constructor_body;
@@ -856,10 +856,10 @@ Module Environment (T : Term).
856856
Definition primitive_invariants (p : prim_tag) (cdecl : constant_body) :=
857857
match p with
858858
| primInt | primFloat =>
859-
[/\ cdecl.(cst_type) = tSort Universe.type0, cdecl.(cst_body) = None &
859+
[/\ cdecl.(cst_type) = tSort Sort.type0, cdecl.(cst_body) = None &
860860
cdecl.(cst_universes) = Monomorphic_ctx]
861861
| primArray =>
862-
let s := Universe.make (Level.lvar 0) in
862+
let s := sType (Universe.make' (Level.lvar 0)) in
863863
[/\ cdecl.(cst_type) = tImpl (tSort s) (tSort s), cdecl.(cst_body) = None &
864864
cdecl.(cst_universes) = Polymorphic_ctx array_uctx]
865865
end.
@@ -1239,7 +1239,7 @@ End EnvironmentDecideReflectInstances.
12391239
Module Type TermUtils (T: Term) (E: EnvironmentSig T).
12401240
Import T E.
12411241

1242-
Parameter Inline destArity : context -> term -> option (context × Universe.t).
1242+
Parameter Inline destArity : context -> term -> option (context × Sort.t).
12431243
Parameter Inline inds : kername -> Instance.t -> list one_inductive_body -> list term.
12441244

12451245
End TermUtils.

common/theories/EnvironmentTyping.v

+36-29
Original file line numberDiff line numberDiff line change
@@ -280,16 +280,16 @@ Module Lookup (T : Term) (E : EnvironmentSig T).
280280
now rewrite H; cbn; autorewrite with len.
281281
Qed.
282282

283-
Definition wf_universe Σ s : Prop :=
284-
Universe.on_sort
285-
(fun u => forall l, LevelExprSet.In l u -> LevelSet.In (LevelExpr.get_level l) (global_ext_levels Σ))
286-
True s.
283+
Definition wf_universe Σ (u : Universe.t) : Prop :=
284+
forall l, LevelExprSet.In l u -> LevelSet.In (LevelExpr.get_level l) (global_ext_levels Σ).
287285

288-
Definition wf_universe_dec Σ s : {@wf_universe Σ s} + {~@wf_universe Σ s}.
286+
Definition wf_sort Σ (s : sort) : Prop :=
287+
Sort.on_sort (wf_universe Σ) True s.
288+
289+
Definition wf_universe_dec Σ u : {wf_universe Σ u} + {~wf_universe Σ u}.
289290
Proof.
290-
destruct s; try (left; exact I).
291-
cbv [wf_universe Universe.on_sort LevelExprSet.In LevelExprSet.this t_set].
292-
destruct t as [[t _] _].
291+
cbv [wf_universe LevelExprSet.In LevelExprSet.this t_set].
292+
destruct u as [[t _] _].
293293
induction t as [|t ts [IHt|IHt]]; [ left | | right ].
294294
{ inversion 1. }
295295
{ destruct (LevelSetProp.In_dec (LevelExpr.get_level t) (global_ext_levels Σ)) as [H|H]; [ left | right ].
@@ -298,6 +298,12 @@ Module Lookup (T : Term) (E : EnvironmentSig T).
298298
{ intro H; apply IHt; intros; apply H; now constructor. }
299299
Defined.
300300

301+
Definition wf_sort_dec Σ s : {@wf_sort Σ s} + {~@wf_sort Σ s}.
302+
Proof.
303+
destruct s; try (left; exact I).
304+
apply wf_universe_dec.
305+
Defined.
306+
301307
Lemma declared_ind_declared_constructors `{cf : checker_flags} {Σ ind mib oib} :
302308
declared_inductive Σ ind mib oib ->
303309
Alli (fun i => declared_constructor Σ (ind, i) mib oib) 0 (ind_ctors oib).
@@ -837,13 +843,13 @@ Module EnvTyping (T : Term) (E : EnvironmentSig T) (TU : TermUtils T E).
837843

838844
Section TypeLocalOver.
839845
Context (checking : context -> term -> term -> Type).
840-
Context (sorting : context -> term -> Universe.t -> Type).
846+
Context (sorting : context -> term -> sort -> Type).
841847
Context (cproperty : forall (Γ : context),
842848
All_local_env (lift_sorting1 checking sorting) Γ ->
843849
forall (t T : term), checking Γ t T -> Type).
844850
Context (sproperty : forall (Γ : context),
845851
All_local_env (lift_sorting1 checking sorting) Γ ->
846-
forall (t : term) (u : Universe.t), sorting Γ t u -> Type).
852+
forall (t : term) (u : sort), sorting Γ t u -> Type).
847853

848854
Inductive All_local_env_over_sorting :
849855
forall (Γ : context), All_local_env (lift_sorting1 checking sorting) Γ -> Type :=
@@ -971,9 +977,9 @@ Module EnvTyping (T : Term) (E : EnvironmentSig T) (TU : TermUtils T E).
971977

972978
Section lift_sorting_size_gen.
973979
Context {checking : term -> term -> Type}.
974-
Context {sorting : term -> Universe.t -> Type}.
980+
Context {sorting : term -> sort -> Type}.
975981
Context (csize : forall (t T : term), checking t T -> size).
976-
Context (ssize : forall (t : term) (u : Universe.t), sorting t u -> size).
982+
Context (ssize : forall (t : term) (u : sort), sorting t u -> size).
977983

978984
Definition lift_sorting_size_gen base j (w : lift_sorting checking sorting j) : size :=
979985
base + option_default_size (fun tm => csize tm _) (j_term j) w.1 + ssize _ _ w.2.π2.1.
@@ -1039,7 +1045,7 @@ Module EnvTyping (T : Term) (E : EnvironmentSig T) (TU : TermUtils T E).
10391045

10401046
Section All_local_env_size.
10411047
Context {checking : forall (Γ : context), term -> term -> Type}.
1042-
Context {sorting : forall (Γ : context), term -> Universe.t -> Type}.
1048+
Context {sorting : forall (Γ : context), term -> sort -> Type}.
10431049
Context (csize : forall Γ t T, checking Γ t T -> size).
10441050
Context (ssize : forall Γ t u, sorting Γ t u -> size).
10451051

@@ -1089,7 +1095,7 @@ Module EnvTyping (T : Term) (E : EnvironmentSig T) (TU : TermUtils T E).
10891095
End Regular.
10901096

10911097
Section Bidirectional.
1092-
Context {checking : context -> term -> term -> Type} {sorting : context -> term -> Universe.t -> Type}.
1098+
Context {checking : context -> term -> term -> Type} {sorting : context -> term -> sort -> Type}.
10931099
Context (checking_size : forall Γ t T, checking Γ t T -> size).
10941100
Context (sorting_size : forall Γ t s, sorting Γ t s -> size).
10951101

@@ -1172,16 +1178,16 @@ Module GlobalMaps (T: Term) (E: EnvironmentSig T) (TU : TermUtils T E) (ET: EnvT
11721178
(** For well-formedness of inductive declarations we need a way to check that a assumptions
11731179
of a given context is typable in a sort [u]. We also force well-typing of the let-ins
11741180
in any universe to imply wf_local. *)
1175-
Fixpoint type_local_ctx Σ (Γ Δ : context) (u : Universe.t) : Type :=
1181+
Fixpoint type_local_ctx Σ (Γ Δ : context) (u : sort) : Type :=
11761182
match Δ with
1177-
| [] => wf_universe Σ u
1183+
| [] => wf_sort Σ u
11781184
| {| decl_name := na; decl_body := None; decl_type := t |} :: Δ =>
11791185
type_local_ctx Σ Γ Δ u × P Σ (Γ ,,, Δ) (TypUniv t u (* na.(binder_relevance) *))
11801186
| {| decl_body := Some _; |} as d :: Δ =>
11811187
type_local_ctx Σ Γ Δ u × P Σ (Γ ,,, Δ) (j_decl d)
11821188
end.
11831189

1184-
Fixpoint sorts_local_ctx Σ (Γ Δ : context) (us : list Universe.t) : Type :=
1190+
Fixpoint sorts_local_ctx Σ (Γ Δ : context) (us : list sort) : Type :=
11851191
match Δ, us with
11861192
| [], [] => unit
11871193
| {| decl_name := na; decl_body := None; decl_type := t |} :: Δ, u :: us =>
@@ -1516,20 +1522,20 @@ Module GlobalMaps (T: Term) (E: EnvironmentSig T) (TU : TermUtils T E) (ET: EnvT
15161522

15171523
Definition check_constructors_smaller φ cunivss ind_sort :=
15181524
Forall (fun cunivs =>
1519-
Forall (fun argsort => leq_universe φ argsort ind_sort) cunivs) cunivss.
1525+
Forall (fun argsort => leq_sort φ argsort ind_sort) cunivs) cunivss.
15201526

15211527
(** This ensures that all sorts in kelim are lower
15221528
or equal to the top elimination sort, if set.
15231529
For inductives in Type we do not check [kelim] currently. *)
15241530

1525-
Definition constructor_univs := list Universe.t.
1531+
Definition constructor_univs := list sort.
15261532
(* The sorts of the arguments context (without lets) *)
15271533

15281534
Definition elim_sort_prop_ind (ind_ctors_sort : list constructor_univs) :=
15291535
match ind_ctors_sort with
15301536
| [] => (* Empty inductive proposition: *) IntoAny
15311537
| [ s ] =>
1532-
if forallb Universes.is_propositional s then
1538+
if forallb Sort.is_propositional s then
15331539
IntoAny (* Singleton elimination *)
15341540
else
15351541
IntoPropSProp (* Squashed: some arguments are higher than Prop, restrict to Prop *)
@@ -1544,23 +1550,25 @@ Module GlobalMaps (T: Term) (E: EnvironmentSig T) (TU : TermUtils T E) (ET: EnvT
15441550

15451551
Definition check_ind_sorts (Σ : global_env_ext)
15461552
params kelim ind_indices cdecls ind_sort : Type :=
1547-
if Universe.is_prop ind_sort then
1553+
match Sort.to_family ind_sort with
1554+
| Sort.fProp =>
15481555
(** The inductive is declared in the impredicative sort Prop *)
15491556
(** No universe-checking to do: any size of constructor argument is allowed,
15501557
however elimination restrictions apply. *)
15511558
(allowed_eliminations_subset kelim (elim_sort_prop_ind cdecls) : Type)
1552-
else if Universe.is_sprop ind_sort then
1559+
| Sort.fSProp =>
15531560
(** The inductive is declared in the impredicative sort SProp *)
15541561
(** No universe-checking to do: any size of constructor argument is allowed,
15551562
however elimination restrictions apply. *)
15561563
(allowed_eliminations_subset kelim (elim_sort_sprop_ind cdecls) : Type)
1557-
else
1564+
| _ =>
15581565
(** The inductive is predicative: check that all constructors arguments are
15591566
smaller than the declared universe. *)
15601567
check_constructors_smaller Σ cdecls ind_sort
15611568
× if indices_matter then
15621569
type_local_ctx Σ params ind_indices ind_sort
1563-
else True.
1570+
else True
1571+
end.
15641572

15651573
Record on_ind_body Σ mind mdecl i idecl :=
15661574
{ (** The type of the inductive must be an arity, sharing the same params
@@ -1776,7 +1784,7 @@ Module GlobalMaps (T: Term) (E: EnvironmentSig T) (TU : TermUtils T E) (ET: EnvT
17761784

17771785
Lemma type_local_ctx_impl (P Q : global_env_ext -> context -> judgment -> Type) Σ Σ' Γ Δ u :
17781786
type_local_ctx P Σ Γ Δ u ->
1779-
(forall u, wf_universe Σ u -> wf_universe Σ' u) ->
1787+
(forall u, wf_sort Σ u -> wf_sort Σ' u) ->
17801788
(forall Γ j, P Σ Γ j -> Q Σ' Γ j) ->
17811789
type_local_ctx Q Σ' Γ Δ u.
17821790
Proof.
@@ -1993,14 +2001,14 @@ Module GlobalMaps (T: Term) (E: EnvironmentSig T) (TU : TermUtils T E) (ET: EnvT
19932001
unfold check_constructors_smaller.
19942002
intro H; apply Forall_impl with (1 := H).
19952003
intros l Hl; apply Forall_impl with (1 := Hl).
1996-
intro u. now apply leq_universe_config_impl.
2004+
intro u. now apply leq_sort_config_impl.
19972005
Qed.
19982006

19992007
Lemma on_global_decl_impl_full {cf1 cf2 : checker_flags} Pcmp1 Pcmp2 P1 P2 Σ Σ' kn d :
20002008
config.impl cf1 cf2 ->
20012009
(forall Γ j, P1 Σ Γ j -> P2 Σ' Γ j) ->
20022010
(forall u Γ pb t t', Pcmp1 (Σ.1, u) Γ pb t t' -> Pcmp2 (Σ'.1, u) Γ pb t t') ->
2003-
(forall u, wf_universe Σ u -> wf_universe Σ' u) ->
2011+
(forall u, wf_sort Σ u -> wf_sort Σ' u) ->
20042012
(forall l s, @check_constructors_smaller cf1 (global_ext_constraints Σ) l s ->
20052013
@check_constructors_smaller cf2 (global_ext_constraints Σ') l s) ->
20062014
(forall u l, @on_variance cf1 Σ.1 u l -> @on_variance cf2 Σ'.1 u l) ->
@@ -2037,8 +2045,7 @@ Module GlobalMaps (T: Term) (E: EnvironmentSig T) (TU : TermUtils T E) (ET: EnvT
20372045
all: rewrite ?andb_false_r //=.
20382046
+ exact (onProjections X).
20392047
+ pose proof (ind_sorts X) as X1. unfold check_ind_sorts in *.
2040-
destruct Universe.is_prop; auto.
2041-
destruct Universe.is_sprop; auto.
2048+
destruct Sort.to_family; auto.
20422049
destruct X1 as [constr_smaller type_local_ctx].
20432050
split.
20442051
* apply Xc, constr_smaller.

common/theories/Reflect.v

+3-3
Original file line numberDiff line numberDiff line change
@@ -397,17 +397,17 @@ Ltac finish_reflect :=
397397
end);
398398
constructor; trivial; congruence.
399399

400-
Definition eqb_universes_decl x y :=
400+
Definition eqb_sorts_decl x y :=
401401
match x, y with
402402
| Monomorphic_ctx, Monomorphic_ctx => true
403403
| Polymorphic_ctx cx, Polymorphic_ctx cy => eqb cx cy
404404
| _, _ => false
405405
end.
406406

407407
#[global,program] Instance reflect_universes_decl : ReflectEq universes_decl :=
408-
{| eqb := eqb_universes_decl |}.
408+
{| eqb := eqb_sorts_decl |}.
409409
Next Obligation.
410-
unfold eqb_universes_decl.
410+
unfold eqb_sorts_decl.
411411
intros [] []; finish_reflect.
412412
Qed.
413413

0 commit comments

Comments
 (0)