%% Type uniqueness for the simply-typed lambda-calculus
%% A single logic approach
Kind tm, ty type.
Type app tm -> tm -> tm.
Type abs ty -> (tm -> tm) -> tm.
Type arr ty -> ty -> ty.
Type bind tm -> ty -> o.
Theorem member_prune : forall (L:olist) E, nabla (x:tm),
member (E x) L -> exists F, E = x\ F.
IH : induction on 1. intros Hmem. case Hmem.
- search.
- HmemTail => apply IH to *HmemTail.
search.
Define ctx : olist -> prop by
ctx nil ;
nabla x, ctx (bind x A :: L) := ctx L.
Define of : olist -> tm -> ty -> prop by
nabla x, of (L x) x A := nabla x, member (bind x A) (L x) ;
of L (app M N) B := exists A, of L M (arr A B) /\ of L N A ;
of L (abs A R) (arr A B) := nabla x, of (bind x A :: L) (R x) B.
Theorem ctx_uniq : forall L E T1 T2,
ctx L -> member (bind E T1) L -> member (bind E T2) L -> T1 = T2.
IH : induction on 1. intros Hctx Hmem1 Hmem2. case Hctx.
- case Hmem1.
- HctxTail => case Hmem1.
+ case Hmem2.
* search.
* Hmem2Tail => apply member_prune to *Hmem2Tail.
+ Hmem1Tail => case Hmem2.
* apply member_prune to *Hmem1Tail.
* Hmem2Tail => apply IH to *HctxTail *Hmem1Tail *Hmem2Tail.
search.
Theorem type_uniq : forall L E T1 T2,
ctx L -> of L E T1 -> of L E T2 -> T1 = T2.
IH : induction on 2. intros Hctx Hof1 Hof2. case Hof1.
- Hmem1 => Hmem2 : case Hof2.
apply ctx_uniq to Hctx Hmem1 Hmem2. search.
- HseqApp1 => HseqApp2 : case Hof2.
apply IH to Hctx HseqApp1 HseqApp2. search.
- HseqAbs => HseqAbs2 : case Hof2.
apply IH to _ HseqAbs HseqAbs2. search.