# HG changeset patch # User Cezary Kaliszyk # Date 1271771997 -7200 # Node ID dbc9e88c44dac2c4e6148312c366cba00da94c48 # Parent 4fa94551eebc6ead5e2a785b53c18c077a988d42 fsets are distributive lattices. diff -r 4fa94551eebc -r dbc9e88c44da Nominal/FSet.thy --- a/Nominal/FSet.thy Tue Apr 20 10:23:39 2010 +0200 +++ b/Nominal/FSet.thy Tue Apr 20 15:59:57 2010 +0200 @@ -63,7 +63,76 @@ "sub_list [] x" by (simp add: sub_list_def) -instantiation fset :: (type) bot +primrec + finter_raw :: "'a list \ 'a list \ '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)" + +lemma not_memb_nil: + shows "\ memb x []" + by (simp add: memb_def) + +lemma memb_cons_iff: + shows "memb x (y # xs) = (x = y \ memb x xs)" + by (induct xs) (auto simp add: memb_def) + +lemma memb_finter_raw: + "memb x (finter_raw xs ys) \ memb x xs \ memb x ys" + apply (induct xs) + apply (simp add: not_memb_nil) + apply (simp add: finter_raw.simps) + apply (simp add: memb_cons_iff) + apply auto + done + +lemma [quot_respect]: + "(op \ ===> op \ ===> op \) finter_raw finter_raw" + by (simp add: memb_def[symmetric] memb_finter_raw) + + +lemma sub_list_append_left: + "sub_list x (x @ y)" + by (simp add: sub_list_def) + +lemma sub_list_append_right: + "sub_list y (x @ y)" + by (simp add: sub_list_def) + +lemma sub_list_inter_left: + shows "sub_list (finter_raw x y) x" + by (simp add: sub_list_def memb_def[symmetric] memb_finter_raw) + +lemma sub_list_inter_right: + shows "sub_list (finter_raw x y) y" + by (simp add: sub_list_def memb_def[symmetric] memb_finter_raw) + +lemma sub_list_list_eq: + "sub_list x y \ sub_list y x \ list_eq x y" + unfolding sub_list_def list_eq.simps by blast + +lemma sub_list_append: + "sub_list y x \ sub_list z x \ sub_list (y @ z) x" + unfolding sub_list_def by auto + +lemma sub_list_inter: + "sub_list x y \ sub_list x z \ sub_list x (finter_raw y z)" + by (simp add: sub_list_def memb_def[symmetric] memb_finter_raw) + +lemma append_inter_distrib: + "x @ (finter_raw y z) \ finter_raw (x @ y) (x @ z)" + apply (induct x) + apply simp + apply simp + apply (rule conjI) + apply (simp_all add: memb_def) + apply (simp add: memb_def[symmetric] memb_finter_raw) + apply (simp add: memb_def) + apply auto + done + +instantiation fset :: (type) "{bot,distrib_lattice}" begin quotient_definition @@ -93,40 +162,6 @@ where "xs |\| ys \ xs < ys" -instance -proof - fix x y z :: "'a fset" - show "(x |\| y) = (x |\| y \ \ y |\| x)" - unfolding less_fset by (lifting sub_list_not_eq) - show "x |\| x" by (lifting sub_list_refl) - show "{||} |\| x" by (lifting sub_list_empty) -next - fix x y z :: "'a fset" - assume a: "x |\| y" - assume b: "y |\| z" - show "x |\| z" using a b by (lifting sub_list_trans) -qed -end - -lemma sub_list_append_left: - "sub_list x (x @ y)" - by (simp add: sub_list_def) - -lemma sub_list_append_right: - "sub_list y (x @ y)" - by (simp add: sub_list_def) - -lemma sub_list_list_eq: - "sub_list x y \ sub_list y x \ list_eq x y" - unfolding sub_list_def list_eq.simps by blast - -lemma sub_list_append: - "sub_list y x \ sub_list z x \ sub_list (y @ z) x" - unfolding sub_list_def by auto - -instantiation fset :: (type) "semilattice_sup" -begin - quotient_definition "sup \ ('a fset \ 'a fset \ 'a fset)" is @@ -137,11 +172,33 @@ where "xs |\| ys \ sup (xs :: 'a fset) ys" +quotient_definition + "inf \ ('a fset \ 'a fset \ 'a fset)" +is + "finter_raw \ ('a list \ 'a list \ 'a list)" + +abbreviation + finter (infixl "|\|" 65) +where + "xs |\| ys \ inf (xs :: 'a fset) ys" + instance proof - fix x y :: "'a fset" + fix x y z :: "'a fset" + show "(x |\| y) = (x |\| y \ \ y |\| x)" + unfolding less_fset by (lifting sub_list_not_eq) + show "x |\| x" by (lifting sub_list_refl) + show "{||} |\| x" by (lifting sub_list_empty) show "x |\| x |\| y" by (lifting sub_list_append_left) show "y |\| x |\| y" by (lifting sub_list_append_right) + show "x |\| y |\| x" by (lifting sub_list_inter_left) + show "x |\| y |\| y" by (lifting sub_list_inter_right) + show "x |\| (y |\| z) = x |\| y |\| (x |\| z)" by (lifting append_inter_distrib) +next + fix x y z :: "'a fset" + assume a: "x |\| y" + assume b: "y |\| z" + show "x |\| z" using a b by (lifting sub_list_trans) next fix x y :: "'a fset" assume a: "x |\| y" @@ -152,7 +209,13 @@ assume a: "y |\| x" assume b: "z |\| x" show "y |\| z |\| x" using a b by (lifting sub_list_append) +next + fix x y z :: "'a fset" + assume a: "x |\| y" + assume b: "x |\| z" + show "x |\| y |\| z" using a b by (lifting sub_list_inter) qed + end section {* Empty fset, Finsert and Membership *} @@ -197,10 +260,6 @@ and "\ (x # xs \ [])" by auto -lemma not_memb_nil: - shows "\ memb x []" - by (simp add: memb_def) - lemma no_memb_nil: "(\x. \ memb x xs) = (xs = [])" by (simp add: memb_def) @@ -209,10 +268,6 @@ "(\x. \ memb x xs) = (xs \ [])" by (simp add: memb_def) -lemma memb_cons_iff: - shows "memb x (y # xs) = (x = y \ memb x xs)" - by (induct xs) (auto simp add: memb_def) - lemma memb_consI1: shows "memb x (x # xs)" by (simp add: memb_def) @@ -490,30 +545,10 @@ "(op = ===> op = ===> op \ ===> op =) ffold_raw ffold_raw" by (simp add: memb_def[symmetric] ffold_raw_rsp_pre) -primrec - finter_raw :: "'a list \ 'a list \ '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)" - lemma finter_raw_empty: "finter_raw l [] = []" by (induct l) (simp_all add: not_memb_nil) -lemma memb_finter_raw: - "memb x (finter_raw xs ys) \ memb x xs \ memb x ys" - apply (induct xs) - apply (simp add: not_memb_nil) - apply (simp add: finter_raw.simps) - apply (simp add: memb_cons_iff) - apply auto - done - -lemma [quot_respect]: - "(op \ ===> op \ ===> op \) finter_raw finter_raw" - by (simp add: memb_def[symmetric] memb_finter_raw) - section {* Constants on the Quotient Type *} quotient_definition @@ -528,12 +563,6 @@ "ffold :: ('a \ 'b \ 'b) \ 'b \ 'a fset \ 'b" is "ffold_raw" -quotient_definition - finter (infix "|\|" 50) -where - "finter :: 'a fset \ 'a fset \ 'a fset" -is "finter_raw" - lemma funion_sym_pre: "xs @ ys \ ys @ xs" by auto