
diff -r 367f67311e6f -r 7b0c6d07a24e Nominal/Term1.thy
--- a/Nominal/Term1.thy	Sun Mar 07 21:30:12 2010 +0100
+++ b/Nominal/Term1.thy	Sun Mar 07 21:30:57 2010 +0100
@@ -138,14 +138,18 @@
   apply(simp_all add: supp_atom)
   done
 
-instance trm1 :: fs
+instance trm1 and bp :: fs
 apply default
-apply (rule rtrm1_bp_fs(1))
+apply (rule rtrm1_bp_fs)+
+done
+lemma fv_eq_bv_pre: "fv_bp bp = bv1 bp"
+apply(induct bp rule: trm1_bp_inducts(2))
+apply(simp_all)
 done
 
-lemma fv_eq_bv: "fv_bp bp = bv1 bp"
-apply(induct bp rule: trm1_bp_inducts(2))
-apply(simp_all)
+lemma fv_eq_bv: "fv_bp = bv1"
+apply(rule ext)
+apply(rule fv_eq_bv_pre)
 done
 
 lemma helper2: "{b. \<forall>pi. pi \<bullet> (a \<rightleftharpoons> b) \<bullet> bp \<noteq> bp} = {}"
@@ -165,6 +169,71 @@
 apply (rule alpha_bp_eq_eq)
 done
 
+lemma ex_out: 
+  "(\<exists>x. Z x \<and> Q) = (Q \<and> (\<exists>x. Z x))"
+  "(\<exists>x. Q \<and> Z x) = (Q \<and> (\<exists>x. Z x))"
+  "(\<exists>x. P x \<and> Q \<and> Z x) = (Q \<and> (\<exists>x. P x \<and> Z x))"
+  "(\<exists>x. Q \<and> P x \<and> Z x) = (Q \<and> (\<exists>x. P x \<and> Z x))"
+  "(\<exists>x. Q \<and> P x \<and> Z x \<and> W x) = (Q \<and> (\<exists>x. P x \<and> Z x \<and> W x))"
+apply (blast)+
+done
+
+lemma "(Abs bs (x, x') = Abs cs (y, y')) = (\<exists>p. (bs, x) \<approx>gen op = supp p (cs, y) \<and> (bs, x') \<approx>gen op = supp p (cs, y'))"
+thm Abs_eq_iff
+apply (simp add: Abs_eq_iff)
+apply (rule arg_cong[of _ _ "Ex"])
+apply (rule ext)
+apply (simp only: alpha_gen)
+apply (simp only: supp_Pair eqvts)
+apply rule
+apply (erule conjE)+
+oops
+
+lemma "(f (p \<bullet> bp), p \<bullet> bp) \<approx>gen op = f pi (f bp, bp) = False"
+apply (simp add: alpha_gen fresh_star_def)
+oops
+
+(* TODO: permute_ABS should be in eqvt? *)
+
+lemma Collect_neg_conj: "{x. \<not>(P x \<and> Q x)} = {x. \<not>(P x)} \<union> {x. \<not>(Q x)}"
+by (simp add: Collect_imp_eq Collect_neg_eq[symmetric])
+
+lemma "
+{a\<Colon>atom. infinite ({b\<Colon>atom. \<not> (\<exists>pi\<Colon>perm. P pi a b \<and> Q pi a b)})} =
+{a\<Colon>atom. infinite {b\<Colon>atom. \<not> (\<exists>p\<Colon>perm. P p a b)}} \<union>
+{a\<Colon>atom. infinite {b\<Colon>atom. \<not> (\<exists>p\<Colon>perm. Q p a b)}}"
+oops
+
+lemma inf_or: "(infinite x \<or> infinite y) = infinite (x \<union> y)"
+by (simp add: finite_Un)
+
+
+lemma supp_fv_let:
+  assumes sa : "fv_bp bp = supp bp"
+  shows "\<lbrakk>fv_trm1 rtrm11 = supp rtrm11; fv_trm1 rtrm12 = supp rtrm12\<rbrakk>
+       \<Longrightarrow> supp (Lt1 bp rtrm11 rtrm12) = fv_trm1 (Lt1 bp rtrm11 rtrm12)"
+apply(simp only: fv_trm1 fv_eq_bv sa[simplified fv_eq_bv])
+apply(fold supp_Abs)
+apply(simp only: fv_trm1 fv_eq_bv sa[simplified fv_eq_bv,symmetric])
+apply(simp (no_asm) only: supp_def permute_set_eq permute_trm1 alpha1_INJ)
+apply(simp only: ex_out Collect_neg_conj permute_ABS Abs_eq_iff)
+apply(simp only: alpha_bp_eq fv_eq_bv)
+apply(simp only: alpha_gen fv_eq_bv supp_Pair)
+apply(simp only: supp_eqvt[symmetric] fv_trm1_eqvt[symmetric] bv1_eqvt fv_eq_bv sa[simplified fv_eq_bv,symmetric])
+apply(simp only: Un_left_commute)
+apply simp
+apply(simp add: fresh_star_def) apply(fold fresh_star_def)
+apply(simp add: Collect_imp_eq Collect_neg_eq[symmetric])
+apply(tactic {* Cong_Tac.cong_tac @{thm cong} 1 *}) apply(rule refl)
+apply(simp only: Un_assoc[symmetric])
+apply(simp only: Un_commute)
+apply(simp only: Un_left_commute)
+apply(simp only: Un_assoc[symmetric])
+apply(simp only: Un_commute)
+apply(tactic {* Cong_Tac.cong_tac @{thm cong} 1 *}) apply(rule refl)
+apply(simp only: Collect_disj_eq[symmetric] inf_or)
+sorry
+
 lemma supp_fv:
   "supp t = fv_trm1 t"
   "supp b = fv_bp b"
@@ -173,7 +242,7 @@
 apply(simp add: supp_def permute_trm1 alpha1_INJ fv_trm1)
 apply(simp only: supp_at_base[simplified supp_def])
 apply(simp add: supp_def permute_trm1 alpha1_INJ fv_trm1)
-apply(simp add: Collect_imp_eq Collect_neg_eq)
+apply(simp add: Collect_imp_eq Collect_neg_eq Un_commute)
 apply(subgoal_tac "supp (Lm1 name rtrm1) = supp (Abs {atom name} rtrm1)")
 apply(simp add: supp_Abs fv_trm1)
 apply(simp (no_asm) add: supp_def permute_set_eq atom_eqvt permute_trm1)
@@ -181,21 +250,32 @@
 apply(simp add: Abs_eq_iff)
 apply(simp add: alpha_gen.simps)
 apply(simp add: supp_eqvt[symmetric] fv_trm1_eqvt[symmetric])
-apply(subgoal_tac "supp (Lt1 bp rtrm11 rtrm12) = supp(rtrm11) \<union> supp (Abs (bv1 bp) rtrm12)")
-apply(simp add: supp_Abs fv_trm1 fv_eq_bv)
-apply(simp (no_asm) add: supp_def permute_trm1)
-apply(simp add: alpha1_INJ alpha_bp_eq)
-apply(simp add: Abs_eq_iff)
-apply(simp add: alpha_gen)
-apply(simp add: supp_eqvt[symmetric] fv_trm1_eqvt[symmetric] bv1_eqvt fv_eq_bv)
-apply(simp add: Collect_imp_eq Collect_neg_eq fresh_star_def helper2)
+defer
 apply(simp (no_asm) add: supp_def permute_set_eq atom_eqvt)
 apply(simp (no_asm) add: supp_def eqvts)
 apply(fold supp_def)
 apply(simp add: supp_at_base)
 apply(simp (no_asm) add: supp_def Collect_imp_eq Collect_neg_eq)
 apply(simp add: Collect_imp_eq[symmetric] Collect_neg_eq[symmetric] supp_def[symmetric])
-done
+(*apply(rule supp_fv_let) apply(simp_all)*)
+apply(subgoal_tac "supp (Lt1 bp rtrm11 rtrm12) = supp (Abs (bv1 bp) (rtrm12)) \<union> supp(rtrm11)")
+(*apply(subgoal_tac "supp (Lt1 bp rtrm11 rtrm12) = supp (Abs (bv1 bp) (bp, rtrm12)) \<union> supp(rtrm11)")*)
+apply(simp add: supp_Abs fv_trm1 supp_Pair Un_Diff Un_assoc fv_eq_bv)
+apply(blast) (* Un_commute in a good place *)
+apply(simp (no_asm) only: supp_def permute_set_eq atom_eqvt permute_trm1)
+apply(simp only: alpha1_INJ permute_ABS permute_prod.simps Abs_eq_iff)
+apply(simp only: ex_out)
+apply(simp only: Un_commute)
+apply(simp only: alpha_bp_eq fv_eq_bv)
+apply(simp only: alpha_gen fv_eq_bv supp_Pair)
+apply(simp only: supp_eqvt[symmetric] fv_trm1_eqvt[symmetric] bv1_eqvt fv_eq_bv)
+apply(simp only: ex_out)
+apply(simp only: Collect_neg_conj finite_Un Diff_cancel)
+apply(simp)
+apply(simp add: Collect_imp_eq)
+apply(simp add: Collect_neg_eq[symmetric] fresh_star_def)
+apply(fold supp_def)
+sorry
 
 lemma trm1_supp:
   "supp (Vr1 x) = {atom x}"




