Nominal/Ex/Lambda.thy
changeset 2912 3c363a5070a5
parent 2902 9c3f6a4d95d4
child 2937 a56d422e17f6
--- a/Nominal/Ex/Lambda.thy	Mon Jun 27 22:51:42 2011 +0100
+++ b/Nominal/Ex/Lambda.thy	Tue Jun 28 00:30:30 2011 +0100
@@ -2,93 +2,116 @@
 imports "../Nominal2" 
 begin
 
+lemma Abs_lst_fcb2:
+  fixes as bs :: "atom list"
+    and x y :: "'b :: fs"
+    and c::"'c::fs"
+  assumes eq: "[as]lst. x = [bs]lst. y"
+  and fcb1: "(set as) \<sharp>* f as x c"
+  and fresh1: "set as \<sharp>* c"
+  and fresh2: "set bs \<sharp>* c"
+  and perm1: "\<And>p. supp p \<sharp>* c \<Longrightarrow> p \<bullet> (f as x c) = f (p \<bullet> as) (p \<bullet> x) c"
+  and perm2: "\<And>p. supp p \<sharp>* c \<Longrightarrow> p \<bullet> (f bs y c) = f (p \<bullet> bs) (p \<bullet> y) c"
+  shows "f as x c = f bs y c"
+proof -
+  have "supp (as, x, c) supports (f as x c)"
+    unfolding  supports_def fresh_def[symmetric]
+    by (simp add: fresh_Pair perm1 fresh_star_def supp_swap swap_fresh_fresh)
+  then have fin1: "finite (supp (f as x c))"
+    by (auto intro: supports_finite simp add: finite_supp)
+  have "supp (bs, y, c) supports (f bs y c)"
+    unfolding  supports_def fresh_def[symmetric]
+    by (simp add: fresh_Pair perm2 fresh_star_def supp_swap swap_fresh_fresh)
+  then have fin2: "finite (supp (f bs y c))"
+    by (auto intro: supports_finite simp add: finite_supp)
+  obtain q::"perm" where 
+    fr1: "(q \<bullet> (set as)) \<sharp>* (x, c, f as x c, f bs y c)" and 
+    fr2: "supp q \<sharp>* Abs_lst as x" and 
+    inc: "supp q \<subseteq> (set as) \<union> q \<bullet> (set as)"
+    using at_set_avoiding3[where xs="set as" and c="(x, c, f as x c, f bs y c)" and x="[as]lst. x"]  
+      fin1 fin2
+    by (auto simp add: supp_Pair finite_supp Abs_fresh_star dest: fresh_star_supp_conv)
+  have "Abs_lst (q \<bullet> as) (q \<bullet> x) = q \<bullet> Abs_lst as x" by simp
+  also have "\<dots> = Abs_lst as x"
+    by (simp only: fr2 perm_supp_eq)
+  finally have "Abs_lst (q \<bullet> as) (q \<bullet> x) = Abs_lst bs y" using eq by simp
+  then obtain r::perm where 
+    qq1: "q \<bullet> x = r \<bullet> y" and 
+    qq2: "q \<bullet> as = r \<bullet> bs" and 
+    qq3: "supp r \<subseteq> (q \<bullet> (set as)) \<union> set bs"
+    apply(drule_tac sym)
+    apply(simp only: Abs_eq_iff2 alphas)
+    apply(erule exE)
+    apply(erule conjE)+
+    apply(drule_tac x="p" in meta_spec)
+    apply(simp add: set_eqvt)
+    apply(blast)
+    done
+  have "(set as) \<sharp>* f as x c" by (rule fcb1)
+  then have "q \<bullet> ((set as) \<sharp>* f as x c)"
+    by (simp add: permute_bool_def)
+  then have "set (q \<bullet> as) \<sharp>* f (q \<bullet> as) (q \<bullet> x) c"
+    apply(simp add: fresh_star_eqvt set_eqvt)
+    apply(subst (asm) perm1)
+    using inc fresh1 fr1
+    apply(auto simp add: fresh_star_def fresh_Pair)
+    done
+  then have "set (r \<bullet> bs) \<sharp>* f (r \<bullet> bs) (r \<bullet> y) c" using qq1 qq2 by simp
+  then have "r \<bullet> ((set bs) \<sharp>* f bs y c)"
+    apply(simp add: fresh_star_eqvt set_eqvt)
+    apply(subst (asm) perm2[symmetric])
+    using qq3 fresh2 fr1
+    apply(auto simp add: set_eqvt fresh_star_def fresh_Pair)
+    done
+  then have fcb2: "(set bs) \<sharp>* f bs y c" by (simp add: permute_bool_def)
+  have "f as x c = q \<bullet> (f as x c)"
+    apply(rule perm_supp_eq[symmetric])
+    using inc fcb1 fr1 by (auto simp add: fresh_star_def)
+  also have "\<dots> = f (q \<bullet> as) (q \<bullet> x) c" 
+    apply(rule perm1)
+    using inc fresh1 fr1 by (auto simp add: fresh_star_def)
+  also have "\<dots> = f (r \<bullet> bs) (r \<bullet> y) c" using qq1 qq2 by simp
+  also have "\<dots> = r \<bullet> (f bs y c)"
+    apply(rule perm2[symmetric])
+    using qq3 fresh2 fr1 by (auto simp add: fresh_star_def)
+  also have "... = f bs y c"
+    apply(rule perm_supp_eq)
+    using qq3 fr1 fcb2 by (auto simp add: fresh_star_def)
+  finally show ?thesis by simp
+qed
 
 lemma Abs_lst1_fcb2:
-  fixes a b :: "'a :: at"
-    and S T :: "'b :: fs"
-    and c::"'c::fs"
-  assumes e: "(Abs_lst [atom a] T) = (Abs_lst [atom b] S)"
-  and fcb1: "atom a \<sharp> f a T c"
-  and fcb2: "atom b \<sharp> f b S c"
+  fixes a b :: "atom"
+    and x y :: "'b :: fs"
+    and c::"'c :: fs"
+  assumes e: "(Abs_lst [a] x) = (Abs_lst [b] y)"
+  and fcb1: "a \<sharp> f a x c"
+  and fresh: "{a, b} \<sharp>* c"
+  and perm1: "\<And>p. supp p \<sharp>* c \<Longrightarrow> p \<bullet> (f a x c) = f (p \<bullet> a) (p \<bullet> x) c"
+  and perm2: "\<And>p. supp p \<sharp>* c \<Longrightarrow> p \<bullet> (f b y c) = f (p \<bullet> b) (p \<bullet> y) c"
+  shows "f a x c = f b y c"
+using e
+apply(drule_tac Abs_lst_fcb2[where c="c" and f="\<lambda>(as::atom list) . f (hd as)"])
+apply(simp_all)
+using fcb1 fresh perm1 perm2
+apply(simp_all add: fresh_star_def)
+done
+
+lemma Abs_lst1_fcb2':
+  fixes a b :: "'a::at"
+    and x y :: "'b :: fs"
+    and c::"'c :: fs"
+  assumes e: "(Abs_lst [atom a] x) = (Abs_lst [atom b] y)"
+  and fcb1: "atom a \<sharp> f a x c"
   and fresh: "{atom a, atom b} \<sharp>* c"
-  and perm1: "\<And>p. supp p \<sharp>* c \<Longrightarrow> p \<bullet> (f a T c) = f (p \<bullet> a) (p \<bullet> T) c"
-  and perm2: "\<And>p. supp p \<sharp>* c \<Longrightarrow> p \<bullet> (f b S c) = f (p \<bullet> b) (p \<bullet> S) c"
-  shows "f a T c = f b S c"
-proof -
-  have fin1: "finite (supp (f a T c))"
-    apply(rule_tac S="supp (a, T, c)" in supports_finite)
-    apply(simp add: supports_def)
-    apply(simp add: fresh_def[symmetric])
-    apply(clarify)
-    apply(subst perm1)
-    apply(simp add: supp_swap fresh_star_def)
-    apply(simp add: swap_fresh_fresh fresh_Pair)
-    apply(simp add: finite_supp)
-    done
-  have fin2: "finite (supp (f b S c))"
-    apply(rule_tac S="supp (b, S, c)" in supports_finite)
-    apply(simp add: supports_def)
-    apply(simp add: fresh_def[symmetric])
-    apply(clarify)
-    apply(subst perm2)
-    apply(simp add: supp_swap fresh_star_def)
-    apply(simp add: swap_fresh_fresh fresh_Pair)
-    apply(simp add: finite_supp)
-    done
-  obtain d::"'a::at" where fr: "atom d \<sharp> (a, b, S, T, c, f a T c, f b S c)" 
-    using obtain_fresh'[where x="(a, b, S, T, c, f a T c, f b S c)"]
-    apply(auto simp add: finite_supp supp_Pair fin1 fin2)
-    done
-  have "(a \<leftrightarrow> d) \<bullet> (Abs_lst [atom a] T) = (b \<leftrightarrow> d) \<bullet> (Abs_lst [atom b] S)" 
-    apply(simp (no_asm_use) only: flip_def)
-    apply(subst swap_fresh_fresh)
-    apply(simp add: Abs_fresh_iff)
-    using fr
-    apply(simp add: Abs_fresh_iff)
-    apply(subst swap_fresh_fresh)
-    apply(simp add: Abs_fresh_iff)
-    using fr
-    apply(simp add: Abs_fresh_iff)
-    apply(rule e)
-    done
-  then have "Abs_lst [atom d] ((a \<leftrightarrow> d) \<bullet> T) = Abs_lst [atom d] ((b \<leftrightarrow> d) \<bullet> S)"
-    apply (simp add: swap_atom flip_def)
-    done
-  then have eq: "(a \<leftrightarrow> d) \<bullet> T = (b \<leftrightarrow> d) \<bullet> S"
-    by (simp add: Abs1_eq_iff)
-  have "f a T c = (a \<leftrightarrow> d) \<bullet> f a T c"
-    unfolding flip_def
-    apply(rule sym)
-    apply(rule swap_fresh_fresh)
-    using fcb1 
-    apply(simp)
-    using fr
-    apply(simp add: fresh_Pair)
-    done
-  also have "... = f d ((a \<leftrightarrow> d) \<bullet> T) c"
-    unfolding flip_def
-    apply(subst perm1)
-    using fresh fr
-    apply(simp add: supp_swap fresh_star_def fresh_Pair)
-    apply(simp)
-    done
-  also have "... = f d ((b \<leftrightarrow> d) \<bullet> S) c" using eq by simp
-  also have "... = (b \<leftrightarrow> d) \<bullet> f b S c"
-    unfolding flip_def
-    apply(subst perm2)
-    using fresh fr
-    apply(simp add: supp_swap fresh_star_def fresh_Pair)
-    apply(simp)
-    done
-  also have "... = f b S c"   
-    apply(rule flip_fresh_fresh)
-    using fcb2
-    apply(simp)
-    using fr
-    apply(simp add: fresh_Pair)
-    done
-  finally show ?thesis by simp
-qed
+  and perm1: "\<And>p. supp p \<sharp>* c \<Longrightarrow> p \<bullet> (f a x c) = f (p \<bullet> a) (p \<bullet> x) c"
+  and perm2: "\<And>p. supp p \<sharp>* c \<Longrightarrow> p \<bullet> (f b y c) = f (p \<bullet> b) (p \<bullet> y) c"
+  shows "f a x c = f b y c"
+using e
+apply(drule_tac Abs_lst1_fcb2[where c="c" and f="\<lambda>a . f ((inv atom) a)"])
+using  fcb1 fresh perm1 perm2
+apply(simp_all add: fresh_star_def inv_f_f inj_on_def atom_eqvt)
+done
 
 
 atom_decl name
@@ -133,7 +156,6 @@
 apply(auto)
 apply (erule_tac c="()" in Abs_lst1_fcb2)
 apply(simp add: supp_removeAll fresh_def)
-apply(simp add: supp_removeAll fresh_def)
 apply(simp add: fresh_star_def fresh_Unit)
 apply(simp add: eqvt_at_def removeAll_eqvt atom_eqvt)
 apply(simp add: eqvt_at_def removeAll_eqvt atom_eqvt)
@@ -163,7 +185,6 @@
   apply(simp)
   apply(erule_tac c="()" in Abs_lst1_fcb2)
   apply(simp add: fresh_minus_atom_set)
-  apply(simp add: fresh_minus_atom_set)
   apply(simp add: fresh_star_def fresh_Unit)
   apply(simp add: Diff_eqvt eqvt_at_def, perm_simp, rule refl)
   apply(simp add: Diff_eqvt eqvt_at_def, perm_simp, rule refl)
@@ -461,8 +482,7 @@
   apply (auto simp add: fresh_star_def)[3]
   apply(simp_all)
   apply(erule conjE)+
-  apply (erule Abs_lst1_fcb2)
-  apply (simp add: fresh_star_def)
+  apply (erule_tac Abs_lst1_fcb2')
   apply (simp add: fresh_star_def)
   apply (simp add: fresh_star_def)
   apply(simp add: eqvt_at_def atom_eqvt fresh_star_Pair perm_supp_eq)
@@ -487,8 +507,7 @@
   apply(rule_tac y="a" and c="b" in lam.strong_exhaust)
   apply(auto simp add: fresh_star_def)[3]
   apply(erule conjE)
-  apply(erule Abs_lst1_fcb2)
-  apply(simp add: pure_fresh fresh_star_def)
+  apply(erule Abs_lst1_fcb2')
   apply(simp add: pure_fresh fresh_star_def)
   apply(simp add: pure_fresh fresh_star_def)
   apply(simp add: eqvt_at_def atom_eqvt fresh_star_Pair perm_supp_eq)
@@ -557,8 +576,7 @@
   apply (auto simp add: fresh_star_def fresh_at_list)[3]
   apply(simp_all)
   apply(erule conjE)
-  apply (erule_tac c="xsa" in Abs_lst1_fcb2)
-  apply (simp add: pure_fresh)
+  apply (erule_tac c="xsa" in Abs_lst1_fcb2')
   apply (simp add: pure_fresh)
   apply(simp add: fresh_star_def fresh_at_list)
   apply(simp add: eqvt_at_def atom_eqvt fresh_star_Pair perm_supp_eq db_in_eqvt)
@@ -661,19 +679,15 @@
   apply(simp_all)
   apply(erule_tac c="()" in Abs_lst1_fcb2)
   apply (simp add: Abs_fresh_iff)
-  apply (simp add: Abs_fresh_iff)
   apply(simp add: fresh_star_def fresh_Unit)
   apply(simp add: eqvt_at_def atom_eqvt fresh_star_Pair perm_supp_eq)
   apply(simp add: eqvt_at_def atom_eqvt fresh_star_Pair perm_supp_eq)
   apply(erule conjE)
-  apply(erule_tac c="t2a" in Abs_lst1_fcb2)
+  apply(erule_tac c="t2a" in Abs_lst1_fcb2')
   apply (erule fresh_eqvt_at)
   apply (simp add: finite_supp)
   apply (simp add: fresh_Inl var_fresh_subst)
-  apply (erule fresh_eqvt_at)
-  apply (simp add: finite_supp)
-  apply (simp add: fresh_Inl var_fresh_subst)
-  apply(simp add: fresh_star_def fresh_Unit)
+  apply(simp add: fresh_star_def)
   apply(simp add: eqvt_at_def atom_eqvt fresh_star_Pair perm_supp_eq subst_eqvt)
   apply(simp add: eqvt_at_def atom_eqvt fresh_star_Pair perm_supp_eq subst_eqvt)
 done