src/HOL/Library/Quotient_Sum.thy
author blanchet
Thu Mar 06 13:36:15 2014 +0100 (2014-03-06)
changeset 55931 62156e694f3d
parent 55564 e81ee43ab290
child 55943 5c2df04e97d1
permissions -rw-r--r--
renamed 'map_sum' to 'sum_map'
wenzelm@47455
     1
(*  Title:      HOL/Library/Quotient_Sum.thy
kuncar@53012
     2
    Author:     Cezary Kaliszyk and Christian Urban
kaliszyk@35222
     3
*)
wenzelm@35788
     4
wenzelm@35788
     5
header {* Quotient infrastructure for the sum type *}
wenzelm@35788
     6
kaliszyk@35222
     7
theory Quotient_Sum
kaliszyk@35222
     8
imports Main Quotient_Syntax
kaliszyk@35222
     9
begin
kaliszyk@35222
    10
kuncar@53012
    11
subsection {* Rules for the Quotient package *}
kuncar@51956
    12
haftmann@40820
    13
lemma sum_rel_map1:
blanchet@55931
    14
  "sum_rel R1 R2 (map_sum f1 f2 x) y \<longleftrightarrow> sum_rel (\<lambda>x. R1 (f1 x)) (\<lambda>x. R2 (f2 x)) x y"
traytel@53026
    15
  by (simp add: sum_rel_def split: sum.split)
haftmann@40820
    16
haftmann@40820
    17
lemma sum_rel_map2:
blanchet@55931
    18
  "sum_rel R1 R2 x (map_sum f1 f2 y) \<longleftrightarrow> sum_rel (\<lambda>x y. R1 x (f1 y)) (\<lambda>x y. R2 x (f2 y)) x y"
traytel@53026
    19
  by (simp add: sum_rel_def split: sum.split)
haftmann@40820
    20
blanchet@55931
    21
lemma map_sum_id [id_simps]:
blanchet@55931
    22
  "map_sum id id = id"
blanchet@55931
    23
  by (simp add: id_def map_sum.identity fun_eq_iff)
kaliszyk@35222
    24
kuncar@53012
    25
lemma sum_rel_eq [id_simps]:
haftmann@40820
    26
  "sum_rel (op =) (op =) = (op =)"
traytel@53026
    27
  by (simp add: sum_rel_def fun_eq_iff split: sum.split)
haftmann@40820
    28
kuncar@55564
    29
lemma reflp_sum_rel:
kuncar@55564
    30
  "reflp R1 \<Longrightarrow> reflp R2 \<Longrightarrow> reflp (sum_rel R1 R2)"
kuncar@55564
    31
  unfolding reflp_def split_sum_all sum_rel_simps by fast
kuncar@55564
    32
haftmann@40820
    33
lemma sum_symp:
haftmann@40820
    34
  "symp R1 \<Longrightarrow> symp R2 \<Longrightarrow> symp (sum_rel R1 R2)"
traytel@53026
    35
  unfolding symp_def split_sum_all sum_rel_simps by fast
haftmann@40820
    36
haftmann@40820
    37
lemma sum_transp:
haftmann@40820
    38
  "transp R1 \<Longrightarrow> transp R2 \<Longrightarrow> transp (sum_rel R1 R2)"
traytel@53026
    39
  unfolding transp_def split_sum_all sum_rel_simps by fast
haftmann@40820
    40
haftmann@40820
    41
lemma sum_equivp [quot_equiv]:
haftmann@40820
    42
  "equivp R1 \<Longrightarrow> equivp R2 \<Longrightarrow> equivp (sum_rel R1 R2)"
kuncar@51994
    43
  by (blast intro: equivpI reflp_sum_rel sum_symp sum_transp elim: equivpE)
huffman@47624
    44
haftmann@40820
    45
lemma sum_quotient [quot_thm]:
kuncar@47308
    46
  assumes q1: "Quotient3 R1 Abs1 Rep1"
kuncar@47308
    47
  assumes q2: "Quotient3 R2 Abs2 Rep2"
blanchet@55931
    48
  shows "Quotient3 (sum_rel R1 R2) (map_sum Abs1 Abs2) (map_sum Rep1 Rep2)"
kuncar@47308
    49
  apply (rule Quotient3I)
blanchet@55931
    50
  apply (simp_all add: map_sum.compositionality comp_def map_sum.identity sum_rel_eq sum_rel_map1 sum_rel_map2
kuncar@47308
    51
    Quotient3_abs_rep [OF q1] Quotient3_rel_rep [OF q1] Quotient3_abs_rep [OF q2] Quotient3_rel_rep [OF q2])
kuncar@47308
    52
  using Quotient3_rel [OF q1] Quotient3_rel [OF q2]
traytel@53026
    53
  apply (simp add: sum_rel_def comp_def split: sum.split)
kaliszyk@35222
    54
  done
kaliszyk@35222
    55
kuncar@47308
    56
declare [[mapQ3 sum = (sum_rel, sum_quotient)]]
kuncar@47094
    57
haftmann@40820
    58
lemma sum_Inl_rsp [quot_respect]:
kuncar@47308
    59
  assumes q1: "Quotient3 R1 Abs1 Rep1"
kuncar@47308
    60
  assumes q2: "Quotient3 R2 Abs2 Rep2"
kaliszyk@35222
    61
  shows "(R1 ===> sum_rel R1 R2) Inl Inl"
haftmann@40465
    62
  by auto
kaliszyk@35222
    63
haftmann@40820
    64
lemma sum_Inr_rsp [quot_respect]:
kuncar@47308
    65
  assumes q1: "Quotient3 R1 Abs1 Rep1"
kuncar@47308
    66
  assumes q2: "Quotient3 R2 Abs2 Rep2"
kaliszyk@35222
    67
  shows "(R2 ===> sum_rel R1 R2) Inr Inr"
haftmann@40465
    68
  by auto
kaliszyk@35222
    69
haftmann@40820
    70
lemma sum_Inl_prs [quot_preserve]:
kuncar@47308
    71
  assumes q1: "Quotient3 R1 Abs1 Rep1"
kuncar@47308
    72
  assumes q2: "Quotient3 R2 Abs2 Rep2"
blanchet@55931
    73
  shows "(Rep1 ---> map_sum Abs1 Abs2) Inl = Inl"
nipkow@39302
    74
  apply(simp add: fun_eq_iff)
kuncar@47308
    75
  apply(simp add: Quotient3_abs_rep[OF q1])
kaliszyk@35222
    76
  done
kaliszyk@35222
    77
haftmann@40820
    78
lemma sum_Inr_prs [quot_preserve]:
kuncar@47308
    79
  assumes q1: "Quotient3 R1 Abs1 Rep1"
kuncar@47308
    80
  assumes q2: "Quotient3 R2 Abs2 Rep2"
blanchet@55931
    81
  shows "(Rep2 ---> map_sum Abs1 Abs2) Inr = Inr"
nipkow@39302
    82
  apply(simp add: fun_eq_iff)
kuncar@47308
    83
  apply(simp add: Quotient3_abs_rep[OF q2])
kaliszyk@35222
    84
  done
kaliszyk@35222
    85
kaliszyk@35222
    86
end