--- a/NEWS Sat Oct 16 16:22:42 2010 -0700
+++ b/NEWS Sat Oct 16 16:39:06 2010 -0700
@@ -103,6 +103,8 @@
* Dropped type classes mult_mono and mult_mono1. INCOMPATIBILITY.
+* Removed output syntax "'a ~=> 'b" for "'a => 'b option". INCOMPATIBILITY.
+
* Theory SetsAndFunctions has been split into Function_Algebras and Set_Algebras;
canonical names for instance definitions for functions; various improvements.
INCOMPATIBILITY.
--- a/src/HOL/Algebra/Lattice.thy Sat Oct 16 16:22:42 2010 -0700
+++ b/src/HOL/Algebra/Lattice.thy Sat Oct 16 16:39:06 2010 -0700
@@ -233,9 +233,8 @@
assumes Acarr: "A \<subseteq> carrier L" and A'carr: "A' \<subseteq> carrier L"
and AA': "A {.=} A'"
shows "Lower L A = Lower L A'"
-using Lower_memD[of y]
unfolding Lower_def
-apply safe
+apply rule
apply clarsimp defer 1
apply clarsimp defer 1
proof -
--- a/src/HOL/Map.thy Sat Oct 16 16:22:42 2010 -0700
+++ b/src/HOL/Map.thy Sat Oct 16 16:39:06 2010 -0700
@@ -12,7 +12,6 @@
begin
types ('a,'b) "map" = "'a => 'b option" (infixr "~=>" 0)
-translations (type) "'a ~=> 'b" <= (type) "'a => 'b option"
type_notation (xsymbols)
"map" (infixr "\<rightharpoonup>" 0)
--- a/src/HOL/Quotient_Examples/FSet.thy Sat Oct 16 16:22:42 2010 -0700
+++ b/src/HOL/Quotient_Examples/FSet.thy Sat Oct 16 16:39:06 2010 -0700
@@ -14,7 +14,7 @@
fun
list_eq :: "'a list \<Rightarrow> 'a list \<Rightarrow> bool" (infix "\<approx>" 50)
where
- "list_eq xs ys = (\<forall>x. x \<in> set xs \<longleftrightarrow> x \<in> set ys)"
+ "list_eq xs ys = (set xs = set ys)"
lemma list_eq_equivp:
shows "equivp list_eq"
@@ -26,7 +26,9 @@
'a fset = "'a list" / "list_eq"
by (rule list_eq_equivp)
-text {* Raw definitions *}
+text {* Raw definitions of membership, sublist, cardinality,
+ intersection
+*}
definition
memb :: "'a \<Rightarrow> 'a list \<Rightarrow> bool"
@@ -36,32 +38,25 @@
definition
sub_list :: "'a list \<Rightarrow> 'a list \<Rightarrow> bool"
where
- "sub_list xs ys \<equiv> (\<forall>x. x \<in> set xs \<longrightarrow> x \<in> set ys)"
+ "sub_list xs ys \<equiv> set xs \<subseteq> set ys"
-fun
+definition
fcard_raw :: "'a list \<Rightarrow> nat"
where
- fcard_raw_nil: "fcard_raw [] = 0"
-| fcard_raw_cons: "fcard_raw (x # xs) = (if memb x xs then fcard_raw xs else Suc (fcard_raw xs))"
+ "fcard_raw xs = card (set xs)"
primrec
finter_raw :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list"
where
- "finter_raw [] l = []"
-| "finter_raw (h # t) l =
- (if memb h l then h # (finter_raw t l) else finter_raw t l)"
-
-primrec
- delete_raw :: "'a list \<Rightarrow> 'a \<Rightarrow> 'a list"
-where
- "delete_raw [] x = []"
-| "delete_raw (a # xs) x = (if (a = x) then delete_raw xs x else a # (delete_raw xs x))"
+ "finter_raw [] ys = []"
+| "finter_raw (x # xs) ys =
+ (if x \<in> set ys then x # (finter_raw xs ys) else finter_raw xs ys)"
primrec
fminus_raw :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list"
where
- "fminus_raw l [] = l"
-| "fminus_raw l (h # t) = fminus_raw (delete_raw l h) t"
+ "fminus_raw ys [] = ys"
+| "fminus_raw ys (x # xs) = fminus_raw (removeAll x ys) xs"
definition
rsp_fold
@@ -74,13 +69,13 @@
"ffold_raw f z [] = z"
| "ffold_raw f z (a # xs) =
(if (rsp_fold f) then
- if memb a xs then ffold_raw f z xs
+ if a \<in> set xs then ffold_raw f z xs
else f a (ffold_raw f z xs)
else z)"
text {* Composition Quotient *}
-lemma list_all2_refl:
+lemma list_all2_refl1:
shows "(list_all2 op \<approx>) r r"
by (rule list_all2_refl) (metis equivp_def fset_equivp)
@@ -88,7 +83,7 @@
shows "(list_all2 op \<approx> OOO op \<approx>) r r"
proof
have *: "r \<approx> r" by (rule equivp_reflp[OF fset_equivp])
- show "list_all2 op \<approx> r r" by (rule list_all2_refl)
+ show "list_all2 op \<approx> r r" by (rule list_all2_refl1)
with * show "(op \<approx> OO list_all2 op \<approx>) r r" ..
qed
@@ -96,12 +91,9 @@
shows "Quotient (list_all2 op \<approx>) (map abs_fset) (map rep_fset)"
by (fact list_quotient[OF Quotient_fset])
-lemma set_in_eq: "(\<forall>e. ((e \<in> xs) \<longleftrightarrow> (e \<in> ys))) \<equiv> xs = ys"
- by (rule eq_reflection) auto
-
lemma map_rel_cong: "b \<approx> ba \<Longrightarrow> map f b \<approx> map f ba"
unfolding list_eq.simps
- by (simp only: set_map set_in_eq)
+ by (simp only: set_map)
lemma quotient_compose_list[quot_thm]:
shows "Quotient ((list_all2 op \<approx>) OOO (op \<approx>))
@@ -112,11 +104,11 @@
show "abs_fset (map abs_fset (map rep_fset (rep_fset a))) = a"
by (simp add: abs_o_rep[OF Quotient_fset] Quotient_abs_rep[OF Quotient_fset] map_id)
have b: "list_all2 op \<approx> (map rep_fset (rep_fset a)) (map rep_fset (rep_fset a))"
- by (rule list_all2_refl)
+ by (rule list_all2_refl1)
have c: "(op \<approx> OO list_all2 op \<approx>) (map rep_fset (rep_fset a)) (map rep_fset (rep_fset a))"
by (rule, rule equivp_reflp[OF fset_equivp]) (rule b)
show "(list_all2 op \<approx> OOO op \<approx>) (map rep_fset (rep_fset a)) (map rep_fset (rep_fset a))"
- by (rule, rule list_all2_refl) (rule c)
+ by (rule, rule list_all2_refl1) (rule c)
show "(list_all2 op \<approx> OOO op \<approx>) r s = ((list_all2 op \<approx> OOO op \<approx>) r r \<and>
(list_all2 op \<approx> OOO op \<approx>) s s \<and> abs_fset (map abs_fset r) = abs_fset (map abs_fset s))"
proof (intro iffI conjI)
@@ -148,23 +140,33 @@
have b: "map rep_fset (map abs_fset r) \<approx> map rep_fset (map abs_fset s)"
by (rule map_rel_cong[OF d])
have y: "list_all2 op \<approx> (map rep_fset (map abs_fset s)) s"
- by (fact rep_abs_rsp_left[OF Quotient_fset_list, OF list_all2_refl[of s]])
+ by (fact rep_abs_rsp_left[OF Quotient_fset_list, OF list_all2_refl1[of s]])
have c: "(op \<approx> OO list_all2 op \<approx>) (map rep_fset (map abs_fset r)) s"
by (rule pred_compI) (rule b, rule y)
have z: "list_all2 op \<approx> r (map rep_fset (map abs_fset r))"
- by (fact rep_abs_rsp[OF Quotient_fset_list, OF list_all2_refl[of r]])
+ by (fact rep_abs_rsp[OF Quotient_fset_list, OF list_all2_refl1[of r]])
then show "(list_all2 op \<approx> OOO op \<approx>) r s"
using a c pred_compI by simp
qed
qed
+
+lemma set_finter_raw[simp]:
+ "set (finter_raw xs ys) = set xs \<inter> set ys"
+ by (induct xs) (auto simp add: memb_def)
+
+lemma set_fminus_raw[simp]:
+ "set (fminus_raw xs ys) = (set xs - set ys)"
+ by (induct ys arbitrary: xs) (auto)
+
+
text {* Respectfullness *}
-lemma [quot_respect]:
- shows "(op \<approx> ===> op \<approx> ===> op \<approx>) op @ op @"
- by auto
+lemma append_rsp[quot_respect]:
+ shows "(op \<approx> ===> op \<approx> ===> op \<approx>) append append"
+ by (simp)
-lemma [quot_respect]:
+lemma sub_list_rsp[quot_respect]:
shows "(op \<approx> ===> op \<approx> ===> op =) sub_list sub_list"
by (auto simp add: sub_list_def)
@@ -173,11 +175,11 @@
by (auto simp add: memb_def)
lemma nil_rsp[quot_respect]:
- shows "[] \<approx> []"
+ shows "(op \<approx>) Nil Nil"
by simp
lemma cons_rsp[quot_respect]:
- shows "(op = ===> op \<approx> ===> op \<approx>) op # op #"
+ shows "(op = ===> op \<approx> ===> op \<approx>) Cons Cons"
by simp
lemma map_rsp[quot_respect]:
@@ -192,6 +194,24 @@
shows "(op \<approx> ===> op \<approx> ===> op =) op \<approx> op \<approx>"
by auto
+lemma finter_raw_rsp[quot_respect]:
+ shows "(op \<approx> ===> op \<approx> ===> op \<approx>) finter_raw finter_raw"
+ by simp
+
+lemma removeAll_rsp[quot_respect]:
+ shows "(op = ===> op \<approx> ===> op \<approx>) removeAll removeAll"
+ by simp
+
+lemma fminus_raw_rsp[quot_respect]:
+ shows "(op \<approx> ===> op \<approx> ===> op \<approx>) fminus_raw fminus_raw"
+ by simp
+
+lemma fcard_raw_rsp[quot_respect]:
+ shows "(op \<approx> ===> op =) fcard_raw fcard_raw"
+ by (simp add: fcard_raw_def)
+
+
+
lemma not_memb_nil:
shows "\<not> memb x []"
by (simp add: memb_def)
@@ -200,85 +220,6 @@
shows "memb x (y # xs) = (x = y \<or> memb x xs)"
by (induct xs) (auto simp add: memb_def)
-lemma memb_finter_raw:
- "memb x (finter_raw xs ys) \<longleftrightarrow> memb x xs \<and> memb x ys"
- by (induct xs) (auto simp add: not_memb_nil memb_cons_iff)
-
-lemma [quot_respect]:
- "(op \<approx> ===> op \<approx> ===> op \<approx>) finter_raw finter_raw"
- by (simp add: memb_def[symmetric] memb_finter_raw)
-
-lemma memb_delete_raw:
- "memb x (delete_raw xs y) = (memb x xs \<and> x \<noteq> y)"
- by (induct xs arbitrary: x y) (auto simp add: memb_def)
-
-lemma [quot_respect]:
- "(op \<approx> ===> op = ===> op \<approx>) delete_raw delete_raw"
- by (simp add: memb_def[symmetric] memb_delete_raw)
-
-lemma fminus_raw_memb: "memb x (fminus_raw xs ys) = (memb x xs \<and> \<not> memb x ys)"
- by (induct ys arbitrary: xs)
- (simp_all add: not_memb_nil memb_delete_raw memb_cons_iff)
-
-lemma [quot_respect]:
- "(op \<approx> ===> op \<approx> ===> op \<approx>) fminus_raw fminus_raw"
- by (simp add: memb_def[symmetric] fminus_raw_memb)
-
-lemma fcard_raw_gt_0:
- assumes a: "x \<in> set xs"
- shows "0 < fcard_raw xs"
- using a by (induct xs) (auto simp add: memb_def)
-
-lemma fcard_raw_delete_one:
- shows "fcard_raw ([x \<leftarrow> xs. x \<noteq> y]) = (if memb y xs then fcard_raw xs - 1 else fcard_raw xs)"
- by (induct xs) (auto dest: fcard_raw_gt_0 simp add: memb_def)
-
-lemma fcard_raw_rsp_aux:
- assumes a: "xs \<approx> ys"
- shows "fcard_raw xs = fcard_raw ys"
- using a
- proof (induct xs arbitrary: ys)
- case Nil
- show ?case using Nil.prems by simp
- next
- case (Cons a xs)
- have a: "a # xs \<approx> ys" by fact
- have b: "\<And>ys. xs \<approx> ys \<Longrightarrow> fcard_raw xs = fcard_raw ys" by fact
- show ?case proof (cases "a \<in> set xs")
- assume c: "a \<in> set xs"
- have "\<forall>x. (x \<in> set xs) = (x \<in> set ys)"
- proof (intro allI iffI)
- fix x
- assume "x \<in> set xs"
- then show "x \<in> set ys" using a by auto
- next
- fix x
- assume d: "x \<in> set ys"
- have e: "(x \<in> set (a # xs)) = (x \<in> set ys)" using a by simp
- show "x \<in> set xs" using c d e unfolding list_eq.simps by simp blast
- qed
- then show ?thesis using b c by (simp add: memb_def)
- next
- assume c: "a \<notin> set xs"
- 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
- have "Suc (fcard_raw xs) = fcard_raw ys"
- proof (cases "a \<in> set ys")
- assume e: "a \<in> set ys"
- have f: "\<forall>x. (x \<in> set xs) = (x \<in> set ys \<and> x \<noteq> a)" using a c
- by (auto simp add: fcard_raw_delete_one)
- have "fcard_raw ys = Suc (fcard_raw ys - 1)" by (rule Suc_pred'[OF fcard_raw_gt_0]) (rule e)
- then show ?thesis using d e f by (simp_all add: fcard_raw_delete_one memb_def)
- next
- case False then show ?thesis using a c d by auto
- qed
- then show ?thesis using a c d by (simp add: memb_def)
- qed
-qed
-
-lemma fcard_raw_rsp[quot_respect]:
- shows "(op \<approx> ===> op =) fcard_raw fcard_raw"
- by (simp add: fcard_raw_rsp_aux)
-
lemma memb_absorb:
shows "memb x xs \<Longrightarrow> x # xs \<approx> xs"
by (induct xs) (auto simp add: memb_def)
@@ -287,53 +228,35 @@
"(\<forall>x. \<not> memb x xs) = (xs \<approx> [])"
by (simp add: memb_def)
-lemma not_memb_delete_raw_ident:
- shows "\<not> memb x xs \<Longrightarrow> delete_raw xs x = xs"
- by (induct xs) (auto simp add: memb_def)
lemma memb_commute_ffold_raw:
- "rsp_fold f \<Longrightarrow> memb h b \<Longrightarrow> ffold_raw f z b = f h (ffold_raw f z (delete_raw b h))"
+ "rsp_fold f \<Longrightarrow> h \<in> set b \<Longrightarrow> ffold_raw f z b = f h (ffold_raw f z (removeAll h b))"
apply (induct b)
- apply (simp_all add: not_memb_nil)
- apply (auto)
- apply (simp_all add: memb_delete_raw not_memb_delete_raw_ident rsp_fold_def memb_cons_iff)
+ apply (auto simp add: rsp_fold_def)
done
lemma ffold_raw_rsp_pre:
- "\<forall>e. memb e a = memb e b \<Longrightarrow> ffold_raw f z a = ffold_raw f z b"
+ "set a = set b \<Longrightarrow> ffold_raw f z a = ffold_raw f z b"
apply (induct a arbitrary: b)
- apply (simp add: memb_absorb memb_def none_memb_nil)
apply (simp)
+ apply (simp (no_asm_use))
apply (rule conjI)
apply (rule_tac [!] impI)
apply (rule_tac [!] conjI)
apply (rule_tac [!] impI)
- apply (subgoal_tac "\<forall>e. memb e a2 = memb e b")
- apply (simp)
- apply (simp add: memb_cons_iff memb_def)
- apply (auto)[1]
- apply (drule_tac x="e" in spec)
- apply (blast)
- apply (case_tac b)
- apply (simp_all)
- apply (subgoal_tac "ffold_raw f z b = f a1 (ffold_raw f z (delete_raw b a1))")
- apply (simp only:)
- apply (rule_tac f="f a1" in arg_cong)
- apply (subgoal_tac "\<forall>e. memb e a2 = memb e (delete_raw b a1)")
- apply (simp)
- apply (simp add: memb_delete_raw)
- apply (auto simp add: memb_cons_iff)[1]
- apply (erule memb_commute_ffold_raw)
- apply (drule_tac x="a1" in spec)
- apply (simp add: memb_cons_iff)
- apply (simp add: memb_cons_iff)
- apply (case_tac b)
- apply (simp_all)
- done
+ apply (metis insert_absorb)
+ apply (metis List.insert_def List.set.simps(2) List.set_insert ffold_raw.simps(2))
+ apply (metis Diff_insert_absorb insertI1 memb_commute_ffold_raw set_removeAll)
+ apply(drule_tac x="removeAll a1 b" in meta_spec)
+ apply(auto)
+ apply(drule meta_mp)
+ apply(blast)
+ by (metis List.set.simps(2) emptyE ffold_raw.simps(2) in_listsp_conv_set listsp.simps mem_def)
-lemma [quot_respect]:
- "(op = ===> op = ===> op \<approx> ===> op =) ffold_raw ffold_raw"
- by (simp add: memb_def[symmetric] ffold_raw_rsp_pre)
+lemma ffold_raw_rsp[quot_respect]:
+ shows "(op = ===> op = ===> op \<approx> ===> op =) ffold_raw ffold_raw"
+ unfolding fun_rel_def
+ by(auto intro: ffold_raw_rsp_pre)
lemma concat_rsp_pre:
assumes a: "list_all2 op \<approx> x x'"
@@ -350,16 +273,18 @@
then show ?thesis using f i by auto
qed
-lemma [quot_respect]:
+lemma concat_rsp[quot_respect]:
shows "(list_all2 op \<approx> OOO op \<approx> ===> op \<approx>) concat concat"
proof (rule fun_relI, elim pred_compE)
fix a b ba bb
assume a: "list_all2 op \<approx> a ba"
assume b: "ba \<approx> bb"
assume c: "list_all2 op \<approx> bb b"
- have "\<forall>x. (\<exists>xa\<in>set a. x \<in> set xa) = (\<exists>xa\<in>set b. x \<in> set xa)" proof
+ have "\<forall>x. (\<exists>xa\<in>set a. x \<in> set xa) = (\<exists>xa\<in>set b. x \<in> set xa)"
+ proof
fix x
- show "(\<exists>xa\<in>set a. x \<in> set xa) = (\<exists>xa\<in>set b. x \<in> set xa)" proof
+ show "(\<exists>xa\<in>set a. x \<in> set xa) = (\<exists>xa\<in>set b. x \<in> set xa)"
+ proof
assume d: "\<exists>xa\<in>set a. x \<in> set xa"
show "\<exists>xa\<in>set b. x \<in> set xa" by (rule concat_rsp_pre[OF a b c d])
next
@@ -370,11 +295,11 @@
show "\<exists>xa\<in>set a. x \<in> set xa" by (rule concat_rsp_pre[OF c' b' a' e])
qed
qed
- then show "concat a \<approx> concat b" by simp
+ then show "concat a \<approx> concat b" by auto
qed
lemma [quot_respect]:
- "((op =) ===> op \<approx> ===> op \<approx>) filter filter"
+ shows "((op =) ===> op \<approx> ===> op \<approx>) filter filter"
by auto
text {* Distributive lattice with bot *}
@@ -382,9 +307,7 @@
lemma append_inter_distrib:
"x @ (finter_raw y z) \<approx> finter_raw (x @ y) (x @ z)"
apply (induct x)
- apply (simp_all add: memb_def)
- apply (simp add: memb_def[symmetric] memb_finter_raw)
- apply (auto simp add: memb_def)
+ apply (auto)
done
instantiation fset :: (type) "{bounded_lattice_bot, distrib_lattice, minus}"
@@ -409,18 +332,19 @@
"xs |\<subseteq>| ys \<equiv> xs \<le> ys"
definition
- less_fset:
- "(xs :: 'a fset) < ys \<equiv> xs \<le> ys \<and> xs \<noteq> ys"
+ less_fset :: "'a fset \<Rightarrow> 'a fset \<Rightarrow> bool"
+where
+ "xs < ys \<equiv> xs \<le> ys \<and> xs \<noteq> (ys::'a fset)"
abbreviation
- f_subset :: "'a fset \<Rightarrow> 'a fset \<Rightarrow> bool" (infix "|\<subset>|" 50)
+ fsubset :: "'a fset \<Rightarrow> 'a fset \<Rightarrow> bool" (infix "|\<subset>|" 50)
where
"xs |\<subset>| ys \<equiv> xs < ys"
quotient_definition
- "sup \<Colon> ('a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset)"
+ "sup :: 'a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
is
- "(op @) \<Colon> ('a list \<Rightarrow> 'a list \<Rightarrow> 'a list)"
+ "append :: 'a list \<Rightarrow> 'a list \<Rightarrow> 'a list"
abbreviation
funion (infixl "|\<union>|" 65)
@@ -428,9 +352,9 @@
"xs |\<union>| ys \<equiv> sup (xs :: 'a fset) ys"
quotient_definition
- "inf \<Colon> ('a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset)"
+ "inf :: 'a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
is
- "finter_raw \<Colon> ('a list \<Rightarrow> 'a list \<Rightarrow> 'a list)"
+ "finter_raw :: 'a list \<Rightarrow> 'a list \<Rightarrow> 'a list"
abbreviation
finter (infixl "|\<inter>|" 65)
@@ -446,16 +370,16 @@
proof
fix x y z :: "'a fset"
show "x |\<subset>| y \<longleftrightarrow> x |\<subseteq>| y \<and> \<not> y |\<subseteq>| x"
- unfolding less_fset
+ unfolding less_fset_def
by (descending) (auto simp add: sub_list_def)
show "x |\<subseteq>| x" by (descending) (simp add: sub_list_def)
show "{||} |\<subseteq>| x" by (descending) (simp add: sub_list_def)
show "x |\<subseteq>| x |\<union>| y" by (descending) (simp add: sub_list_def)
show "y |\<subseteq>| x |\<union>| y" by (descending) (simp add: sub_list_def)
- show "x |\<inter>| y |\<subseteq>| x"
- by (descending) (simp add: sub_list_def memb_def[symmetric] memb_finter_raw)
+ show "x |\<inter>| y |\<subseteq>| x"
+ by (descending) (simp add: sub_list_def memb_def[symmetric])
show "x |\<inter>| y |\<subseteq>| y"
- by (descending) (simp add: sub_list_def memb_def[symmetric] memb_finter_raw)
+ by (descending) (simp add: sub_list_def memb_def[symmetric])
show "x |\<union>| (y |\<inter>| z) = x |\<union>| y |\<inter>| (x |\<union>| z)"
by (descending) (rule append_inter_distrib)
next
@@ -481,7 +405,7 @@
assume a: "x |\<subseteq>| y"
assume b: "x |\<subseteq>| z"
show "x |\<subseteq>| y |\<inter>| z" using a b
- by (descending) (simp add: sub_list_def memb_def[symmetric] memb_finter_raw)
+ by (descending) (simp add: sub_list_def memb_def[symmetric])
qed
end
@@ -490,7 +414,7 @@
quotient_definition
"finsert :: 'a \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
-is "op #"
+is "Cons"
syntax
"@Finset" :: "args => 'a fset" ("{|(_)|}")
@@ -514,19 +438,19 @@
quotient_definition
"fcard :: 'a fset \<Rightarrow> nat"
is
- "fcard_raw"
+ fcard_raw
quotient_definition
"fmap :: ('a \<Rightarrow> 'b) \<Rightarrow> 'a fset \<Rightarrow> 'b fset"
is
- "map"
+ map
quotient_definition
- "fdelete :: 'a fset \<Rightarrow> 'a \<Rightarrow> 'a fset"
- is "delete_raw"
+ "fdelete :: 'a \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
+ is removeAll
quotient_definition
- "fset_to_set :: 'a fset \<Rightarrow> 'a set"
+ "fset :: 'a fset \<Rightarrow> 'a set"
is "set"
quotient_definition
@@ -552,9 +476,8 @@
by simp
lemma [quot_respect]:
- "(op \<approx> ===> list_all2 op \<approx> OOO op \<approx> ===> list_all2 op \<approx> OOO op \<approx>) op # op #"
+ shows "(op \<approx> ===> list_all2 op \<approx> OOO op \<approx> ===> list_all2 op \<approx> OOO op \<approx>) Cons Cons"
apply auto
- apply (simp add: set_in_eq)
apply (rule_tac b="x # b" in pred_compI)
apply auto
apply (rule_tac b="x # ba" in pred_compI)
@@ -581,13 +504,13 @@
assumes a:"list_all2 op \<approx> x x'"
shows "list_all2 op \<approx> (x @ z) (x' @ z)"
using a apply (induct x x' rule: list_induct2')
- by simp_all (rule list_all2_refl)
+ by simp_all (rule list_all2_refl1)
lemma append_rsp2_pre1:
assumes a:"list_all2 op \<approx> x x'"
shows "list_all2 op \<approx> (z @ x) (z @ x')"
using a apply (induct x x' arbitrary: z rule: list_induct2')
- apply (rule list_all2_refl)
+ apply (rule list_all2_refl1)
apply (simp_all del: list_eq.simps)
apply (rule list_all2_app_l)
apply (simp_all add: reflp_def)
@@ -602,7 +525,7 @@
apply (rule a)
using b apply (induct z z' rule: list_induct2')
apply (simp_all only: append_Nil2)
- apply (rule list_all2_refl)
+ apply (rule list_all2_refl1)
apply simp_all
apply (rule append_rsp2_pre1)
apply simp
@@ -648,52 +571,22 @@
lemma singleton_list_eq:
shows "[x] \<approx> [y] \<longleftrightarrow> x = y"
- by (simp add: id_simps) auto
+ by (simp)
lemma sub_list_cons:
"sub_list (x # xs) ys = (memb x ys \<and> sub_list xs ys)"
by (auto simp add: memb_def sub_list_def)
-lemma fminus_raw_red: "fminus_raw (x # xs) ys = (if memb x ys then fminus_raw xs ys else x # (fminus_raw xs ys))"
- by (induct ys arbitrary: xs x)
- (simp_all add: not_memb_nil memb_delete_raw memb_cons_iff)
+lemma fminus_raw_red:
+ "fminus_raw (x # xs) ys = (if x \<in> set ys then fminus_raw xs ys else x # (fminus_raw xs ys))"
+ by (induct ys arbitrary: xs x) (simp_all)
text {* Cardinality of finite sets *}
lemma fcard_raw_0:
shows "fcard_raw xs = 0 \<longleftrightarrow> xs \<approx> []"
- by (induct xs) (auto simp add: memb_def)
-
-lemma fcard_raw_not_memb:
- shows "\<not> memb x xs \<longleftrightarrow> fcard_raw (x # xs) = Suc (fcard_raw xs)"
- by auto
-
-lemma fcard_raw_suc:
- assumes a: "fcard_raw xs = Suc n"
- shows "\<exists>x ys. \<not> (memb x ys) \<and> xs \<approx> (x # ys) \<and> fcard_raw ys = n"
- using a
- by (induct xs) (auto simp add: memb_def split: if_splits)
-
-lemma singleton_fcard_1:
- shows "set xs = {x} \<Longrightarrow> fcard_raw xs = 1"
- by (induct xs) (auto simp add: memb_def subset_insert)
-
-lemma fcard_raw_1:
- shows "fcard_raw xs = 1 \<longleftrightarrow> (\<exists>x. xs \<approx> [x])"
- apply (auto dest!: fcard_raw_suc)
- apply (simp add: fcard_raw_0)
- apply (rule_tac x="x" in exI)
- apply simp
- apply (subgoal_tac "set xs = {x}")
- apply (drule singleton_fcard_1)
- apply auto
- done
-
-lemma fcard_raw_suc_memb:
- assumes a: "fcard_raw A = Suc n"
- shows "\<exists>a. memb a A"
- using a
- by (induct A) (auto simp add: memb_def)
+ unfolding fcard_raw_def
+ by (induct xs) (auto)
lemma memb_card_not_0:
assumes a: "memb a A"
@@ -749,21 +642,18 @@
section {* deletion *}
-lemma memb_delete_raw_ident:
- shows "\<not> memb x (delete_raw xs x)"
+
+lemma fset_raw_removeAll_cases:
+ "xs = [] \<or> (\<exists>x. memb x xs \<and> xs \<approx> x # removeAll x xs)"
by (induct xs) (auto simp add: memb_def)
-lemma fset_raw_delete_raw_cases:
- "xs = [] \<or> (\<exists>x. memb x xs \<and> xs \<approx> x # delete_raw xs x)"
- by (induct xs) (auto simp add: memb_def)
-
-lemma fdelete_raw_filter:
- "delete_raw xs y = [x \<leftarrow> xs. x \<noteq> y]"
+lemma fremoveAll_filter:
+ "removeAll y xs = [x \<leftarrow> xs. x \<noteq> y]"
by (induct xs) simp_all
lemma fcard_raw_delete:
- "fcard_raw (delete_raw xs y) = (if memb y xs then fcard_raw xs - 1 else fcard_raw xs)"
- by (simp add: fdelete_raw_filter fcard_raw_delete_one)
+ "fcard_raw (removeAll y xs) = (if memb y xs then fcard_raw xs - 1 else fcard_raw xs)"
+ by (auto simp add: fcard_raw_def memb_def)
lemma set_cong:
shows "(x \<approx> y) = (set x = set y)"
@@ -791,7 +681,7 @@
by (induct xs) (auto intro: list_eq2.intros)
lemma cons_delete_list_eq2:
- shows "list_eq2 (a # (delete_raw A a)) (if memb a A then A else a # A)"
+ shows "list_eq2 (a # (removeAll a A)) (if memb a A then A else a # A)"
apply (induct A)
apply (simp add: memb_def list_eq2_refl)
apply (case_tac "memb a (aa # A)")
@@ -802,19 +692,15 @@
apply (auto simp add: memb_def)[2]
apply (metis list_eq2.intros(3) list_eq2.intros(4) list_eq2.intros(5) list_eq2.intros(6))
apply (metis list_eq2.intros(1) list_eq2.intros(5) list_eq2.intros(6))
- apply (auto simp add: list_eq2_refl not_memb_delete_raw_ident)
+ apply (auto simp add: list_eq2_refl memb_def)
done
lemma memb_delete_list_eq2:
assumes a: "memb e r"
- shows "list_eq2 (e # delete_raw r e) r"
+ shows "list_eq2 (e # removeAll e r) r"
using a cons_delete_list_eq2[of e r]
by simp
-lemma delete_raw_rsp:
- "xs \<approx> ys \<Longrightarrow> delete_raw xs x \<approx> delete_raw ys x"
- by (simp add: memb_def[symmetric] memb_delete_raw)
-
lemma list_eq2_equiv:
"(l \<approx> r) \<longleftrightarrow> (list_eq2 l r)"
proof
@@ -836,58 +722,27 @@
case (Suc m)
have b: "l \<approx> r" by fact
have d: "fcard_raw l = Suc m" by fact
- then have "\<exists>a. memb a l" by (rule fcard_raw_suc_memb)
+ then have "\<exists>a. memb a l"
+ apply(simp add: fcard_raw_def memb_def)
+ apply(drule card_eq_SucD)
+ apply(blast)
+ done
then obtain a where e: "memb a l" by auto
- then have e': "memb a r" using list_eq.simps[simplified memb_def[symmetric], of l r] b by auto
- have f: "fcard_raw (delete_raw l a) = m" using fcard_raw_delete[of l a] e d by simp
- have g: "delete_raw l a \<approx> delete_raw r a" using delete_raw_rsp[OF b] by simp
- have "list_eq2 (delete_raw l a) (delete_raw r a)" by (rule Suc.hyps[OF f g])
- then have h: "list_eq2 (a # delete_raw l a) (a # delete_raw r a)" by (rule list_eq2.intros(5))
- have i: "list_eq2 l (a # delete_raw l a)"
+ then have e': "memb a r" using list_eq.simps[simplified memb_def[symmetric], of l r] b
+ unfolding memb_def by auto
+ have f: "fcard_raw (removeAll a l) = m" using fcard_raw_delete[of a l] e d by simp
+ have g: "removeAll a l \<approx> removeAll a r" using removeAll_rsp b by simp
+ have "list_eq2 (removeAll a l) (removeAll a r)" by (rule Suc.hyps[OF f g])
+ then have h: "list_eq2 (a # removeAll a l) (a # removeAll a r)" by (rule list_eq2.intros(5))
+ have i: "list_eq2 l (a # removeAll a l)"
by (rule list_eq2.intros(3)[OF memb_delete_list_eq2[OF e]])
- have "list_eq2 l (a # delete_raw r a)" by (rule list_eq2.intros(6)[OF i h])
+ have "list_eq2 l (a # removeAll a r)" by (rule list_eq2.intros(6)[OF i h])
then show ?case using list_eq2.intros(6)[OF _ memb_delete_list_eq2[OF e']] by simp
qed
}
then show "l \<approx> r \<Longrightarrow> list_eq2 l r" by blast
qed
-text {* Set *}
-
-lemma sub_list_set: "sub_list xs ys = (set xs \<subseteq> set ys)"
- unfolding sub_list_def by auto
-
-lemma sub_list_neq_set: "(sub_list xs ys \<and> \<not> list_eq xs ys) = (set xs \<subset> set ys)"
- by (auto simp add: sub_list_set)
-
-lemma fcard_raw_set: "fcard_raw xs = card (set xs)"
- by (induct xs) (auto simp add: insert_absorb memb_def card_insert_disjoint finite_set)
-
-lemma memb_set: "memb x xs = (x \<in> set xs)"
- by (simp only: memb_def)
-
-lemma filter_set: "set (filter P xs) = P \<inter> (set xs)"
- by (induct xs, simp)
- (metis Int_insert_right_if0 Int_insert_right_if1 List.set.simps(2) filter.simps(2) mem_def)
-
-lemma delete_raw_set: "set (delete_raw xs x) = set xs - {x}"
- by (induct xs) auto
-
-lemma inter_raw_set: "set (finter_raw xs ys) = set xs \<inter> set ys"
- by (induct xs) (simp_all add: memb_def)
-
-lemma fminus_raw_set: "set (fminus_raw xs ys) = set xs - set ys"
- by (induct ys arbitrary: xs)
- (simp_all add: fminus_raw.simps delete_raw_set, blast)
-
-text {* Raw theorems of ffilter *}
-
-lemma sub_list_filter: "sub_list (filter P xs) (filter Q xs) = (\<forall> x. memb x xs \<longrightarrow> P x \<longrightarrow> Q x)"
-unfolding sub_list_def memb_def by auto
-
-lemma list_eq_filter: "list_eq (filter P xs) (filter Q xs) = (\<forall>x. memb x xs \<longrightarrow> P x = Q x)"
-unfolding memb_def by auto
-
text {* Lifted theorems *}
lemma not_fin_fnil: "x |\<notin>| {||}"
@@ -924,16 +779,15 @@
by (descending) (auto)
-text {* fset_to_set *}
+text {* fset *}
-lemma fset_to_set_simps [simp]:
- fixes h::"'a"
- shows "fset_to_set {||} = ({} :: 'a set)"
- and "fset_to_set (finsert h t) = insert h (fset_to_set t)"
+lemma fset_simps[simp]:
+ "fset {||} = ({} :: 'a set)"
+ "fset (finsert (h :: 'a) t) = insert h (fset t)"
by (lifting set.simps)
-lemma in_fset_to_set:
- "x \<in> fset_to_set S \<equiv> x |\<in>| S"
+lemma in_fset:
+ "x \<in> fset S \<equiv> x |\<in>| S"
by (lifting memb_def[symmetric])
lemma none_fin_fempty:
@@ -941,47 +795,62 @@
by (lifting none_memb_nil)
lemma fset_cong:
- "S = T \<longleftrightarrow> fset_to_set S = fset_to_set T"
+ "S = T \<longleftrightarrow> fset S = fset T"
by (lifting set_cong)
+
text {* fcard *}
-lemma fcard_fempty [simp]:
- shows "fcard {||} = 0"
- by (descending) (simp)
-
lemma fcard_finsert_if [simp]:
shows "fcard (finsert x S) = (if x |\<in>| S then fcard S else Suc (fcard S))"
- by (descending) (simp)
+ by (descending) (auto simp add: fcard_raw_def memb_def insert_absorb)
-lemma fcard_0:
- "fcard S = 0 \<longleftrightarrow> S = {||}"
- by (lifting fcard_raw_0)
+lemma fcard_0[simp]:
+ shows "fcard S = 0 \<longleftrightarrow> S = {||}"
+ by (descending) (simp add: fcard_raw_def)
+
+lemma fcard_fempty[simp]:
+ shows "fcard {||} = 0"
+ by (simp add: fcard_0)
lemma fcard_1:
shows "fcard S = 1 \<longleftrightarrow> (\<exists>x. S = {|x|})"
- by (lifting fcard_raw_1)
+ by (descending) (auto simp add: fcard_raw_def card_Suc_eq)
lemma fcard_gt_0:
- shows "x \<in> fset_to_set S \<Longrightarrow> 0 < fcard S"
- by (lifting fcard_raw_gt_0)
-
+ shows "x \<in> fset S \<Longrightarrow> 0 < fcard S"
+ by (descending) (auto simp add: fcard_raw_def card_gt_0_iff)
+
lemma fcard_not_fin:
shows "(x |\<notin>| S) = (fcard (finsert x S) = Suc (fcard S))"
- by (lifting fcard_raw_not_memb)
+ by (descending) (auto simp add: memb_def fcard_raw_def insert_absorb)
lemma fcard_suc: "fcard S = Suc n \<Longrightarrow> \<exists>x T. x |\<notin>| T \<and> S = finsert x T \<and> fcard T = n"
- by (lifting fcard_raw_suc)
+ apply descending
+ apply(simp add: fcard_raw_def memb_def)
+ apply(drule card_eq_SucD)
+ apply(auto)
+ apply(rule_tac x="b" in exI)
+ apply(rule_tac x="removeAll b S" in exI)
+ apply(auto)
+ done
lemma fcard_delete:
- "fcard (fdelete S y) = (if y |\<in>| S then fcard S - 1 else fcard S)"
+ "fcard (fdelete y S) = (if y |\<in>| S then fcard S - 1 else fcard S)"
by (lifting fcard_raw_delete)
-lemma fcard_suc_memb: "fcard A = Suc n \<Longrightarrow> \<exists>a. a |\<in>| A"
- by (lifting fcard_raw_suc_memb)
+lemma fcard_suc_memb:
+ shows "fcard A = Suc n \<Longrightarrow> \<exists>a. a |\<in>| A"
+ apply(descending)
+ apply(simp add: fcard_raw_def memb_def)
+ apply(drule card_eq_SucD)
+ apply(auto)
+ done
-lemma fin_fcard_not_0: "a |\<in>| A \<Longrightarrow> fcard A \<noteq> 0"
- by (lifting memb_card_not_0)
+lemma fin_fcard_not_0:
+ shows "a |\<in>| A \<Longrightarrow> fcard A \<noteq> 0"
+ by (descending) (auto simp add: fcard_raw_def memb_def)
+
text {* funion *}
@@ -1001,7 +870,8 @@
shows "S |\<union>| {|a|} = finsert a S"
by (subst sup.commute) simp
-section {* Induction and Cases rules for finite sets *}
+
+section {* Induction and Cases rules for fsets *}
lemma fset_strong_cases:
obtains "xs = {||}"
@@ -1066,7 +936,7 @@
by (lifting map.simps)
lemma fmap_set_image:
- "fset_to_set (fmap f S) = f ` (fset_to_set S)"
+ "fset (fmap f S) = f ` (fset S)"
by (induct S) simp_all
lemma inj_fmap_eq_iff:
@@ -1081,103 +951,107 @@
shows "x |\<in>| S |\<union>| T \<longleftrightarrow> x |\<in>| S \<or> x |\<in>| T"
by (lifting memb_append)
-text {* to_set *}
+
+section {* fset *}
lemma fin_set:
- shows "x |\<in>| xs \<longleftrightarrow> x \<in> fset_to_set xs"
- by (lifting memb_set)
+ shows "x |\<in>| xs \<longleftrightarrow> x \<in> fset xs"
+ by (lifting memb_def)
lemma fnotin_set:
- shows "x |\<notin>| xs \<longleftrightarrow> x \<notin> fset_to_set xs"
+ shows "x |\<notin>| xs \<longleftrightarrow> x \<notin> fset xs"
by (simp add: fin_set)
lemma fcard_set:
- shows "fcard xs = card (fset_to_set xs)"
- by (lifting fcard_raw_set)
+ shows "fcard xs = card (fset xs)"
+ by (lifting fcard_raw_def)
lemma fsubseteq_set:
- shows "xs |\<subseteq>| ys \<longleftrightarrow> fset_to_set xs \<subseteq> fset_to_set ys"
- by (lifting sub_list_set)
+ shows "xs |\<subseteq>| ys \<longleftrightarrow> fset xs \<subseteq> fset ys"
+ by (lifting sub_list_def)
lemma fsubset_set:
- shows "xs |\<subset>| ys \<longleftrightarrow> fset_to_set xs \<subset> fset_to_set ys"
- unfolding less_fset by (lifting sub_list_neq_set)
+ shows "xs |\<subset>| ys \<longleftrightarrow> fset xs \<subset> fset ys"
+ unfolding less_fset_def
+ by (descending) (auto simp add: sub_list_def)
-lemma ffilter_set:
- shows "fset_to_set (ffilter P xs) = P \<inter> fset_to_set xs"
- by (lifting filter_set)
+lemma ffilter_set [simp]:
+ shows "fset (ffilter P xs) = P \<inter> fset xs"
+ by (descending) (auto simp add: mem_def)
-lemma fdelete_set:
- shows "fset_to_set (fdelete xs x) = fset_to_set xs - {x}"
- by (lifting delete_raw_set)
+lemma fdelete_set [simp]:
+ shows "fset (fdelete x xs) = fset xs - {x}"
+ by (lifting set_removeAll)
-lemma finter_set:
- shows "fset_to_set (xs |\<inter>| ys) = fset_to_set xs \<inter> fset_to_set ys"
- by (lifting inter_raw_set)
+lemma finter_set [simp]:
+ shows "fset (xs |\<inter>| ys) = fset xs \<inter> fset ys"
+ by (lifting set_finter_raw)
-lemma funion_set:
- shows "fset_to_set (xs |\<union>| ys) = fset_to_set xs \<union> fset_to_set ys"
+lemma funion_set [simp]:
+ shows "fset (xs |\<union>| ys) = fset xs \<union> fset ys"
by (lifting set_append)
-lemma fminus_set:
- shows "fset_to_set (xs - ys) = fset_to_set xs - fset_to_set ys"
- by (lifting fminus_raw_set)
+lemma fminus_set [simp]:
+ shows "fset (xs - ys) = fset xs - fset ys"
+ by (lifting set_fminus_raw)
lemmas fset_to_set_trans =
fin_set fnotin_set fcard_set fsubseteq_set fsubset_set
- finter_set funion_set ffilter_set fset_to_set_simps
+ finter_set funion_set ffilter_set fset_simps
fset_cong fdelete_set fmap_set_image fminus_set
text {* ffold *}
-lemma ffold_nil: "ffold f z {||} = z"
+lemma ffold_nil:
+ shows "ffold f z {||} = z"
by (lifting ffold_raw.simps(1)[where 'a="'b" and 'b="'a"])
lemma ffold_finsert: "ffold f z (finsert a A) =
(if rsp_fold f then if a |\<in>| A then ffold f z A else f a (ffold f z A) else z)"
- by (lifting ffold_raw.simps(2)[where 'a="'b" and 'b="'a"])
+ by (descending) (simp add: memb_def)
lemma fin_commute_ffold:
- "\<lbrakk>rsp_fold f; h |\<in>| b\<rbrakk> \<Longrightarrow> ffold f z b = f h (ffold f z (fdelete b h))"
- by (lifting memb_commute_ffold_raw)
+ "\<lbrakk>rsp_fold f; h |\<in>| b\<rbrakk> \<Longrightarrow> ffold f z b = f h (ffold f z (fdelete h b))"
+ by (descending) (simp add: memb_def memb_commute_ffold_raw)
+
text {* fdelete *}
lemma fin_fdelete:
- shows "x |\<in>| fdelete S y \<longleftrightarrow> x |\<in>| S \<and> x \<noteq> y"
- by (lifting memb_delete_raw)
+ shows "x |\<in>| fdelete y S \<longleftrightarrow> x |\<in>| S \<and> x \<noteq> y"
+ by (descending) (simp add: memb_def)
-lemma fin_fdelete_ident:
- shows "x |\<notin>| fdelete S x"
- by (lifting memb_delete_raw_ident)
+lemma fnotin_fdelete:
+ shows "x |\<notin>| fdelete x S"
+ by (descending) (simp add: memb_def)
-lemma not_memb_fdelete_ident:
- shows "x |\<notin>| S \<Longrightarrow> fdelete S x = S"
- by (lifting not_memb_delete_raw_ident)
+lemma fnotin_fdelete_ident:
+ shows "x |\<notin>| S \<Longrightarrow> fdelete x S = S"
+ by (descending) (simp add: memb_def)
lemma fset_fdelete_cases:
- shows "S = {||} \<or> (\<exists>x. x |\<in>| S \<and> S = finsert x (fdelete S x))"
- by (lifting fset_raw_delete_raw_cases)
+ shows "S = {||} \<or> (\<exists>x. x |\<in>| S \<and> S = finsert x (fdelete x S))"
+ by (lifting fset_raw_removeAll_cases)
text {* finite intersection *}
-lemma finter_empty_l:
+lemma finter_empty_l:
shows "{||} |\<inter>| S = {||}"
by simp
-lemma finter_empty_r:
+lemma finter_empty_r:
shows "S |\<inter>| {||} = {||}"
by simp
lemma finter_finsert:
- "finsert x S |\<inter>| T = (if x |\<in>| T then finsert x (S |\<inter>| T) else S |\<inter>| T)"
- by (lifting finter_raw.simps(2))
+ shows "finsert x S |\<inter>| T = (if x |\<in>| T then finsert x (S |\<inter>| T) else S |\<inter>| T)"
+ by (descending) (simp add: memb_def)
lemma fin_finter:
- "x |\<in>| (S |\<inter>| T) \<longleftrightarrow> x |\<in>| S \<and> x |\<in>| T"
- by (lifting memb_finter_raw)
+ shows "x |\<in>| (S |\<inter>| T) \<longleftrightarrow> x |\<in>| S \<and> x |\<in>| T"
+ by (descending) (simp add: memb_def)
lemma fsubset_finsert:
shows "finsert x xs |\<subseteq>| ys \<longleftrightarrow> x |\<in>| ys \<and> xs |\<subseteq>| ys"
@@ -1185,20 +1059,19 @@
lemma
shows "xs |\<subseteq>| ys \<equiv> \<forall>x. x |\<in>| xs \<longrightarrow> x |\<in>| ys"
- by (lifting sub_list_def[simplified memb_def[symmetric]])
+ by (descending) (auto simp add: sub_list_def memb_def)
lemma fsubset_fin:
shows "xs |\<subseteq>| ys = (\<forall>x. x |\<in>| xs \<longrightarrow> x |\<in>| ys)"
-by (rule meta_eq_to_obj_eq)
- (lifting sub_list_def[simplified memb_def[symmetric]])
+ by (descending) (auto simp add: sub_list_def memb_def)
lemma fminus_fin:
shows "x |\<in>| xs - ys \<longleftrightarrow> x |\<in>| xs \<and> x |\<notin>| ys"
- by (lifting fminus_raw_memb)
+ by (descending) (simp add: memb_def)
lemma fminus_red:
shows "finsert x xs - ys = (if x |\<in>| ys then xs - ys else finsert x (xs - ys))"
- by (lifting fminus_raw_red)
+ by (descending) (auto simp add: memb_def)
lemma fminus_red_fin [simp]:
shows "x |\<in>| ys \<Longrightarrow> finsert x xs - ys = xs - ys"
@@ -1208,9 +1081,9 @@
shows "x |\<notin>| ys \<Longrightarrow> finsert x xs - ys = finsert x (xs - ys)"
by (simp add: fminus_red)
-lemma expand_fset_eq:
+lemma fset_eq_iff:
shows "S = T \<longleftrightarrow> (\<forall>x. (x |\<in>| S) = (x |\<in>| T))"
- by (lifting list_eq.simps[simplified memb_def[symmetric]])
+ by (descending) (auto simp add: memb_def)
(* We cannot write it as "assumes .. shows" since Isabelle changes
the quantifiers to schematic variables and reintroduces them in
@@ -1256,20 +1129,22 @@
lemma subseteq_filter:
shows "ffilter P xs <= ffilter Q xs = (\<forall> x. x |\<in>| xs \<longrightarrow> P x \<longrightarrow> Q x)"
- by (lifting sub_list_filter)
+ by (descending) (auto simp add: memb_def sub_list_def)
lemma eq_ffilter:
shows "(ffilter P xs = ffilter Q xs) = (\<forall>x. x |\<in>| xs \<longrightarrow> P x = Q x)"
- by (lifting list_eq_filter)
+ by (descending) (auto simp add: memb_def)
-lemma subset_ffilter:
+lemma subset_ffilter:
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"
- unfolding less_fset by (auto simp add: subseteq_filter eq_ffilter)
+ unfolding less_fset_def by (auto simp add: subseteq_filter eq_ffilter)
+
section {* lemmas transferred from Finite_Set theory *}
text {* finiteness for finite sets holds *}
-lemma finite_fset: "finite (fset_to_set S)"
+lemma finite_fset [simp]:
+ shows "finite (fset S)"
by (induct S) auto
lemma fset_choice:
@@ -1277,16 +1152,14 @@
unfolding fset_to_set_trans
by (rule finite_set_choice[simplified Ball_def, OF finite_fset])
-lemma fsubseteq_fnil:
+lemma fsubseteq_fempty:
shows "xs |\<subseteq>| {||} \<longleftrightarrow> xs = {||}"
- unfolding fset_to_set_trans
- by (rule subset_empty)
+ by (metis finter_empty_r le_iff_inf)
lemma not_fsubset_fnil:
shows "\<not> xs |\<subset>| {||}"
- unfolding fset_to_set_trans
- by (rule not_psubset_empty)
-
+ by (metis fset_simps(1) fsubset_set not_psubset_empty)
+
lemma fcard_mono:
shows "xs |\<subseteq>| ys \<Longrightarrow> fcard xs \<le> fcard ys"
unfolding fset_to_set_trans
@@ -1294,8 +1167,8 @@
lemma fcard_fseteq:
shows "xs |\<subseteq>| ys \<Longrightarrow> fcard ys \<le> fcard xs \<Longrightarrow> xs = ys"
- unfolding fset_to_set_trans
- by (rule card_seteq[OF finite_fset])
+ unfolding fcard_set fsubseteq_set
+ by (simp add: card_seteq[OF finite_fset] fset_cong)
lemma psubset_fcard_mono:
shows "xs |\<subset>| ys \<Longrightarrow> fcard xs < fcard ys"
@@ -1313,17 +1186,17 @@
by (rule card_Un_disjoint[OF finite_fset finite_fset])
lemma fcard_delete1_less:
- shows "x |\<in>| xs \<Longrightarrow> fcard (fdelete xs x) < fcard xs"
+ shows "x |\<in>| xs \<Longrightarrow> fcard (fdelete x xs) < fcard xs"
unfolding fset_to_set_trans
by (rule card_Diff1_less[OF finite_fset])
lemma fcard_delete2_less:
- shows "x |\<in>| xs \<Longrightarrow> y |\<in>| xs \<Longrightarrow> fcard (fdelete (fdelete xs x) y) < fcard xs"
+ shows "x |\<in>| xs \<Longrightarrow> y |\<in>| xs \<Longrightarrow> fcard (fdelete y (fdelete x xs)) < fcard xs"
unfolding fset_to_set_trans
by (rule card_Diff2_less[OF finite_fset])
lemma fcard_delete1_le:
- shows "fcard (fdelete xs x) \<le> fcard xs"
+ shows "fcard (fdelete x xs) \<le> fcard xs"
unfolding fset_to_set_trans
by (rule card_Diff1_le[OF finite_fset])
@@ -1347,14 +1220,16 @@
unfolding fset_to_set_trans
by blast
-lemma fin_mdef: "x |\<in>| F \<longleftrightarrow> x |\<notin>| (F - {|x|}) \<and> F = finsert x (F - {|x|})"
+lemma fin_mdef:
+ "x |\<in>| F \<longleftrightarrow> x |\<notin>| (F - {|x|}) \<and> F = finsert x (F - {|x|})"
unfolding fset_to_set_trans
by blast
lemma fcard_fminus_finsert[simp]:
assumes "a |\<in>| A" and "a |\<notin>| B"
shows "fcard(A - finsert a B) = fcard(A - B) - 1"
- using assms unfolding fset_to_set_trans
+ using assms
+ unfolding fset_to_set_trans
by (rule card_Diff_insert[OF finite_fset])
lemma fcard_fminus_fsubset:
@@ -1364,7 +1239,7 @@
by (rule card_Diff_subset[OF finite_fset])
lemma fcard_fminus_subset_finter:
- "fcard (A - B) = fcard A - fcard (A |\<inter>| B)"
+ shows "fcard (A - B) = fcard A - fcard (A |\<inter>| B)"
unfolding fset_to_set_trans
by (rule card_Diff_subset_Int) (fold finter_set, rule finite_fset)
--- a/src/Pure/type.ML Sat Oct 16 16:22:42 2010 -0700
+++ b/src/Pure/type.ML Sat Oct 16 16:39:06 2010 -0700
@@ -418,10 +418,12 @@
fun typ_match tsig =
let
- fun match (TVar (v, S), T) subs =
+ fun match (T0 as TVar (v, S), T) subs =
(case lookup subs (v, S) of
NONE =>
- if of_sort tsig (T, S) then Vartab.update_new (v, (S, T)) subs
+ if of_sort tsig (T, S)
+ then if T0 = T then subs (*types already identical; don't create cycle!*)
+ else Vartab.update_new (v, (S, T)) subs
else raise TYPE_MATCH
| SOME U => if U = T then subs else raise TYPE_MATCH)
| match (Type (a, Ts), Type (b, Us)) subs =
--- a/src/Pure/unify.ML Sat Oct 16 16:22:42 2010 -0700
+++ b/src/Pure/unify.ML Sat Oct 16 16:39:06 2010 -0700
@@ -205,6 +205,14 @@
exception ASSIGN; (*Raised if not an assignment*)
+fun self_asgt (ix,(_,TVar (ix',_))) = (ix = ix')
+ | self_asgt (ix, _) = false;
+
+fun check_tyenv msg tys tyenv =
+ if Vartab.exists self_asgt tyenv
+ then raise TYPE (msg ^ ": looping type envir!!", tys, [])
+ else tyenv;
+
fun unify_types thy (T, U, env) =
if T = U then env
else
@@ -715,7 +723,7 @@
fun result env =
if Envir.above env maxidx then (* FIXME proper handling of generated vars!? *)
SOME (Envir.Envir {maxidx = maxidx,
- tyenv = Vartab.make (map (norm_tvar env) pat_tvars),
+ tyenv = Vartab.make (filter_out self_asgt (map (norm_tvar env) pat_tvars)),
tenv = Vartab.make (map (norm_var env) pat_vars)})
else NONE;
--- a/src/ZF/ex/misc.thy Sat Oct 16 16:22:42 2010 -0700
+++ b/src/ZF/ex/misc.thy Sat Oct 16 16:39:06 2010 -0700
@@ -39,19 +39,19 @@
lemma "(X = Y Un Z) <-> (Y \<subseteq> X & Z \<subseteq> X & (\<forall>V. Y \<subseteq> V & Z \<subseteq> V --> X \<subseteq> V))"
by (blast intro!: equalityI)
-text{*the dual of the previous one}
+text{*the dual of the previous one*}
lemma "(X = Y Int Z) <-> (X \<subseteq> Y & X \<subseteq> Z & (\<forall>V. V \<subseteq> Y & V \<subseteq> Z --> V \<subseteq> X))"
by (blast intro!: equalityI)
-text{*trivial example of term synthesis: apparently hard for some provers!}
-lemma "a \<noteq> b ==> a:?X & b \<notin> ?X"
+text{*trivial example of term synthesis: apparently hard for some provers!*}
+schematic_lemma "a \<noteq> b ==> a:?X & b \<notin> ?X"
by blast
-text{*Nice Blast_tac benchmark. Proved in 0.3s; old tactics can't manage it!}
+text{*Nice blast benchmark. Proved in 0.3s; old tactics can't manage it!*}
lemma "\<forall>x \<in> S. \<forall>y \<in> S. x \<subseteq> y ==> \<exists>z. S \<subseteq> {z}"
by blast
-text{*variant of the benchmark above}
+text{*variant of the benchmark above*}
lemma "\<forall>x \<in> S. Union(S) \<subseteq> x ==> \<exists>z. S \<subseteq> {z}"
by blast
@@ -74,7 +74,7 @@
Set Theory in First-Order Logic: Clauses for G\"odel's Axioms,
JAR 2 (1986), 287-327 *}
-text{*collecting the relevant lemmas}
+text{*collecting the relevant lemmas*}
declare comp_fun [simp] SigmaI [simp] apply_funtype [simp]
(*Force helps prove conditions of rewrites such as comp_fun_apply, since
@@ -86,7 +86,7 @@
(K O J) \<in> hom(A,f,C,h)"
by force
-text{*Another version, with meta-level rewriting}
+text{*Another version, with meta-level rewriting*}
lemma "(!! A f B g. hom(A,f,B,g) ==
{H \<in> A->B. f \<in> A*A->A & g \<in> B*B->B &
(\<forall>x \<in> A. \<forall>y \<in> A. H`(f`<x,y>) = g`<H`x,H`y>)})
@@ -108,7 +108,7 @@
"[| (h O g O f) \<in> inj(A,A);
(f O h O g) \<in> surj(B,B);
(g O f O h) \<in> surj(C,C);
- f \<in> A->B; g \<in> B->C; h \<in> C->A |] ==> h \<in> bij(C,A)";
+ f \<in> A->B; g \<in> B->C; h \<in> C->A |] ==> h \<in> bij(C,A)"
by (unfold bij_def, blast)
lemma pastre3: