merged
authorhuffman
Sat Oct 16 16:39:06 2010 -0700 (2010-10-16)
changeset 4002798f2d8280eb4
parent 40026 8f8f18a88685
parent 39998 b253319c9a95
child 40028 9ee4e0ab2964
merged
     1.1 --- a/NEWS	Sat Oct 16 16:22:42 2010 -0700
     1.2 +++ b/NEWS	Sat Oct 16 16:39:06 2010 -0700
     1.3 @@ -103,6 +103,8 @@
     1.4  
     1.5  * Dropped type classes mult_mono and mult_mono1.  INCOMPATIBILITY.
     1.6  
     1.7 +* Removed output syntax "'a ~=> 'b" for "'a => 'b option". INCOMPATIBILITY.
     1.8 +
     1.9  * Theory SetsAndFunctions has been split into Function_Algebras and Set_Algebras;
    1.10  canonical names for instance definitions for functions; various improvements.
    1.11  INCOMPATIBILITY.
     2.1 --- a/src/HOL/Algebra/Lattice.thy	Sat Oct 16 16:22:42 2010 -0700
     2.2 +++ b/src/HOL/Algebra/Lattice.thy	Sat Oct 16 16:39:06 2010 -0700
     2.3 @@ -233,9 +233,8 @@
     2.4    assumes Acarr: "A \<subseteq> carrier L" and A'carr: "A' \<subseteq> carrier L"
     2.5      and AA': "A {.=} A'"
     2.6    shows "Lower L A = Lower L A'"
     2.7 -using Lower_memD[of y]
     2.8  unfolding Lower_def
     2.9 -apply safe
    2.10 +apply rule
    2.11   apply clarsimp defer 1
    2.12   apply clarsimp defer 1
    2.13  proof -
     3.1 --- a/src/HOL/Map.thy	Sat Oct 16 16:22:42 2010 -0700
     3.2 +++ b/src/HOL/Map.thy	Sat Oct 16 16:39:06 2010 -0700
     3.3 @@ -12,7 +12,6 @@
     3.4  begin
     3.5  
     3.6  types ('a,'b) "map" = "'a => 'b option" (infixr "~=>" 0)
     3.7 -translations (type) "'a ~=> 'b" <= (type) "'a => 'b option"
     3.8  
     3.9  type_notation (xsymbols)
    3.10    "map" (infixr "\<rightharpoonup>" 0)
     4.1 --- a/src/HOL/Quotient_Examples/FSet.thy	Sat Oct 16 16:22:42 2010 -0700
     4.2 +++ b/src/HOL/Quotient_Examples/FSet.thy	Sat Oct 16 16:39:06 2010 -0700
     4.3 @@ -14,7 +14,7 @@
     4.4  fun
     4.5    list_eq :: "'a list \<Rightarrow> 'a list \<Rightarrow> bool" (infix "\<approx>" 50)
     4.6  where
     4.7 -  "list_eq xs ys = (\<forall>x. x \<in> set xs \<longleftrightarrow> x \<in> set ys)"
     4.8 +  "list_eq xs ys = (set xs = set ys)"
     4.9  
    4.10  lemma list_eq_equivp:
    4.11    shows "equivp list_eq"
    4.12 @@ -26,7 +26,9 @@
    4.13    'a fset = "'a list" / "list_eq"
    4.14    by (rule list_eq_equivp)
    4.15  
    4.16 -text {* Raw definitions *}
    4.17 +text {* Raw definitions of membership, sublist, cardinality,
    4.18 +  intersection
    4.19 +*}
    4.20  
    4.21  definition
    4.22    memb :: "'a \<Rightarrow> 'a list \<Rightarrow> bool"
    4.23 @@ -36,32 +38,25 @@
    4.24  definition
    4.25    sub_list :: "'a list \<Rightarrow> 'a list \<Rightarrow> bool"
    4.26  where
    4.27 -  "sub_list xs ys \<equiv> (\<forall>x. x \<in> set xs \<longrightarrow> x \<in> set ys)"
    4.28 +  "sub_list xs ys \<equiv> set xs \<subseteq> set ys"
    4.29  
    4.30 -fun
    4.31 +definition
    4.32    fcard_raw :: "'a list \<Rightarrow> nat"
    4.33  where
    4.34 -  fcard_raw_nil:  "fcard_raw [] = 0"
    4.35 -| fcard_raw_cons: "fcard_raw (x # xs) = (if memb x xs then fcard_raw xs else Suc (fcard_raw xs))"
    4.36 +  "fcard_raw xs = card (set xs)"
    4.37  
    4.38  primrec
    4.39    finter_raw :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list"
    4.40  where
    4.41 -  "finter_raw [] l = []"
    4.42 -| "finter_raw (h # t) l =
    4.43 -     (if memb h l then h # (finter_raw t l) else finter_raw t l)"
    4.44 -
    4.45 -primrec
    4.46 -  delete_raw :: "'a list \<Rightarrow> 'a \<Rightarrow> 'a list"
    4.47 -where
    4.48 -  "delete_raw [] x = []"
    4.49 -| "delete_raw (a # xs) x = (if (a = x) then delete_raw xs x else a # (delete_raw xs x))"
    4.50 +  "finter_raw [] ys = []"
    4.51 +| "finter_raw (x # xs) ys =
    4.52 +    (if x \<in> set ys then x # (finter_raw xs ys) else finter_raw xs ys)"
    4.53  
    4.54  primrec
    4.55    fminus_raw :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list"
    4.56  where
    4.57 -  "fminus_raw l [] = l"
    4.58 -| "fminus_raw l (h # t) = fminus_raw (delete_raw l h) t"
    4.59 +  "fminus_raw ys [] = ys"
    4.60 +| "fminus_raw ys (x # xs) = fminus_raw (removeAll x ys) xs"
    4.61  
    4.62  definition
    4.63    rsp_fold
    4.64 @@ -74,13 +69,13 @@
    4.65    "ffold_raw f z [] = z"
    4.66  | "ffold_raw f z (a # xs) =
    4.67       (if (rsp_fold f) then
    4.68 -       if memb a xs then ffold_raw f z xs
    4.69 +       if a \<in> set xs then ffold_raw f z xs
    4.70         else f a (ffold_raw f z xs)
    4.71       else z)"
    4.72  
    4.73  text {* Composition Quotient *}
    4.74  
    4.75 -lemma list_all2_refl:
    4.76 +lemma list_all2_refl1:
    4.77    shows "(list_all2 op \<approx>) r r"
    4.78    by (rule list_all2_refl) (metis equivp_def fset_equivp)
    4.79  
    4.80 @@ -88,7 +83,7 @@
    4.81    shows "(list_all2 op \<approx> OOO op \<approx>) r r"
    4.82  proof
    4.83    have *: "r \<approx> r" by (rule equivp_reflp[OF fset_equivp])
    4.84 -  show "list_all2 op \<approx> r r" by (rule list_all2_refl)
    4.85 +  show "list_all2 op \<approx> r r" by (rule list_all2_refl1)
    4.86    with * show "(op \<approx> OO list_all2 op \<approx>) r r" ..
    4.87  qed
    4.88  
    4.89 @@ -96,12 +91,9 @@
    4.90    shows "Quotient (list_all2 op \<approx>) (map abs_fset) (map rep_fset)"
    4.91    by (fact list_quotient[OF Quotient_fset])
    4.92  
    4.93 -lemma set_in_eq: "(\<forall>e. ((e \<in> xs) \<longleftrightarrow> (e \<in> ys))) \<equiv> xs = ys"
    4.94 -  by (rule eq_reflection) auto
    4.95 -
    4.96  lemma map_rel_cong: "b \<approx> ba \<Longrightarrow> map f b \<approx> map f ba"
    4.97    unfolding list_eq.simps
    4.98 -  by (simp only: set_map set_in_eq)
    4.99 +  by (simp only: set_map)
   4.100  
   4.101  lemma quotient_compose_list[quot_thm]:
   4.102    shows  "Quotient ((list_all2 op \<approx>) OOO (op \<approx>))
   4.103 @@ -112,11 +104,11 @@
   4.104    show "abs_fset (map abs_fset (map rep_fset (rep_fset a))) = a"
   4.105      by (simp add: abs_o_rep[OF Quotient_fset] Quotient_abs_rep[OF Quotient_fset] map_id)
   4.106    have b: "list_all2 op \<approx> (map rep_fset (rep_fset a)) (map rep_fset (rep_fset a))"
   4.107 -    by (rule list_all2_refl)
   4.108 +    by (rule list_all2_refl1)
   4.109    have c: "(op \<approx> OO list_all2 op \<approx>) (map rep_fset (rep_fset a)) (map rep_fset (rep_fset a))"
   4.110      by (rule, rule equivp_reflp[OF fset_equivp]) (rule b)
   4.111    show "(list_all2 op \<approx> OOO op \<approx>) (map rep_fset (rep_fset a)) (map rep_fset (rep_fset a))"
   4.112 -    by (rule, rule list_all2_refl) (rule c)
   4.113 +    by (rule, rule list_all2_refl1) (rule c)
   4.114    show "(list_all2 op \<approx> OOO op \<approx>) r s = ((list_all2 op \<approx> OOO op \<approx>) r r \<and>
   4.115          (list_all2 op \<approx> OOO op \<approx>) s s \<and> abs_fset (map abs_fset r) = abs_fset (map abs_fset s))"
   4.116    proof (intro iffI conjI)
   4.117 @@ -148,23 +140,33 @@
   4.118      have b: "map rep_fset (map abs_fset r) \<approx> map rep_fset (map abs_fset s)"
   4.119        by (rule map_rel_cong[OF d])
   4.120      have y: "list_all2 op \<approx> (map rep_fset (map abs_fset s)) s"
   4.121 -      by (fact rep_abs_rsp_left[OF Quotient_fset_list, OF list_all2_refl[of s]])
   4.122 +      by (fact rep_abs_rsp_left[OF Quotient_fset_list, OF list_all2_refl1[of s]])
   4.123      have c: "(op \<approx> OO list_all2 op \<approx>) (map rep_fset (map abs_fset r)) s"
   4.124        by (rule pred_compI) (rule b, rule y)
   4.125      have z: "list_all2 op \<approx> r (map rep_fset (map abs_fset r))"
   4.126 -      by (fact rep_abs_rsp[OF Quotient_fset_list, OF list_all2_refl[of r]])
   4.127 +      by (fact rep_abs_rsp[OF Quotient_fset_list, OF list_all2_refl1[of r]])
   4.128      then show "(list_all2 op \<approx> OOO op \<approx>) r s"
   4.129        using a c pred_compI by simp
   4.130    qed
   4.131  qed
   4.132  
   4.133 +
   4.134 +lemma set_finter_raw[simp]:
   4.135 +  "set (finter_raw xs ys) = set xs \<inter> set ys"
   4.136 +  by (induct xs) (auto simp add: memb_def)
   4.137 +
   4.138 +lemma set_fminus_raw[simp]: 
   4.139 +  "set (fminus_raw xs ys) = (set xs - set ys)"
   4.140 +  by (induct ys arbitrary: xs) (auto)
   4.141 +
   4.142 +
   4.143  text {* Respectfullness *}
   4.144  
   4.145 -lemma [quot_respect]:
   4.146 -  shows "(op \<approx> ===> op \<approx> ===> op \<approx>) op @ op @"
   4.147 -  by auto
   4.148 +lemma append_rsp[quot_respect]:
   4.149 +  shows "(op \<approx> ===> op \<approx> ===> op \<approx>) append append"
   4.150 +  by (simp)
   4.151  
   4.152 -lemma [quot_respect]:
   4.153 +lemma sub_list_rsp[quot_respect]:
   4.154    shows "(op \<approx> ===> op \<approx> ===> op =) sub_list sub_list"
   4.155    by (auto simp add: sub_list_def)
   4.156  
   4.157 @@ -173,11 +175,11 @@
   4.158    by (auto simp add: memb_def)
   4.159  
   4.160  lemma nil_rsp[quot_respect]:
   4.161 -  shows "[] \<approx> []"
   4.162 +  shows "(op \<approx>) Nil Nil"
   4.163    by simp
   4.164  
   4.165  lemma cons_rsp[quot_respect]:
   4.166 -  shows "(op = ===> op \<approx> ===> op \<approx>) op # op #"
   4.167 +  shows "(op = ===> op \<approx> ===> op \<approx>) Cons Cons"
   4.168    by simp
   4.169  
   4.170  lemma map_rsp[quot_respect]:
   4.171 @@ -192,6 +194,24 @@
   4.172    shows "(op \<approx> ===> op \<approx> ===> op =) op \<approx> op \<approx>"
   4.173    by auto
   4.174  
   4.175 +lemma finter_raw_rsp[quot_respect]:
   4.176 +  shows "(op \<approx> ===> op \<approx> ===> op \<approx>) finter_raw finter_raw"
   4.177 +  by simp
   4.178 +
   4.179 +lemma removeAll_rsp[quot_respect]:
   4.180 +  shows "(op = ===> op \<approx> ===> op \<approx>) removeAll removeAll"
   4.181 +  by simp
   4.182 +
   4.183 +lemma fminus_raw_rsp[quot_respect]:
   4.184 +  shows "(op \<approx> ===> op \<approx> ===> op \<approx>) fminus_raw fminus_raw"
   4.185 +  by simp
   4.186 +
   4.187 +lemma fcard_raw_rsp[quot_respect]:
   4.188 +  shows "(op \<approx> ===> op =) fcard_raw fcard_raw"
   4.189 +  by (simp add: fcard_raw_def)
   4.190 +
   4.191 +
   4.192 +
   4.193  lemma not_memb_nil:
   4.194    shows "\<not> memb x []"
   4.195    by (simp add: memb_def)
   4.196 @@ -200,85 +220,6 @@
   4.197    shows "memb x (y # xs) = (x = y \<or> memb x xs)"
   4.198    by (induct xs) (auto simp add: memb_def)
   4.199  
   4.200 -lemma memb_finter_raw:
   4.201 -  "memb x (finter_raw xs ys) \<longleftrightarrow> memb x xs \<and> memb x ys"
   4.202 -  by (induct xs) (auto simp add: not_memb_nil memb_cons_iff)
   4.203 -
   4.204 -lemma [quot_respect]:
   4.205 -  "(op \<approx> ===> op \<approx> ===> op \<approx>) finter_raw finter_raw"
   4.206 -  by (simp add: memb_def[symmetric] memb_finter_raw)
   4.207 -
   4.208 -lemma memb_delete_raw:
   4.209 -  "memb x (delete_raw xs y) = (memb x xs \<and> x \<noteq> y)"
   4.210 -  by (induct xs arbitrary: x y) (auto simp add: memb_def)
   4.211 -
   4.212 -lemma [quot_respect]:
   4.213 -  "(op \<approx> ===> op = ===> op \<approx>) delete_raw delete_raw"
   4.214 -  by (simp add: memb_def[symmetric] memb_delete_raw)
   4.215 -
   4.216 -lemma fminus_raw_memb: "memb x (fminus_raw xs ys) = (memb x xs \<and> \<not> memb x ys)"
   4.217 -  by (induct ys arbitrary: xs)
   4.218 -     (simp_all add: not_memb_nil memb_delete_raw memb_cons_iff)
   4.219 -
   4.220 -lemma [quot_respect]:
   4.221 -  "(op \<approx> ===> op \<approx> ===> op \<approx>) fminus_raw fminus_raw"
   4.222 -  by (simp add: memb_def[symmetric] fminus_raw_memb)
   4.223 -
   4.224 -lemma fcard_raw_gt_0:
   4.225 -  assumes a: "x \<in> set xs"
   4.226 -  shows "0 < fcard_raw xs"
   4.227 -  using a by (induct xs) (auto simp add: memb_def)
   4.228 -
   4.229 -lemma fcard_raw_delete_one:
   4.230 -  shows "fcard_raw ([x \<leftarrow> xs. x \<noteq> y]) = (if memb y xs then fcard_raw xs - 1 else fcard_raw xs)"
   4.231 -  by (induct xs) (auto dest: fcard_raw_gt_0 simp add: memb_def)
   4.232 -
   4.233 -lemma fcard_raw_rsp_aux:
   4.234 -  assumes a: "xs \<approx> ys"
   4.235 -  shows "fcard_raw xs = fcard_raw ys"
   4.236 -  using a
   4.237 -  proof (induct xs arbitrary: ys)
   4.238 -    case Nil
   4.239 -    show ?case using Nil.prems by simp
   4.240 -  next
   4.241 -    case (Cons a xs)
   4.242 -    have a: "a # xs \<approx> ys" by fact
   4.243 -    have b: "\<And>ys. xs \<approx> ys \<Longrightarrow> fcard_raw xs = fcard_raw ys" by fact
   4.244 -    show ?case proof (cases "a \<in> set xs")
   4.245 -      assume c: "a \<in> set xs"
   4.246 -      have "\<forall>x. (x \<in> set xs) = (x \<in> set ys)"
   4.247 -      proof (intro allI iffI)
   4.248 -        fix x
   4.249 -        assume "x \<in> set xs"
   4.250 -        then show "x \<in> set ys" using a by auto
   4.251 -      next
   4.252 -        fix x
   4.253 -        assume d: "x \<in> set ys"
   4.254 -        have e: "(x \<in> set (a # xs)) = (x \<in> set ys)" using a by simp
   4.255 -        show "x \<in> set xs" using c d e unfolding list_eq.simps by simp blast
   4.256 -      qed
   4.257 -      then show ?thesis using b c by (simp add: memb_def)
   4.258 -    next
   4.259 -      assume c: "a \<notin> set xs"
   4.260 -      have d: "xs \<approx> [x\<leftarrow>ys . x \<noteq> a] \<Longrightarrow> fcard_raw xs = fcard_raw [x\<leftarrow>ys . x \<noteq> a]" using b by simp
   4.261 -      have "Suc (fcard_raw xs) = fcard_raw ys"
   4.262 -      proof (cases "a \<in> set ys")
   4.263 -        assume e: "a \<in> set ys"
   4.264 -        have f: "\<forall>x. (x \<in> set xs) = (x \<in> set ys \<and> x \<noteq> a)" using a c
   4.265 -          by (auto simp add: fcard_raw_delete_one)
   4.266 -        have "fcard_raw ys = Suc (fcard_raw ys - 1)" by (rule Suc_pred'[OF fcard_raw_gt_0]) (rule e)
   4.267 -        then show ?thesis using d e f by (simp_all add: fcard_raw_delete_one memb_def)
   4.268 -      next
   4.269 -        case False then show ?thesis using a c d by auto
   4.270 -      qed
   4.271 -      then show ?thesis using a c d by (simp add: memb_def)
   4.272 -  qed
   4.273 -qed
   4.274 -
   4.275 -lemma fcard_raw_rsp[quot_respect]:
   4.276 -  shows "(op \<approx> ===> op =) fcard_raw fcard_raw"
   4.277 -  by (simp add: fcard_raw_rsp_aux)
   4.278 -
   4.279  lemma memb_absorb:
   4.280    shows "memb x xs \<Longrightarrow> x # xs \<approx> xs"
   4.281    by (induct xs) (auto simp add: memb_def)
   4.282 @@ -287,53 +228,35 @@
   4.283    "(\<forall>x. \<not> memb x xs) = (xs \<approx> [])"
   4.284    by (simp add: memb_def)
   4.285  
   4.286 -lemma not_memb_delete_raw_ident:
   4.287 -  shows "\<not> memb x xs \<Longrightarrow> delete_raw xs x = xs"
   4.288 -  by (induct xs) (auto simp add: memb_def)
   4.289  
   4.290  lemma memb_commute_ffold_raw:
   4.291 -  "rsp_fold f \<Longrightarrow> memb h b \<Longrightarrow> ffold_raw f z b = f h (ffold_raw f z (delete_raw b h))"
   4.292 +  "rsp_fold f \<Longrightarrow> h \<in> set b \<Longrightarrow> ffold_raw f z b = f h (ffold_raw f z (removeAll h b))"
   4.293    apply (induct b)
   4.294 -  apply (simp_all add: not_memb_nil)
   4.295 -  apply (auto)
   4.296 -  apply (simp_all add: memb_delete_raw not_memb_delete_raw_ident rsp_fold_def  memb_cons_iff)
   4.297 +  apply (auto simp add: rsp_fold_def)
   4.298    done
   4.299  
   4.300  lemma ffold_raw_rsp_pre:
   4.301 -  "\<forall>e. memb e a = memb e b \<Longrightarrow> ffold_raw f z a = ffold_raw f z b"
   4.302 +  "set a = set b \<Longrightarrow> ffold_raw f z a = ffold_raw f z b"
   4.303    apply (induct a arbitrary: b)
   4.304 -  apply (simp add: memb_absorb memb_def none_memb_nil)
   4.305    apply (simp)
   4.306 +  apply (simp (no_asm_use))
   4.307    apply (rule conjI)
   4.308    apply (rule_tac [!] impI)
   4.309    apply (rule_tac [!] conjI)
   4.310    apply (rule_tac [!] impI)
   4.311 -  apply (subgoal_tac "\<forall>e. memb e a2 = memb e b")
   4.312 -  apply (simp)
   4.313 -  apply (simp add: memb_cons_iff memb_def)
   4.314 -  apply (auto)[1]
   4.315 -  apply (drule_tac x="e" in spec)
   4.316 -  apply (blast)
   4.317 -  apply (case_tac b)
   4.318 -  apply (simp_all)
   4.319 -  apply (subgoal_tac "ffold_raw f z b = f a1 (ffold_raw f z (delete_raw b a1))")
   4.320 -  apply (simp only:)
   4.321 -  apply (rule_tac f="f a1" in arg_cong)
   4.322 -  apply (subgoal_tac "\<forall>e. memb e a2 = memb e (delete_raw b a1)")
   4.323 -  apply (simp)
   4.324 -  apply (simp add: memb_delete_raw)
   4.325 -  apply (auto simp add: memb_cons_iff)[1]
   4.326 -  apply (erule memb_commute_ffold_raw)
   4.327 -  apply (drule_tac x="a1" in spec)
   4.328 -  apply (simp add: memb_cons_iff)
   4.329 -  apply (simp add: memb_cons_iff)
   4.330 -  apply (case_tac b)
   4.331 -  apply (simp_all)
   4.332 -  done
   4.333 +  apply (metis insert_absorb)
   4.334 +  apply (metis List.insert_def List.set.simps(2) List.set_insert ffold_raw.simps(2))
   4.335 +  apply (metis Diff_insert_absorb insertI1 memb_commute_ffold_raw set_removeAll)
   4.336 +  apply(drule_tac x="removeAll a1 b" in meta_spec)
   4.337 +  apply(auto)
   4.338 +  apply(drule meta_mp)
   4.339 +  apply(blast)
   4.340 +  by (metis List.set.simps(2) emptyE ffold_raw.simps(2) in_listsp_conv_set listsp.simps mem_def)
   4.341  
   4.342 -lemma [quot_respect]:
   4.343 -  "(op = ===> op = ===> op \<approx> ===> op =) ffold_raw ffold_raw"
   4.344 -  by (simp add: memb_def[symmetric] ffold_raw_rsp_pre)
   4.345 +lemma ffold_raw_rsp[quot_respect]:
   4.346 +  shows "(op = ===> op = ===> op \<approx> ===> op =) ffold_raw ffold_raw"
   4.347 +  unfolding fun_rel_def
   4.348 +  by(auto intro: ffold_raw_rsp_pre)
   4.349  
   4.350  lemma concat_rsp_pre:
   4.351    assumes a: "list_all2 op \<approx> x x'"
   4.352 @@ -350,16 +273,18 @@
   4.353    then show ?thesis using f i by auto
   4.354  qed
   4.355  
   4.356 -lemma [quot_respect]:
   4.357 +lemma concat_rsp[quot_respect]:
   4.358    shows "(list_all2 op \<approx> OOO op \<approx> ===> op \<approx>) concat concat"
   4.359  proof (rule fun_relI, elim pred_compE)
   4.360    fix a b ba bb
   4.361    assume a: "list_all2 op \<approx> a ba"
   4.362    assume b: "ba \<approx> bb"
   4.363    assume c: "list_all2 op \<approx> bb b"
   4.364 -  have "\<forall>x. (\<exists>xa\<in>set a. x \<in> set xa) = (\<exists>xa\<in>set b. x \<in> set xa)" proof
   4.365 +  have "\<forall>x. (\<exists>xa\<in>set a. x \<in> set xa) = (\<exists>xa\<in>set b. x \<in> set xa)" 
   4.366 +  proof
   4.367      fix x
   4.368 -    show "(\<exists>xa\<in>set a. x \<in> set xa) = (\<exists>xa\<in>set b. x \<in> set xa)" proof
   4.369 +    show "(\<exists>xa\<in>set a. x \<in> set xa) = (\<exists>xa\<in>set b. x \<in> set xa)" 
   4.370 +    proof
   4.371        assume d: "\<exists>xa\<in>set a. x \<in> set xa"
   4.372        show "\<exists>xa\<in>set b. x \<in> set xa" by (rule concat_rsp_pre[OF a b c d])
   4.373      next
   4.374 @@ -370,11 +295,11 @@
   4.375        show "\<exists>xa\<in>set a. x \<in> set xa" by (rule concat_rsp_pre[OF c' b' a' e])
   4.376      qed
   4.377    qed
   4.378 -  then show "concat a \<approx> concat b" by simp
   4.379 +  then show "concat a \<approx> concat b" by auto
   4.380  qed
   4.381  
   4.382  lemma [quot_respect]:
   4.383 -  "((op =) ===> op \<approx> ===> op \<approx>) filter filter"
   4.384 +  shows "((op =) ===> op \<approx> ===> op \<approx>) filter filter"
   4.385    by auto
   4.386  
   4.387  text {* Distributive lattice with bot *}
   4.388 @@ -382,9 +307,7 @@
   4.389  lemma append_inter_distrib:
   4.390    "x @ (finter_raw y z) \<approx> finter_raw (x @ y) (x @ z)"
   4.391    apply (induct x)
   4.392 -  apply (simp_all add: memb_def)
   4.393 -  apply (simp add: memb_def[symmetric] memb_finter_raw)
   4.394 -  apply (auto simp add: memb_def)
   4.395 +  apply (auto)
   4.396    done
   4.397  
   4.398  instantiation fset :: (type) "{bounded_lattice_bot, distrib_lattice, minus}"
   4.399 @@ -409,18 +332,19 @@
   4.400    "xs |\<subseteq>| ys \<equiv> xs \<le> ys"
   4.401  
   4.402  definition
   4.403 -  less_fset:
   4.404 -  "(xs :: 'a fset) < ys \<equiv> xs \<le> ys \<and> xs \<noteq> ys"
   4.405 +  less_fset :: "'a fset \<Rightarrow> 'a fset \<Rightarrow> bool"
   4.406 +where  
   4.407 +  "xs < ys \<equiv> xs \<le> ys \<and> xs \<noteq> (ys::'a fset)"
   4.408  
   4.409  abbreviation
   4.410 -  f_subset :: "'a fset \<Rightarrow> 'a fset \<Rightarrow> bool" (infix "|\<subset>|" 50)
   4.411 +  fsubset :: "'a fset \<Rightarrow> 'a fset \<Rightarrow> bool" (infix "|\<subset>|" 50)
   4.412  where
   4.413    "xs |\<subset>| ys \<equiv> xs < ys"
   4.414  
   4.415  quotient_definition
   4.416 -  "sup  \<Colon> ('a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset)"
   4.417 +  "sup :: 'a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
   4.418  is
   4.419 -  "(op @) \<Colon> ('a list \<Rightarrow> 'a list \<Rightarrow> 'a list)"
   4.420 +  "append :: 'a list \<Rightarrow> 'a list \<Rightarrow> 'a list"
   4.421  
   4.422  abbreviation
   4.423    funion (infixl "|\<union>|" 65)
   4.424 @@ -428,9 +352,9 @@
   4.425    "xs |\<union>| ys \<equiv> sup (xs :: 'a fset) ys"
   4.426  
   4.427  quotient_definition
   4.428 -  "inf \<Colon> ('a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset)"
   4.429 +  "inf :: 'a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
   4.430  is
   4.431 -  "finter_raw \<Colon> ('a list \<Rightarrow> 'a list \<Rightarrow> 'a list)"
   4.432 +  "finter_raw :: 'a list \<Rightarrow> 'a list \<Rightarrow> 'a list"
   4.433  
   4.434  abbreviation
   4.435    finter (infixl "|\<inter>|" 65)
   4.436 @@ -446,16 +370,16 @@
   4.437  proof
   4.438    fix x y z :: "'a fset"
   4.439    show "x |\<subset>| y \<longleftrightarrow> x |\<subseteq>| y \<and> \<not> y |\<subseteq>| x"
   4.440 -    unfolding less_fset 
   4.441 +    unfolding less_fset_def 
   4.442      by (descending) (auto simp add: sub_list_def)
   4.443    show "x |\<subseteq>| x"  by (descending) (simp add: sub_list_def)
   4.444    show "{||} |\<subseteq>| x" by (descending) (simp add: sub_list_def)
   4.445    show "x |\<subseteq>| x |\<union>| y" by (descending) (simp add: sub_list_def)
   4.446    show "y |\<subseteq>| x |\<union>| y" by (descending) (simp add: sub_list_def)
   4.447 -  show "x |\<inter>| y |\<subseteq>| x" 
   4.448 -    by (descending) (simp add: sub_list_def memb_def[symmetric] memb_finter_raw)
   4.449 +  show "x |\<inter>| y |\<subseteq>| x"
   4.450 +    by (descending) (simp add: sub_list_def memb_def[symmetric])
   4.451    show "x |\<inter>| y |\<subseteq>| y" 
   4.452 -    by (descending) (simp add: sub_list_def memb_def[symmetric] memb_finter_raw)
   4.453 +    by (descending) (simp add: sub_list_def memb_def[symmetric])
   4.454    show "x |\<union>| (y |\<inter>| z) = x |\<union>| y |\<inter>| (x |\<union>| z)" 
   4.455      by (descending) (rule append_inter_distrib)
   4.456  next
   4.457 @@ -481,7 +405,7 @@
   4.458    assume a: "x |\<subseteq>| y"
   4.459    assume b: "x |\<subseteq>| z"
   4.460    show "x |\<subseteq>| y |\<inter>| z" using a b 
   4.461 -    by (descending) (simp add: sub_list_def memb_def[symmetric] memb_finter_raw)
   4.462 +    by (descending) (simp add: sub_list_def memb_def[symmetric])
   4.463  qed
   4.464  
   4.465  end
   4.466 @@ -490,7 +414,7 @@
   4.467  
   4.468  quotient_definition
   4.469    "finsert :: 'a \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
   4.470 -is "op #"
   4.471 +is "Cons"
   4.472  
   4.473  syntax
   4.474    "@Finset"     :: "args => 'a fset"  ("{|(_)|}")
   4.475 @@ -514,19 +438,19 @@
   4.476  quotient_definition
   4.477    "fcard :: 'a fset \<Rightarrow> nat"
   4.478  is
   4.479 -  "fcard_raw"
   4.480 +  fcard_raw
   4.481  
   4.482  quotient_definition
   4.483    "fmap :: ('a \<Rightarrow> 'b) \<Rightarrow> 'a fset \<Rightarrow> 'b fset"
   4.484  is
   4.485 - "map"
   4.486 +  map
   4.487  
   4.488  quotient_definition
   4.489 -  "fdelete :: 'a fset \<Rightarrow> 'a \<Rightarrow> 'a fset"
   4.490 -  is "delete_raw"
   4.491 +  "fdelete :: 'a \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
   4.492 +  is removeAll
   4.493  
   4.494  quotient_definition
   4.495 -  "fset_to_set :: 'a fset \<Rightarrow> 'a set"
   4.496 +  "fset :: 'a fset \<Rightarrow> 'a set"
   4.497    is "set"
   4.498  
   4.499  quotient_definition
   4.500 @@ -552,9 +476,8 @@
   4.501    by simp
   4.502  
   4.503  lemma [quot_respect]:
   4.504 -  "(op \<approx> ===> list_all2 op \<approx> OOO op \<approx> ===> list_all2 op \<approx> OOO op \<approx>) op # op #"
   4.505 +  shows "(op \<approx> ===> list_all2 op \<approx> OOO op \<approx> ===> list_all2 op \<approx> OOO op \<approx>) Cons Cons"
   4.506    apply auto
   4.507 -  apply (simp add: set_in_eq)
   4.508    apply (rule_tac b="x # b" in pred_compI)
   4.509    apply auto
   4.510    apply (rule_tac b="x # ba" in pred_compI)
   4.511 @@ -581,13 +504,13 @@
   4.512    assumes a:"list_all2 op \<approx> x x'"
   4.513    shows "list_all2 op \<approx> (x @ z) (x' @ z)"
   4.514    using a apply (induct x x' rule: list_induct2')
   4.515 -  by simp_all (rule list_all2_refl)
   4.516 +  by simp_all (rule list_all2_refl1)
   4.517  
   4.518  lemma append_rsp2_pre1:
   4.519    assumes a:"list_all2 op \<approx> x x'"
   4.520    shows "list_all2 op \<approx> (z @ x) (z @ x')"
   4.521    using a apply (induct x x' arbitrary: z rule: list_induct2')
   4.522 -  apply (rule list_all2_refl)
   4.523 +  apply (rule list_all2_refl1)
   4.524    apply (simp_all del: list_eq.simps)
   4.525    apply (rule list_all2_app_l)
   4.526    apply (simp_all add: reflp_def)
   4.527 @@ -602,7 +525,7 @@
   4.528    apply (rule a)
   4.529    using b apply (induct z z' rule: list_induct2')
   4.530    apply (simp_all only: append_Nil2)
   4.531 -  apply (rule list_all2_refl)
   4.532 +  apply (rule list_all2_refl1)
   4.533    apply simp_all
   4.534    apply (rule append_rsp2_pre1)
   4.535    apply simp
   4.536 @@ -648,52 +571,22 @@
   4.537  
   4.538  lemma singleton_list_eq:
   4.539    shows "[x] \<approx> [y] \<longleftrightarrow> x = y"
   4.540 -  by (simp add: id_simps) auto
   4.541 +  by (simp)
   4.542  
   4.543  lemma sub_list_cons:
   4.544    "sub_list (x # xs) ys = (memb x ys \<and> sub_list xs ys)"
   4.545    by (auto simp add: memb_def sub_list_def)
   4.546  
   4.547 -lemma fminus_raw_red: "fminus_raw (x # xs) ys = (if memb x ys then fminus_raw xs ys else x # (fminus_raw xs ys))"
   4.548 -  by (induct ys arbitrary: xs x)
   4.549 -     (simp_all add: not_memb_nil memb_delete_raw memb_cons_iff)
   4.550 +lemma fminus_raw_red: 
   4.551 +  "fminus_raw (x # xs) ys = (if x \<in> set ys then fminus_raw xs ys else x # (fminus_raw xs ys))"
   4.552 +  by (induct ys arbitrary: xs x) (simp_all)
   4.553  
   4.554  text {* Cardinality of finite sets *}
   4.555  
   4.556  lemma fcard_raw_0:
   4.557    shows "fcard_raw xs = 0 \<longleftrightarrow> xs \<approx> []"
   4.558 -  by (induct xs) (auto simp add: memb_def)
   4.559 -
   4.560 -lemma fcard_raw_not_memb:
   4.561 -  shows "\<not> memb x xs \<longleftrightarrow> fcard_raw (x # xs) = Suc (fcard_raw xs)"
   4.562 -  by auto
   4.563 -
   4.564 -lemma fcard_raw_suc:
   4.565 -  assumes a: "fcard_raw xs = Suc n"
   4.566 -  shows "\<exists>x ys. \<not> (memb x ys) \<and> xs \<approx> (x # ys) \<and> fcard_raw ys = n"
   4.567 -  using a
   4.568 -  by (induct xs) (auto simp add: memb_def split: if_splits)
   4.569 -
   4.570 -lemma singleton_fcard_1:
   4.571 -  shows "set xs = {x} \<Longrightarrow> fcard_raw xs = 1"
   4.572 -  by (induct xs) (auto simp add: memb_def subset_insert)
   4.573 -
   4.574 -lemma fcard_raw_1:
   4.575 -  shows "fcard_raw xs = 1 \<longleftrightarrow> (\<exists>x. xs \<approx> [x])"
   4.576 -  apply (auto dest!: fcard_raw_suc)
   4.577 -  apply (simp add: fcard_raw_0)
   4.578 -  apply (rule_tac x="x" in exI)
   4.579 -  apply simp
   4.580 -  apply (subgoal_tac "set xs = {x}")
   4.581 -  apply (drule singleton_fcard_1)
   4.582 -  apply auto
   4.583 -  done
   4.584 -
   4.585 -lemma fcard_raw_suc_memb:
   4.586 -  assumes a: "fcard_raw A = Suc n"
   4.587 -  shows "\<exists>a. memb a A"
   4.588 -  using a
   4.589 -  by (induct A) (auto simp add: memb_def)
   4.590 +  unfolding fcard_raw_def
   4.591 +  by (induct xs) (auto)
   4.592  
   4.593  lemma memb_card_not_0:
   4.594    assumes a: "memb a A"
   4.595 @@ -749,21 +642,18 @@
   4.596  
   4.597  section {* deletion *}
   4.598  
   4.599 -lemma memb_delete_raw_ident:
   4.600 -  shows "\<not> memb x (delete_raw xs x)"
   4.601 +
   4.602 +lemma fset_raw_removeAll_cases:
   4.603 +  "xs = [] \<or> (\<exists>x. memb x xs \<and> xs \<approx> x # removeAll x xs)"
   4.604    by (induct xs) (auto simp add: memb_def)
   4.605  
   4.606 -lemma fset_raw_delete_raw_cases:
   4.607 -  "xs = [] \<or> (\<exists>x. memb x xs \<and> xs \<approx> x # delete_raw xs x)"
   4.608 -  by (induct xs) (auto simp add: memb_def)
   4.609 -
   4.610 -lemma fdelete_raw_filter:
   4.611 -  "delete_raw xs y = [x \<leftarrow> xs. x \<noteq> y]"
   4.612 +lemma fremoveAll_filter:
   4.613 +  "removeAll y xs = [x \<leftarrow> xs. x \<noteq> y]"
   4.614    by (induct xs) simp_all
   4.615  
   4.616  lemma fcard_raw_delete:
   4.617 -  "fcard_raw (delete_raw xs y) = (if memb y xs then fcard_raw xs - 1 else fcard_raw xs)"
   4.618 -  by (simp add: fdelete_raw_filter fcard_raw_delete_one)
   4.619 +  "fcard_raw (removeAll y xs) = (if memb y xs then fcard_raw xs - 1 else fcard_raw xs)"
   4.620 +  by (auto simp add: fcard_raw_def memb_def)
   4.621  
   4.622  lemma set_cong:
   4.623    shows "(x \<approx> y) = (set x = set y)"
   4.624 @@ -791,7 +681,7 @@
   4.625    by (induct xs) (auto intro: list_eq2.intros)
   4.626  
   4.627  lemma cons_delete_list_eq2:
   4.628 -  shows "list_eq2 (a # (delete_raw A a)) (if memb a A then A else a # A)"
   4.629 +  shows "list_eq2 (a # (removeAll a A)) (if memb a A then A else a # A)"
   4.630    apply (induct A)
   4.631    apply (simp add: memb_def list_eq2_refl)
   4.632    apply (case_tac "memb a (aa # A)")
   4.633 @@ -802,19 +692,15 @@
   4.634    apply (auto simp add: memb_def)[2]
   4.635    apply (metis list_eq2.intros(3) list_eq2.intros(4) list_eq2.intros(5) list_eq2.intros(6))
   4.636    apply (metis list_eq2.intros(1) list_eq2.intros(5) list_eq2.intros(6))
   4.637 -  apply (auto simp add: list_eq2_refl not_memb_delete_raw_ident)
   4.638 +  apply (auto simp add: list_eq2_refl memb_def)
   4.639    done
   4.640  
   4.641  lemma memb_delete_list_eq2:
   4.642    assumes a: "memb e r"
   4.643 -  shows "list_eq2 (e # delete_raw r e) r"
   4.644 +  shows "list_eq2 (e # removeAll e r) r"
   4.645    using a cons_delete_list_eq2[of e r]
   4.646    by simp
   4.647  
   4.648 -lemma delete_raw_rsp:
   4.649 -  "xs \<approx> ys \<Longrightarrow> delete_raw xs x \<approx> delete_raw ys x"
   4.650 -  by (simp add: memb_def[symmetric] memb_delete_raw)
   4.651 -
   4.652  lemma list_eq2_equiv:
   4.653    "(l \<approx> r) \<longleftrightarrow> (list_eq2 l r)"
   4.654  proof
   4.655 @@ -836,58 +722,27 @@
   4.656        case (Suc m)
   4.657        have b: "l \<approx> r" by fact
   4.658        have d: "fcard_raw l = Suc m" by fact
   4.659 -      then have "\<exists>a. memb a l" by (rule fcard_raw_suc_memb)
   4.660 +      then have "\<exists>a. memb a l" 
   4.661 +	apply(simp add: fcard_raw_def memb_def)
   4.662 +	apply(drule card_eq_SucD)
   4.663 +	apply(blast)
   4.664 +	done
   4.665        then obtain a where e: "memb a l" by auto
   4.666 -      then have e': "memb a r" using list_eq.simps[simplified memb_def[symmetric], of l r] b by auto
   4.667 -      have f: "fcard_raw (delete_raw l a) = m" using fcard_raw_delete[of l a] e d by simp
   4.668 -      have g: "delete_raw l a \<approx> delete_raw r a" using delete_raw_rsp[OF b] by simp
   4.669 -      have "list_eq2 (delete_raw l a) (delete_raw r a)" by (rule Suc.hyps[OF f g])
   4.670 -      then have h: "list_eq2 (a # delete_raw l a) (a # delete_raw r a)" by (rule list_eq2.intros(5))
   4.671 -      have i: "list_eq2 l (a # delete_raw l a)"
   4.672 +      then have e': "memb a r" using list_eq.simps[simplified memb_def[symmetric], of l r] b 
   4.673 +	unfolding memb_def by auto
   4.674 +      have f: "fcard_raw (removeAll a l) = m" using fcard_raw_delete[of a l] e d by simp
   4.675 +      have g: "removeAll a l \<approx> removeAll a r" using removeAll_rsp b by simp
   4.676 +      have "list_eq2 (removeAll a l) (removeAll a r)" by (rule Suc.hyps[OF f g])
   4.677 +      then have h: "list_eq2 (a # removeAll a l) (a # removeAll a r)" by (rule list_eq2.intros(5))
   4.678 +      have i: "list_eq2 l (a # removeAll a l)"
   4.679          by (rule list_eq2.intros(3)[OF memb_delete_list_eq2[OF e]])
   4.680 -      have "list_eq2 l (a # delete_raw r a)" by (rule list_eq2.intros(6)[OF i h])
   4.681 +      have "list_eq2 l (a # removeAll a r)" by (rule list_eq2.intros(6)[OF i h])
   4.682        then show ?case using list_eq2.intros(6)[OF _ memb_delete_list_eq2[OF e']] by simp
   4.683      qed
   4.684      }
   4.685    then show "l \<approx> r \<Longrightarrow> list_eq2 l r" by blast
   4.686  qed
   4.687  
   4.688 -text {* Set *}
   4.689 -
   4.690 -lemma sub_list_set: "sub_list xs ys = (set xs \<subseteq> set ys)"
   4.691 -  unfolding sub_list_def by auto
   4.692 -
   4.693 -lemma sub_list_neq_set: "(sub_list xs ys \<and> \<not> list_eq xs ys) = (set xs \<subset> set ys)"
   4.694 -  by (auto simp add: sub_list_set)
   4.695 -
   4.696 -lemma fcard_raw_set: "fcard_raw xs = card (set xs)"
   4.697 -  by (induct xs) (auto simp add: insert_absorb memb_def card_insert_disjoint finite_set)
   4.698 -
   4.699 -lemma memb_set: "memb x xs = (x \<in> set xs)"
   4.700 -  by (simp only: memb_def)
   4.701 -
   4.702 -lemma filter_set: "set (filter P xs) = P \<inter> (set xs)"
   4.703 -  by (induct xs, simp)
   4.704 -     (metis Int_insert_right_if0 Int_insert_right_if1 List.set.simps(2) filter.simps(2) mem_def)
   4.705 -
   4.706 -lemma delete_raw_set: "set (delete_raw xs x) = set xs - {x}"
   4.707 -  by (induct xs) auto
   4.708 -
   4.709 -lemma inter_raw_set: "set (finter_raw xs ys) = set xs \<inter> set ys"
   4.710 -  by (induct xs) (simp_all add: memb_def)
   4.711 -
   4.712 -lemma fminus_raw_set: "set (fminus_raw xs ys) = set xs - set ys"
   4.713 -  by (induct ys arbitrary: xs)
   4.714 -     (simp_all add: fminus_raw.simps delete_raw_set, blast)
   4.715 -
   4.716 -text {* Raw theorems of ffilter *}
   4.717 -
   4.718 -lemma sub_list_filter: "sub_list (filter P xs) (filter Q xs) = (\<forall> x. memb x xs \<longrightarrow> P x \<longrightarrow> Q x)"
   4.719 -unfolding sub_list_def memb_def by auto
   4.720 -
   4.721 -lemma list_eq_filter: "list_eq (filter P xs) (filter Q xs) = (\<forall>x. memb x xs \<longrightarrow> P x = Q x)"
   4.722 -unfolding memb_def by auto
   4.723 -
   4.724  text {* Lifted theorems *}
   4.725  
   4.726  lemma not_fin_fnil: "x |\<notin>| {||}"
   4.727 @@ -924,16 +779,15 @@
   4.728    by (descending) (auto)
   4.729  
   4.730  
   4.731 -text {* fset_to_set *}
   4.732 +text {* fset *}
   4.733  
   4.734 -lemma fset_to_set_simps [simp]:
   4.735 -  fixes h::"'a"
   4.736 -  shows "fset_to_set {||} = ({} :: 'a set)"
   4.737 -  and "fset_to_set (finsert h t) = insert h (fset_to_set t)"
   4.738 +lemma fset_simps[simp]:
   4.739 +  "fset {||} = ({} :: 'a set)"
   4.740 +  "fset (finsert (h :: 'a) t) = insert h (fset t)"
   4.741    by (lifting set.simps)
   4.742  
   4.743 -lemma in_fset_to_set:
   4.744 -  "x \<in> fset_to_set S \<equiv> x |\<in>| S"
   4.745 +lemma in_fset:
   4.746 +  "x \<in> fset S \<equiv> x |\<in>| S"
   4.747    by (lifting memb_def[symmetric])
   4.748  
   4.749  lemma none_fin_fempty:
   4.750 @@ -941,47 +795,62 @@
   4.751    by (lifting none_memb_nil)
   4.752  
   4.753  lemma fset_cong:
   4.754 -  "S = T \<longleftrightarrow> fset_to_set S = fset_to_set T"
   4.755 +  "S = T \<longleftrightarrow> fset S = fset T"
   4.756    by (lifting set_cong)
   4.757  
   4.758 +
   4.759  text {* fcard *}
   4.760  
   4.761 -lemma fcard_fempty [simp]:
   4.762 -  shows "fcard {||} = 0"
   4.763 -  by (descending) (simp)
   4.764 -
   4.765  lemma fcard_finsert_if [simp]:
   4.766    shows "fcard (finsert x S) = (if x |\<in>| S then fcard S else Suc (fcard S))"
   4.767 -  by (descending) (simp)
   4.768 +  by (descending) (auto simp add: fcard_raw_def memb_def insert_absorb)
   4.769  
   4.770 -lemma fcard_0: 
   4.771 -  "fcard S = 0 \<longleftrightarrow> S = {||}"
   4.772 -  by (lifting fcard_raw_0)
   4.773 +lemma fcard_0[simp]:
   4.774 +  shows "fcard S = 0 \<longleftrightarrow> S = {||}"
   4.775 +  by (descending) (simp add: fcard_raw_def)
   4.776 +
   4.777 +lemma fcard_fempty[simp]:
   4.778 +  shows "fcard {||} = 0"
   4.779 +  by (simp add: fcard_0)
   4.780  
   4.781  lemma fcard_1:
   4.782    shows "fcard S = 1 \<longleftrightarrow> (\<exists>x. S = {|x|})"
   4.783 -  by (lifting fcard_raw_1)
   4.784 +  by (descending) (auto simp add: fcard_raw_def card_Suc_eq)
   4.785  
   4.786  lemma fcard_gt_0:
   4.787 -  shows "x \<in> fset_to_set S \<Longrightarrow> 0 < fcard S"
   4.788 -  by (lifting fcard_raw_gt_0)
   4.789 -
   4.790 +  shows "x \<in> fset S \<Longrightarrow> 0 < fcard S"
   4.791 +  by (descending) (auto simp add: fcard_raw_def card_gt_0_iff)
   4.792 +  
   4.793  lemma fcard_not_fin:
   4.794    shows "(x |\<notin>| S) = (fcard (finsert x S) = Suc (fcard S))"
   4.795 -  by (lifting fcard_raw_not_memb)
   4.796 +  by (descending) (auto simp add: memb_def fcard_raw_def insert_absorb)
   4.797  
   4.798  lemma fcard_suc: "fcard S = Suc n \<Longrightarrow> \<exists>x T. x |\<notin>| T \<and> S = finsert x T \<and> fcard T = n"
   4.799 -  by (lifting fcard_raw_suc)
   4.800 +  apply descending
   4.801 +  apply(simp add: fcard_raw_def memb_def)
   4.802 +  apply(drule card_eq_SucD)
   4.803 +  apply(auto)
   4.804 +  apply(rule_tac x="b" in exI)
   4.805 +  apply(rule_tac x="removeAll b S" in exI)
   4.806 +  apply(auto)
   4.807 +  done
   4.808  
   4.809  lemma fcard_delete:
   4.810 -  "fcard (fdelete S y) = (if y |\<in>| S then fcard S - 1 else fcard S)"
   4.811 +  "fcard (fdelete y S) = (if y |\<in>| S then fcard S - 1 else fcard S)"
   4.812    by (lifting fcard_raw_delete)
   4.813  
   4.814 -lemma fcard_suc_memb: "fcard A = Suc n \<Longrightarrow> \<exists>a. a |\<in>| A"
   4.815 -  by (lifting fcard_raw_suc_memb)
   4.816 +lemma fcard_suc_memb: 
   4.817 +  shows "fcard A = Suc n \<Longrightarrow> \<exists>a. a |\<in>| A"
   4.818 +  apply(descending)
   4.819 +  apply(simp add: fcard_raw_def memb_def)
   4.820 +  apply(drule card_eq_SucD)
   4.821 +  apply(auto)
   4.822 +  done
   4.823  
   4.824 -lemma fin_fcard_not_0: "a |\<in>| A \<Longrightarrow> fcard A \<noteq> 0"
   4.825 -  by (lifting memb_card_not_0)
   4.826 +lemma fin_fcard_not_0: 
   4.827 +  shows "a |\<in>| A \<Longrightarrow> fcard A \<noteq> 0"
   4.828 +  by (descending) (auto simp add: fcard_raw_def memb_def)
   4.829 +
   4.830  
   4.831  text {* funion *}
   4.832  
   4.833 @@ -1001,7 +870,8 @@
   4.834    shows "S |\<union>| {|a|} = finsert a S"
   4.835    by (subst sup.commute) simp
   4.836  
   4.837 -section {* Induction and Cases rules for finite sets *}
   4.838 +
   4.839 +section {* Induction and Cases rules for fsets *}
   4.840  
   4.841  lemma fset_strong_cases:
   4.842    obtains "xs = {||}"
   4.843 @@ -1066,7 +936,7 @@
   4.844    by (lifting map.simps)
   4.845  
   4.846  lemma fmap_set_image:
   4.847 -  "fset_to_set (fmap f S) = f ` (fset_to_set S)"
   4.848 +  "fset (fmap f S) = f ` (fset S)"
   4.849    by (induct S) simp_all
   4.850  
   4.851  lemma inj_fmap_eq_iff:
   4.852 @@ -1081,103 +951,107 @@
   4.853    shows "x |\<in>| S |\<union>| T \<longleftrightarrow> x |\<in>| S \<or> x |\<in>| T"
   4.854    by (lifting memb_append)
   4.855  
   4.856 -text {* to_set *}
   4.857 +
   4.858 +section {* fset *}
   4.859  
   4.860  lemma fin_set: 
   4.861 -  shows "x |\<in>| xs \<longleftrightarrow> x \<in> fset_to_set xs"
   4.862 -  by (lifting memb_set)
   4.863 +  shows "x |\<in>| xs \<longleftrightarrow> x \<in> fset xs"
   4.864 +  by (lifting memb_def)
   4.865  
   4.866  lemma fnotin_set: 
   4.867 -  shows "x |\<notin>| xs \<longleftrightarrow> x \<notin> fset_to_set xs"
   4.868 +  shows "x |\<notin>| xs \<longleftrightarrow> x \<notin> fset xs"
   4.869    by (simp add: fin_set)
   4.870  
   4.871  lemma fcard_set: 
   4.872 -  shows "fcard xs = card (fset_to_set xs)"
   4.873 -  by (lifting fcard_raw_set)
   4.874 +  shows "fcard xs = card (fset xs)"
   4.875 +  by (lifting fcard_raw_def)
   4.876  
   4.877  lemma fsubseteq_set: 
   4.878 -  shows "xs |\<subseteq>| ys \<longleftrightarrow> fset_to_set xs \<subseteq> fset_to_set ys"
   4.879 -  by (lifting sub_list_set)
   4.880 +  shows "xs |\<subseteq>| ys \<longleftrightarrow> fset xs \<subseteq> fset ys"
   4.881 +  by (lifting sub_list_def)
   4.882  
   4.883  lemma fsubset_set: 
   4.884 -  shows "xs |\<subset>| ys \<longleftrightarrow> fset_to_set xs \<subset> fset_to_set ys"
   4.885 -  unfolding less_fset by (lifting sub_list_neq_set)
   4.886 +  shows "xs |\<subset>| ys \<longleftrightarrow> fset xs \<subset> fset ys"
   4.887 +  unfolding less_fset_def 
   4.888 +  by (descending) (auto simp add: sub_list_def)
   4.889  
   4.890 -lemma ffilter_set: 
   4.891 -  shows "fset_to_set (ffilter P xs) = P \<inter> fset_to_set xs"
   4.892 -  by (lifting filter_set)
   4.893 +lemma ffilter_set [simp]: 
   4.894 +  shows "fset (ffilter P xs) = P \<inter> fset xs"
   4.895 +  by (descending) (auto simp add: mem_def)
   4.896  
   4.897 -lemma fdelete_set: 
   4.898 -  shows "fset_to_set (fdelete xs x) = fset_to_set xs - {x}"
   4.899 -  by (lifting delete_raw_set)
   4.900 +lemma fdelete_set [simp]: 
   4.901 +  shows "fset (fdelete x xs) = fset xs - {x}"
   4.902 +  by (lifting set_removeAll)
   4.903  
   4.904 -lemma finter_set: 
   4.905 -  shows "fset_to_set (xs |\<inter>| ys) = fset_to_set xs \<inter> fset_to_set ys"
   4.906 -  by (lifting inter_raw_set)
   4.907 +lemma finter_set [simp]: 
   4.908 +  shows "fset (xs |\<inter>| ys) = fset xs \<inter> fset ys"
   4.909 +  by (lifting set_finter_raw)
   4.910  
   4.911 -lemma funion_set: 
   4.912 -  shows "fset_to_set (xs |\<union>| ys) = fset_to_set xs \<union> fset_to_set ys"
   4.913 +lemma funion_set [simp]: 
   4.914 +  shows "fset (xs |\<union>| ys) = fset xs \<union> fset ys"
   4.915    by (lifting set_append)
   4.916  
   4.917 -lemma fminus_set: 
   4.918 -  shows "fset_to_set (xs - ys) = fset_to_set xs - fset_to_set ys"
   4.919 -  by (lifting fminus_raw_set)
   4.920 +lemma fminus_set [simp]: 
   4.921 +  shows "fset (xs - ys) = fset xs - fset ys"
   4.922 +  by (lifting set_fminus_raw)
   4.923  
   4.924  lemmas fset_to_set_trans =
   4.925    fin_set fnotin_set fcard_set fsubseteq_set fsubset_set
   4.926 -  finter_set funion_set ffilter_set fset_to_set_simps
   4.927 +  finter_set funion_set ffilter_set fset_simps
   4.928    fset_cong fdelete_set fmap_set_image fminus_set
   4.929  
   4.930  
   4.931  text {* ffold *}
   4.932  
   4.933 -lemma ffold_nil: "ffold f z {||} = z"
   4.934 +lemma ffold_nil: 
   4.935 +  shows "ffold f z {||} = z"
   4.936    by (lifting ffold_raw.simps(1)[where 'a="'b" and 'b="'a"])
   4.937  
   4.938  lemma ffold_finsert: "ffold f z (finsert a A) =
   4.939    (if rsp_fold f then if a |\<in>| A then ffold f z A else f a (ffold f z A) else z)"
   4.940 -  by (lifting ffold_raw.simps(2)[where 'a="'b" and 'b="'a"])
   4.941 +  by (descending) (simp add: memb_def)
   4.942  
   4.943  lemma fin_commute_ffold:
   4.944 -  "\<lbrakk>rsp_fold f; h |\<in>| b\<rbrakk> \<Longrightarrow> ffold f z b = f h (ffold f z (fdelete b h))"
   4.945 -  by (lifting memb_commute_ffold_raw)
   4.946 +  "\<lbrakk>rsp_fold f; h |\<in>| b\<rbrakk> \<Longrightarrow> ffold f z b = f h (ffold f z (fdelete h b))"
   4.947 +  by (descending) (simp add: memb_def memb_commute_ffold_raw)
   4.948 +
   4.949  
   4.950  text {* fdelete *}
   4.951  
   4.952  lemma fin_fdelete:
   4.953 -  shows "x |\<in>| fdelete S y \<longleftrightarrow> x |\<in>| S \<and> x \<noteq> y"
   4.954 -  by (lifting memb_delete_raw)
   4.955 +  shows "x |\<in>| fdelete y S \<longleftrightarrow> x |\<in>| S \<and> x \<noteq> y"
   4.956 +  by (descending) (simp add: memb_def)
   4.957  
   4.958 -lemma fin_fdelete_ident:
   4.959 -  shows "x |\<notin>| fdelete S x"
   4.960 -  by (lifting memb_delete_raw_ident)
   4.961 +lemma fnotin_fdelete:
   4.962 +  shows "x |\<notin>| fdelete x S"
   4.963 +  by (descending) (simp add: memb_def)
   4.964  
   4.965 -lemma not_memb_fdelete_ident:
   4.966 -  shows "x |\<notin>| S \<Longrightarrow> fdelete S x = S"
   4.967 -  by (lifting not_memb_delete_raw_ident)
   4.968 +lemma fnotin_fdelete_ident:
   4.969 +  shows "x |\<notin>| S \<Longrightarrow> fdelete x S = S"
   4.970 +  by (descending) (simp add: memb_def)
   4.971  
   4.972  lemma fset_fdelete_cases:
   4.973 -  shows "S = {||} \<or> (\<exists>x. x |\<in>| S \<and> S = finsert x (fdelete S x))"
   4.974 -  by (lifting fset_raw_delete_raw_cases)
   4.975 +  shows "S = {||} \<or> (\<exists>x. x |\<in>| S \<and> S = finsert x (fdelete x S))"
   4.976 +  by (lifting fset_raw_removeAll_cases)
   4.977  
   4.978  text {* finite intersection *}
   4.979  
   4.980 -lemma finter_empty_l: 
   4.981 +lemma finter_empty_l:
   4.982    shows "{||} |\<inter>| S = {||}"
   4.983    by simp
   4.984  
   4.985  
   4.986 -lemma finter_empty_r: 
   4.987 +lemma finter_empty_r:
   4.988    shows "S |\<inter>| {||} = {||}"
   4.989    by simp
   4.990  
   4.991  lemma finter_finsert:
   4.992 -  "finsert x S |\<inter>| T = (if x |\<in>| T then finsert x (S |\<inter>| T) else S |\<inter>| T)"
   4.993 -  by (lifting finter_raw.simps(2))
   4.994 +  shows "finsert x S |\<inter>| T = (if x |\<in>| T then finsert x (S |\<inter>| T) else S |\<inter>| T)"
   4.995 +  by (descending) (simp add: memb_def)
   4.996  
   4.997  lemma fin_finter:
   4.998 -  "x |\<in>| (S |\<inter>| T) \<longleftrightarrow> x |\<in>| S \<and> x |\<in>| T"
   4.999 -  by (lifting memb_finter_raw)
  4.1000 +  shows "x |\<in>| (S |\<inter>| T) \<longleftrightarrow> x |\<in>| S \<and> x |\<in>| T"
  4.1001 +  by (descending) (simp add: memb_def)
  4.1002  
  4.1003  lemma fsubset_finsert:
  4.1004    shows "finsert x xs |\<subseteq>| ys \<longleftrightarrow> x |\<in>| ys \<and> xs |\<subseteq>| ys"
  4.1005 @@ -1185,20 +1059,19 @@
  4.1006  
  4.1007  lemma 
  4.1008    shows "xs |\<subseteq>| ys \<equiv> \<forall>x. x |\<in>| xs \<longrightarrow> x |\<in>| ys"
  4.1009 -  by (lifting sub_list_def[simplified memb_def[symmetric]])
  4.1010 +  by (descending) (auto simp add: sub_list_def memb_def)
  4.1011  
  4.1012  lemma fsubset_fin: 
  4.1013    shows "xs |\<subseteq>| ys = (\<forall>x. x |\<in>| xs \<longrightarrow> x |\<in>| ys)"
  4.1014 -by (rule meta_eq_to_obj_eq)
  4.1015 -   (lifting sub_list_def[simplified memb_def[symmetric]])
  4.1016 +  by (descending) (auto simp add: sub_list_def memb_def)
  4.1017  
  4.1018  lemma fminus_fin: 
  4.1019    shows "x |\<in>| xs - ys \<longleftrightarrow> x |\<in>| xs \<and> x |\<notin>| ys"
  4.1020 -  by (lifting fminus_raw_memb)
  4.1021 +  by (descending) (simp add: memb_def)
  4.1022  
  4.1023  lemma fminus_red: 
  4.1024    shows "finsert x xs - ys = (if x |\<in>| ys then xs - ys else finsert x (xs - ys))"
  4.1025 -  by (lifting fminus_raw_red)
  4.1026 +  by (descending) (auto simp add: memb_def)
  4.1027  
  4.1028  lemma fminus_red_fin [simp]: 
  4.1029    shows "x |\<in>| ys \<Longrightarrow> finsert x xs - ys = xs - ys"
  4.1030 @@ -1208,9 +1081,9 @@
  4.1031    shows "x |\<notin>| ys \<Longrightarrow> finsert x xs - ys = finsert x (xs - ys)"
  4.1032    by (simp add: fminus_red)
  4.1033  
  4.1034 -lemma expand_fset_eq:
  4.1035 +lemma fset_eq_iff:
  4.1036    shows "S = T \<longleftrightarrow> (\<forall>x. (x |\<in>| S) = (x |\<in>| T))"
  4.1037 -  by (lifting list_eq.simps[simplified memb_def[symmetric]])
  4.1038 +  by (descending) (auto simp add: memb_def)
  4.1039  
  4.1040  (* We cannot write it as "assumes .. shows" since Isabelle changes
  4.1041     the quantifiers to schematic variables and reintroduces them in
  4.1042 @@ -1256,20 +1129,22 @@
  4.1043  
  4.1044  lemma subseteq_filter: 
  4.1045    shows "ffilter P xs <= ffilter Q xs = (\<forall> x. x |\<in>| xs \<longrightarrow> P x \<longrightarrow> Q x)"
  4.1046 -  by (lifting sub_list_filter)
  4.1047 +  by  (descending) (auto simp add: memb_def sub_list_def)
  4.1048  
  4.1049  lemma eq_ffilter: 
  4.1050    shows "(ffilter P xs = ffilter Q xs) = (\<forall>x. x |\<in>| xs \<longrightarrow> P x = Q x)"
  4.1051 -  by (lifting list_eq_filter)
  4.1052 +  by (descending) (auto simp add: memb_def)
  4.1053  
  4.1054 -lemma subset_ffilter: 
  4.1055 +lemma subset_ffilter:
  4.1056    shows "(\<And>x. x |\<in>| xs \<Longrightarrow> P x \<Longrightarrow> Q x) \<Longrightarrow> (x |\<in>| xs & \<not> P x & Q x) \<Longrightarrow> ffilter P xs < ffilter Q xs"
  4.1057 -  unfolding less_fset by (auto simp add: subseteq_filter eq_ffilter)
  4.1058 +  unfolding less_fset_def by (auto simp add: subseteq_filter eq_ffilter)
  4.1059 +
  4.1060  
  4.1061  section {* lemmas transferred from Finite_Set theory *}
  4.1062  
  4.1063  text {* finiteness for finite sets holds *}
  4.1064 -lemma finite_fset: "finite (fset_to_set S)"
  4.1065 +lemma finite_fset [simp]: 
  4.1066 +  shows "finite (fset S)"
  4.1067    by (induct S) auto
  4.1068  
  4.1069  lemma fset_choice: 
  4.1070 @@ -1277,16 +1152,14 @@
  4.1071    unfolding fset_to_set_trans
  4.1072    by (rule finite_set_choice[simplified Ball_def, OF finite_fset])
  4.1073  
  4.1074 -lemma fsubseteq_fnil: 
  4.1075 +lemma fsubseteq_fempty:
  4.1076    shows "xs |\<subseteq>| {||} \<longleftrightarrow> xs = {||}"
  4.1077 -  unfolding fset_to_set_trans
  4.1078 -  by (rule subset_empty)
  4.1079 +  by (metis finter_empty_r le_iff_inf)
  4.1080  
  4.1081  lemma not_fsubset_fnil: 
  4.1082    shows "\<not> xs |\<subset>| {||}"
  4.1083 -  unfolding fset_to_set_trans
  4.1084 -  by (rule not_psubset_empty)
  4.1085 -
  4.1086 +  by (metis fset_simps(1) fsubset_set not_psubset_empty)
  4.1087 +  
  4.1088  lemma fcard_mono: 
  4.1089    shows "xs |\<subseteq>| ys \<Longrightarrow> fcard xs \<le> fcard ys"
  4.1090    unfolding fset_to_set_trans
  4.1091 @@ -1294,8 +1167,8 @@
  4.1092  
  4.1093  lemma fcard_fseteq: 
  4.1094    shows "xs |\<subseteq>| ys \<Longrightarrow> fcard ys \<le> fcard xs \<Longrightarrow> xs = ys"
  4.1095 -  unfolding fset_to_set_trans
  4.1096 -  by (rule card_seteq[OF finite_fset])
  4.1097 +  unfolding fcard_set fsubseteq_set
  4.1098 +  by (simp add: card_seteq[OF finite_fset] fset_cong)
  4.1099  
  4.1100  lemma psubset_fcard_mono: 
  4.1101    shows "xs |\<subset>| ys \<Longrightarrow> fcard xs < fcard ys"
  4.1102 @@ -1313,17 +1186,17 @@
  4.1103    by (rule card_Un_disjoint[OF finite_fset finite_fset])
  4.1104  
  4.1105  lemma fcard_delete1_less: 
  4.1106 -  shows "x |\<in>| xs \<Longrightarrow> fcard (fdelete xs x) < fcard xs"
  4.1107 +  shows "x |\<in>| xs \<Longrightarrow> fcard (fdelete x xs) < fcard xs"
  4.1108    unfolding fset_to_set_trans
  4.1109    by (rule card_Diff1_less[OF finite_fset])
  4.1110  
  4.1111  lemma fcard_delete2_less: 
  4.1112 -  shows "x |\<in>| xs \<Longrightarrow> y |\<in>| xs \<Longrightarrow> fcard (fdelete (fdelete xs x) y) < fcard xs"
  4.1113 +  shows "x |\<in>| xs \<Longrightarrow> y |\<in>| xs \<Longrightarrow> fcard (fdelete y (fdelete x xs)) < fcard xs"
  4.1114    unfolding fset_to_set_trans
  4.1115    by (rule card_Diff2_less[OF finite_fset])
  4.1116  
  4.1117  lemma fcard_delete1_le: 
  4.1118 -  shows "fcard (fdelete xs x) \<le> fcard xs"
  4.1119 +  shows "fcard (fdelete x xs) \<le> fcard xs"
  4.1120    unfolding fset_to_set_trans
  4.1121    by (rule card_Diff1_le[OF finite_fset])
  4.1122  
  4.1123 @@ -1347,14 +1220,16 @@
  4.1124    unfolding fset_to_set_trans
  4.1125    by blast
  4.1126  
  4.1127 -lemma fin_mdef: "x |\<in>| F \<longleftrightarrow> x |\<notin>| (F - {|x|}) \<and> F = finsert x (F - {|x|})"
  4.1128 +lemma fin_mdef: 
  4.1129 +  "x |\<in>| F \<longleftrightarrow> x |\<notin>| (F - {|x|}) \<and> F = finsert x (F - {|x|})"
  4.1130    unfolding fset_to_set_trans
  4.1131    by blast
  4.1132  
  4.1133  lemma fcard_fminus_finsert[simp]:
  4.1134    assumes "a |\<in>| A" and "a |\<notin>| B"
  4.1135    shows "fcard(A - finsert a B) = fcard(A - B) - 1"
  4.1136 -  using assms unfolding fset_to_set_trans
  4.1137 +  using assms 
  4.1138 +  unfolding fset_to_set_trans
  4.1139    by (rule card_Diff_insert[OF finite_fset])
  4.1140  
  4.1141  lemma fcard_fminus_fsubset:
  4.1142 @@ -1364,7 +1239,7 @@
  4.1143    by (rule card_Diff_subset[OF finite_fset])
  4.1144  
  4.1145  lemma fcard_fminus_subset_finter:
  4.1146 -  "fcard (A - B) = fcard A - fcard (A |\<inter>| B)"
  4.1147 +  shows "fcard (A - B) = fcard A - fcard (A |\<inter>| B)"
  4.1148    unfolding fset_to_set_trans
  4.1149    by (rule card_Diff_subset_Int) (fold finter_set, rule finite_fset)
  4.1150  
     5.1 --- a/src/Pure/type.ML	Sat Oct 16 16:22:42 2010 -0700
     5.2 +++ b/src/Pure/type.ML	Sat Oct 16 16:39:06 2010 -0700
     5.3 @@ -418,10 +418,12 @@
     5.4  
     5.5  fun typ_match tsig =
     5.6    let
     5.7 -    fun match (TVar (v, S), T) subs =
     5.8 +    fun match (T0 as TVar (v, S), T) subs = 
     5.9            (case lookup subs (v, S) of
    5.10              NONE =>
    5.11 -              if of_sort tsig (T, S) then Vartab.update_new (v, (S, T)) subs
    5.12 +              if of_sort tsig (T, S) 
    5.13 +              then if T0 = T then subs (*types already identical; don't create cycle!*)
    5.14 +                   else Vartab.update_new (v, (S, T)) subs
    5.15                else raise TYPE_MATCH
    5.16            | SOME U => if U = T then subs else raise TYPE_MATCH)
    5.17        | match (Type (a, Ts), Type (b, Us)) subs =
     6.1 --- a/src/Pure/unify.ML	Sat Oct 16 16:22:42 2010 -0700
     6.2 +++ b/src/Pure/unify.ML	Sat Oct 16 16:39:06 2010 -0700
     6.3 @@ -205,6 +205,14 @@
     6.4  exception ASSIGN;  (*Raised if not an assignment*)
     6.5  
     6.6  
     6.7 +fun self_asgt (ix,(_,TVar (ix',_))) = (ix = ix')
     6.8 +  | self_asgt (ix, _) = false;
     6.9 +
    6.10 +fun check_tyenv msg tys tyenv = 
    6.11 +  if Vartab.exists self_asgt tyenv
    6.12 +  then raise TYPE (msg ^ ": looping type envir!!", tys, []) 
    6.13 +  else tyenv;
    6.14 +
    6.15  fun unify_types thy (T, U, env) =
    6.16    if T = U then env
    6.17    else
    6.18 @@ -715,7 +723,7 @@
    6.19          fun result env =
    6.20            if Envir.above env maxidx then   (* FIXME proper handling of generated vars!? *)
    6.21              SOME (Envir.Envir {maxidx = maxidx,
    6.22 -              tyenv = Vartab.make (map (norm_tvar env) pat_tvars),
    6.23 +              tyenv = Vartab.make (filter_out self_asgt (map (norm_tvar env) pat_tvars)),
    6.24                tenv = Vartab.make (map (norm_var env) pat_vars)})
    6.25            else NONE;
    6.26  
     7.1 --- a/src/ZF/ex/misc.thy	Sat Oct 16 16:22:42 2010 -0700
     7.2 +++ b/src/ZF/ex/misc.thy	Sat Oct 16 16:39:06 2010 -0700
     7.3 @@ -39,19 +39,19 @@
     7.4  lemma "(X = Y Un Z) <-> (Y \<subseteq> X & Z \<subseteq> X & (\<forall>V. Y \<subseteq> V & Z \<subseteq> V --> X \<subseteq> V))"
     7.5  by (blast intro!: equalityI)
     7.6  
     7.7 -text{*the dual of the previous one}
     7.8 +text{*the dual of the previous one*}
     7.9  lemma "(X = Y Int Z) <-> (X \<subseteq> Y & X \<subseteq> Z & (\<forall>V. V \<subseteq> Y & V \<subseteq> Z --> V \<subseteq> X))"
    7.10  by (blast intro!: equalityI)
    7.11  
    7.12 -text{*trivial example of term synthesis: apparently hard for some provers!}
    7.13 -lemma "a \<noteq> b ==> a:?X & b \<notin> ?X"
    7.14 +text{*trivial example of term synthesis: apparently hard for some provers!*}
    7.15 +schematic_lemma "a \<noteq> b ==> a:?X & b \<notin> ?X"
    7.16  by blast
    7.17  
    7.18 -text{*Nice Blast_tac benchmark.  Proved in 0.3s; old tactics can't manage it!}
    7.19 +text{*Nice blast benchmark.  Proved in 0.3s; old tactics can't manage it!*}
    7.20  lemma "\<forall>x \<in> S. \<forall>y \<in> S. x \<subseteq> y ==> \<exists>z. S \<subseteq> {z}"
    7.21  by blast
    7.22  
    7.23 -text{*variant of the benchmark above}
    7.24 +text{*variant of the benchmark above*}
    7.25  lemma "\<forall>x \<in> S. Union(S) \<subseteq> x ==> \<exists>z. S \<subseteq> {z}"
    7.26  by blast
    7.27  
    7.28 @@ -74,7 +74,7 @@
    7.29    Set Theory in First-Order Logic: Clauses for G\"odel's Axioms,
    7.30    JAR 2 (1986), 287-327 *}
    7.31  
    7.32 -text{*collecting the relevant lemmas}
    7.33 +text{*collecting the relevant lemmas*}
    7.34  declare comp_fun [simp] SigmaI [simp] apply_funtype [simp]
    7.35  
    7.36  (*Force helps prove conditions of rewrites such as comp_fun_apply, since
    7.37 @@ -86,7 +86,7 @@
    7.38         (K O J) \<in> hom(A,f,C,h)"
    7.39  by force
    7.40  
    7.41 -text{*Another version, with meta-level rewriting}
    7.42 +text{*Another version, with meta-level rewriting*}
    7.43  lemma "(!! A f B g. hom(A,f,B,g) ==  
    7.44             {H \<in> A->B. f \<in> A*A->A & g \<in> B*B->B &  
    7.45                       (\<forall>x \<in> A. \<forall>y \<in> A. H`(f`<x,y>) = g`<H`x,H`y>)}) 
    7.46 @@ -108,7 +108,7 @@
    7.47      "[| (h O g O f) \<in> inj(A,A);           
    7.48          (f O h O g) \<in> surj(B,B);          
    7.49          (g O f O h) \<in> surj(C,C);          
    7.50 -        f \<in> A->B;  g \<in> B->C;  h \<in> C->A |] ==> h \<in> bij(C,A)";
    7.51 +        f \<in> A->B;  g \<in> B->C;  h \<in> C->A |] ==> h \<in> bij(C,A)"
    7.52  by (unfold bij_def, blast)
    7.53  
    7.54  lemma pastre3: