src/HOL/Library/Quotient_Product.thy
author haftmann
Mon Nov 15 14:14:38 2010 +0100 (2010-11-15)
changeset 40541 7850b4cc1507
parent 40465 2989f9f3aa10
child 40607 30d512bf47a7
permissions -rw-r--r--
re-generalized type of prod_rel (accident from 2989f9f3aa10)
     1 (*  Title:      HOL/Library/Quotient_Product.thy
     2     Author:     Cezary Kaliszyk and Christian Urban
     3 *)
     4 
     5 header {* Quotient infrastructure for the product type *}
     6 
     7 theory Quotient_Product
     8 imports Main Quotient_Syntax
     9 begin
    10 
    11 definition
    12   prod_rel :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> ('c \<Rightarrow> 'd \<Rightarrow> bool) \<Rightarrow> 'a \<times> 'c \<Rightarrow> 'b \<times> 'd \<Rightarrow> bool"
    13 where
    14   "prod_rel R1 R2 = (\<lambda>(a, b) (c, d). R1 a c \<and> R2 b d)"
    15 
    16 declare [[map prod = (prod_fun, prod_rel)]]
    17 
    18 lemma prod_rel_apply [simp]:
    19   "prod_rel R1 R2 (a, b) (c, d) \<longleftrightarrow> R1 a c \<and> R2 b d"
    20   by (simp add: prod_rel_def)
    21 
    22 lemma prod_equivp[quot_equiv]:
    23   assumes a: "equivp R1"
    24   assumes b: "equivp R2"
    25   shows "equivp (prod_rel R1 R2)"
    26   apply(rule equivpI)
    27   unfolding reflp_def symp_def transp_def
    28   apply(simp_all add: split_paired_all prod_rel_def)
    29   apply(blast intro: equivp_reflp[OF a] equivp_reflp[OF b])
    30   apply(blast intro: equivp_symp[OF a] equivp_symp[OF b])
    31   apply(blast intro: equivp_transp[OF a] equivp_transp[OF b])
    32   done
    33 
    34 lemma prod_quotient[quot_thm]:
    35   assumes q1: "Quotient R1 Abs1 Rep1"
    36   assumes q2: "Quotient R2 Abs2 Rep2"
    37   shows "Quotient (prod_rel R1 R2) (prod_fun Abs1 Abs2) (prod_fun Rep1 Rep2)"
    38   unfolding Quotient_def
    39   apply(simp add: split_paired_all)
    40   apply(simp add: Quotient_abs_rep[OF q1] Quotient_rel_rep[OF q1])
    41   apply(simp add: Quotient_abs_rep[OF q2] Quotient_rel_rep[OF q2])
    42   using q1 q2
    43   unfolding Quotient_def
    44   apply(blast)
    45   done
    46 
    47 lemma Pair_rsp[quot_respect]:
    48   assumes q1: "Quotient R1 Abs1 Rep1"
    49   assumes q2: "Quotient R2 Abs2 Rep2"
    50   shows "(R1 ===> R2 ===> prod_rel R1 R2) Pair Pair"
    51   by (auto simp add: prod_rel_def)
    52 
    53 lemma Pair_prs[quot_preserve]:
    54   assumes q1: "Quotient R1 Abs1 Rep1"
    55   assumes q2: "Quotient R2 Abs2 Rep2"
    56   shows "(Rep1 ---> Rep2 ---> (prod_fun Abs1 Abs2)) Pair = Pair"
    57   apply(simp add: fun_eq_iff)
    58   apply(simp add: Quotient_abs_rep[OF q1] Quotient_abs_rep[OF q2])
    59   done
    60 
    61 lemma fst_rsp[quot_respect]:
    62   assumes "Quotient R1 Abs1 Rep1"
    63   assumes "Quotient R2 Abs2 Rep2"
    64   shows "(prod_rel R1 R2 ===> R1) fst fst"
    65   by auto
    66 
    67 lemma fst_prs[quot_preserve]:
    68   assumes q1: "Quotient R1 Abs1 Rep1"
    69   assumes q2: "Quotient R2 Abs2 Rep2"
    70   shows "(prod_fun Rep1 Rep2 ---> Abs1) fst = fst"
    71   by (simp add: fun_eq_iff Quotient_abs_rep[OF q1])
    72 
    73 lemma snd_rsp[quot_respect]:
    74   assumes "Quotient R1 Abs1 Rep1"
    75   assumes "Quotient R2 Abs2 Rep2"
    76   shows "(prod_rel R1 R2 ===> R2) snd snd"
    77   by auto
    78 
    79 lemma snd_prs[quot_preserve]:
    80   assumes q1: "Quotient R1 Abs1 Rep1"
    81   assumes q2: "Quotient R2 Abs2 Rep2"
    82   shows "(prod_fun Rep1 Rep2 ---> Abs2) snd = snd"
    83   by (simp add: fun_eq_iff Quotient_abs_rep[OF q2])
    84 
    85 lemma split_rsp[quot_respect]:
    86   shows "((R1 ===> R2 ===> (op =)) ===> (prod_rel R1 R2) ===> (op =)) split split"
    87   by (auto intro!: fun_relI elim!: fun_relE)
    88 
    89 lemma split_prs[quot_preserve]:
    90   assumes q1: "Quotient R1 Abs1 Rep1"
    91   and     q2: "Quotient R2 Abs2 Rep2"
    92   shows "(((Abs1 ---> Abs2 ---> id) ---> prod_fun Rep1 Rep2 ---> id) split) = split"
    93   by (simp add: fun_eq_iff Quotient_abs_rep[OF q1] Quotient_abs_rep[OF q2])
    94 
    95 lemma [quot_respect]:
    96   shows "((R2 ===> R2 ===> op =) ===> (R1 ===> R1 ===> op =) ===>
    97   prod_rel R2 R1 ===> prod_rel R2 R1 ===> op =) prod_rel prod_rel"
    98   by (auto simp add: fun_rel_def)
    99 
   100 lemma [quot_preserve]:
   101   assumes q1: "Quotient R1 abs1 rep1"
   102   and     q2: "Quotient R2 abs2 rep2"
   103   shows "((abs1 ---> abs1 ---> id) ---> (abs2 ---> abs2 ---> id) --->
   104   prod_fun rep1 rep2 ---> prod_fun rep1 rep2 ---> id) prod_rel = prod_rel"
   105   by (simp add: fun_eq_iff Quotient_abs_rep[OF q1] Quotient_abs_rep[OF q2])
   106 
   107 lemma [quot_preserve]:
   108   shows"(prod_rel ((rep1 ---> rep1 ---> id) R1) ((rep2 ---> rep2 ---> id) R2)
   109   (l1, l2) (r1, r2)) = (R1 (rep1 l1) (rep1 r1) \<and> R2 (rep2 l2) (rep2 r2))"
   110   by simp
   111 
   112 declare Pair_eq[quot_preserve]
   113 
   114 lemma prod_fun_id[id_simps]:
   115   shows "prod_fun id id = id"
   116   by (simp add: fun_eq_iff)
   117 
   118 lemma prod_rel_eq[id_simps]:
   119   shows "prod_rel (op =) (op =) = (op =)"
   120   by (simp add: fun_eq_iff)
   121 
   122 end