diff -r 0062c9e5c842 -r 28b264299590 LFex.thy --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LFex.thy Fri Nov 06 19:26:08 2009 +0100 @@ -0,0 +1,175 @@ +theory LFex +imports Nominal QuotMain +begin + +atom_decl name id + +nominal_datatype kind = + Type + | KPi "ty" "name" "kind" +and ty = + TConst "id" + | TApp "ty" "trm" + | TPi "ty" "name" "ty" +and trm = + Const "id" + | Var "name" + | App "trm" "trm" + | Lam "ty" "name" "trm" + +function + fv_kind :: "kind \ name set" +and fv_ty :: "ty \ name set" +and fv_trm :: "trm \ name set" +where + "fv_kind (Type) = {}" +| "fv_kind (KPi A x K) = (fv_ty A) \ ((fv_kind K) - {x})" +| "fv_ty (TConst i) = {}" +| "fv_ty (TApp A M) = (fv_ty A) \ (fv_trm M)" +| "fv_ty (TPi A x B) = (fv_ty A) \ ((fv_ty B) - {x})" +| "fv_trm (Const i) = {}" +| "fv_trm (Var x) = {x}" +| "fv_trm (App M N) = (fv_trm M) \ (fv_trm N)" +| "fv_trm (Lam A x M) = (fv_ty A) \ ((fv_trm M) - {x})" +sorry + +termination fv_kind sorry + +inductive + akind :: "kind \ kind \ bool" ("_ \ki _" [100, 100] 100) +and aty :: "ty \ ty \ bool" ("_ \ty _" [100, 100] 100) +and atrm :: "trm \ trm \ bool" ("_ \tr _" [100, 100] 100) +where + a1: "(Type) \ki (Type)" +| a21: "\A \ty A'; K \ki K'\ \ (KPi A x K) \ki (KPi A' x K')" +| a22: "\A \ty A'; K \ki ([(x,x')]\K'); x \ (fv_ty A'); x \ ((fv_kind K') - {x'})\ + \ (KPi A x K) \ki (KPi A' x' K')" +| a3: "i = j \ (TConst i) \ty (TConst j)" +| a4: "\A \ty A'; M \tr M'\ \ (TApp A M) \ty (TApp A' M')" +| a51: "\A \ty A'; B \ty B'\ \ (TPi A x B) \ty (TPi A' x B')" +| a52: "\A \ty A'; B \ty ([(x,x')]\B'); x \ (fv_ty B'); x \ ((fv_ty B') - {x'})\ + \ (TPi A x B) \ty (TPi A' x' B')" +| a6: "i = j \ (Const i) \trm (Const j)" +| a7: "x = y \ (Var x) \trm (Var y)" +| a8: "\M \trm M'; N \tr N'\ \ (App M N) \tr (App M' N')" +| a91: "\A \ty A'; M \tr M'\ \ (Lam A x M) \tr (Lam A' x M')" +| a92: "\A \ty A'; M \tr ([(x,x')]\M'); x \ (fv_ty B'); x \ ((fv_trm M') - {x'})\ + \ (Lam A x M) \tr (Lam A' x' M')" + +lemma al_refl: + fixes K::"kind" + and A::"ty" + and M::"trm" + shows "K \ki K" + and "A \ty A" + and "M \tr M" + apply(induct K and A and M rule: kind_ty_trm.inducts) + apply(auto intro: akind_aty_atrm.intros) + done + +lemma alpha_EQUIVs: + shows "EQUIV akind" + and "EQUIV aty" + and "EQUIV atrm" +sorry + +quotient KIND = kind / akind + by (rule alpha_EQUIVs) + +quotient TY = ty / aty + and TRM = trm / atrm + by (auto intro: alpha_EQUIVs) + +print_quotients + +quotient_def + TYP :: "KIND" +where + "TYP \ Type" + +quotient_def + KPI :: "TY \ name \ KIND \ KIND" +where + "KPI \ KPi" + +quotient_def + TCONST :: "id \ TY" +where + "TCONST \ TConst" + +quotient_def + TAPP :: "TY \ TRM \ TY" +where + "TAPP \ TApp" + +quotient_def + TPI :: "TY \ name \ TY \ TY" +where + "TPI \ TPi" + +(* FIXME: does not work with CONST *) +quotient_def + CONS :: "id \ TRM" +where + "CONS \ Const" + +quotient_def + VAR :: "name \ TRM" +where + "VAR \ Var" + +quotient_def + APP :: "TRM \ TRM \ TRM" +where + "APP \ App" + +quotient_def + LAM :: "TY \ name \ TRM \ TRM" +where + "LAM \ Lam" + +thm TYP_def +thm KPI_def +thm TCONST_def +thm TAPP_def +thm TPI_def +thm VAR_def +thm CONS_def +thm APP_def +thm LAM_def + +(* FIXME: print out a warning if the type contains a liftet type, like kind \ name set *) +quotient_def + FV_kind :: "KIND \ name set" +where + "FV_kind \ fv_kind" + +quotient_def + FV_ty :: "TY \ name set" +where + "FV_ty \ fv_ty" + +quotient_def + FV_trm :: "TRM \ name set" +where + "FV_trm \ fv_trm" + +thm FV_kind_def +thm FV_ty_def +thm FV_trm_def + +(* FIXME: does not work yet *) +(* +overloading + perm_kind \ "perm :: 'x prm \ KIND \ KIND" (unchecked) + perm_ty \ "perm :: 'x prm \ TY \ TY" (unchecked) + perm_trm \ "perm :: 'x prm \ TRM \ TRM" (unchecked) +begin + +quotient_def + perm_kind :: "'x prm \ KIND \ KIND" +where + "perm_kind \ (perm::'x prm \ KIND \ KIND)" +end +*) +