src/HOL/Library/Quotient_Product.thy
author nipkow
Mon Sep 13 11:13:15 2010 +0200 (2010-09-13)
changeset 39302 d7728f65b353
parent 39198 f967a16dfcdd
child 40465 2989f9f3aa10
permissions -rw-r--r--
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
     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 fun
    12   prod_rel
    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 
    19 lemma prod_equivp[quot_equiv]:
    20   assumes a: "equivp R1"
    21   assumes b: "equivp R2"
    22   shows "equivp (prod_rel R1 R2)"
    23   apply(rule equivpI)
    24   unfolding reflp_def symp_def transp_def
    25   apply(simp_all add: split_paired_all)
    26   apply(blast intro: equivp_reflp[OF a] equivp_reflp[OF b])
    27   apply(blast intro: equivp_symp[OF a] equivp_symp[OF b])
    28   apply(blast intro: equivp_transp[OF a] equivp_transp[OF b])
    29   done
    30 
    31 lemma prod_quotient[quot_thm]:
    32   assumes q1: "Quotient R1 Abs1 Rep1"
    33   assumes q2: "Quotient R2 Abs2 Rep2"
    34   shows "Quotient (prod_rel R1 R2) (prod_fun Abs1 Abs2) (prod_fun Rep1 Rep2)"
    35   unfolding Quotient_def
    36   apply(simp add: split_paired_all)
    37   apply(simp add: Quotient_abs_rep[OF q1] Quotient_rel_rep[OF q1])
    38   apply(simp add: Quotient_abs_rep[OF q2] Quotient_rel_rep[OF q2])
    39   using q1 q2
    40   unfolding Quotient_def
    41   apply(blast)
    42   done
    43 
    44 lemma Pair_rsp[quot_respect]:
    45   assumes q1: "Quotient R1 Abs1 Rep1"
    46   assumes q2: "Quotient R2 Abs2 Rep2"
    47   shows "(R1 ===> R2 ===> prod_rel R1 R2) Pair Pair"
    48   by simp
    49 
    50 lemma Pair_prs[quot_preserve]:
    51   assumes q1: "Quotient R1 Abs1 Rep1"
    52   assumes q2: "Quotient R2 Abs2 Rep2"
    53   shows "(Rep1 ---> Rep2 ---> (prod_fun Abs1 Abs2)) Pair = Pair"
    54   apply(simp add: fun_eq_iff)
    55   apply(simp add: Quotient_abs_rep[OF q1] Quotient_abs_rep[OF q2])
    56   done
    57 
    58 lemma fst_rsp[quot_respect]:
    59   assumes "Quotient R1 Abs1 Rep1"
    60   assumes "Quotient R2 Abs2 Rep2"
    61   shows "(prod_rel R1 R2 ===> R1) fst fst"
    62   by simp
    63 
    64 lemma fst_prs[quot_preserve]:
    65   assumes q1: "Quotient R1 Abs1 Rep1"
    66   assumes q2: "Quotient R2 Abs2 Rep2"
    67   shows "(prod_fun Rep1 Rep2 ---> Abs1) fst = fst"
    68   apply(simp add: fun_eq_iff)
    69   apply(simp add: Quotient_abs_rep[OF q1])
    70   done
    71 
    72 lemma snd_rsp[quot_respect]:
    73   assumes "Quotient R1 Abs1 Rep1"
    74   assumes "Quotient R2 Abs2 Rep2"
    75   shows "(prod_rel R1 R2 ===> R2) snd snd"
    76   by simp
    77 
    78 lemma snd_prs[quot_preserve]:
    79   assumes q1: "Quotient R1 Abs1 Rep1"
    80   assumes q2: "Quotient R2 Abs2 Rep2"
    81   shows "(prod_fun Rep1 Rep2 ---> Abs2) snd = snd"
    82   apply(simp add: fun_eq_iff)
    83   apply(simp add: Quotient_abs_rep[OF q2])
    84   done
    85 
    86 lemma split_rsp[quot_respect]:
    87   shows "((R1 ===> R2 ===> (op =)) ===> (prod_rel R1 R2) ===> (op =)) split split"
    88   by auto
    89 
    90 lemma split_prs[quot_preserve]:
    91   assumes q1: "Quotient R1 Abs1 Rep1"
    92   and     q2: "Quotient R2 Abs2 Rep2"
    93   shows "(((Abs1 ---> Abs2 ---> id) ---> prod_fun Rep1 Rep2 ---> id) split) = split"
    94   by (simp add: fun_eq_iff Quotient_abs_rep[OF q1] Quotient_abs_rep[OF q2])
    95 
    96 lemma [quot_respect]:
    97   shows "((R2 ===> R2 ===> op =) ===> (R1 ===> R1 ===> op =) ===>
    98   prod_rel R2 R1 ===> prod_rel R2 R1 ===> op =) prod_rel prod_rel"
    99   by auto
   100 
   101 lemma [quot_preserve]:
   102   assumes q1: "Quotient R1 abs1 rep1"
   103   and     q2: "Quotient R2 abs2 rep2"
   104   shows "((abs1 ---> abs1 ---> id) ---> (abs2 ---> abs2 ---> id) --->
   105   prod_fun rep1 rep2 ---> prod_fun rep1 rep2 ---> id) prod_rel = prod_rel"
   106   by (simp add: fun_eq_iff Quotient_abs_rep[OF q1] Quotient_abs_rep[OF q2])
   107 
   108 lemma [quot_preserve]:
   109   shows"(prod_rel ((rep1 ---> rep1 ---> id) R1) ((rep2 ---> rep2 ---> id) R2)
   110   (l1, l2) (r1, r2)) = (R1 (rep1 l1) (rep1 r1) \<and> R2 (rep2 l2) (rep2 r2))"
   111   by simp
   112 
   113 declare Pair_eq[quot_preserve]
   114 
   115 lemma prod_fun_id[id_simps]:
   116   shows "prod_fun id id = id"
   117   by (simp add: prod_fun_def)
   118 
   119 lemma prod_rel_eq[id_simps]:
   120   shows "prod_rel (op =) (op =) = (op =)"
   121   by (simp add: fun_eq_iff)
   122 
   123 end