--- 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