src/HOL/Library/Quotient_Product.thy
author wenzelm
Wed Mar 08 10:50:59 2017 +0100 (2017-03-08)
changeset 65151 a7394aa4d21c
parent 62954 c5d0fdc260fa
child 67399 eab6ce8368fa
permissions -rw-r--r--
tuned proofs;
     1 (*  Title:      HOL/Library/Quotient_Product.thy
     2     Author:     Cezary Kaliszyk and Christian Urban
     3 *)
     4 
     5 section \<open>Quotient infrastructure for the product type\<close>
     6 
     7 theory Quotient_Product
     8 imports Quotient_Syntax
     9 begin
    10 
    11 subsection \<open>Rules for the Quotient package\<close>
    12 
    13 lemma map_prod_id [id_simps]:
    14   shows "map_prod id id = id"
    15   by (simp add: fun_eq_iff)
    16 
    17 lemma rel_prod_eq [id_simps]:
    18   shows "rel_prod (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 (rel_prod 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 (rel_prod R1 R2) (map_prod Abs1 Abs2) (map_prod Rep1 Rep2)"
    31   apply (rule Quotient3I)
    32   apply (simp add: map_prod.compositionality comp_def map_prod.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 = (rel_prod, 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 ===> rel_prod 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_prod 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 "(rel_prod 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_prod 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 "(rel_prod 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_prod Rep1 Rep2 ---> Abs2) snd = snd"
    77   by (simp add: fun_eq_iff Quotient3_abs_rep[OF q2])
    78 
    79 lemma case_prod_rsp [quot_respect]:
    80   shows "((R1 ===> R2 ===> (op =)) ===> (rel_prod R1 R2) ===> (op =)) case_prod case_prod"
    81   by (rule case_prod_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_prod Rep1 Rep2 ---> id) case_prod) = case_prod"
    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   rel_prod R2 R1 ===> rel_prod R2 R1 ===> op =) rel_prod rel_prod"
    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_prod rep1 rep2 ---> map_prod rep1 rep2 ---> id) rel_prod = rel_prod"
    99   by (simp add: fun_eq_iff Quotient3_abs_rep[OF q1] Quotient3_abs_rep[OF q2])
   100 
   101 lemma [quot_preserve]:
   102   shows"(rel_prod ((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 prod.inject[quot_preserve]
   107 
   108 end