more systematic and compact proofs on type relation operators using natural deduction rules
authorhaftmann
Tue, 30 Nov 2010 15:58:09 +0100
changeset 40820 fd9c98ead9a9
parent 40819 2ac5af6eb8a8
child 40821 9f32d7b8b24f
more systematic and compact proofs on type relation operators using natural deduction rules
src/HOL/Library/Quotient_List.thy
src/HOL/Library/Quotient_Option.thy
src/HOL/Library/Quotient_Product.thy
src/HOL/Library/Quotient_Sum.thy
--- a/src/HOL/Library/Quotient_List.thy	Tue Nov 30 15:58:09 2010 +0100
+++ b/src/HOL/Library/Quotient_List.thy	Tue Nov 30 15:58:09 2010 +0100
@@ -10,94 +10,96 @@
 
 declare [[map list = (map, list_all2)]]
 
-lemma split_list_all:
-  shows "(\<forall>x. P x) \<longleftrightarrow> P [] \<and> (\<forall>x xs. P (x#xs))"
-  apply(auto)
-  apply(case_tac x)
-  apply(simp_all)
-  done
+lemma map_id [id_simps]:
+  "map id = id"
+  by (simp add: id_def fun_eq_iff map.identity)
 
-lemma map_id[id_simps]:
-  shows "map id = id"
-  apply(simp add: fun_eq_iff)
-  apply(rule allI)
-  apply(induct_tac x)
-  apply(simp_all)
-  done
+lemma list_all2_map1:
+  "list_all2 R (map f xs) ys \<longleftrightarrow> list_all2 (\<lambda>x. R (f x)) xs ys"
+  by (induct xs ys rule: list_induct2') simp_all
+
+lemma list_all2_map2:
+  "list_all2 R xs (map f ys) \<longleftrightarrow> list_all2 (\<lambda>x y. R x (f y)) xs ys"
+  by (induct xs ys rule: list_induct2') simp_all
 
-lemma list_all2_reflp:
-  shows "equivp R \<Longrightarrow> list_all2 R xs xs"
-  by (induct xs, simp_all add: equivp_reflp)
+lemma list_all2_eq [id_simps]:
+  "list_all2 (op =) = (op =)"
+proof (rule ext)+
+  fix xs ys
+  show "list_all2 (op =) xs ys \<longleftrightarrow> xs = ys"
+    by (induct xs ys rule: list_induct2') simp_all
+qed
 
-lemma list_all2_symp:
-  assumes a: "equivp R"
-  and b: "list_all2 R xs ys"
-  shows "list_all2 R ys xs"
-  using list_all2_lengthD[OF b] b
-  apply(induct xs ys rule: list_induct2)
-  apply(simp_all)
-  apply(rule equivp_symp[OF a])
-  apply(simp)
-  done
+lemma list_reflp:
+  assumes "reflp R"
+  shows "reflp (list_all2 R)"
+proof (rule reflpI)
+  from assms have *: "\<And>xs. R xs xs" by (rule reflpE)
+  fix xs
+  show "list_all2 R xs xs"
+    by (induct xs) (simp_all add: *)
+qed
 
-lemma list_all2_transp:
-  assumes a: "equivp R"
-  and b: "list_all2 R xs1 xs2"
-  and c: "list_all2 R xs2 xs3"
-  shows "list_all2 R xs1 xs3"
-  using list_all2_lengthD[OF b] list_all2_lengthD[OF c] b c
-  apply(induct rule: list_induct3)
-  apply(simp_all)
-  apply(auto intro: equivp_transp[OF a])
-  done
+lemma list_symp:
+  assumes "symp R"
+  shows "symp (list_all2 R)"
+proof (rule sympI)
+  from assms have *: "\<And>xs ys. R xs ys \<Longrightarrow> R ys xs" by (rule sympE)
+  fix xs ys
+  assume "list_all2 R xs ys"
+  then show "list_all2 R ys xs"
+    by (induct xs ys rule: list_induct2') (simp_all add: *)
+qed
 
-lemma list_equivp[quot_equiv]:
-  assumes a: "equivp R"
-  shows "equivp (list_all2 R)"
-  apply (intro equivpI)
-  unfolding reflp_def symp_def transp_def
-  apply(simp add: list_all2_reflp[OF a])
-  apply(blast intro: list_all2_symp[OF a])
-  apply(blast intro: list_all2_transp[OF a])
-  done
+lemma list_transp:
+  assumes "transp R"
+  shows "transp (list_all2 R)"
+proof (rule transpI)
+  from assms have *: "\<And>xs ys zs. R xs ys \<Longrightarrow> R ys zs \<Longrightarrow> R xs zs" by (rule transpE)
+  fix xs ys zs
+  assume A: "list_all2 R xs ys" "list_all2 R ys zs"
+  then have "length xs = length ys" "length ys = length zs" by (blast dest: list_all2_lengthD)+
+  then show "list_all2 R xs zs" using A
+    by (induct xs ys zs rule: list_induct3) (auto intro: *)
+qed
 
-lemma list_all2_rel:
-  assumes q: "Quotient R Abs Rep"
-  shows "list_all2 R r s = (list_all2 R r r \<and> list_all2 R s s \<and> (map Abs r = map Abs s))"
-  apply(induct r s rule: list_induct2')
-  apply(simp_all)
-  using Quotient_rel[OF q]
-  apply(metis)
-  done
+lemma list_equivp [quot_equiv]:
+  "equivp R \<Longrightarrow> equivp (list_all2 R)"
+  by (blast intro: equivpI list_reflp list_symp list_transp elim: equivpE)
 
-lemma list_quotient[quot_thm]:
-  assumes q: "Quotient R Abs Rep"
+lemma list_quotient [quot_thm]:
+  assumes "Quotient R Abs Rep"
   shows "Quotient (list_all2 R) (map Abs) (map Rep)"
-  unfolding Quotient_def
-  apply(subst split_list_all)
-  apply(simp add: Quotient_abs_rep[OF q] abs_o_rep[OF q] map_id)
-  apply(intro conjI allI)
-  apply(induct_tac a)
-  apply(simp_all add: Quotient_rep_reflp[OF q])
-  apply(rule list_all2_rel[OF q])
-  done
+proof (rule QuotientI)
+  from assms have "\<And>x. Abs (Rep x) = x" by (rule Quotient_abs_rep)
+  then show "\<And>xs. map Abs (map Rep xs) = xs" by (simp add: comp_def)
+next
+  from assms have "\<And>x y. R (Rep x) (Rep y) \<longleftrightarrow> x = y" by (rule Quotient_rel_rep)
+  then show "\<And>xs. list_all2 R (map Rep xs) (map Rep xs)"
+    by (simp add: list_all2_map1 list_all2_map2 list_all2_eq)
+next
+  fix xs ys
+  from assms have "\<And>x y. R x x \<and> R y y \<and> Abs x = Abs y \<longleftrightarrow> R x y" by (rule Quotient_rel)
+  then show "list_all2 R xs ys \<longleftrightarrow> list_all2 R xs xs \<and> list_all2 R ys ys \<and> map Abs xs = map Abs ys"
+    by (induct xs ys rule: list_induct2') auto
+qed
 
-lemma cons_prs[quot_preserve]:
+lemma cons_prs [quot_preserve]:
   assumes q: "Quotient R Abs Rep"
   shows "(Rep ---> (map Rep) ---> (map Abs)) (op #) = (op #)"
   by (auto simp add: fun_eq_iff comp_def Quotient_abs_rep [OF q])
 
-lemma cons_rsp[quot_respect]:
+lemma cons_rsp [quot_respect]:
   assumes q: "Quotient R Abs Rep"
   shows "(R ===> list_all2 R ===> list_all2 R) (op #) (op #)"
   by auto
 
-lemma nil_prs[quot_preserve]:
+lemma nil_prs [quot_preserve]:
   assumes q: "Quotient R Abs Rep"
   shows "map Abs [] = []"
   by simp
 
-lemma nil_rsp[quot_respect]:
+lemma nil_rsp [quot_respect]:
   assumes q: "Quotient R Abs Rep"
   shows "list_all2 R [] []"
   by simp
@@ -109,7 +111,7 @@
   by (induct l)
      (simp_all add: Quotient_abs_rep[OF a] Quotient_abs_rep[OF b])
 
-lemma map_prs[quot_preserve]:
+lemma map_prs [quot_preserve]:
   assumes a: "Quotient R1 abs1 rep1"
   and     b: "Quotient R2 abs2 rep2"
   shows "((abs1 ---> rep2) ---> (map rep1) ---> (map abs2)) map = map"
@@ -117,8 +119,7 @@
   by (simp_all only: fun_eq_iff map_prs_aux[OF a b] comp_def)
     (simp_all add: Quotient_abs_rep[OF a] Quotient_abs_rep[OF b])
 
-
-lemma map_rsp[quot_respect]:
+lemma map_rsp [quot_respect]:
   assumes q1: "Quotient R1 Abs1 Rep1"
   and     q2: "Quotient R2 Abs2 Rep2"
   shows "((R1 ===> R2) ===> (list_all2 R1) ===> list_all2 R2) map map"
@@ -137,7 +138,7 @@
   shows "abs2 (foldr ((abs1 ---> abs2 ---> rep2) f) (map rep1 l) (rep2 e)) = foldr f l e"
   by (induct l) (simp_all add: Quotient_abs_rep[OF a] Quotient_abs_rep[OF b])
 
-lemma foldr_prs[quot_preserve]:
+lemma foldr_prs [quot_preserve]:
   assumes a: "Quotient R1 abs1 rep1"
   and     b: "Quotient R2 abs2 rep2"
   shows "((abs1 ---> abs2 ---> rep2) ---> (map rep1) ---> rep2 ---> abs2) foldr = foldr"
@@ -151,8 +152,7 @@
   shows "abs1 (foldl ((abs1 ---> abs2 ---> rep1) f) (rep1 e) (map rep2 l)) = foldl f e l"
   by (induct l arbitrary:e) (simp_all add: Quotient_abs_rep[OF a] Quotient_abs_rep[OF b])
 
-
-lemma foldl_prs[quot_preserve]:
+lemma foldl_prs [quot_preserve]:
   assumes a: "Quotient R1 abs1 rep1"
   and     b: "Quotient R2 abs2 rep2"
   shows "((abs1 ---> abs2 ---> rep1) ---> rep1 ---> (map rep2) ---> abs1) foldl = foldl"
@@ -217,11 +217,11 @@
     qed
   qed
 
-lemma[quot_respect]:
+lemma [quot_respect]:
   "((R ===> R ===> op =) ===> list_all2 R ===> list_all2 R ===> op =) list_all2 list_all2"
   by (simp add: list_all2_rsp fun_rel_def)
 
-lemma[quot_preserve]:
+lemma [quot_preserve]:
   assumes a: "Quotient R abs1 rep1"
   shows "((abs1 ---> abs1 ---> id) ---> map rep1 ---> map rep1 ---> id) list_all2 = list_all2"
   apply (simp add: fun_eq_iff)
@@ -230,19 +230,11 @@
   apply (simp_all add: Quotient_abs_rep[OF a])
   done
 
-lemma[quot_preserve]:
+lemma [quot_preserve]:
   assumes a: "Quotient R abs1 rep1"
   shows "(list_all2 ((rep1 ---> rep1 ---> id) R) l m) = (l = m)"
   by (induct l m rule: list_induct2') (simp_all add: Quotient_rel_rep[OF a])
 
-lemma list_all2_eq[id_simps]:
-  shows "(list_all2 (op =)) = (op =)"
-  unfolding fun_eq_iff
-  apply(rule allI)+
-  apply(induct_tac x xa rule: list_induct2')
-  apply(simp_all)
-  done
-
 lemma list_all2_find_element:
   assumes a: "x \<in> set a"
   and b: "list_all2 R a b"
--- a/src/HOL/Library/Quotient_Option.thy	Tue Nov 30 15:58:09 2010 +0100
+++ b/src/HOL/Library/Quotient_Option.thy	Tue Nov 30 15:58:09 2010 +0100
@@ -18,64 +18,73 @@
 
 declare [[map option = (Option.map, option_rel)]]
 
-text {* should probably be in Option.thy *}
-lemma split_option_all:
-  shows "(\<forall>x. P x) \<longleftrightarrow> P None \<and> (\<forall>a. P (Some a))"
-  apply(auto)
-  apply(case_tac x)
-  apply(simp_all)
+lemma option_rel_unfold:
+  "option_rel R x y = (case (x, y) of (None, None) \<Rightarrow> True
+    | (Some x, Some y) \<Rightarrow> R x y
+    | _ \<Rightarrow> False)"
+  by (cases x) (cases y, simp_all)+
+
+lemma option_rel_map1:
+  "option_rel R (Option.map f x) y \<longleftrightarrow> option_rel (\<lambda>x. R (f x)) x y"
+  by (simp add: option_rel_unfold split: option.split)
+
+lemma option_rel_map2:
+  "option_rel R x (Option.map f y) \<longleftrightarrow> option_rel (\<lambda>x y. R x (f y)) x y"
+  by (simp add: option_rel_unfold split: option.split)
+
+lemma option_map_id [id_simps]:
+  "Option.map id = id"
+  by (simp add: id_def Option.map.identity fun_eq_iff)
+
+lemma option_rel_eq [id_simps]:
+  "option_rel (op =) = (op =)"
+  by (simp add: option_rel_unfold fun_eq_iff split: option.split)
+
+lemma option_reflp:
+  "reflp R \<Longrightarrow> reflp (option_rel R)"
+  by (auto simp add: option_rel_unfold split: option.splits intro!: reflpI elim: reflpE)
+
+lemma option_symp:
+  "symp R \<Longrightarrow> symp (option_rel R)"
+  by (auto simp add: option_rel_unfold split: option.splits intro!: sympI elim: sympE)
+
+lemma option_transp:
+  "transp R \<Longrightarrow> transp (option_rel R)"
+  by (auto simp add: option_rel_unfold split: option.splits intro!: transpI elim: transpE)
+
+lemma option_equivp [quot_equiv]:
+  "equivp R \<Longrightarrow> equivp (option_rel R)"
+  by (blast intro: equivpI option_reflp option_symp option_transp elim: equivpE)
+
+lemma option_quotient [quot_thm]:
+  assumes "Quotient R Abs Rep"
+  shows "Quotient (option_rel R) (Option.map Abs) (Option.map Rep)"
+  apply (rule QuotientI)
+  apply (simp_all add: Option.map.compositionality Option.map.identity option_rel_eq option_rel_map1 option_rel_map2 Quotient_abs_rep [OF assms] Quotient_rel_rep [OF assms])
+  using Quotient_rel [OF assms]
+  apply (simp add: option_rel_unfold split: option.split)
   done
 
-lemma option_quotient[quot_thm]:
-  assumes q: "Quotient R Abs Rep"
-  shows "Quotient (option_rel R) (Option.map Abs) (Option.map Rep)"
-  unfolding Quotient_def
-  apply(simp add: split_option_all)
-  apply(simp add: Quotient_abs_rep[OF q] Quotient_rel_rep[OF q])
-  using q
-  unfolding Quotient_def
-  apply(blast)
-  done
-
-lemma option_equivp[quot_equiv]:
-  assumes a: "equivp R"
-  shows "equivp (option_rel R)"
-  apply(rule equivpI)
-  unfolding reflp_def symp_def transp_def
-  apply(simp_all add: split_option_all)
-  apply(blast intro: equivp_reflp[OF a])
-  apply(blast intro: equivp_symp[OF a])
-  apply(blast intro: equivp_transp[OF a])
-  done
-
-lemma option_None_rsp[quot_respect]:
+lemma option_None_rsp [quot_respect]:
   assumes q: "Quotient R Abs Rep"
   shows "option_rel R None None"
   by simp
 
-lemma option_Some_rsp[quot_respect]:
+lemma option_Some_rsp [quot_respect]:
   assumes q: "Quotient R Abs Rep"
   shows "(R ===> option_rel R) Some Some"
   by auto
 
-lemma option_None_prs[quot_preserve]:
+lemma option_None_prs [quot_preserve]:
   assumes q: "Quotient R Abs Rep"
   shows "Option.map Abs None = None"
   by simp
 
-lemma option_Some_prs[quot_preserve]:
+lemma option_Some_prs [quot_preserve]:
   assumes q: "Quotient R Abs Rep"
   shows "(Rep ---> Option.map Abs) Some = Some"
   apply(simp add: fun_eq_iff)
   apply(simp add: Quotient_abs_rep[OF q])
   done
 
-lemma option_map_id[id_simps]:
-  shows "Option.map id = id"
-  by (simp add: fun_eq_iff split_option_all)
-
-lemma option_rel_eq[id_simps]:
-  shows "option_rel (op =) = (op =)"
-  by (simp add: fun_eq_iff split_option_all)
-
 end
--- a/src/HOL/Library/Quotient_Product.thy	Tue Nov 30 15:58:09 2010 +0100
+++ b/src/HOL/Library/Quotient_Product.thy	Tue Nov 30 15:58:09 2010 +0100
@@ -19,38 +19,39 @@
   "prod_rel R1 R2 (a, b) (c, d) \<longleftrightarrow> R1 a c \<and> R2 b d"
   by (simp add: prod_rel_def)
 
-lemma prod_equivp[quot_equiv]:
-  assumes a: "equivp R1"
-  assumes b: "equivp R2"
+lemma map_pair_id [id_simps]:
+  shows "map_pair id id = id"
+  by (simp add: fun_eq_iff)
+
+lemma prod_rel_eq [id_simps]:
+  shows "prod_rel (op =) (op =) = (op =)"
+  by (simp add: fun_eq_iff)
+
+lemma prod_equivp [quot_equiv]:
+  assumes "equivp R1"
+  assumes "equivp R2"
   shows "equivp (prod_rel R1 R2)"
-  apply(rule equivpI)
-  unfolding reflp_def symp_def transp_def
-  apply(simp_all add: split_paired_all prod_rel_def)
-  apply(blast intro: equivp_reflp[OF a] equivp_reflp[OF b])
-  apply(blast intro: equivp_symp[OF a] equivp_symp[OF b])
-  apply(blast intro: equivp_transp[OF a] equivp_transp[OF b])
+  using assms by (auto intro!: equivpI reflpI sympI transpI elim!: equivpE elim: reflpE sympE transpE)
+
+lemma prod_quotient [quot_thm]:
+  assumes "Quotient R1 Abs1 Rep1"
+  assumes "Quotient R2 Abs2 Rep2"
+  shows "Quotient (prod_rel R1 R2) (map_pair Abs1 Abs2) (map_pair Rep1 Rep2)"
+  apply (rule QuotientI)
+  apply (simp add: map_pair.compositionality map_pair.identity
+     Quotient_abs_rep [OF assms(1)] Quotient_abs_rep [OF assms(2)])
+  apply (simp add: split_paired_all Quotient_rel_rep [OF assms(1)] Quotient_rel_rep [OF assms(2)])
+  using Quotient_rel [OF assms(1)] Quotient_rel [OF assms(2)]
+  apply (auto simp add: split_paired_all)
   done
 
-lemma prod_quotient[quot_thm]:
-  assumes q1: "Quotient R1 Abs1 Rep1"
-  assumes q2: "Quotient R2 Abs2 Rep2"
-  shows "Quotient (prod_rel R1 R2) (map_pair Abs1 Abs2) (map_pair Rep1 Rep2)"
-  unfolding Quotient_def
-  apply(simp add: split_paired_all)
-  apply(simp add: Quotient_abs_rep[OF q1] Quotient_rel_rep[OF q1])
-  apply(simp add: Quotient_abs_rep[OF q2] Quotient_rel_rep[OF q2])
-  using q1 q2
-  unfolding Quotient_def
-  apply(blast)
-  done
-
-lemma Pair_rsp[quot_respect]:
+lemma Pair_rsp [quot_respect]:
   assumes q1: "Quotient R1 Abs1 Rep1"
   assumes q2: "Quotient R2 Abs2 Rep2"
   shows "(R1 ===> R2 ===> prod_rel R1 R2) Pair Pair"
   by (auto simp add: prod_rel_def)
 
-lemma Pair_prs[quot_preserve]:
+lemma Pair_prs [quot_preserve]:
   assumes q1: "Quotient R1 Abs1 Rep1"
   assumes q2: "Quotient R2 Abs2 Rep2"
   shows "(Rep1 ---> Rep2 ---> (map_pair Abs1 Abs2)) Pair = Pair"
@@ -58,35 +59,35 @@
   apply(simp add: Quotient_abs_rep[OF q1] Quotient_abs_rep[OF q2])
   done
 
-lemma fst_rsp[quot_respect]:
+lemma fst_rsp [quot_respect]:
   assumes "Quotient R1 Abs1 Rep1"
   assumes "Quotient R2 Abs2 Rep2"
   shows "(prod_rel R1 R2 ===> R1) fst fst"
   by auto
 
-lemma fst_prs[quot_preserve]:
+lemma fst_prs [quot_preserve]:
   assumes q1: "Quotient R1 Abs1 Rep1"
   assumes q2: "Quotient R2 Abs2 Rep2"
   shows "(map_pair Rep1 Rep2 ---> Abs1) fst = fst"
   by (simp add: fun_eq_iff Quotient_abs_rep[OF q1])
 
-lemma snd_rsp[quot_respect]:
+lemma snd_rsp [quot_respect]:
   assumes "Quotient R1 Abs1 Rep1"
   assumes "Quotient R2 Abs2 Rep2"
   shows "(prod_rel R1 R2 ===> R2) snd snd"
   by auto
 
-lemma snd_prs[quot_preserve]:
+lemma snd_prs [quot_preserve]:
   assumes q1: "Quotient R1 Abs1 Rep1"
   assumes q2: "Quotient R2 Abs2 Rep2"
   shows "(map_pair Rep1 Rep2 ---> Abs2) snd = snd"
   by (simp add: fun_eq_iff Quotient_abs_rep[OF q2])
 
-lemma split_rsp[quot_respect]:
+lemma split_rsp [quot_respect]:
   shows "((R1 ===> R2 ===> (op =)) ===> (prod_rel R1 R2) ===> (op =)) split split"
   by (auto intro!: fun_relI elim!: fun_relE)
 
-lemma split_prs[quot_preserve]:
+lemma split_prs [quot_preserve]:
   assumes q1: "Quotient R1 Abs1 Rep1"
   and     q2: "Quotient R2 Abs2 Rep2"
   shows "(((Abs1 ---> Abs2 ---> id) ---> map_pair Rep1 Rep2 ---> id) split) = split"
@@ -111,12 +112,4 @@
 
 declare Pair_eq[quot_preserve]
 
-lemma map_pair_id[id_simps]:
-  shows "map_pair id id = id"
-  by (simp add: fun_eq_iff)
-
-lemma prod_rel_eq[id_simps]:
-  shows "prod_rel (op =) (op =) = (op =)"
-  by (simp add: fun_eq_iff)
-
 end
--- a/src/HOL/Library/Quotient_Sum.thy	Tue Nov 30 15:58:09 2010 +0100
+++ b/src/HOL/Library/Quotient_Sum.thy	Tue Nov 30 15:58:09 2010 +0100
@@ -18,53 +18,68 @@
 
 declare [[map sum = (sum_map, sum_rel)]]
 
+lemma sum_rel_unfold:
+  "sum_rel R1 R2 x y = (case (x, y) of (Inl x, Inl y) \<Rightarrow> R1 x y
+    | (Inr x, Inr y) \<Rightarrow> R2 x y
+    | _ \<Rightarrow> False)"
+  by (cases x) (cases y, simp_all)+
 
-text {* should probably be in @{theory Sum_Type} *}
-lemma split_sum_all:
-  shows "(\<forall>x. P x) \<longleftrightarrow> (\<forall>x. P (Inl x)) \<and> (\<forall>x. P (Inr x))"
-  apply(auto)
-  apply(case_tac x)
-  apply(simp_all)
-  done
+lemma sum_rel_map1:
+  "sum_rel R1 R2 (sum_map f1 f2 x) y \<longleftrightarrow> sum_rel (\<lambda>x. R1 (f1 x)) (\<lambda>x. R2 (f2 x)) x y"
+  by (simp add: sum_rel_unfold split: sum.split)
+
+lemma sum_rel_map2:
+  "sum_rel R1 R2 x (sum_map f1 f2 y) \<longleftrightarrow> sum_rel (\<lambda>x y. R1 x (f1 y)) (\<lambda>x y. R2 x (f2 y)) x y"
+  by (simp add: sum_rel_unfold split: sum.split)
+
+lemma sum_map_id [id_simps]:
+  "sum_map id id = id"
+  by (simp add: id_def sum_map.identity fun_eq_iff)
 
-lemma sum_equivp[quot_equiv]:
-  assumes a: "equivp R1"
-  assumes b: "equivp R2"
-  shows "equivp (sum_rel R1 R2)"
-  apply(rule equivpI)
-  unfolding reflp_def symp_def transp_def
-  apply(simp_all add: split_sum_all)
-  apply(blast intro: equivp_reflp[OF a] equivp_reflp[OF b])
-  apply(blast intro: equivp_symp[OF a] equivp_symp[OF b])
-  apply(blast intro: equivp_transp[OF a] equivp_transp[OF b])
-  done
+lemma sum_rel_eq [id_simps]:
+  "sum_rel (op =) (op =) = (op =)"
+  by (simp add: sum_rel_unfold fun_eq_iff split: sum.split)
+
+lemma sum_reflp:
+  "reflp R1 \<Longrightarrow> reflp R2 \<Longrightarrow> reflp (sum_rel R1 R2)"
+  by (auto simp add: sum_rel_unfold split: sum.splits intro!: reflpI elim: reflpE)
 
-lemma sum_quotient[quot_thm]:
+lemma sum_symp:
+  "symp R1 \<Longrightarrow> symp R2 \<Longrightarrow> symp (sum_rel R1 R2)"
+  by (auto simp add: sum_rel_unfold split: sum.splits intro!: sympI elim: sympE)
+
+lemma sum_transp:
+  "transp R1 \<Longrightarrow> transp R2 \<Longrightarrow> transp (sum_rel R1 R2)"
+  by (auto simp add: sum_rel_unfold split: sum.splits intro!: transpI elim: transpE)
+
+lemma sum_equivp [quot_equiv]:
+  "equivp R1 \<Longrightarrow> equivp R2 \<Longrightarrow> equivp (sum_rel R1 R2)"
+  by (blast intro: equivpI sum_reflp sum_symp sum_transp elim: equivpE)
+  
+lemma sum_quotient [quot_thm]:
   assumes q1: "Quotient R1 Abs1 Rep1"
   assumes q2: "Quotient R2 Abs2 Rep2"
   shows "Quotient (sum_rel R1 R2) (sum_map Abs1 Abs2) (sum_map Rep1 Rep2)"
-  unfolding Quotient_def
-  apply(simp add: split_sum_all)
-  apply(simp_all add: Quotient_abs_rep[OF q1] Quotient_rel_rep[OF q1])
-  apply(simp_all add: Quotient_abs_rep[OF q2] Quotient_rel_rep[OF q2])
-  using q1 q2
-  unfolding Quotient_def
-  apply(blast)+
+  apply (rule QuotientI)
+  apply (simp_all add: sum_map.compositionality sum_map.identity sum_rel_eq sum_rel_map1 sum_rel_map2
+    Quotient_abs_rep [OF q1] Quotient_rel_rep [OF q1] Quotient_abs_rep [OF q2] Quotient_rel_rep [OF q2])
+  using Quotient_rel [OF q1] Quotient_rel [OF q2]
+  apply (simp add: sum_rel_unfold split: sum.split)
   done
 
-lemma sum_Inl_rsp[quot_respect]:
+lemma sum_Inl_rsp [quot_respect]:
   assumes q1: "Quotient R1 Abs1 Rep1"
   assumes q2: "Quotient R2 Abs2 Rep2"
   shows "(R1 ===> sum_rel R1 R2) Inl Inl"
   by auto
 
-lemma sum_Inr_rsp[quot_respect]:
+lemma sum_Inr_rsp [quot_respect]:
   assumes q1: "Quotient R1 Abs1 Rep1"
   assumes q2: "Quotient R2 Abs2 Rep2"
   shows "(R2 ===> sum_rel R1 R2) Inr Inr"
   by auto
 
-lemma sum_Inl_prs[quot_preserve]:
+lemma sum_Inl_prs [quot_preserve]:
   assumes q1: "Quotient R1 Abs1 Rep1"
   assumes q2: "Quotient R2 Abs2 Rep2"
   shows "(Rep1 ---> sum_map Abs1 Abs2) Inl = Inl"
@@ -72,7 +87,7 @@
   apply(simp add: Quotient_abs_rep[OF q1])
   done
 
-lemma sum_Inr_prs[quot_preserve]:
+lemma sum_Inr_prs [quot_preserve]:
   assumes q1: "Quotient R1 Abs1 Rep1"
   assumes q2: "Quotient R2 Abs2 Rep2"
   shows "(Rep2 ---> sum_map Abs1 Abs2) Inr = Inr"
@@ -80,12 +95,4 @@
   apply(simp add: Quotient_abs_rep[OF q2])
   done
 
-lemma sum_map_id[id_simps]:
-  shows "sum_map id id = id"
-  by (simp add: fun_eq_iff split_sum_all)
-
-lemma sum_rel_eq[id_simps]:
-  shows "sum_rel (op =) (op =) = (op =)"
-  by (simp add: fun_eq_iff split_sum_all)
-
 end