src/HOL/Library/Quotient_Sum.thy
changeset 53012 cb82606b8215
parent 53010 ec5e6f69bd65
child 53026 e1a548c11845
     1.1 --- a/src/HOL/Library/Quotient_Sum.thy	Tue Aug 13 15:59:22 2013 +0200
     1.2 +++ b/src/HOL/Library/Quotient_Sum.thy	Tue Aug 13 15:59:22 2013 +0200
     1.3 @@ -1,5 +1,5 @@
     1.4  (*  Title:      HOL/Library/Quotient_Sum.thy
     1.5 -    Author:     Cezary Kaliszyk, Christian Urban and Brian Huffman
     1.6 +    Author:     Cezary Kaliszyk and Christian Urban
     1.7  *)
     1.8  
     1.9  header {* Quotient infrastructure for the sum type *}
    1.10 @@ -8,31 +8,7 @@
    1.11  imports Main Quotient_Syntax
    1.12  begin
    1.13  
    1.14 -subsection {* Relator for sum type *}
    1.15 -
    1.16 -fun
    1.17 -  sum_rel :: "('a \<Rightarrow> 'c \<Rightarrow> bool) \<Rightarrow> ('b \<Rightarrow> 'd \<Rightarrow> bool) \<Rightarrow> 'a + 'b \<Rightarrow> 'c + 'd \<Rightarrow> bool"
    1.18 -where
    1.19 -  "sum_rel R1 R2 (Inl a1) (Inl b1) = R1 a1 b1"
    1.20 -| "sum_rel R1 R2 (Inl a1) (Inr b2) = False"
    1.21 -| "sum_rel R1 R2 (Inr a2) (Inl b1) = False"
    1.22 -| "sum_rel R1 R2 (Inr a2) (Inr b2) = R2 a2 b2"
    1.23 -
    1.24 -lemma sum_rel_unfold:
    1.25 -  "sum_rel R1 R2 x y = (case (x, y) of (Inl x, Inl y) \<Rightarrow> R1 x y
    1.26 -    | (Inr x, Inr y) \<Rightarrow> R2 x y
    1.27 -    | _ \<Rightarrow> False)"
    1.28 -  by (cases x) (cases y, simp_all)+
    1.29 -
    1.30 -fun sum_pred :: "('a \<Rightarrow> bool) \<Rightarrow> ('b \<Rightarrow> bool) \<Rightarrow> 'a + 'b \<Rightarrow> bool"
    1.31 -where
    1.32 -  "sum_pred P1 P2 (Inl a) = P1 a"
    1.33 -| "sum_pred P1 P2 (Inr a) = P2 a"
    1.34 -
    1.35 -lemma sum_pred_unfold:
    1.36 -  "sum_pred P1 P2 x = (case x of Inl x \<Rightarrow> P1 x
    1.37 -    | Inr x \<Rightarrow> P2 x)"
    1.38 -by (cases x) simp_all
    1.39 +subsection {* Rules for the Quotient package *}
    1.40  
    1.41  lemma sum_rel_map1:
    1.42    "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"
    1.43 @@ -46,39 +22,10 @@
    1.44    "sum_map id id = id"
    1.45    by (simp add: id_def sum_map.identity fun_eq_iff)
    1.46  
    1.47 -lemma sum_rel_eq [id_simps, relator_eq]:
    1.48 +lemma sum_rel_eq [id_simps]:
    1.49    "sum_rel (op =) (op =) = (op =)"
    1.50    by (simp add: sum_rel_unfold fun_eq_iff split: sum.split)
    1.51  
    1.52 -lemma sum_rel_mono[relator_mono]:
    1.53 -  assumes "A \<le> C"
    1.54 -  assumes "B \<le> D"
    1.55 -  shows "(sum_rel A B) \<le> (sum_rel C D)"
    1.56 -using assms by (auto simp: sum_rel_unfold split: sum.splits)
    1.57 -
    1.58 -lemma sum_rel_OO[relator_distr]:
    1.59 -  "(sum_rel A B) OO (sum_rel C D) = sum_rel (A OO C) (B OO D)"
    1.60 -by (rule ext)+ (auto simp add: sum_rel_unfold OO_def split_sum_ex split: sum.split)
    1.61 -
    1.62 -lemma Domainp_sum[relator_domain]:
    1.63 -  assumes "Domainp R1 = P1"
    1.64 -  assumes "Domainp R2 = P2"
    1.65 -  shows "Domainp (sum_rel R1 R2) = (sum_pred P1 P2)"
    1.66 -using assms
    1.67 -by (auto simp add: Domainp_iff split_sum_ex sum_pred_unfold iff: fun_eq_iff split: sum.split)
    1.68 -
    1.69 -lemma reflp_sum_rel[reflexivity_rule]:
    1.70 -  "reflp R1 \<Longrightarrow> reflp R2 \<Longrightarrow> reflp (sum_rel R1 R2)"
    1.71 -  unfolding reflp_def split_sum_all sum_rel.simps by fast
    1.72 -
    1.73 -lemma left_total_sum_rel[reflexivity_rule]:
    1.74 -  "left_total R1 \<Longrightarrow> left_total R2 \<Longrightarrow> left_total (sum_rel R1 R2)"
    1.75 -  using assms unfolding left_total_def split_sum_all split_sum_ex by simp
    1.76 -
    1.77 -lemma left_unique_sum_rel [reflexivity_rule]:
    1.78 -  "left_unique R1 \<Longrightarrow> left_unique R2 \<Longrightarrow> left_unique (sum_rel R1 R2)"
    1.79 -  using assms unfolding left_unique_def split_sum_all by simp
    1.80 -
    1.81  lemma sum_symp:
    1.82    "symp R1 \<Longrightarrow> symp R2 \<Longrightarrow> symp (sum_rel R1 R2)"
    1.83    unfolding symp_def split_sum_all sum_rel.simps by fast
    1.84 @@ -91,50 +38,6 @@
    1.85    "equivp R1 \<Longrightarrow> equivp R2 \<Longrightarrow> equivp (sum_rel R1 R2)"
    1.86    by (blast intro: equivpI reflp_sum_rel sum_symp sum_transp elim: equivpE)
    1.87  
    1.88 -lemma right_total_sum_rel [transfer_rule]:
    1.89 -  "right_total R1 \<Longrightarrow> right_total R2 \<Longrightarrow> right_total (sum_rel R1 R2)"
    1.90 -  unfolding right_total_def split_sum_all split_sum_ex by simp
    1.91 -
    1.92 -lemma right_unique_sum_rel [transfer_rule]:
    1.93 -  "right_unique R1 \<Longrightarrow> right_unique R2 \<Longrightarrow> right_unique (sum_rel R1 R2)"
    1.94 -  unfolding right_unique_def split_sum_all by simp
    1.95 -
    1.96 -lemma bi_total_sum_rel [transfer_rule]:
    1.97 -  "bi_total R1 \<Longrightarrow> bi_total R2 \<Longrightarrow> bi_total (sum_rel R1 R2)"
    1.98 -  using assms unfolding bi_total_def split_sum_all split_sum_ex by simp
    1.99 -
   1.100 -lemma bi_unique_sum_rel [transfer_rule]:
   1.101 -  "bi_unique R1 \<Longrightarrow> bi_unique R2 \<Longrightarrow> bi_unique (sum_rel R1 R2)"
   1.102 -  using assms unfolding bi_unique_def split_sum_all by simp
   1.103 -
   1.104 -subsection {* Transfer rules for transfer package *}
   1.105 -
   1.106 -lemma Inl_transfer [transfer_rule]: "(A ===> sum_rel A B) Inl Inl"
   1.107 -  unfolding fun_rel_def by simp
   1.108 -
   1.109 -lemma Inr_transfer [transfer_rule]: "(B ===> sum_rel A B) Inr Inr"
   1.110 -  unfolding fun_rel_def by simp
   1.111 -
   1.112 -lemma sum_case_transfer [transfer_rule]:
   1.113 -  "((A ===> C) ===> (B ===> C) ===> sum_rel A B ===> C) sum_case sum_case"
   1.114 -  unfolding fun_rel_def sum_rel_unfold by (simp split: sum.split)
   1.115 -
   1.116 -subsection {* Setup for lifting package *}
   1.117 -
   1.118 -lemma Quotient_sum[quot_map]:
   1.119 -  assumes "Quotient R1 Abs1 Rep1 T1"
   1.120 -  assumes "Quotient R2 Abs2 Rep2 T2"
   1.121 -  shows "Quotient (sum_rel R1 R2) (sum_map Abs1 Abs2)
   1.122 -    (sum_map Rep1 Rep2) (sum_rel T1 T2)"
   1.123 -  using assms unfolding Quotient_alt_def
   1.124 -  by (simp add: split_sum_all)
   1.125 -
   1.126 -lemma sum_invariant_commute [invariant_commute]: 
   1.127 -  "sum_rel (Lifting.invariant P1) (Lifting.invariant P2) = Lifting.invariant (sum_pred P1 P2)"
   1.128 -  by (auto simp add: fun_eq_iff Lifting.invariant_def sum_rel_unfold sum_pred_unfold split: sum.split)
   1.129 -
   1.130 -subsection {* Rules for quotient package *}
   1.131 -
   1.132  lemma sum_quotient [quot_thm]:
   1.133    assumes q1: "Quotient3 R1 Abs1 Rep1"
   1.134    assumes q2: "Quotient3 R2 Abs2 Rep2"