src/HOL/Lifting_Sum.thy
changeset 56525 b5b6ad5dc2ae
parent 56520 3373f5d1e074
child 56526 58ac520db7ae
equal deleted inserted replaced
56524:f4ba736040fa 56525:b5b6ad5dc2ae
     5 header {* Setup for Lifting/Transfer for the sum type *}
     5 header {* Setup for Lifting/Transfer for the sum type *}
     6 
     6 
     7 theory Lifting_Sum
     7 theory Lifting_Sum
     8 imports Lifting Basic_BNFs
     8 imports Lifting Basic_BNFs
     9 begin
     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   "Domainp (rel_sum R1 R2) = (sum_pred (Domainp R1) (Domainp R2))"
       
    24 by (auto simp add: Domainp_iff split_sum_ex iff: fun_eq_iff split: sum.split)
       
    25 
       
    26 lemma left_total_rel_sum[transfer_rule]:
       
    27   "left_total R1 \<Longrightarrow> left_total R2 \<Longrightarrow> left_total (rel_sum R1 R2)"
       
    28   using assms unfolding left_total_def split_sum_all split_sum_ex by simp
       
    29 
       
    30 lemma left_unique_rel_sum [transfer_rule]:
       
    31   "left_unique R1 \<Longrightarrow> left_unique R2 \<Longrightarrow> left_unique (rel_sum R1 R2)"
       
    32   using assms unfolding left_unique_def split_sum_all by simp
       
    33 
       
    34 lemma right_total_rel_sum [transfer_rule]:
       
    35   "right_total R1 \<Longrightarrow> right_total R2 \<Longrightarrow> right_total (rel_sum R1 R2)"
       
    36   unfolding right_total_def split_sum_all split_sum_ex by simp
       
    37 
       
    38 lemma right_unique_rel_sum [transfer_rule]:
       
    39   "right_unique R1 \<Longrightarrow> right_unique R2 \<Longrightarrow> right_unique (rel_sum R1 R2)"
       
    40   unfolding right_unique_def split_sum_all by simp
       
    41 
       
    42 lemma bi_total_rel_sum [transfer_rule]:
       
    43   "bi_total R1 \<Longrightarrow> bi_total R2 \<Longrightarrow> bi_total (rel_sum R1 R2)"
       
    44   using assms unfolding bi_total_def split_sum_all split_sum_ex by simp
       
    45 
       
    46 lemma bi_unique_rel_sum [transfer_rule]:
       
    47   "bi_unique R1 \<Longrightarrow> bi_unique R2 \<Longrightarrow> bi_unique (rel_sum R1 R2)"
       
    48   using assms unfolding bi_unique_def split_sum_all by simp
       
    49 
       
    50 lemma sum_relator_eq_onp [relator_eq_onp]: 
       
    51   "rel_sum (eq_onp P1) (eq_onp P2) = eq_onp (sum_pred P1 P2)"
       
    52   by (auto simp add: fun_eq_iff eq_onp_def rel_sum_def split: sum.split)
       
    53 
       
    54 subsection {* Quotient theorem for the Lifting package *}
       
    55 
       
    56 lemma Quotient_sum[quot_map]:
       
    57   assumes "Quotient R1 Abs1 Rep1 T1"
       
    58   assumes "Quotient R2 Abs2 Rep2 T2"
       
    59   shows "Quotient (rel_sum R1 R2) (map_sum Abs1 Abs2) (map_sum Rep1 Rep2) (rel_sum T1 T2)"
       
    60   using assms unfolding Quotient_alt_def
       
    61   by (simp add: split_sum_all)
       
    62 
    10 
    63 subsection {* Transfer rules for the Transfer package *}
    11 subsection {* Transfer rules for the Transfer package *}
    64 
    12 
    65 context
    13 context
    66 begin
    14 begin