src/HOL/Library/Quotient_Product.thy
author haftmann
Wed Jul 18 20:51:21 2018 +0200 (11 months ago)
changeset 68658 16cc1161ad7f
parent 67399 eab6ce8368fa
permissions -rw-r--r--
tuned equation
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@60500
     5
section \<open>Quotient infrastructure for the product type\<close>
wenzelm@35788
     6
kaliszyk@35222
     7
theory Quotient_Product
wenzelm@62954
     8
imports Quotient_Syntax
kaliszyk@35222
     9
begin
kaliszyk@35222
    10
wenzelm@60500
    11
subsection \<open>Rules for the Quotient package\<close>
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
blanchet@55944
    17
lemma rel_prod_eq [id_simps]:
nipkow@67399
    18
  shows "rel_prod (=) (=) = (=)"
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"
blanchet@55944
    24
  shows "equivp (rel_prod 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@55944
    30
  shows "Quotient3 (rel_prod 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
blanchet@55944
    39
declare [[mapQ3 prod = (rel_prod, 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"
blanchet@55944
    44
  shows "(R1 ===> R2 ===> rel_prod 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"
blanchet@55944
    58
  shows "(rel_prod 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"
blanchet@55944
    70
  shows "(rel_prod 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@61424
    79
lemma case_prod_rsp [quot_respect]:
nipkow@67399
    80
  shows "((R1 ===> R2 ===> (=)) ===> (rel_prod R1 R2) ===> (=)) case_prod case_prod"
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"
haftmann@61424
    86
  shows "(((Abs1 ---> Abs2 ---> id) ---> map_prod Rep1 Rep2 ---> id) case_prod) = case_prod"
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]:
nipkow@67399
    90
  shows "((R2 ===> R2 ===> (=)) ===> (R1 ===> R1 ===> (=)) ===>
nipkow@67399
    91
  rel_prod R2 R1 ===> rel_prod R2 R1 ===> (=)) rel_prod rel_prod"
traytel@58916
    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@55944
    98
  map_prod rep1 rep2 ---> map_prod rep1 rep2 ---> id) rel_prod = rel_prod"
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]:
blanchet@55944
   102
  shows"(rel_prod ((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
haftmann@61424
   106
declare prod.inject[quot_preserve]
kaliszyk@36695
   107
kaliszyk@35222
   108
end