src/HOL/Library/Quotient_Product.thy
author kuncar
Tue Apr 03 16:26:48 2012 +0200 (2012-04-03)
changeset 47308 9caab698dbe4
parent 47301 ca743eafa1dd
child 47455 26315a545e26
permissions -rw-r--r--
new package Lifting - initial commit
kuncar@47308
     1
(*  Title:      HOL/Library/Quotient3_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
haftmann@40465
    16
lemma prod_rel_apply [simp]:
haftmann@40465
    17
  "prod_rel R1 R2 (a, b) (c, d) \<longleftrightarrow> R1 a c \<and> R2 b d"
haftmann@40465
    18
  by (simp add: prod_rel_def)
kaliszyk@35222
    19
haftmann@40820
    20
lemma map_pair_id [id_simps]:
haftmann@40820
    21
  shows "map_pair id id = id"
haftmann@40820
    22
  by (simp add: fun_eq_iff)
haftmann@40820
    23
haftmann@40820
    24
lemma prod_rel_eq [id_simps]:
haftmann@40820
    25
  shows "prod_rel (op =) (op =) = (op =)"
haftmann@40820
    26
  by (simp add: fun_eq_iff)
haftmann@40820
    27
haftmann@40820
    28
lemma prod_equivp [quot_equiv]:
haftmann@40820
    29
  assumes "equivp R1"
haftmann@40820
    30
  assumes "equivp R2"
kaliszyk@35222
    31
  shows "equivp (prod_rel R1 R2)"
haftmann@40820
    32
  using assms by (auto intro!: equivpI reflpI sympI transpI elim!: equivpE elim: reflpE sympE transpE)
haftmann@40820
    33
haftmann@40820
    34
lemma prod_quotient [quot_thm]:
kuncar@47308
    35
  assumes "Quotient3 R1 Abs1 Rep1"
kuncar@47308
    36
  assumes "Quotient3 R2 Abs2 Rep2"
kuncar@47308
    37
  shows "Quotient3 (prod_rel R1 R2) (map_pair Abs1 Abs2) (map_pair Rep1 Rep2)"
kuncar@47308
    38
  apply (rule Quotient3I)
haftmann@41372
    39
  apply (simp add: map_pair.compositionality comp_def map_pair.identity
kuncar@47308
    40
     Quotient3_abs_rep [OF assms(1)] Quotient3_abs_rep [OF assms(2)])
kuncar@47308
    41
  apply (simp add: split_paired_all Quotient3_rel_rep [OF assms(1)] Quotient3_rel_rep [OF assms(2)])
kuncar@47308
    42
  using Quotient3_rel [OF assms(1)] Quotient3_rel [OF assms(2)]
haftmann@40820
    43
  apply (auto simp add: split_paired_all)
kaliszyk@35222
    44
  done
kaliszyk@35222
    45
kuncar@47308
    46
declare [[mapQ3 prod = (prod_rel, prod_quotient)]]
kuncar@47094
    47
haftmann@40820
    48
lemma Pair_rsp [quot_respect]:
kuncar@47308
    49
  assumes q1: "Quotient3 R1 Abs1 Rep1"
kuncar@47308
    50
  assumes q2: "Quotient3 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]:
kuncar@47308
    55
  assumes q1: "Quotient3 R1 Abs1 Rep1"
kuncar@47308
    56
  assumes q2: "Quotient3 R2 Abs2 Rep2"
haftmann@40607
    57
  shows "(Rep1 ---> Rep2 ---> (map_pair Abs1 Abs2)) Pair = Pair"
nipkow@39302
    58
  apply(simp add: fun_eq_iff)
kuncar@47308
    59
  apply(simp add: Quotient3_abs_rep[OF q1] Quotient3_abs_rep[OF q2])
kaliszyk@35222
    60
  done
kaliszyk@35222
    61
haftmann@40820
    62
lemma fst_rsp [quot_respect]:
kuncar@47308
    63
  assumes "Quotient3 R1 Abs1 Rep1"
kuncar@47308
    64
  assumes "Quotient3 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]:
kuncar@47308
    69
  assumes q1: "Quotient3 R1 Abs1 Rep1"
kuncar@47308
    70
  assumes q2: "Quotient3 R2 Abs2 Rep2"
haftmann@40607
    71
  shows "(map_pair Rep1 Rep2 ---> Abs1) fst = fst"
kuncar@47308
    72
  by (simp add: fun_eq_iff Quotient3_abs_rep[OF q1])
kaliszyk@35222
    73
haftmann@40820
    74
lemma snd_rsp [quot_respect]:
kuncar@47308
    75
  assumes "Quotient3 R1 Abs1 Rep1"
kuncar@47308
    76
  assumes "Quotient3 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]:
kuncar@47308
    81
  assumes q1: "Quotient3 R1 Abs1 Rep1"
kuncar@47308
    82
  assumes q2: "Quotient3 R2 Abs2 Rep2"
haftmann@40607
    83
  shows "(map_pair Rep1 Rep2 ---> Abs2) snd = snd"
kuncar@47308
    84
  by (simp add: fun_eq_iff Quotient3_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"
urbanc@47301
    88
  unfolding prod_rel_def fun_rel_def
urbanc@47301
    89
  by auto
kaliszyk@35222
    90
haftmann@40820
    91
lemma split_prs [quot_preserve]:
kuncar@47308
    92
  assumes q1: "Quotient3 R1 Abs1 Rep1"
kuncar@47308
    93
  and     q2: "Quotient3 R2 Abs2 Rep2"
haftmann@40607
    94
  shows "(((Abs1 ---> Abs2 ---> id) ---> map_pair Rep1 Rep2 ---> id) split) = split"
kuncar@47308
    95
  by (simp add: fun_eq_iff Quotient3_abs_rep[OF q1] Quotient3_abs_rep[OF q2])
kaliszyk@35222
    96
kaliszyk@36695
    97
lemma [quot_respect]:
kaliszyk@36695
    98
  shows "((R2 ===> R2 ===> op =) ===> (R1 ===> R1 ===> op =) ===>
kaliszyk@36695
    99
  prod_rel R2 R1 ===> prod_rel R2 R1 ===> op =) prod_rel prod_rel"
haftmann@40465
   100
  by (auto simp add: fun_rel_def)
kaliszyk@36695
   101
kaliszyk@36695
   102
lemma [quot_preserve]:
kuncar@47308
   103
  assumes q1: "Quotient3 R1 abs1 rep1"
kuncar@47308
   104
  and     q2: "Quotient3 R2 abs2 rep2"
kaliszyk@36695
   105
  shows "((abs1 ---> abs1 ---> id) ---> (abs2 ---> abs2 ---> id) --->
haftmann@40607
   106
  map_pair rep1 rep2 ---> map_pair rep1 rep2 ---> id) prod_rel = prod_rel"
kuncar@47308
   107
  by (simp add: fun_eq_iff Quotient3_abs_rep[OF q1] Quotient3_abs_rep[OF q2])
kaliszyk@36695
   108
kaliszyk@36695
   109
lemma [quot_preserve]:
kaliszyk@36695
   110
  shows"(prod_rel ((rep1 ---> rep1 ---> id) R1) ((rep2 ---> rep2 ---> id) R2)
kaliszyk@36695
   111
  (l1, l2) (r1, r2)) = (R1 (rep1 l1) (rep1 r1) \<and> R2 (rep2 l2) (rep2 r2))"
kaliszyk@36695
   112
  by simp
kaliszyk@36695
   113
kaliszyk@36695
   114
declare Pair_eq[quot_preserve]
kaliszyk@36695
   115
kaliszyk@35222
   116
end