ladder-calculus/coq/typing.v

55 lines
1.5 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.

(* This module defines the typing relation
* where each expression is assigned a type.
*)
From Coq Require Import Strings.String.
Require Import terms.
Require Import subst.
Include Terms.
Include Subst.
Module Typing.
Inductive context : Type :=
| ctx_assign : string -> type_term -> context -> context
| ctx_empty : context
.
Inductive context_contains : context -> string -> type_term -> Prop :=
| C_take : forall (x:string) (X:type_term) (Γ:context),
(context_contains (ctx_assign x X Γ) x X)
| C_shuffle : forall x X y Y Γ,
(context_contains Γ x X) ->
(context_contains (ctx_assign y Y Γ) x X).
Reserved Notation "Gamma '|-' x '\in' X" (at level 101, x at next level, X at level 0).
Inductive expr_type : context -> expr -> ladder_type -> Prop :=
| T_Var : forall Γ x X,
(context_contains Γ x X) ->
Γ |- x \in X
| T_Let : forall Γ s (σ:ladder_type) t τ x,
Γ |- s \in σ ->
Γ |- t \in τ ->
Γ |- (expr_let x σ s t) \in τ
| T_Abs : forall (Γ:context) (x:string) (X:ladder_type) (t:expr) (T:ladder_type),
Γ |- t \in T ->
Γ |- (expr_tm_abs x X t) \in (type_fun X T)
| T_App : forall (Γ:context) (f:expr) (a:expr) (S:ladder_type) (T:ladder_type),
Γ |- f \in (type_fun S T) ->
Γ |- a \in S ->
Γ |- (expr_tm_app f a) \in T
where "Γ '|-' x '\in' X" := (expr_type Γ x X).
Example typing1 :
ctx_empty |-
(expr_ty_abs "T" (expr_tm_abs "x" (type_var "T") (expr_var "x"))) \in
(type_univ "T" (type_fun (type_var "T") (type_var "T"))).
Proof.
Admitted.
End Typing.