src/HOL/Library/Quotient_Product.thy
author haftmann
Fri Nov 01 18:51:14 2013 +0100 (2013-11-01)
changeset 54230 b1d955791529
parent 53012 cb82606b8215
child 55414 eab03e9cee8a
permissions -rw-r--r--
more simplification rules on unary and binary minus
     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 subsection {* Rules for the Quotient package *}
    12 
    13 lemma map_pair_id [id_simps]:
    14   shows "map_pair id id = id"
    15   by (simp add: fun_eq_iff)
    16 
    17 lemma prod_rel_eq [id_simps]:
    18   shows "prod_rel (op =) (op =) = (op =)"
    19   by (simp add: fun_eq_iff)
    20 
    21 lemma prod_equivp [quot_equiv]:
    22   assumes "equivp R1"
    23   assumes "equivp R2"
    24   shows "equivp (prod_rel R1 R2)"
    25   using assms by (auto intro!: equivpI reflpI sympI transpI elim!: equivpE elim: reflpE sympE transpE)
    26 
    27 lemma prod_quotient [quot_thm]:
    28   assumes "Quotient3 R1 Abs1 Rep1"
    29   assumes "Quotient3 R2 Abs2 Rep2"
    30   shows "Quotient3 (prod_rel R1 R2) (map_pair Abs1 Abs2) (map_pair Rep1 Rep2)"
    31   apply (rule Quotient3I)
    32   apply (simp add: map_pair.compositionality comp_def map_pair.identity
    33      Quotient3_abs_rep [OF assms(1)] Quotient3_abs_rep [OF assms(2)])
    34   apply (simp add: split_paired_all Quotient3_rel_rep [OF assms(1)] Quotient3_rel_rep [OF assms(2)])
    35   using Quotient3_rel [OF assms(1)] Quotient3_rel [OF assms(2)]
    36   apply (auto simp add: split_paired_all)
    37   done
    38 
    39 declare [[mapQ3 prod = (prod_rel, prod_quotient)]]
    40 
    41 lemma Pair_rsp [quot_respect]:
    42   assumes q1: "Quotient3 R1 Abs1 Rep1"
    43   assumes q2: "Quotient3 R2 Abs2 Rep2"
    44   shows "(R1 ===> R2 ===> prod_rel R1 R2) Pair Pair"
    45   by (rule Pair_transfer)
    46 
    47 lemma Pair_prs [quot_preserve]:
    48   assumes q1: "Quotient3 R1 Abs1 Rep1"
    49   assumes q2: "Quotient3 R2 Abs2 Rep2"
    50   shows "(Rep1 ---> Rep2 ---> (map_pair Abs1 Abs2)) Pair = Pair"
    51   apply(simp add: fun_eq_iff)
    52   apply(simp add: Quotient3_abs_rep[OF q1] Quotient3_abs_rep[OF q2])
    53   done
    54 
    55 lemma fst_rsp [quot_respect]:
    56   assumes "Quotient3 R1 Abs1 Rep1"
    57   assumes "Quotient3 R2 Abs2 Rep2"
    58   shows "(prod_rel R1 R2 ===> R1) fst fst"
    59   by auto
    60 
    61 lemma fst_prs [quot_preserve]:
    62   assumes q1: "Quotient3 R1 Abs1 Rep1"
    63   assumes q2: "Quotient3 R2 Abs2 Rep2"
    64   shows "(map_pair Rep1 Rep2 ---> Abs1) fst = fst"
    65   by (simp add: fun_eq_iff Quotient3_abs_rep[OF q1])
    66 
    67 lemma snd_rsp [quot_respect]:
    68   assumes "Quotient3 R1 Abs1 Rep1"
    69   assumes "Quotient3 R2 Abs2 Rep2"
    70   shows "(prod_rel R1 R2 ===> R2) snd snd"
    71   by auto
    72 
    73 lemma snd_prs [quot_preserve]:
    74   assumes q1: "Quotient3 R1 Abs1 Rep1"
    75   assumes q2: "Quotient3 R2 Abs2 Rep2"
    76   shows "(map_pair Rep1 Rep2 ---> Abs2) snd = snd"
    77   by (simp add: fun_eq_iff Quotient3_abs_rep[OF q2])
    78 
    79 lemma split_rsp [quot_respect]:
    80   shows "((R1 ===> R2 ===> (op =)) ===> (prod_rel R1 R2) ===> (op =)) split split"
    81   by (rule prod_case_transfer)
    82 
    83 lemma split_prs [quot_preserve]:
    84   assumes q1: "Quotient3 R1 Abs1 Rep1"
    85   and     q2: "Quotient3 R2 Abs2 Rep2"
    86   shows "(((Abs1 ---> Abs2 ---> id) ---> map_pair Rep1 Rep2 ---> id) split) = split"
    87   by (simp add: fun_eq_iff Quotient3_abs_rep[OF q1] Quotient3_abs_rep[OF q2])
    88 
    89 lemma [quot_respect]:
    90   shows "((R2 ===> R2 ===> op =) ===> (R1 ===> R1 ===> op =) ===>
    91   prod_rel R2 R1 ===> prod_rel R2 R1 ===> op =) prod_rel prod_rel"
    92   by (rule prod_rel_transfer)
    93 
    94 lemma [quot_preserve]:
    95   assumes q1: "Quotient3 R1 abs1 rep1"
    96   and     q2: "Quotient3 R2 abs2 rep2"
    97   shows "((abs1 ---> abs1 ---> id) ---> (abs2 ---> abs2 ---> id) --->
    98   map_pair rep1 rep2 ---> map_pair rep1 rep2 ---> id) prod_rel = prod_rel"
    99   by (simp add: fun_eq_iff Quotient3_abs_rep[OF q1] Quotient3_abs_rep[OF q2])
   100 
   101 lemma [quot_preserve]:
   102   shows"(prod_rel ((rep1 ---> rep1 ---> id) R1) ((rep2 ---> rep2 ---> id) R2)
   103   (l1, l2) (r1, r2)) = (R1 (rep1 l1) (rep1 r1) \<and> R2 (rep2 l2) (rep2 r2))"
   104   by simp
   105 
   106 declare Pair_eq[quot_preserve]
   107 
   108 end