floating-levels/theories/typing.v
2025-05-29 13:46:56 -04:00

62 lines
1.6 KiB
Coq
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Require Import Autosubst2.syntax List.
Reserved Notation "Γ ⊢ a ;; ∈ A" (at level 70).
Definition get_level a :=
match a with
| Fixed =>
| Floating =>
end.
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 Γ
end.
Fixpoint fixed_ctx (Γ : ctx) :=
match Γ with
| nil => nil
| (Fixed , A) :: Γ => false :: fixed_ctx Γ
| (Floating , A) :: Γ => true :: 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
| FlApp a b => liftable Φ a /\ liftable Φ b
| App a b => liftable Φ a
| FlAbs a => liftable (false :: Φ) a
| Abs a => liftable (false :: Φ) a
end.
Inductive Wt (Γ : ctx) : Tm -> bool -> Ty -> Prop :=
| T_Var i 0 A :
Bool.le (get_level 0) ->
nth_error Γ i = Some (0, A) ->
Γ VarTm i ;; A
| T_FlApp a b A B :
Γ b ;; FlFun A B ->
Γ a ;; A ->
Γ FlApp b a ;; B
| T_FlAbs a A B :
(Floating , A) :: Γ a ;; B ->
Γ FlAbs a ;; FlFun A B
| T_App 0 a b A B :
Γ b ;; Fun 0 A B ->
Γ a ;; 0 A ->
Γ App b a ;; A
| T_Abs 0 b A B :
(Fixed 0, A) :: Γ b ;; B ->
Γ Abs b ;; Fun 0 A B
where "Γ ⊢ a ;; ∈ A" := (Wt Γ a A).