src/HOL/Library/Quotient_Product.thy
author kuncar
Fri, 23 Mar 2012 14:20:09 +0100
changeset 47964 1a7ad2601cb5
parent 46673 b16f976db515
child 48146 ca743eafa1dd
permissions -rw-r--r--
store the relational theorem for every relator
     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 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 "Quotient R1 Abs1 Rep1"
    36   assumes "Quotient R2 Abs2 Rep2"
    37   shows "Quotient (prod_rel R1 R2) (map_pair Abs1 Abs2) (map_pair Rep1 Rep2)"
    38   apply (rule QuotientI)
    39   apply (simp add: map_pair.compositionality comp_def map_pair.identity
    40      Quotient_abs_rep [OF assms(1)] Quotient_abs_rep [OF assms(2)])
    41   apply (simp add: split_paired_all Quotient_rel_rep [OF assms(1)] Quotient_rel_rep [OF assms(2)])
    42   using Quotient_rel [OF assms(1)] Quotient_rel [OF assms(2)]
    43   apply (auto simp add: split_paired_all)
    44   done
    45 
    46 declare [[map prod = (prod_rel, prod_quotient)]]
    47 
    48 lemma Pair_rsp [quot_respect]:
    49   assumes q1: "Quotient R1 Abs1 Rep1"
    50   assumes q2: "Quotient 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: "Quotient R1 Abs1 Rep1"
    56   assumes q2: "Quotient R2 Abs2 Rep2"
    57   shows "(Rep1 ---> Rep2 ---> (map_pair Abs1 Abs2)) Pair = Pair"
    58   apply(simp add: fun_eq_iff)
    59   apply(simp add: Quotient_abs_rep[OF q1] Quotient_abs_rep[OF q2])
    60   done
    61 
    62 lemma fst_rsp [quot_respect]:
    63   assumes "Quotient R1 Abs1 Rep1"
    64   assumes "Quotient 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: "Quotient R1 Abs1 Rep1"
    70   assumes q2: "Quotient R2 Abs2 Rep2"
    71   shows "(map_pair Rep1 Rep2 ---> Abs1) fst = fst"
    72   by (simp add: fun_eq_iff Quotient_abs_rep[OF q1])
    73 
    74 lemma snd_rsp [quot_respect]:
    75   assumes "Quotient R1 Abs1 Rep1"
    76   assumes "Quotient 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: "Quotient R1 Abs1 Rep1"
    82   assumes q2: "Quotient R2 Abs2 Rep2"
    83   shows "(map_pair Rep1 Rep2 ---> Abs2) snd = snd"
    84   by (simp add: fun_eq_iff Quotient_abs_rep[OF q2])
    85 
    86 lemma split_rsp [quot_respect]:
    87   shows "((R1 ===> R2 ===> (op =)) ===> (prod_rel R1 R2) ===> (op =)) split split"
    88   by (auto intro!: fun_relI elim!: fun_relE)
    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) ---> map_pair 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 simp add: fun_rel_def)
   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   map_pair rep1 rep2 ---> map_pair 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 end