diff -r db158e995bfc -r 9df6144e281b Quot/Examples/LFex.thy --- a/Quot/Examples/LFex.thy Thu Feb 25 07:48:57 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,297 +0,0 @@ -theory LFex -imports Nominal "../Quotient_List" -begin - -atom_decl name ident - -nominal_datatype kind = - Type - | KPi "ty" "name" "kind" -and ty = - TConst "ident" - | TApp "ty" "trm" - | TPi "ty" "name" "ty" -and trm = - Const "ident" - | 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_equivps: - shows "equivp akind" - and "equivp aty" - and "equivp atrm" -sorry - -quotient_type KIND = kind / akind - by (rule alpha_equivps) - -quotient_type - TY = ty / aty and - TRM = trm / atrm - by (auto intro: alpha_equivps) - -quotient_definition - "TYP :: KIND" -is - "Type" - -quotient_definition - "KPI :: TY \ name \ KIND \ KIND" -is - "KPi" - -quotient_definition - "TCONST :: ident \ TY" -is - "TConst" - -quotient_definition - "TAPP :: TY \ TRM \ TY" -is - "TApp" - -quotient_definition - "TPI :: TY \ name \ TY \ TY" -is - "TPi" - -(* FIXME: does not work with CONST *) -quotient_definition - "CONS :: ident \ TRM" -is - "Const" - -quotient_definition - "VAR :: name \ TRM" -is - "Var" - -quotient_definition - "APP :: TRM \ TRM \ TRM" -is - "App" - -quotient_definition - "LAM :: TY \ name \ TRM \ TRM" -is - "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_definition - "FV_kind :: KIND \ name set" -is - "fv_kind" - -quotient_definition - "FV_ty :: TY \ name set" -is - "fv_ty" - -quotient_definition - "FV_trm :: TRM \ name set" -is - "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_definition - "perm_kind :: 'x prm \ KIND \ KIND" -is - "(perm::'x prm \ kind \ kind)" - -quotient_definition - "perm_ty :: 'x prm \ TY \ TY" -is - "(perm::'x prm \ ty \ ty)" - -quotient_definition - "perm_trm :: 'x prm \ TRM \ TRM" -is - "(perm::'x prm \ trm \ trm)" - -end - -(* TODO/FIXME: Think whether these RSP theorems are true. *) -lemma kpi_rsp[quot_respect]: - "(aty ===> op = ===> akind ===> akind) KPi KPi" sorry -lemma tconst_rsp[quot_respect]: - "(op = ===> aty) TConst TConst" sorry -lemma tapp_rsp[quot_respect]: - "(aty ===> atrm ===> aty) TApp TApp" sorry -lemma tpi_rsp[quot_respect]: - "(aty ===> op = ===> aty ===> aty) TPi TPi" sorry -lemma var_rsp[quot_respect]: - "(op = ===> atrm) Var Var" sorry -lemma app_rsp[quot_respect]: - "(atrm ===> atrm ===> atrm) App App" sorry -lemma const_rsp[quot_respect]: - "(op = ===> atrm) Const Const" sorry -lemma lam_rsp[quot_respect]: - "(aty ===> op = ===> atrm ===> atrm) Lam Lam" sorry - -lemma perm_kind_rsp[quot_respect]: - "(op = ===> akind ===> akind) op \ op \" sorry -lemma perm_ty_rsp[quot_respect]: - "(op = ===> aty ===> aty) op \ op \" sorry -lemma perm_trm_rsp[quot_respect]: - "(op = ===> atrm ===> atrm) op \ op \" sorry - -lemma fv_ty_rsp[quot_respect]: - "(aty ===> op =) fv_ty fv_ty" sorry -lemma fv_kind_rsp[quot_respect]: - "(akind ===> op =) fv_kind fv_kind" sorry -lemma fv_trm_rsp[quot_respect]: - "(atrm ===> op =) fv_trm fv_trm" sorry - - -thm akind_aty_atrm.induct -thm kind_ty_trm.induct - - -lemma - assumes a0: - "P1 TYP TYP" - and a1: - "\A A' K K' x. \(A::TY) = A'; P2 A A'; (K::KIND) = K'; P1 K K'\ - \ P1 (KPI A x K) (KPI A' x K')" - and a2: - "\A A' K K' x x'. \(A ::TY) = A'; P2 A A'; (K :: KIND) = ([(x, x')] \ K'); P1 K ([(x, x')] \ K'); - x \ FV_ty A'; x \ FV_kind K' - {x'}\ \ P1 (KPI A x K) (KPI A' x' K')" - and a3: - "\i j. i = j \ P2 (TCONST i) (TCONST j)" - and a4: - "\A A' M M'. \(A ::TY) = A'; P2 A A'; (M :: TRM) = M'; P3 M M'\ \ P2 (TAPP A M) (TAPP A' M')" - and a5: - "\A A' B B' x. \(A ::TY) = A'; P2 A A'; (B ::TY) = B'; P2 B B'\ \ P2 (TPI A x B) (TPI A' x B')" - and a6: - "\A A' B x x' B'. \(A ::TY) = A'; P2 A A'; (B ::TY) = ([(x, x')] \ B'); P2 B ([(x, x')] \ B'); - x \ FV_ty B'; x \ FV_ty B' - {x'}\ \ P2 (TPI A x B) (TPI A' x' B')" - and a7: - "\i j m. i = j \ P3 (CONS i) (m (CONS j))" - and a8: - "\x y m. x = y \ P3 (VAR x) (m (VAR y))" - and a9: - "\M m M' N N'. \(M :: TRM) = m M'; P3 M (m M'); (N :: TRM) = N'; P3 N N'\ \ P3 (APP M N) (APP M' N')" - and a10: - "\A A' M M' x. \(A ::TY) = A'; P2 A A'; (M :: TRM) = M'; P3 M M'\ \ P3 (LAM A x M) (LAM A' x M')" - and a11: - "\A A' M x x' M' B'. \(A ::TY) = A'; P2 A A'; (M :: TRM) = ([(x, x')] \ M'); P3 M ([(x, x')] \ M'); - x \ FV_ty B'; x \ FV_trm M' - {x'}\ \ P3 (LAM A x M) (LAM A' x' M')" - shows "((x1 :: KIND) = x2 \ P1 x1 x2) \ - ((x3 ::TY) = x4 \ P2 x3 x4) \ - ((x5 :: TRM) = x6 \ P3 x5 x6)" -using a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 -apply(lifting akind_aty_atrm.induct) -(* -Profiling: -ML_prf {* fun ith i = (#concl (fst (Subgoal.focus @{context} i (#goal (Isar.goal ()))))) *} -ML_prf {* profile 2 Seq.list_of ((clean_tac @{context} quot defs 1) (ith 3)) *} -ML_prf {* profile 2 Seq.list_of ((regularize_tac @{context} @{thms alpha_equivps} 1) (ith 1)) *} -ML_prf {* PolyML.profiling 1 *} -ML_prf {* profile 2 Seq.list_of ((all_inj_repabs_tac @{context} quot rel_refl trans2 1) (#goal (Isar.goal ()))) *} -*) - done - -(* Does not work: -lemma - assumes a0: "P1 TYP" - and a1: "\ty name kind. \P2 ty; P1 kind\ \ P1 (KPI ty name kind)" - and a2: "\id. P2 (TCONST id)" - and a3: "\ty trm. \P2 ty; P3 trm\ \ P2 (TAPP ty trm)" - and a4: "\ty1 name ty2. \P2 ty1; P2 ty2\ \ P2 (TPI ty1 name ty2)" - and a5: "\id. P3 (CONS id)" - and a6: "\name. P3 (VAR name)" - and a7: "\trm1 trm2. \P3 trm1; P3 trm2\ \ P3 (APP trm1 trm2)" - and a8: "\ty name trm. \P2 ty; P3 trm\ \ P3 (LAM ty name trm)" - shows "P1 mkind \ P2 mty \ P3 mtrm" -using a0 a1 a2 a3 a4 a5 a6 a7 a8 -*) - - -lemma "\P TYP; - \ty name kind. \Q ty; P kind\ \ P (KPI ty name kind); - \id. Q (TCONST id); - \ty trm. \Q ty; R trm\ \ Q (TAPP ty trm); - \ty1 name ty2. \Q ty1; Q ty2\ \ Q (TPI ty1 name ty2); - \id. R (CONS id); \name. R (VAR name); - \trm1 trm2. \R trm1; R trm2\ \ R (APP trm1 trm2); - \ty name trm. \Q ty; R trm\ \ R (LAM ty name trm)\ - \ P mkind \ Q mty \ R mtrm" -apply(lifting kind_ty_trm.induct) -done - -end - - - -