diff -r 88d1daae0319 -r de048d4968d9 src/HOL/Nominal/Examples/Lam_substs.thy --- a/src/HOL/Nominal/Examples/Lam_substs.thy Wed Nov 01 15:39:20 2006 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,347 +0,0 @@ -(* $Id$ *) - -theory Lam_substs -imports Iteration -begin - -constdefs - depth_Var :: "name \ nat" - "depth_Var \ \(a::name). 1" - - depth_App :: "nat \ nat \ nat" - "depth_App \ \n1 n2. (max n1 n2)+1" - - depth_Lam :: "name \ nat \ nat" - "depth_Lam \ \(a::name) n. n+1" - - depth_lam :: "lam \ nat" - "depth_lam \ itfun depth_Var depth_App depth_Lam" - -lemma supp_depth_Var: - shows "((supp depth_Var)::name set)={}" - apply(simp add: depth_Var_def) - apply(simp add: supp_def) - apply(simp add: perm_fun_def) - apply(simp add: perm_nat_def) - done - -lemma supp_depth_App: - shows "((supp depth_App)::name set)={}" - apply(simp add: depth_App_def) - apply(simp add: supp_def) - apply(simp add: perm_fun_def) - apply(simp add: perm_nat_def) - done - -lemma supp_depth_Lam: - shows "((supp depth_Lam)::name set)={}" - apply(simp add: depth_Lam_def) - apply(simp add: supp_def) - apply(simp add: perm_fun_def) - apply(simp add: perm_nat_def) - done - -lemma fin_supp_depth: - shows "finite ((supp (depth_Var,depth_App,depth_Lam))::name set)" - by (finite_guess add: depth_Var_def depth_App_def depth_Lam_def perm_nat_def fs_name1) - -lemma fresh_depth_Lam: - shows "\(a::name). a\depth_Lam \ (\n. a\depth_Lam a n)" -apply(rule exI) -apply(rule conjI) -apply(simp add: fresh_def) -apply(force simp add: supp_depth_Lam) -apply(unfold fresh_def) -apply(simp add: supp_def) -apply(simp add: perm_nat_def) -done - -lemma depth_Var: - shows "depth_lam (Var c) = 1" -apply(simp add: depth_lam_def) -apply(simp add: itfun_Var[OF fin_supp_depth, OF fresh_depth_Lam]) -apply(simp add: depth_Var_def) -done - -lemma depth_App: - shows "depth_lam (App t1 t2) = (max (depth_lam t1) (depth_lam t2))+1" -apply(simp add: depth_lam_def) -apply(simp add: itfun_App[OF fin_supp_depth, OF fresh_depth_Lam]) -apply(simp add: depth_App_def) -done - -lemma depth_Lam: - shows "depth_lam (Lam [a].t) = (depth_lam t)+1" -apply(simp add: depth_lam_def) -apply(rule trans) -apply(rule itfun_Lam[OF fin_supp_depth, OF fresh_depth_Lam]) -apply(simp add: fresh_def supp_prod supp_depth_Var supp_depth_App supp_depth_Lam) -apply(simp add: depth_Lam_def) -done - -text {* substitution *} -constdefs - subst_Var :: "name \lam \ name \ lam" - "subst_Var b t \ \a. (if a=b then t else (Var a))" - - subst_App :: "name \ lam \ lam \ lam \ lam" - "subst_App b t \ \r1 r2. App r1 r2" - - subst_Lam :: "name \ lam \ name \ lam \ lam" - "subst_Lam b t \ \a r. Lam [a].r" - - subst_lam :: "name \ lam \ lam \ lam" - "subst_lam b t \ itfun (subst_Var b t) (subst_App b t) (subst_Lam b t)" - -lemma supports_subst_Var: - shows "((supp (b,t))::name set) supports (subst_Var b t)" -apply(supports_simp add: subst_Var_def) -apply(rule impI) -apply(drule pt_bij1[OF pt_name_inst, OF at_name_inst]) -apply(simp add: pt_fresh_fresh[OF pt_name_inst, OF at_name_inst]) -done - -lemma supports_subst_App: - shows "((supp (b,t))::name set) supports subst_App b t" -by (supports_simp add: subst_App_def) - -lemma supports_subst_Lam: - shows "((supp (b,t))::name set) supports subst_Lam b t" - by (supports_simp add: subst_Lam_def) - -lemma fin_supp_subst: - shows "finite ((supp (subst_Var b t,subst_App b t,subst_Lam b t))::name set)" -apply(auto simp add: supp_prod) -apply(rule supports_finite) -apply(rule supports_subst_Var) -apply(simp add: fs_name1) -apply(rule supports_finite) -apply(rule supports_subst_App) -apply(simp add: fs_name1) -apply(rule supports_finite) -apply(rule supports_subst_Lam) -apply(simp add: fs_name1) -done - -lemma fresh_subst_Lam: - shows "\(a::name). a\(subst_Lam b t)\ (\y. a\(subst_Lam b t) a y)" -apply(subgoal_tac "\(c::name). c\(b,t)") -apply(auto) -apply(rule_tac x="c" in exI) -apply(auto) -apply(rule supports_fresh) -apply(rule supports_subst_Lam) -apply(simp_all add: fresh_def[symmetric] fs_name1) -apply(simp add: subst_Lam_def) -apply(simp add: abs_fresh) -apply(rule at_exists_fresh[OF at_name_inst]) -apply(simp add: fs_name1) -done - -lemma subst_Var: - shows "subst_lam b t (Var a) = (if a=b then t else (Var a))" -apply(simp add: subst_lam_def) -apply(auto simp add: itfun_Var[OF fin_supp_subst, OF fresh_subst_Lam]) -apply(auto simp add: subst_Var_def) -done - -lemma subst_App: - shows "subst_lam b t (App t1 t2) = App (subst_lam b t t1) (subst_lam b t t2)" -apply(simp add: subst_lam_def) -apply(auto simp add: itfun_App[OF fin_supp_subst, OF fresh_subst_Lam]) -apply(auto simp add: subst_App_def) -done - -lemma subst_Lam: - assumes a: "a\(b,t)" - shows "subst_lam b t (Lam [a].t1) = Lam [a].(subst_lam b t t1)" -using a -apply(simp add: subst_lam_def) -apply(subgoal_tac "a\(subst_Var b t,subst_App b t,subst_Lam b t)") -apply(auto simp add: itfun_Lam[OF fin_supp_subst, OF fresh_subst_Lam]) -apply(simp (no_asm) add: subst_Lam_def) -apply(auto simp add: fresh_prod) -apply(rule supports_fresh) -apply(rule supports_subst_Var) -apply(simp_all add: fs_name1 fresh_def[symmetric] fresh_prod) -apply(rule supports_fresh) -apply(rule supports_subst_App) -apply(simp_all add: fs_name1 fresh_def[symmetric] fresh_prod) -apply(rule supports_fresh) -apply(rule supports_subst_Lam) -apply(simp_all add: fs_name1 fresh_def[symmetric] fresh_prod) -done - -lemma subst_Lam': - assumes a: "a\b" - and b: "a\t" - shows "subst_lam b t (Lam [a].t1) = Lam [a].(subst_lam b t t1)" -by (simp add: subst_Lam fresh_prod a b fresh_atm) - -lemma subst_Lam'': - assumes a: "a\b" - and b: "a\t" - shows "subst_lam b t (Lam [a].t1) = Lam [a].(subst_lam b t t1)" -by (simp add: subst_Lam fresh_prod a b) - -consts - subst_syn :: "lam \ name \ lam \ lam" ("_[_::=_]" [100,100,100] 900) -translations - "t1[a::=t2]" \ "subst_lam a t2 t1" - -declare subst_Var[simp] -declare subst_App[simp] -declare subst_Lam[simp] -declare subst_Lam'[simp] -declare subst_Lam''[simp] - -lemma subst_eqvt[simp]: - fixes pi:: "name prm" - and t1:: "lam" - and t2:: "lam" - and a :: "name" - shows "pi\(t1[b::=t2]) = (pi\t1)[(pi\b)::=(pi\t2)]" -apply(nominal_induct t1 avoiding: b t2 rule: lam.induct) -apply(auto simp add: perm_bij fresh_prod fresh_atm) -apply(subgoal_tac "(pi\name)\(pi\b,pi\t2)")(*A*) -apply(simp) -(*A*) -apply(simp add: pt_fresh_right[OF pt_name_inst, OF at_name_inst], perm_simp add: fresh_prod fresh_atm) -done - -lemma subst_supp: - shows "supp(t1[a::=t2]) \ (((supp(t1)-{a})\supp(t2))::name set)" -apply(nominal_induct t1 avoiding: a t2 rule: lam.induct) -apply(auto simp add: lam.supp supp_atm fresh_prod abs_supp) -apply(blast)+ -done - -(* parallel substitution *) - -consts - "domain" :: "(name\lam) list \ (name list)" -primrec - "domain [] = []" - "domain (x#\) = (fst x)#(domain \)" - -consts - "apply_sss" :: "(name\lam) list \ name \ lam" (" _ < _ >" [80,80] 80) -primrec -"(x#\) = (if (a = fst x) then (snd x) else \)" - - -lemma apply_sss_eqvt[rule_format]: - fixes pi::"name prm" - shows "a\set (domain \) \ pi\(\) = (pi\\)a>" -apply(induct_tac \) -apply(auto) -apply(simp add: pt_bij[OF pt_name_inst, OF at_name_inst]) -done - -lemma domain_eqvt[rule_format]: - fixes pi::"name prm" - shows "((pi\a)\set (domain \)) = (a\set (domain ((rev pi)\\)))" -apply(induct_tac \) -apply(auto) -apply(simp_all add: pt_rev_pi[OF pt_name_inst, OF at_name_inst]) -apply(simp_all add: pt_pi_rev[OF pt_name_inst, OF at_name_inst]) -done - -constdefs - psubst_Var :: "(name\lam) list \ name \ lam" - "psubst_Var \ \ \a. (if a\set (domain \) then \ else (Var a))" - - psubst_App :: "(name\lam) list \ lam \ lam \ lam" - "psubst_App \ \ \r1 r2. App r1 r2" - - psubst_Lam :: "(name\lam) list \ name \ lam \ lam" - "psubst_Lam \ \ \a r. Lam [a].r" - - psubst_lam :: "(name\lam) list \ lam \ lam" - "psubst_lam \ \ itfun (psubst_Var \) (psubst_App \) (psubst_Lam \)" - -lemma supports_psubst_Var: - shows "((supp \)::name set) supports (psubst_Var \)" - by (supports_simp add: psubst_Var_def apply_sss_eqvt domain_eqvt) - -lemma supports_psubst_App: - shows "((supp \)::name set) supports psubst_App \" - by (supports_simp add: psubst_App_def) - -lemma supports_psubst_Lam: - shows "((supp \)::name set) supports psubst_Lam \" - by (supports_simp add: psubst_Lam_def) - -lemma fin_supp_psubst: - shows "finite ((supp (psubst_Var \,psubst_App \,psubst_Lam \))::name set)" -apply(auto simp add: supp_prod) -apply(rule supports_finite) -apply(rule supports_psubst_Var) -apply(simp add: fs_name1) -apply(rule supports_finite) -apply(rule supports_psubst_App) -apply(simp add: fs_name1) -apply(rule supports_finite) -apply(rule supports_psubst_Lam) -apply(simp add: fs_name1) -done - -lemma fresh_psubst_Lam: - shows "\(a::name). a\(psubst_Lam \)\ (\y. a\(psubst_Lam \) a y)" -apply(subgoal_tac "\(c::name). c\\") -apply(auto) -apply(rule_tac x="c" in exI) -apply(auto) -apply(rule supports_fresh) -apply(rule supports_psubst_Lam) -apply(simp_all add: fresh_def[symmetric] fs_name1) -apply(simp add: psubst_Lam_def) -apply(simp add: abs_fresh) -apply(rule at_exists_fresh[OF at_name_inst]) -apply(simp add: fs_name1) -done - -lemma psubst_Var: - shows "psubst_lam \ (Var a) = (if a\set (domain \) then \ else (Var a))" -apply(simp add: psubst_lam_def) -apply(auto simp add: itfun_Var[OF fin_supp_psubst, OF fresh_psubst_Lam]) -apply(auto simp add: psubst_Var_def) -done - -lemma psubst_App: - shows "psubst_lam \ (App t1 t2) = App (psubst_lam \ t1) (psubst_lam \ t2)" -apply(simp add: psubst_lam_def) -apply(auto simp add: itfun_App[OF fin_supp_psubst, OF fresh_psubst_Lam]) -apply(auto simp add: psubst_App_def) -done - -lemma psubst_Lam: - assumes a: "a\\" - shows "psubst_lam \ (Lam [a].t1) = Lam [a].(psubst_lam \ t1)" -using a -apply(simp add: psubst_lam_def) -apply(subgoal_tac "a\(psubst_Var \,psubst_App \,psubst_Lam \)") -apply(auto simp add: itfun_Lam[OF fin_supp_psubst, OF fresh_psubst_Lam]) -apply(simp (no_asm) add: psubst_Lam_def) -apply(auto simp add: fresh_prod) -apply(rule supports_fresh) -apply(rule supports_psubst_Var) -apply(simp_all add: fs_name1 fresh_def[symmetric] fresh_prod) -apply(rule supports_fresh) -apply(rule supports_psubst_App) -apply(simp_all add: fs_name1 fresh_def[symmetric] fresh_prod) -apply(rule supports_fresh) -apply(rule supports_psubst_Lam) -apply(simp_all add: fs_name1 fresh_def[symmetric] fresh_prod) -done - -declare psubst_Var[simp] -declare psubst_App[simp] -declare psubst_Lam[simp] - -consts - psubst_syn :: "lam \ (name\lam) list \ lam" ("_[<_>]" [100,100] 900) -translations - "t[<\>]" \ "psubst_lam \ t" - -end \ No newline at end of file