src/HOL/Library/Quotient_Product.thy
author kuncar
Fri Dec 09 18:07:04 2011 +0100 (2011-12-09)
changeset 45802 b16f976db515
parent 41372 551eb49a6e91
child 47094 1a7ad2601cb5
permissions -rw-r--r--
Quotient_Info stores only relation maps
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@40541
    12
  prod_rel :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> ('c \<Rightarrow> 'd \<Rightarrow> bool) \<Rightarrow> 'a \<times> 'c \<Rightarrow> 'b \<times> 'd \<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
kuncar@45802
    16
declare [[map prod = 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
haftmann@40820
    22
lemma map_pair_id [id_simps]:
haftmann@40820
    23
  shows "map_pair id id = id"
haftmann@40820
    24
  by (simp add: fun_eq_iff)
haftmann@40820
    25
haftmann@40820
    26
lemma prod_rel_eq [id_simps]:
haftmann@40820
    27
  shows "prod_rel (op =) (op =) = (op =)"
haftmann@40820
    28
  by (simp add: fun_eq_iff)
haftmann@40820
    29
haftmann@40820
    30
lemma prod_equivp [quot_equiv]:
haftmann@40820
    31
  assumes "equivp R1"
haftmann@40820
    32
  assumes "equivp R2"
kaliszyk@35222
    33
  shows "equivp (prod_rel R1 R2)"
haftmann@40820
    34
  using assms by (auto intro!: equivpI reflpI sympI transpI elim!: equivpE elim: reflpE sympE transpE)
haftmann@40820
    35
haftmann@40820
    36
lemma prod_quotient [quot_thm]:
haftmann@40820
    37
  assumes "Quotient R1 Abs1 Rep1"
haftmann@40820
    38
  assumes "Quotient R2 Abs2 Rep2"
haftmann@40820
    39
  shows "Quotient (prod_rel R1 R2) (map_pair Abs1 Abs2) (map_pair Rep1 Rep2)"
haftmann@40820
    40
  apply (rule QuotientI)
haftmann@41372
    41
  apply (simp add: map_pair.compositionality comp_def map_pair.identity
haftmann@40820
    42
     Quotient_abs_rep [OF assms(1)] Quotient_abs_rep [OF assms(2)])
haftmann@40820
    43
  apply (simp add: split_paired_all Quotient_rel_rep [OF assms(1)] Quotient_rel_rep [OF assms(2)])
haftmann@40820
    44
  using Quotient_rel [OF assms(1)] Quotient_rel [OF assms(2)]
haftmann@40820
    45
  apply (auto simp add: split_paired_all)
kaliszyk@35222
    46
  done
kaliszyk@35222
    47
haftmann@40820
    48
lemma Pair_rsp [quot_respect]:
kaliszyk@35222
    49
  assumes q1: "Quotient R1 Abs1 Rep1"
kaliszyk@35222
    50
  assumes q2: "Quotient R2 Abs2 Rep2"
kaliszyk@35222
    51
  shows "(R1 ===> R2 ===> prod_rel R1 R2) Pair Pair"
haftmann@40465
    52
  by (auto simp add: prod_rel_def)
kaliszyk@35222
    53
haftmann@40820
    54
lemma Pair_prs [quot_preserve]:
kaliszyk@35222
    55
  assumes q1: "Quotient R1 Abs1 Rep1"
kaliszyk@35222
    56
  assumes q2: "Quotient R2 Abs2 Rep2"
haftmann@40607
    57
  shows "(Rep1 ---> Rep2 ---> (map_pair Abs1 Abs2)) Pair = Pair"
nipkow@39302
    58
  apply(simp add: fun_eq_iff)
kaliszyk@35222
    59
  apply(simp add: Quotient_abs_rep[OF q1] Quotient_abs_rep[OF q2])
kaliszyk@35222
    60
  done
kaliszyk@35222
    61
haftmann@40820
    62
lemma fst_rsp [quot_respect]:
kaliszyk@35222
    63
  assumes "Quotient R1 Abs1 Rep1"
kaliszyk@35222
    64
  assumes "Quotient R2 Abs2 Rep2"
kaliszyk@35222
    65
  shows "(prod_rel R1 R2 ===> R1) fst fst"
haftmann@40465
    66
  by auto
kaliszyk@35222
    67
haftmann@40820
    68
lemma fst_prs [quot_preserve]:
kaliszyk@35222
    69
  assumes q1: "Quotient R1 Abs1 Rep1"
kaliszyk@35222
    70
  assumes q2: "Quotient R2 Abs2 Rep2"
haftmann@40607
    71
  shows "(map_pair Rep1 Rep2 ---> Abs1) fst = fst"
haftmann@40465
    72
  by (simp add: fun_eq_iff Quotient_abs_rep[OF q1])
kaliszyk@35222
    73
haftmann@40820
    74
lemma snd_rsp [quot_respect]:
kaliszyk@35222
    75
  assumes "Quotient R1 Abs1 Rep1"
kaliszyk@35222
    76
  assumes "Quotient R2 Abs2 Rep2"
kaliszyk@35222
    77
  shows "(prod_rel R1 R2 ===> R2) snd snd"
haftmann@40465
    78
  by auto
kaliszyk@35222
    79
haftmann@40820
    80
lemma snd_prs [quot_preserve]:
kaliszyk@35222
    81
  assumes q1: "Quotient R1 Abs1 Rep1"
kaliszyk@35222
    82
  assumes q2: "Quotient R2 Abs2 Rep2"
haftmann@40607
    83
  shows "(map_pair Rep1 Rep2 ---> Abs2) snd = snd"
haftmann@40465
    84
  by (simp add: fun_eq_iff Quotient_abs_rep[OF q2])
kaliszyk@35222
    85
haftmann@40820
    86
lemma split_rsp [quot_respect]:
kaliszyk@35222
    87
  shows "((R1 ===> R2 ===> (op =)) ===> (prod_rel R1 R2) ===> (op =)) split split"
haftmann@40465
    88
  by (auto intro!: fun_relI elim!: fun_relE)
kaliszyk@35222
    89
haftmann@40820
    90
lemma split_prs [quot_preserve]:
kaliszyk@35222
    91
  assumes q1: "Quotient R1 Abs1 Rep1"
kaliszyk@35222
    92
  and     q2: "Quotient R2 Abs2 Rep2"
haftmann@40607
    93
  shows "(((Abs1 ---> Abs2 ---> id) ---> map_pair Rep1 Rep2 ---> id) split) = split"
nipkow@39302
    94
  by (simp add: fun_eq_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"
haftmann@40465
    99
  by (auto simp add: fun_rel_def)
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) --->
haftmann@40607
   105
  map_pair rep1 rep2 ---> map_pair rep1 rep2 ---> id) prod_rel = prod_rel"
nipkow@39302
   106
  by (simp add: fun_eq_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
end