src/HOL/Lifting_Sum.thy
 author blanchet Thu Mar 06 15:40:33 2014 +0100 (2014-03-06) changeset 55945 e96383acecf9 parent 55943 5c2df04e97d1 child 56518 beb3b6851665 permissions -rw-r--r--
renamed 'fun_rel' to 'rel_fun'
```     1 (*  Title:      HOL/Lifting_Sum.thy
```
```     2     Author:     Brian Huffman and Ondrej Kuncar
```
```     3 *)
```
```     4
```
```     5 header {* Setup for Lifting/Transfer for the sum type *}
```
```     6
```
```     7 theory Lifting_Sum
```
```     8 imports Lifting Basic_BNFs
```
```     9 begin
```
```    10
```
```    11 subsection {* Relator and predicator properties *}
```
```    12
```
```    13 abbreviation (input) "sum_pred \<equiv> case_sum"
```
```    14
```
```    15 lemmas rel_sum_eq[relator_eq] = sum.rel_eq
```
```    16 lemmas rel_sum_mono[relator_mono] = sum.rel_mono
```
```    17
```
```    18 lemma rel_sum_OO[relator_distr]:
```
```    19   "(rel_sum A B) OO (rel_sum C D) = rel_sum (A OO C) (B OO D)"
```
```    20   by (rule ext)+ (auto simp add: rel_sum_def OO_def split_sum_ex split: sum.split)
```
```    21
```
```    22 lemma Domainp_sum[relator_domain]:
```
```    23   assumes "Domainp R1 = P1"
```
```    24   assumes "Domainp R2 = P2"
```
```    25   shows "Domainp (rel_sum R1 R2) = (sum_pred P1 P2)"
```
```    26 using assms
```
```    27 by (auto simp add: Domainp_iff split_sum_ex iff: fun_eq_iff split: sum.split)
```
```    28
```
```    29 lemma left_total_rel_sum[reflexivity_rule]:
```
```    30   "left_total R1 \<Longrightarrow> left_total R2 \<Longrightarrow> left_total (rel_sum R1 R2)"
```
```    31   using assms unfolding left_total_def split_sum_all split_sum_ex by simp
```
```    32
```
```    33 lemma left_unique_rel_sum [reflexivity_rule]:
```
```    34   "left_unique R1 \<Longrightarrow> left_unique R2 \<Longrightarrow> left_unique (rel_sum R1 R2)"
```
```    35   using assms unfolding left_unique_def split_sum_all by simp
```
```    36
```
```    37 lemma right_total_rel_sum [transfer_rule]:
```
```    38   "right_total R1 \<Longrightarrow> right_total R2 \<Longrightarrow> right_total (rel_sum R1 R2)"
```
```    39   unfolding right_total_def split_sum_all split_sum_ex by simp
```
```    40
```
```    41 lemma right_unique_rel_sum [transfer_rule]:
```
```    42   "right_unique R1 \<Longrightarrow> right_unique R2 \<Longrightarrow> right_unique (rel_sum R1 R2)"
```
```    43   unfolding right_unique_def split_sum_all by simp
```
```    44
```
```    45 lemma bi_total_rel_sum [transfer_rule]:
```
```    46   "bi_total R1 \<Longrightarrow> bi_total R2 \<Longrightarrow> bi_total (rel_sum R1 R2)"
```
```    47   using assms unfolding bi_total_def split_sum_all split_sum_ex by simp
```
```    48
```
```    49 lemma bi_unique_rel_sum [transfer_rule]:
```
```    50   "bi_unique R1 \<Longrightarrow> bi_unique R2 \<Longrightarrow> bi_unique (rel_sum R1 R2)"
```
```    51   using assms unfolding bi_unique_def split_sum_all by simp
```
```    52
```
```    53 lemma sum_invariant_commute [invariant_commute]:
```
```    54   "rel_sum (Lifting.invariant P1) (Lifting.invariant P2) = Lifting.invariant (sum_pred P1 P2)"
```
```    55   by (auto simp add: fun_eq_iff Lifting.invariant_def rel_sum_def split: sum.split)
```
```    56
```
```    57 subsection {* Quotient theorem for the Lifting package *}
```
```    58
```
```    59 lemma Quotient_sum[quot_map]:
```
```    60   assumes "Quotient R1 Abs1 Rep1 T1"
```
```    61   assumes "Quotient R2 Abs2 Rep2 T2"
```
```    62   shows "Quotient (rel_sum R1 R2) (map_sum Abs1 Abs2) (map_sum Rep1 Rep2) (rel_sum T1 T2)"
```
```    63   using assms unfolding Quotient_alt_def
```
```    64   by (simp add: split_sum_all)
```
```    65
```
```    66 subsection {* Transfer rules for the Transfer package *}
```
```    67
```
```    68 context
```
```    69 begin
```
```    70 interpretation lifting_syntax .
```
```    71
```
```    72 lemma Inl_transfer [transfer_rule]: "(A ===> rel_sum A B) Inl Inl"
```
```    73   unfolding rel_fun_def by simp
```
```    74
```
```    75 lemma Inr_transfer [transfer_rule]: "(B ===> rel_sum A B) Inr Inr"
```
```    76   unfolding rel_fun_def by simp
```
```    77
```
```    78 lemma case_sum_transfer [transfer_rule]:
```
```    79   "((A ===> C) ===> (B ===> C) ===> rel_sum A B ===> C) case_sum case_sum"
```
```    80   unfolding rel_fun_def rel_sum_def by (simp split: sum.split)
```
```    81
```
```    82 end
```
```    83
```
```    84 end
```