src/HOL/Library/Quotient_Product.thy
author blanchet
Thu Mar 06 13:36:48 2014 +0100 (2014-03-06)
changeset 55932 68c5104d2204
parent 55414 eab03e9cee8a
child 55944 7ab8f003fe41
permissions -rw-r--r--
renamed 'map_pair' to 'map_prod'
wenzelm@47455
     1
(*  Title:      HOL/Library/Quotient_Product.thy
kuncar@53012
     2
    Author:     Cezary Kaliszyk and Christian Urban
kaliszyk@35222
     3
*)
wenzelm@35788
     4
wenzelm@35788
     5
header {* Quotient infrastructure for the product type *}
wenzelm@35788
     6
kaliszyk@35222
     7
theory Quotient_Product
kaliszyk@35222
     8
imports Main Quotient_Syntax
kaliszyk@35222
     9
begin
kaliszyk@35222
    10
kuncar@53012
    11
subsection {* Rules for the Quotient package *}
kuncar@51956
    12
blanchet@55932
    13
lemma map_prod_id [id_simps]:
blanchet@55932
    14
  shows "map_prod id id = id"
haftmann@40820
    15
  by (simp add: fun_eq_iff)
haftmann@40820
    16
kuncar@53012
    17
lemma prod_rel_eq [id_simps]:
haftmann@40820
    18
  shows "prod_rel (op =) (op =) = (op =)"
haftmann@40820
    19
  by (simp add: fun_eq_iff)
haftmann@40820
    20
haftmann@40820
    21
lemma prod_equivp [quot_equiv]:
haftmann@40820
    22
  assumes "equivp R1"
haftmann@40820
    23
  assumes "equivp R2"
kaliszyk@35222
    24
  shows "equivp (prod_rel R1 R2)"
haftmann@40820
    25
  using assms by (auto intro!: equivpI reflpI sympI transpI elim!: equivpE elim: reflpE sympE transpE)
haftmann@40820
    26
haftmann@40820
    27
lemma prod_quotient [quot_thm]:
kuncar@47308
    28
  assumes "Quotient3 R1 Abs1 Rep1"
kuncar@47308
    29
  assumes "Quotient3 R2 Abs2 Rep2"
blanchet@55932
    30
  shows "Quotient3 (prod_rel R1 R2) (map_prod Abs1 Abs2) (map_prod Rep1 Rep2)"
kuncar@47308
    31
  apply (rule Quotient3I)
blanchet@55932
    32
  apply (simp add: map_prod.compositionality comp_def map_prod.identity
kuncar@47308
    33
     Quotient3_abs_rep [OF assms(1)] Quotient3_abs_rep [OF assms(2)])
kuncar@47308
    34
  apply (simp add: split_paired_all Quotient3_rel_rep [OF assms(1)] Quotient3_rel_rep [OF assms(2)])
kuncar@47308
    35
  using Quotient3_rel [OF assms(1)] Quotient3_rel [OF assms(2)]
haftmann@40820
    36
  apply (auto simp add: split_paired_all)
kaliszyk@35222
    37
  done
kaliszyk@35222
    38
kuncar@47308
    39
declare [[mapQ3 prod = (prod_rel, prod_quotient)]]
kuncar@47094
    40
haftmann@40820
    41
lemma Pair_rsp [quot_respect]:
kuncar@47308
    42
  assumes q1: "Quotient3 R1 Abs1 Rep1"
kuncar@47308
    43
  assumes q2: "Quotient3 R2 Abs2 Rep2"
kaliszyk@35222
    44
  shows "(R1 ===> R2 ===> prod_rel R1 R2) Pair Pair"
huffman@47624
    45
  by (rule Pair_transfer)
kaliszyk@35222
    46
haftmann@40820
    47
lemma Pair_prs [quot_preserve]:
kuncar@47308
    48
  assumes q1: "Quotient3 R1 Abs1 Rep1"
kuncar@47308
    49
  assumes q2: "Quotient3 R2 Abs2 Rep2"
blanchet@55932
    50
  shows "(Rep1 ---> Rep2 ---> (map_prod Abs1 Abs2)) Pair = Pair"
nipkow@39302
    51
  apply(simp add: fun_eq_iff)
kuncar@47308
    52
  apply(simp add: Quotient3_abs_rep[OF q1] Quotient3_abs_rep[OF q2])
kaliszyk@35222
    53
  done
kaliszyk@35222
    54
haftmann@40820
    55
lemma fst_rsp [quot_respect]:
kuncar@47308
    56
  assumes "Quotient3 R1 Abs1 Rep1"
kuncar@47308
    57
  assumes "Quotient3 R2 Abs2 Rep2"
kaliszyk@35222
    58
  shows "(prod_rel R1 R2 ===> R1) fst fst"
haftmann@40465
    59
  by auto
kaliszyk@35222
    60
haftmann@40820
    61
lemma fst_prs [quot_preserve]:
kuncar@47308
    62
  assumes q1: "Quotient3 R1 Abs1 Rep1"
kuncar@47308
    63
  assumes q2: "Quotient3 R2 Abs2 Rep2"
blanchet@55932
    64
  shows "(map_prod Rep1 Rep2 ---> Abs1) fst = fst"
kuncar@47308
    65
  by (simp add: fun_eq_iff Quotient3_abs_rep[OF q1])
kaliszyk@35222
    66
haftmann@40820
    67
lemma snd_rsp [quot_respect]:
kuncar@47308
    68
  assumes "Quotient3 R1 Abs1 Rep1"
kuncar@47308
    69
  assumes "Quotient3 R2 Abs2 Rep2"
kaliszyk@35222
    70
  shows "(prod_rel R1 R2 ===> R2) snd snd"
haftmann@40465
    71
  by auto
kaliszyk@35222
    72
haftmann@40820
    73
lemma snd_prs [quot_preserve]:
kuncar@47308
    74
  assumes q1: "Quotient3 R1 Abs1 Rep1"
kuncar@47308
    75
  assumes q2: "Quotient3 R2 Abs2 Rep2"
blanchet@55932
    76
  shows "(map_prod Rep1 Rep2 ---> Abs2) snd = snd"
kuncar@47308
    77
  by (simp add: fun_eq_iff Quotient3_abs_rep[OF q2])
kaliszyk@35222
    78
haftmann@40820
    79
lemma split_rsp [quot_respect]:
kaliszyk@35222
    80
  shows "((R1 ===> R2 ===> (op =)) ===> (prod_rel R1 R2) ===> (op =)) split split"
blanchet@55414
    81
  by (rule case_prod_transfer)
kaliszyk@35222
    82
haftmann@40820
    83
lemma split_prs [quot_preserve]:
kuncar@47308
    84
  assumes q1: "Quotient3 R1 Abs1 Rep1"
kuncar@47308
    85
  and     q2: "Quotient3 R2 Abs2 Rep2"
blanchet@55932
    86
  shows "(((Abs1 ---> Abs2 ---> id) ---> map_prod Rep1 Rep2 ---> id) split) = split"
kuncar@47308
    87
  by (simp add: fun_eq_iff Quotient3_abs_rep[OF q1] Quotient3_abs_rep[OF q2])
kaliszyk@35222
    88
kaliszyk@36695
    89
lemma [quot_respect]:
kaliszyk@36695
    90
  shows "((R2 ===> R2 ===> op =) ===> (R1 ===> R1 ===> op =) ===>
kaliszyk@36695
    91
  prod_rel R2 R1 ===> prod_rel R2 R1 ===> op =) prod_rel prod_rel"
huffman@47624
    92
  by (rule prod_rel_transfer)
kaliszyk@36695
    93
kaliszyk@36695
    94
lemma [quot_preserve]:
kuncar@47308
    95
  assumes q1: "Quotient3 R1 abs1 rep1"
kuncar@47308
    96
  and     q2: "Quotient3 R2 abs2 rep2"
kaliszyk@36695
    97
  shows "((abs1 ---> abs1 ---> id) ---> (abs2 ---> abs2 ---> id) --->
blanchet@55932
    98
  map_prod rep1 rep2 ---> map_prod rep1 rep2 ---> id) prod_rel = prod_rel"
kuncar@47308
    99
  by (simp add: fun_eq_iff Quotient3_abs_rep[OF q1] Quotient3_abs_rep[OF q2])
kaliszyk@36695
   100
kaliszyk@36695
   101
lemma [quot_preserve]:
kaliszyk@36695
   102
  shows"(prod_rel ((rep1 ---> rep1 ---> id) R1) ((rep2 ---> rep2 ---> id) R2)
kaliszyk@36695
   103
  (l1, l2) (r1, r2)) = (R1 (rep1 l1) (rep1 r1) \<and> R2 (rep2 l2) (rep2 r2))"
kaliszyk@36695
   104
  by simp
kaliszyk@36695
   105
kaliszyk@36695
   106
declare Pair_eq[quot_preserve]
kaliszyk@36695
   107
kaliszyk@35222
   108
end