src/HOL/Library/Quotient_Product.thy
author hoelzl
Tue Jul 19 14:37:49 2011 +0200 (2011-07-19)
changeset 43922 c6f35921056e
parent 41372 551eb49a6e91
child 45802 b16f976db515
permissions -rw-r--r--
add nat => enat coercion
     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 = (map_pair, 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 map_pair_id [id_simps]:
    23   shows "map_pair id id = id"
    24   by (simp add: fun_eq_iff)
    25 
    26 lemma prod_rel_eq [id_simps]:
    27   shows "prod_rel (op =) (op =) = (op =)"
    28   by (simp add: fun_eq_iff)
    29 
    30 lemma prod_equivp [quot_equiv]:
    31   assumes "equivp R1"
    32   assumes "equivp R2"
    33   shows "equivp (prod_rel R1 R2)"
    34   using assms by (auto intro!: equivpI reflpI sympI transpI elim!: equivpE elim: reflpE sympE transpE)
    35 
    36 lemma prod_quotient [quot_thm]:
    37   assumes "Quotient R1 Abs1 Rep1"
    38   assumes "Quotient R2 Abs2 Rep2"
    39   shows "Quotient (prod_rel R1 R2) (map_pair Abs1 Abs2) (map_pair Rep1 Rep2)"
    40   apply (rule QuotientI)
    41   apply (simp add: map_pair.compositionality comp_def map_pair.identity
    42      Quotient_abs_rep [OF assms(1)] Quotient_abs_rep [OF assms(2)])
    43   apply (simp add: split_paired_all Quotient_rel_rep [OF assms(1)] Quotient_rel_rep [OF assms(2)])
    44   using Quotient_rel [OF assms(1)] Quotient_rel [OF assms(2)]
    45   apply (auto simp add: split_paired_all)
    46   done
    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