@@ -217,18 +217,13 @@ Record judgment_ {universe Term} := Judge {
217
217
j_term : option Term ;
218
218
j_typ : Term ;
219
219
j_univ : option universe;
220
- (* rel : option relevance; *)
220
+ (* j_rel : option relevance; *)
221
221
}.
222
222
Arguments judgment_ : clear implicits.
223
223
Arguments Judge {universe Term } _ _ _.
224
- Notation Typ typ := (Judge None typ None).
225
- Notation TermTyp tm ty := (Judge (Some tm) ty None).
226
- Notation TermoptTyp tm typ := (Judge tm typ None).
227
- Notation TypUniv ty u := (Judge None ty (Some u)).
228
- Notation TermTypUniv tm ty u := (Judge (Some tm) ty (Some u)).
229
224
230
225
Definition judgment_map {univ T A} (f: T -> A) (j : judgment_ univ T) :=
231
- Judge (option_map f (j_term j)) (f (j_typ j)) (j_univ j) (* rel *) .
226
+ Judge (option_map f (j_term j)) (f (j_typ j)) (j_univ j) (* (j_rel j) *) .
232
227
233
228
Section Contexts.
234
229
Context {term : Type}.
@@ -244,8 +239,15 @@ End Contexts.
244
239
245
240
Arguments context_decl : clear implicits.
246
241
247
- Definition judgment_of_decl {term universe} d : judgment_ term universe :=
248
- TermoptTyp (decl_body d) (decl_type d).
242
+ Notation Typ typ := (Judge None typ None).
243
+ Notation TermTyp tm ty := (Judge (Some tm) ty None).
244
+ Notation TermoptTyp tm typ := (Judge tm typ None).
245
+ Notation TypUniv ty u := (Judge None ty (Some u)).
246
+ Notation TermTypUniv tm ty u := (Judge (Some tm) ty (Some u)).
247
+
248
+ Notation j_vass na ty := (Typ ty (* na.(binder_relevance) *)).
249
+ Notation j_vdef na b ty := (TermTyp b ty (* na.(binder_relevance) *)).
250
+ Notation j_decl d := (TermoptTyp (decl_body d) (decl_type d) (* (decl_name d).(binder_relevance) *)).
249
251
250
252
251
253
Definition map_decl {term term'} (f : term -> term') (d : context_decl term) : context_decl term' :=
@@ -314,8 +316,46 @@ Definition snoc {A} (Γ : list A) (d : A) := d :: Γ.
314
316
315
317
Notation " Γ ,, d " := (snoc Γ d) (at level 20, d at next level).
316
318
319
+ Definition app_context {A} (Γ Γ': list A) := Γ' ++ Γ.
320
+
321
+ Notation "Γ ,,, Γ'" := (app_context Γ Γ') (at level 25, Γ' at next level, left associativity).
322
+
323
+ Lemma app_context_nil_l {T} Γ : [] ,,, Γ = Γ :> list T.
324
+ Proof .
325
+ unfold app_context. rewrite app_nil_r. reflexivity.
326
+ Qed .
327
+
328
+ Lemma app_context_assoc {T} Γ Γ' Γ'' : Γ ,,, (Γ' ,,, Γ'') = Γ ,,, Γ' ,,, Γ'' :> list T.
329
+ Proof . unfold app_context; now rewrite app_assoc. Qed .
330
+
331
+ Lemma app_context_cons {T} Γ Γ' A : Γ ,,, (Γ' ,, A) = (Γ ,,, Γ') ,, A :> list T.
332
+ Proof . exact (app_context_assoc _ _ [A]). Qed .
333
+
334
+ Lemma app_context_push {T} Γ Δ Δ' d : (Γ ,,, Δ ,,, Δ') ,, d = (Γ ,,, Δ ,,, (Δ' ,, d)) :> list T.
335
+ Proof using Type .
336
+ reflexivity.
337
+ Qed .
338
+
339
+ Lemma snoc_app_context {T Γ Δ d} : (Γ ,,, (d :: Δ)) = (Γ ,,, Δ) ,,, [d] :> list T.
340
+ Proof using Type .
341
+ reflexivity.
342
+ Qed .
343
+
344
+ Lemma app_context_length {T} (Γ Γ' : list T) : #|Γ ,,, Γ'| = #|Γ'| + #|Γ|.
345
+ Proof . unfold app_context. now rewrite app_length. Qed .
346
+ #[global] Hint Rewrite @app_context_length : len.
347
+
348
+ Lemma nth_error_app_context_ge {T} v Γ Γ' :
349
+ #|Γ'| <= v -> nth_error (Γ ,,, Γ') v = nth_error Γ (v - #|Γ'|) :> option T.
350
+ Proof . apply nth_error_app_ge. Qed .
351
+
352
+ Lemma nth_error_app_context_lt {T} v Γ Γ' :
353
+ v < #|Γ'| -> nth_error (Γ ,,, Γ') v = nth_error Γ' v :> option T.
354
+ Proof . apply nth_error_app_lt. Qed .
355
+
356
+
317
357
Definition ondecl {A} (P : A -> Type ) (d : context_decl A) :=
318
- P d.(decl_type) × option_default P d.(decl_body) unit .
358
+ option_default P d.(decl_body) unit × P d.(decl_type) .
319
359
320
360
Notation onctx P := (All (ondecl P)).
321
361
0 commit comments