src/HOL/Library/Quotient_Product.thy
author nipkow
Tue Sep 07 10:05:19 2010 +0200 (2010-09-07)
changeset 39198 f967a16dfcdd
parent 37678 0040bafffdef
child 39302 d7728f65b353
permissions -rw-r--r--
expand_fun_eq -> ext_iff
expand_set_eq -> set_ext_iff
Naming in line now with multisets
wenzelm@35788
     1
(*  Title:      HOL/Library/Quotient_Product.thy
kaliszyk@35222
     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
kaliszyk@35222
    11
fun
kaliszyk@35222
    12
  prod_rel
kaliszyk@35222
    13
where
kaliszyk@35222
    14
  "prod_rel R1 R2 = (\<lambda>(a, b) (c, d). R1 a c \<and> R2 b d)"
kaliszyk@35222
    15
haftmann@37678
    16
declare [[map prod = (prod_fun, prod_rel)]]
kaliszyk@35222
    17
kaliszyk@35222
    18
kaliszyk@35222
    19
lemma prod_equivp[quot_equiv]:
kaliszyk@35222
    20
  assumes a: "equivp R1"
kaliszyk@35222
    21
  assumes b: "equivp R2"
kaliszyk@35222
    22
  shows "equivp (prod_rel R1 R2)"
kaliszyk@35222
    23
  apply(rule equivpI)
kaliszyk@35222
    24
  unfolding reflp_def symp_def transp_def
kaliszyk@35222
    25
  apply(simp_all add: split_paired_all)
kaliszyk@35222
    26
  apply(blast intro: equivp_reflp[OF a] equivp_reflp[OF b])
kaliszyk@35222
    27
  apply(blast intro: equivp_symp[OF a] equivp_symp[OF b])
kaliszyk@35222
    28
  apply(blast intro: equivp_transp[OF a] equivp_transp[OF b])
kaliszyk@35222
    29
  done
kaliszyk@35222
    30
kaliszyk@35222
    31
lemma prod_quotient[quot_thm]:
kaliszyk@35222
    32
  assumes q1: "Quotient R1 Abs1 Rep1"
kaliszyk@35222
    33
  assumes q2: "Quotient R2 Abs2 Rep2"
kaliszyk@35222
    34
  shows "Quotient (prod_rel R1 R2) (prod_fun Abs1 Abs2) (prod_fun Rep1 Rep2)"
kaliszyk@35222
    35
  unfolding Quotient_def
kaliszyk@35222
    36
  apply(simp add: split_paired_all)
kaliszyk@35222
    37
  apply(simp add: Quotient_abs_rep[OF q1] Quotient_rel_rep[OF q1])
kaliszyk@35222
    38
  apply(simp add: Quotient_abs_rep[OF q2] Quotient_rel_rep[OF q2])
kaliszyk@35222
    39
  using q1 q2
kaliszyk@35222
    40
  unfolding Quotient_def
kaliszyk@35222
    41
  apply(blast)
kaliszyk@35222
    42
  done
kaliszyk@35222
    43
kaliszyk@35222
    44
lemma Pair_rsp[quot_respect]:
kaliszyk@35222
    45
  assumes q1: "Quotient R1 Abs1 Rep1"
kaliszyk@35222
    46
  assumes q2: "Quotient R2 Abs2 Rep2"
kaliszyk@35222
    47
  shows "(R1 ===> R2 ===> prod_rel R1 R2) Pair Pair"
kaliszyk@35222
    48
  by simp
kaliszyk@35222
    49
kaliszyk@35222
    50
lemma Pair_prs[quot_preserve]:
kaliszyk@35222
    51
  assumes q1: "Quotient R1 Abs1 Rep1"
kaliszyk@35222
    52
  assumes q2: "Quotient R2 Abs2 Rep2"
kaliszyk@35222
    53
  shows "(Rep1 ---> Rep2 ---> (prod_fun Abs1 Abs2)) Pair = Pair"
nipkow@39198
    54
  apply(simp add: ext_iff)
kaliszyk@35222
    55
  apply(simp add: Quotient_abs_rep[OF q1] Quotient_abs_rep[OF q2])
kaliszyk@35222
    56
  done
kaliszyk@35222
    57
kaliszyk@35222
    58
lemma fst_rsp[quot_respect]:
kaliszyk@35222
    59
  assumes "Quotient R1 Abs1 Rep1"
kaliszyk@35222
    60
  assumes "Quotient R2 Abs2 Rep2"
kaliszyk@35222
    61
  shows "(prod_rel R1 R2 ===> R1) fst fst"
kaliszyk@35222
    62
  by simp
kaliszyk@35222
    63
kaliszyk@35222
    64
lemma fst_prs[quot_preserve]:
kaliszyk@35222
    65
  assumes q1: "Quotient R1 Abs1 Rep1"
kaliszyk@35222
    66
  assumes q2: "Quotient R2 Abs2 Rep2"
kaliszyk@35222
    67
  shows "(prod_fun Rep1 Rep2 ---> Abs1) fst = fst"
nipkow@39198
    68
  apply(simp add: ext_iff)
kaliszyk@35222
    69
  apply(simp add: Quotient_abs_rep[OF q1])
kaliszyk@35222
    70
  done
kaliszyk@35222
    71
kaliszyk@35222
    72
lemma snd_rsp[quot_respect]:
kaliszyk@35222
    73
  assumes "Quotient R1 Abs1 Rep1"
kaliszyk@35222
    74
  assumes "Quotient R2 Abs2 Rep2"
kaliszyk@35222
    75
  shows "(prod_rel R1 R2 ===> R2) snd snd"
kaliszyk@35222
    76
  by simp
kaliszyk@35222
    77
kaliszyk@35222
    78
lemma snd_prs[quot_preserve]:
kaliszyk@35222
    79
  assumes q1: "Quotient R1 Abs1 Rep1"
kaliszyk@35222
    80
  assumes q2: "Quotient R2 Abs2 Rep2"
kaliszyk@35222
    81
  shows "(prod_fun Rep1 Rep2 ---> Abs2) snd = snd"
nipkow@39198
    82
  apply(simp add: ext_iff)
kaliszyk@35222
    83
  apply(simp add: Quotient_abs_rep[OF q2])
kaliszyk@35222
    84
  done
kaliszyk@35222
    85
kaliszyk@35222
    86
lemma split_rsp[quot_respect]:
kaliszyk@35222
    87
  shows "((R1 ===> R2 ===> (op =)) ===> (prod_rel R1 R2) ===> (op =)) split split"
kaliszyk@35222
    88
  by auto
kaliszyk@35222
    89
kaliszyk@35222
    90
lemma split_prs[quot_preserve]:
kaliszyk@35222
    91
  assumes q1: "Quotient R1 Abs1 Rep1"
kaliszyk@35222
    92
  and     q2: "Quotient R2 Abs2 Rep2"
kaliszyk@35222
    93
  shows "(((Abs1 ---> Abs2 ---> id) ---> prod_fun Rep1 Rep2 ---> id) split) = split"
nipkow@39198
    94
  by (simp add: ext_iff Quotient_abs_rep[OF q1] Quotient_abs_rep[OF q2])
kaliszyk@35222
    95
kaliszyk@36695
    96
lemma [quot_respect]:
kaliszyk@36695
    97
  shows "((R2 ===> R2 ===> op =) ===> (R1 ===> R1 ===> op =) ===>
kaliszyk@36695
    98
  prod_rel R2 R1 ===> prod_rel R2 R1 ===> op =) prod_rel prod_rel"
kaliszyk@36695
    99
  by auto
kaliszyk@36695
   100
kaliszyk@36695
   101
lemma [quot_preserve]:
kaliszyk@36695
   102
  assumes q1: "Quotient R1 abs1 rep1"
kaliszyk@36695
   103
  and     q2: "Quotient R2 abs2 rep2"
kaliszyk@36695
   104
  shows "((abs1 ---> abs1 ---> id) ---> (abs2 ---> abs2 ---> id) --->
kaliszyk@36695
   105
  prod_fun rep1 rep2 ---> prod_fun rep1 rep2 ---> id) prod_rel = prod_rel"
nipkow@39198
   106
  by (simp add: ext_iff Quotient_abs_rep[OF q1] Quotient_abs_rep[OF q2])
kaliszyk@36695
   107
kaliszyk@36695
   108
lemma [quot_preserve]:
kaliszyk@36695
   109
  shows"(prod_rel ((rep1 ---> rep1 ---> id) R1) ((rep2 ---> rep2 ---> id) R2)
kaliszyk@36695
   110
  (l1, l2) (r1, r2)) = (R1 (rep1 l1) (rep1 r1) \<and> R2 (rep2 l2) (rep2 r2))"
kaliszyk@36695
   111
  by simp
kaliszyk@36695
   112
kaliszyk@36695
   113
declare Pair_eq[quot_preserve]
kaliszyk@36695
   114
kaliszyk@35222
   115
lemma prod_fun_id[id_simps]:
kaliszyk@35222
   116
  shows "prod_fun id id = id"
kaliszyk@35222
   117
  by (simp add: prod_fun_def)
kaliszyk@35222
   118
kaliszyk@35222
   119
lemma prod_rel_eq[id_simps]:
kaliszyk@35222
   120
  shows "prod_rel (op =) (op =) = (op =)"
nipkow@39198
   121
  by (simp add: ext_iff)
kaliszyk@35222
   122
kaliszyk@35222
   123
end