Skip to content

Commit 652eeaa

Browse files
committed
Prove determinancy of typing and kinding
1 parent 9343569 commit 652eeaa

File tree

3 files changed

+48
-3
lines changed

3 files changed

+48
-3
lines changed

Determinancy.thy

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
theory Determinancy
2+
imports Typing Typing_Lemmas
3+
begin
4+
5+
lemma unique_ty: "\<lbrakk> \<Gamma> \<turnstile>\<^sub>t\<^sub>y \<tau> : k1 ; \<Gamma> \<turnstile>\<^sub>t\<^sub>y \<tau> : k2 \<rbrakk> \<Longrightarrow> k1 = k2"
6+
proof (nominal_induct \<tau> arbitrary: k1 k2 rule: \<tau>.strong_induct)
7+
case (TyVar x)
8+
then show ?case using isin_split isin_same(1) by blast
9+
next
10+
case (TyConApp \<tau>1 \<tau>2)
11+
then show ?case by fastforce
12+
next
13+
case (TyForall x1 x2a x3)
14+
then show ?case by (metis Ty_Forall_Inv_2)
15+
qed auto
16+
17+
lemma unique_tm: "\<lbrakk> \<Gamma> \<turnstile> e : \<tau>1 ; \<Gamma> \<turnstile> e : \<tau>2 \<rbrakk> \<Longrightarrow> \<tau>1 = \<tau>2"
18+
proof (nominal_induct e avoiding: \<Gamma> \<tau>1 \<tau>2 rule: term.strong_induct)
19+
case (Var x)
20+
then show ?case using isin_split isin_same(2) by blast
21+
next
22+
case (TyApp e1 \<tau>)
23+
obtain a1 k1 \<sigma>1 where 1: "\<Gamma> \<turnstile> e1 : \<forall> a1:k1. \<sigma>1" "\<tau>1 = \<sigma>1[\<tau>/a1]" by (cases rule: Tm.cases[OF TyApp(2)]) auto
24+
obtain a2 k2 \<sigma>2 where 2: "\<Gamma> \<turnstile> e1 : \<forall> a2:k2. \<sigma>2" "\<tau>2 = \<sigma>2[\<tau>/a2]" by (cases rule: Tm.cases[OF TyApp(3)]) auto
25+
show ?case using TyApp(1)[OF 1(1) 2(1)] subst_type_same 1(2) 2(2) by simp
26+
next
27+
case (Lam x \<tau> e)
28+
then show ?case by (metis T_Abs_Inv)
29+
next
30+
case (TyLam a k e)
31+
then show ?case by (metis T_AbsT_Inv)
32+
next
33+
case (Let x \<tau> e1 e2)
34+
then show ?case using T_Let_Inv by blast
35+
qed fastforce+
36+
37+
end

ROOT

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ session Lambda = HOL + sessions "HOL-Eisbach" Nominal2
22
theories
33
Confluence
44
Soundness
5+
Determinancy

Typing_Lemmas.thy

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,20 @@ qed simp
182182
lemma context_split_valid: "\<turnstile> \<Gamma>' @ \<Gamma> \<Longrightarrow> \<turnstile> \<Gamma>"
183183
by (induction \<Gamma>') (auto simp: Ctx_Empty)
184184

185-
lemma isin_split: "\<lbrakk> BVar x \<tau> \<in> \<Gamma> ; \<turnstile> \<Gamma> \<rbrakk> \<Longrightarrow> \<exists>\<Gamma>1 \<Gamma>2. \<Gamma> = \<Gamma>1 @ BVar x \<tau> # \<Gamma>2"
185+
lemma isin_split: "\<lbrakk> b \<in> \<Gamma> ; \<turnstile> \<Gamma> \<rbrakk> \<Longrightarrow> \<exists>\<Gamma>1 \<Gamma>2. \<Gamma> = \<Gamma>1 @ b # \<Gamma>2"
186186
proof (induction \<Gamma>)
187187
case (Cons bndr \<Gamma>)
188188
then show ?case
189-
proof (cases "bndr = BVar x \<tau>")
189+
proof (cases "bndr = b")
190190
case False
191-
then have "BVar x \<tau> \<in> \<Gamma>" using Cons(2) by (cases bndr rule: binder.exhaust) auto
191+
then have "b \<in> \<Gamma>"
192+
proof (cases bndr rule: binder.exhaust)
193+
case (BVar x \<tau>)
194+
then show ?thesis using False Cons by (cases b rule: binder.exhaust) auto
195+
next
196+
case (BTyVar a k)
197+
then show ?thesis using False Cons by (cases b rule: binder.exhaust) auto
198+
qed
192199
then show ?thesis by (metis Cons.IH Cons.prems(2) Cons_eq_appendI context_cons_valid)
193200
qed blast
194201
qed auto

0 commit comments

Comments
 (0)