@@ -280,16 +280,16 @@ Module Lookup (T : Term) (E : EnvironmentSig T).
280
280
now rewrite H; cbn; autorewrite with len.
281
281
Qed .
282
282
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 Σ).
287
285
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}.
289
290
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 _] _].
293
293
induction t as [|t ts [IHt|IHt]]; [ left | | right ].
294
294
{ inversion 1. }
295
295
{ 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).
298
298
{ intro H; apply IHt; intros; apply H; now constructor. }
299
299
Defined .
300
300
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
+
301
307
Lemma declared_ind_declared_constructors `{cf : checker_flags} {Σ ind mib oib} :
302
308
declared_inductive Σ ind mib oib ->
303
309
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).
837
843
838
844
Section TypeLocalOver.
839
845
Context (checking : context -> term -> term -> Type).
840
- Context (sorting : context -> term -> Universe.t -> Type ).
846
+ Context (sorting : context -> term -> sort -> Type).
841
847
Context (cproperty : forall (Γ : context),
842
848
All_local_env (lift_sorting1 checking sorting) Γ ->
843
849
forall (t T : term), checking Γ t T -> Type ).
844
850
Context (sproperty : forall (Γ : context),
845
851
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 ).
847
853
848
854
Inductive All_local_env_over_sorting :
849
855
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).
971
977
972
978
Section lift_sorting_size_gen.
973
979
Context {checking : term -> term -> Type}.
974
- Context {sorting : term -> Universe.t -> Type }.
980
+ Context {sorting : term -> sort -> Type}.
975
981
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).
977
983
978
984
Definition lift_sorting_size_gen base j (w : lift_sorting checking sorting j) : size :=
979
985
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).
1039
1045
1040
1046
Section All_local_env_size.
1041
1047
Context {checking : forall (Γ : context), term -> term -> Type }.
1042
- Context {sorting : forall (Γ : context), term -> Universe .t -> Type }.
1048
+ Context {sorting : forall (Γ : context), term -> sort -> Type }.
1043
1049
Context (csize : forall Γ t T, checking Γ t T -> size).
1044
1050
Context (ssize : forall Γ t u, sorting Γ t u -> size).
1045
1051
@@ -1089,7 +1095,7 @@ Module EnvTyping (T : Term) (E : EnvironmentSig T) (TU : TermUtils T E).
1089
1095
End Regular.
1090
1096
1091
1097
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}.
1093
1099
Context (checking_size : forall Γ t T, checking Γ t T -> size).
1094
1100
Context (sorting_size : forall Γ t s, sorting Γ t s -> size).
1095
1101
@@ -1172,16 +1178,16 @@ Module GlobalMaps (T: Term) (E: EnvironmentSig T) (TU : TermUtils T E) (ET: EnvT
1172
1178
(** For well-formedness of inductive declarations we need a way to check that a assumptions
1173
1179
of a given context is typable in a sort [u]. We also force well-typing of the let-ins
1174
1180
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 :=
1176
1182
match Δ with
1177
- | [] => wf_universe Σ u
1183
+ | [] => wf_sort Σ u
1178
1184
| {| decl_name := na; decl_body := None; decl_type := t |} :: Δ =>
1179
1185
type_local_ctx Σ Γ Δ u × P Σ (Γ ,,, Δ) (TypUniv t u (* na.(binder_relevance) *) )
1180
1186
| {| decl_body := Some _; |} as d :: Δ =>
1181
1187
type_local_ctx Σ Γ Δ u × P Σ (Γ ,,, Δ) (j_decl d)
1182
1188
end .
1183
1189
1184
- Fixpoint sorts_local_ctx Σ (Γ Δ : context) (us : list Universe.t ) : Type :=
1190
+ Fixpoint sorts_local_ctx Σ (Γ Δ : context) (us : list sort ) : Type :=
1185
1191
match Δ, us with
1186
1192
| [], [] => unit
1187
1193
| {| 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
1516
1522
1517
1523
Definition check_constructors_smaller φ cunivss ind_sort :=
1518
1524
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.
1520
1526
1521
1527
(** This ensures that all sorts in kelim are lower
1522
1528
or equal to the top elimination sort, if set.
1523
1529
For inductives in Type we do not check [kelim] currently. *)
1524
1530
1525
- Definition constructor_univs := list Universe.t .
1531
+ Definition constructor_univs := list sort .
1526
1532
(* The sorts of the arguments context (without lets) *)
1527
1533
1528
1534
Definition elim_sort_prop_ind (ind_ctors_sort : list constructor_univs) :=
1529
1535
match ind_ctors_sort with
1530
1536
| [] => (* Empty inductive proposition: *) IntoAny
1531
1537
| [ s ] =>
1532
- if forallb Universes .is_propositional s then
1538
+ if forallb Sort .is_propositional s then
1533
1539
IntoAny (* Singleton elimination *)
1534
1540
else
1535
1541
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
1544
1550
1545
1551
Definition check_ind_sorts (Σ : global_env_ext)
1546
1552
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 =>
1548
1555
(** The inductive is declared in the impredicative sort Prop *)
1549
1556
(** No universe-checking to do: any size of constructor argument is allowed,
1550
1557
however elimination restrictions apply. *)
1551
1558
(allowed_eliminations_subset kelim (elim_sort_prop_ind cdecls) : Type )
1552
- else if Universe .is_sprop ind_sort then
1559
+ | Sort.fSProp =>
1553
1560
(** The inductive is declared in the impredicative sort SProp *)
1554
1561
(** No universe-checking to do: any size of constructor argument is allowed,
1555
1562
however elimination restrictions apply. *)
1556
1563
(allowed_eliminations_subset kelim (elim_sort_sprop_ind cdecls) : Type )
1557
- else
1564
+ | _ =>
1558
1565
(** The inductive is predicative: check that all constructors arguments are
1559
1566
smaller than the declared universe. *)
1560
1567
check_constructors_smaller Σ cdecls ind_sort
1561
1568
× if indices_matter then
1562
1569
type_local_ctx Σ params ind_indices ind_sort
1563
- else True.
1570
+ else True
1571
+ end .
1564
1572
1565
1573
Record on_ind_body Σ mind mdecl i idecl :=
1566
1574
{ (** 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
1776
1784
1777
1785
Lemma type_local_ctx_impl (P Q : global_env_ext -> context -> judgment -> Type ) Σ Σ' Γ Δ u :
1778
1786
type_local_ctx P Σ Γ Δ u ->
1779
- (forall u, wf_universe Σ u -> wf_universe Σ' u) ->
1787
+ (forall u, wf_sort Σ u -> wf_sort Σ' u) ->
1780
1788
(forall Γ j, P Σ Γ j -> Q Σ' Γ j) ->
1781
1789
type_local_ctx Q Σ' Γ Δ u.
1782
1790
Proof .
@@ -1993,14 +2001,14 @@ Module GlobalMaps (T: Term) (E: EnvironmentSig T) (TU : TermUtils T E) (ET: EnvT
1993
2001
unfold check_constructors_smaller.
1994
2002
intro H; apply Forall_impl with (1 := H).
1995
2003
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 .
1997
2005
Qed .
1998
2006
1999
2007
Lemma on_global_decl_impl_full {cf1 cf2 : checker_flags} Pcmp1 Pcmp2 P1 P2 Σ Σ' kn d :
2000
2008
config.impl cf1 cf2 ->
2001
2009
(forall Γ j, P1 Σ Γ j -> P2 Σ' Γ j) ->
2002
2010
(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) ->
2004
2012
(forall l s, @check_constructors_smaller cf1 (global_ext_constraints Σ) l s ->
2005
2013
@check_constructors_smaller cf2 (global_ext_constraints Σ') l s) ->
2006
2014
(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
2037
2045
all: rewrite ?andb_false_r //=.
2038
2046
+ exact (onProjections X).
2039
2047
+ 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.
2042
2049
destruct X1 as [constr_smaller type_local_ctx].
2043
2050
split.
2044
2051
* apply Xc, constr_smaller.
0 commit comments