src/HOL/Library/Quotient_Product.thy
author haftmann
Tue Nov 09 14:02:13 2010 +0100 (2010-11-09)
changeset 40465 2989f9f3aa10
parent 39302 d7728f65b353
child 40541 7850b4cc1507
permissions -rw-r--r--
more appropriate specification packages; fun_rel_def is no simp rule by default
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
haftmann@40465
    11
definition
haftmann@40465
    12
  prod_rel :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> ('b \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> 'a \<times> 'b \<Rightarrow> 'a \<times> 'b \<Rightarrow> bool"
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
haftmann@40465
    18
lemma prod_rel_apply [simp]:
haftmann@40465
    19
  "prod_rel R1 R2 (a, b) (c, d) \<longleftrightarrow> R1 a c \<and> R2 b d"
haftmann@40465
    20
  by (simp add: prod_rel_def)
kaliszyk@35222
    21
kaliszyk@35222
    22
lemma prod_equivp[quot_equiv]:
kaliszyk@35222
    23
  assumes a: "equivp R1"
kaliszyk@35222
    24
  assumes b: "equivp R2"
kaliszyk@35222
    25
  shows "equivp (prod_rel R1 R2)"
kaliszyk@35222
    26
  apply(rule equivpI)
kaliszyk@35222
    27
  unfolding reflp_def symp_def transp_def
haftmann@40465
    28
  apply(simp_all add: split_paired_all prod_rel_def)
kaliszyk@35222
    29
  apply(blast intro: equivp_reflp[OF a] equivp_reflp[OF b])
kaliszyk@35222
    30
  apply(blast intro: equivp_symp[OF a] equivp_symp[OF b])
kaliszyk@35222
    31
  apply(blast intro: equivp_transp[OF a] equivp_transp[OF b])
kaliszyk@35222
    32
  done
kaliszyk@35222
    33
kaliszyk@35222
    34
lemma prod_quotient[quot_thm]:
kaliszyk@35222
    35
  assumes q1: "Quotient R1 Abs1 Rep1"
kaliszyk@35222
    36
  assumes q2: "Quotient R2 Abs2 Rep2"
kaliszyk@35222
    37
  shows "Quotient (prod_rel R1 R2) (prod_fun Abs1 Abs2) (prod_fun Rep1 Rep2)"
kaliszyk@35222
    38
  unfolding Quotient_def
kaliszyk@35222
    39
  apply(simp add: split_paired_all)
kaliszyk@35222
    40
  apply(simp add: Quotient_abs_rep[OF q1] Quotient_rel_rep[OF q1])
kaliszyk@35222
    41
  apply(simp add: Quotient_abs_rep[OF q2] Quotient_rel_rep[OF q2])
kaliszyk@35222
    42
  using q1 q2
kaliszyk@35222
    43
  unfolding Quotient_def
kaliszyk@35222
    44
  apply(blast)
kaliszyk@35222
    45
  done
kaliszyk@35222
    46
kaliszyk@35222
    47
lemma Pair_rsp[quot_respect]:
kaliszyk@35222
    48
  assumes q1: "Quotient R1 Abs1 Rep1"
kaliszyk@35222
    49
  assumes q2: "Quotient R2 Abs2 Rep2"
kaliszyk@35222
    50
  shows "(R1 ===> R2 ===> prod_rel R1 R2) Pair Pair"
haftmann@40465
    51
  by (auto simp add: prod_rel_def)
kaliszyk@35222
    52
kaliszyk@35222
    53
lemma Pair_prs[quot_preserve]:
kaliszyk@35222
    54
  assumes q1: "Quotient R1 Abs1 Rep1"
kaliszyk@35222
    55
  assumes q2: "Quotient R2 Abs2 Rep2"
kaliszyk@35222
    56
  shows "(Rep1 ---> Rep2 ---> (prod_fun Abs1 Abs2)) Pair = Pair"
nipkow@39302
    57
  apply(simp add: fun_eq_iff)
kaliszyk@35222
    58
  apply(simp add: Quotient_abs_rep[OF q1] Quotient_abs_rep[OF q2])
kaliszyk@35222
    59
  done
kaliszyk@35222
    60
kaliszyk@35222
    61
lemma fst_rsp[quot_respect]:
kaliszyk@35222
    62
  assumes "Quotient R1 Abs1 Rep1"
kaliszyk@35222
    63
  assumes "Quotient R2 Abs2 Rep2"
kaliszyk@35222
    64
  shows "(prod_rel R1 R2 ===> R1) fst fst"
haftmann@40465
    65
  by auto
kaliszyk@35222
    66
kaliszyk@35222
    67
lemma fst_prs[quot_preserve]:
kaliszyk@35222
    68
  assumes q1: "Quotient R1 Abs1 Rep1"
kaliszyk@35222
    69
  assumes q2: "Quotient R2 Abs2 Rep2"
kaliszyk@35222
    70
  shows "(prod_fun Rep1 Rep2 ---> Abs1) fst = fst"
haftmann@40465
    71
  by (simp add: fun_eq_iff Quotient_abs_rep[OF q1])
kaliszyk@35222
    72
kaliszyk@35222
    73
lemma snd_rsp[quot_respect]:
kaliszyk@35222
    74
  assumes "Quotient R1 Abs1 Rep1"
kaliszyk@35222
    75
  assumes "Quotient R2 Abs2 Rep2"
kaliszyk@35222
    76
  shows "(prod_rel R1 R2 ===> R2) snd snd"
haftmann@40465
    77
  by auto
kaliszyk@35222
    78
kaliszyk@35222
    79
lemma snd_prs[quot_preserve]:
kaliszyk@35222
    80
  assumes q1: "Quotient R1 Abs1 Rep1"
kaliszyk@35222
    81
  assumes q2: "Quotient R2 Abs2 Rep2"
kaliszyk@35222
    82
  shows "(prod_fun Rep1 Rep2 ---> Abs2) snd = snd"
haftmann@40465
    83
  by (simp add: fun_eq_iff Quotient_abs_rep[OF q2])
kaliszyk@35222
    84
kaliszyk@35222
    85
lemma split_rsp[quot_respect]:
kaliszyk@35222
    86
  shows "((R1 ===> R2 ===> (op =)) ===> (prod_rel R1 R2) ===> (op =)) split split"
haftmann@40465
    87
  by (auto intro!: fun_relI elim!: fun_relE)
kaliszyk@35222
    88
kaliszyk@35222
    89
lemma split_prs[quot_preserve]:
kaliszyk@35222
    90
  assumes q1: "Quotient R1 Abs1 Rep1"
kaliszyk@35222
    91
  and     q2: "Quotient R2 Abs2 Rep2"
kaliszyk@35222
    92
  shows "(((Abs1 ---> Abs2 ---> id) ---> prod_fun Rep1 Rep2 ---> id) split) = split"
nipkow@39302
    93
  by (simp add: fun_eq_iff Quotient_abs_rep[OF q1] Quotient_abs_rep[OF q2])
kaliszyk@35222
    94
kaliszyk@36695
    95
lemma [quot_respect]:
kaliszyk@36695
    96
  shows "((R2 ===> R2 ===> op =) ===> (R1 ===> R1 ===> op =) ===>
kaliszyk@36695
    97
  prod_rel R2 R1 ===> prod_rel R2 R1 ===> op =) prod_rel prod_rel"
haftmann@40465
    98
  by (auto simp add: fun_rel_def)
kaliszyk@36695
    99
kaliszyk@36695
   100
lemma [quot_preserve]:
kaliszyk@36695
   101
  assumes q1: "Quotient R1 abs1 rep1"
kaliszyk@36695
   102
  and     q2: "Quotient R2 abs2 rep2"
kaliszyk@36695
   103
  shows "((abs1 ---> abs1 ---> id) ---> (abs2 ---> abs2 ---> id) --->
kaliszyk@36695
   104
  prod_fun rep1 rep2 ---> prod_fun rep1 rep2 ---> id) prod_rel = prod_rel"
nipkow@39302
   105
  by (simp add: fun_eq_iff Quotient_abs_rep[OF q1] Quotient_abs_rep[OF q2])
kaliszyk@36695
   106
kaliszyk@36695
   107
lemma [quot_preserve]:
kaliszyk@36695
   108
  shows"(prod_rel ((rep1 ---> rep1 ---> id) R1) ((rep2 ---> rep2 ---> id) R2)
kaliszyk@36695
   109
  (l1, l2) (r1, r2)) = (R1 (rep1 l1) (rep1 r1) \<and> R2 (rep2 l2) (rep2 r2))"
kaliszyk@36695
   110
  by simp
kaliszyk@36695
   111
kaliszyk@36695
   112
declare Pair_eq[quot_preserve]
kaliszyk@36695
   113
kaliszyk@35222
   114
lemma prod_fun_id[id_simps]:
kaliszyk@35222
   115
  shows "prod_fun id id = id"
haftmann@40465
   116
  by (simp add: fun_eq_iff)
kaliszyk@35222
   117
kaliszyk@35222
   118
lemma prod_rel_eq[id_simps]:
kaliszyk@35222
   119
  shows "prod_rel (op =) (op =) = (op =)"
nipkow@39302
   120
  by (simp add: fun_eq_iff)
kaliszyk@35222
   121
kaliszyk@35222
   122
end