Add renaming

This commit is contained in:
Yiyun Liu 2025-05-29 16:35:49 -04:00
parent c28102c0f0
commit 40cedc388f
2 changed files with 113 additions and 9 deletions

View file

@ -8,27 +8,31 @@ Definition get_level a :=
| Floating =>
end.
Inductive lookup {A} : nat -> list A -> A -> Prop :=
| here A Γ : lookup 0 (cons A Γ) A
| there i Γ A B :
lookup i Γ A ->
lookup (S i) (cons B Γ) A.
Definition ctx := list (Level * Ty).
Fixpoint fix_ctx (Γ : ctx) :=
match Γ with
| nil => nil
| (Fixed , A) :: Γ => (Fixed , A) :: fix_ctx Γ
| (Floating , A) :: Γ => (Fixed , A) :: fix_ctx Γ
Definition squash a :=
match a with
| Fixed => false
| Floating => true
end.
Fixpoint fixed_ctx (Γ : ctx) :=
match Γ with
| nil => nil
| (Fixed , A) :: Γ => false :: fixed_ctx Γ
| (Floating , A) :: Γ => true :: fixed_ctx Γ
| (a, _) :: Γ => squash a :: fixed_ctx Γ
end.
(* false <= true *)
(* A term is liftable if it remains well-typed raising the levels of the floating levels to the current level *)
Fixpoint liftable Φ (a : Tm) :=
match a with
| VarTm i => nth_default true Φ i = false
| VarTm i => lookup i Φ false
| FlApp a b => liftable Φ a /\ liftable Φ b
| App a b => liftable Φ a
| FlAbs a => liftable (false :: Φ) a
@ -38,7 +42,7 @@ Fixpoint liftable Φ (a : Tm) :=
Inductive Wt (Γ : ctx) : Tm -> bool -> Ty -> Prop :=
| T_Var i 0 A :
Bool.le (get_level 0) ->
nth_error Γ i = Some (0, A) ->
lookup i Γ (0, A) ->
Γ VarTm i ;; A
| T_FlApp a b A B :
@ -53,6 +57,7 @@ Inductive Wt (Γ : ctx) : Tm -> bool -> Ty -> Prop :=
| T_App 0 a b A B :
Γ b ;; Fun 0 A B ->
Γ a ;; 0 A ->
liftable (fixed_ctx Γ) a ->
Γ App b a ;; A
| T_Abs 0 b A B :