src/HOL/Library/Quotient_Product.thy
author kuncar
Tue Apr 03 16:26:48 2012 +0200 (2012-04-03)
changeset 47308 9caab698dbe4
parent 47301 ca743eafa1dd
child 47455 26315a545e26
permissions -rw-r--r--
new package Lifting - initial commit
     1 (*  Title:      HOL/Library/Quotient3_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 lemma prod_rel_apply [simp]:
    17   "prod_rel R1 R2 (a, b) (c, d) \<longleftrightarrow> R1 a c \<and> R2 b d"
    18   by (simp add: prod_rel_def)
    19 
    20 lemma map_pair_id [id_simps]:
    21   shows "map_pair id id = id"
    22   by (simp add: fun_eq_iff)
    23 
    24 lemma prod_rel_eq [id_simps]:
    25   shows "prod_rel (op =) (op =) = (op =)"
    26   by (simp add: fun_eq_iff)
    27 
    28 lemma prod_equivp [quot_equiv]:
    29   assumes "equivp R1"
    30   assumes "equivp R2"
    31   shows "equivp (prod_rel R1 R2)"
    32   using assms by (auto intro!: equivpI reflpI sympI transpI elim!: equivpE elim: reflpE sympE transpE)
    33 
    34 lemma prod_quotient [quot_thm]:
    35   assumes "Quotient3 R1 Abs1 Rep1"
    36   assumes "Quotient3 R2 Abs2 Rep2"
    37   shows "Quotient3 (prod_rel R1 R2) (map_pair Abs1 Abs2) (map_pair Rep1 Rep2)"
    38   apply (rule Quotient3I)
    39   apply (simp add: map_pair.compositionality comp_def map_pair.identity
    40      Quotient3_abs_rep [OF assms(1)] Quotient3_abs_rep [OF assms(2)])
    41   apply (simp add: split_paired_all Quotient3_rel_rep [OF assms(1)] Quotient3_rel_rep [OF assms(2)])
    42   using Quotient3_rel [OF assms(1)] Quotient3_rel [OF assms(2)]
    43   apply (auto simp add: split_paired_all)
    44   done
    45 
    46 declare [[mapQ3 prod = (prod_rel, prod_quotient)]]
    47 
    48 lemma Pair_rsp [quot_respect]:
    49   assumes q1: "Quotient3 R1 Abs1 Rep1"
    50   assumes q2: "Quotient3 R2 Abs2 Rep2"
    51   shows "(R1 ===> R2 ===> prod_rel R1 R2) Pair Pair"
    52   by (auto simp add: prod_rel_def)
    53 
    54 lemma Pair_prs [quot_preserve]:
    55   assumes q1: "Quotient3 R1 Abs1 Rep1"
    56   assumes q2: "Quotient3 R2 Abs2 Rep2"
    57   shows "(Rep1 ---> Rep2 ---> (map_pair Abs1 Abs2)) Pair = Pair"
    58   apply(simp add: fun_eq_iff)
    59   apply(simp add: Quotient3_abs_rep[OF q1] Quotient3_abs_rep[OF q2])
    60   done
    61 
    62 lemma fst_rsp [quot_respect]:
    63   assumes "Quotient3 R1 Abs1 Rep1"
    64   assumes "Quotient3 R2 Abs2 Rep2"
    65   shows "(prod_rel R1 R2 ===> R1) fst fst"
    66   by auto
    67 
    68 lemma fst_prs [quot_preserve]:
    69   assumes q1: "Quotient3 R1 Abs1 Rep1"
    70   assumes q2: "Quotient3 R2 Abs2 Rep2"
    71   shows "(map_pair Rep1 Rep2 ---> Abs1) fst = fst"
    72   by (simp add: fun_eq_iff Quotient3_abs_rep[OF q1])
    73 
    74 lemma snd_rsp [quot_respect]:
    75   assumes "Quotient3 R1 Abs1 Rep1"
    76   assumes "Quotient3 R2 Abs2 Rep2"
    77   shows "(prod_rel R1 R2 ===> R2) snd snd"
    78   by auto
    79 
    80 lemma snd_prs [quot_preserve]:
    81   assumes q1: "Quotient3 R1 Abs1 Rep1"
    82   assumes q2: "Quotient3 R2 Abs2 Rep2"
    83   shows "(map_pair Rep1 Rep2 ---> Abs2) snd = snd"
    84   by (simp add: fun_eq_iff Quotient3_abs_rep[OF q2])
    85 
    86 lemma split_rsp [quot_respect]:
    87   shows "((R1 ===> R2 ===> (op =)) ===> (prod_rel R1 R2) ===> (op =)) split split"
    88   unfolding prod_rel_def fun_rel_def
    89   by auto
    90 
    91 lemma split_prs [quot_preserve]:
    92   assumes q1: "Quotient3 R1 Abs1 Rep1"
    93   and     q2: "Quotient3 R2 Abs2 Rep2"
    94   shows "(((Abs1 ---> Abs2 ---> id) ---> map_pair Rep1 Rep2 ---> id) split) = split"
    95   by (simp add: fun_eq_iff Quotient3_abs_rep[OF q1] Quotient3_abs_rep[OF q2])
    96 
    97 lemma [quot_respect]:
    98   shows "((R2 ===> R2 ===> op =) ===> (R1 ===> R1 ===> op =) ===>
    99   prod_rel R2 R1 ===> prod_rel R2 R1 ===> op =) prod_rel prod_rel"
   100   by (auto simp add: fun_rel_def)
   101 
   102 lemma [quot_preserve]:
   103   assumes q1: "Quotient3 R1 abs1 rep1"
   104   and     q2: "Quotient3 R2 abs2 rep2"
   105   shows "((abs1 ---> abs1 ---> id) ---> (abs2 ---> abs2 ---> id) --->
   106   map_pair rep1 rep2 ---> map_pair rep1 rep2 ---> id) prod_rel = prod_rel"
   107   by (simp add: fun_eq_iff Quotient3_abs_rep[OF q1] Quotient3_abs_rep[OF q2])
   108 
   109 lemma [quot_preserve]:
   110   shows"(prod_rel ((rep1 ---> rep1 ---> id) R1) ((rep2 ---> rep2 ---> id) R2)
   111   (l1, l2) (r1, r2)) = (R1 (rep1 l1) (rep1 r1) \<and> R2 (rep2 l2) (rep2 r2))"
   112   by simp
   113 
   114 declare Pair_eq[quot_preserve]
   115 
   116 end