src/HOL/Lifting_Option.thy
changeset 55525 70b7e91fa1f9
parent 55466 786edc984c98
child 55564 e81ee43ab290
     1.1 --- a/src/HOL/Lifting_Option.thy	Sun Feb 16 21:33:28 2014 +0100
     1.2 +++ b/src/HOL/Lifting_Option.thy	Sun Feb 16 21:33:28 2014 +0100
     1.3 @@ -11,81 +11,73 @@
     1.4  
     1.5  subsection {* Relator and predicator properties *}
     1.6  
     1.7 -definition
     1.8 -  option_rel :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> 'a option \<Rightarrow> 'b option \<Rightarrow> bool"
     1.9 -where
    1.10 -  "option_rel R x y = (case (x, y) of (None, None) \<Rightarrow> True
    1.11 +lemma rel_option_iff:
    1.12 +  "rel_option R x y = (case (x, y) of (None, None) \<Rightarrow> True
    1.13      | (Some x, Some y) \<Rightarrow> R x y
    1.14      | _ \<Rightarrow> False)"
    1.15 -
    1.16 -lemma option_rel_simps[simp]:
    1.17 -  "option_rel R None None = True"
    1.18 -  "option_rel R (Some x) None = False"
    1.19 -  "option_rel R None (Some y) = False"
    1.20 -  "option_rel R (Some x) (Some y) = R x y"
    1.21 -  unfolding option_rel_def by simp_all
    1.22 +by (auto split: prod.split option.split)
    1.23  
    1.24  abbreviation (input) option_pred :: "('a \<Rightarrow> bool) \<Rightarrow> 'a option \<Rightarrow> bool" where
    1.25    "option_pred \<equiv> case_option True"
    1.26  
    1.27 -lemma option_rel_eq [relator_eq]:
    1.28 -  "option_rel (op =) = (op =)"
    1.29 -  by (simp add: option_rel_def fun_eq_iff split: option.split)
    1.30 +lemma rel_option_eq [relator_eq]:
    1.31 +  "rel_option (op =) = (op =)"
    1.32 +  by (simp add: rel_option_iff fun_eq_iff split: option.split)
    1.33  
    1.34 -lemma option_rel_mono[relator_mono]:
    1.35 +lemma rel_option_mono[relator_mono]:
    1.36    assumes "A \<le> B"
    1.37 -  shows "(option_rel A) \<le> (option_rel B)"
    1.38 -using assms by (auto simp: option_rel_def split: option.splits)
    1.39 +  shows "(rel_option A) \<le> (rel_option B)"
    1.40 +using assms by (auto simp: rel_option_iff split: option.splits)
    1.41  
    1.42 -lemma option_rel_OO[relator_distr]:
    1.43 -  "(option_rel A) OO (option_rel B) = option_rel (A OO B)"
    1.44 -by (rule ext)+ (auto simp: option_rel_def OO_def split: option.split)
    1.45 +lemma rel_option_OO[relator_distr]:
    1.46 +  "(rel_option A) OO (rel_option B) = rel_option (A OO B)"
    1.47 +by (rule ext)+ (auto simp: rel_option_iff OO_def split: option.split)
    1.48  
    1.49  lemma Domainp_option[relator_domain]:
    1.50    assumes "Domainp A = P"
    1.51 -  shows "Domainp (option_rel A) = (option_pred P)"
    1.52 -using assms unfolding Domainp_iff[abs_def] option_rel_def[abs_def]
    1.53 +  shows "Domainp (rel_option A) = (option_pred P)"
    1.54 +using assms unfolding Domainp_iff[abs_def] rel_option_iff[abs_def]
    1.55  by (auto iff: fun_eq_iff split: option.split)
    1.56  
    1.57 -lemma reflp_option_rel[reflexivity_rule]:
    1.58 -  "reflp R \<Longrightarrow> reflp (option_rel R)"
    1.59 +lemma reflp_rel_option[reflexivity_rule]:
    1.60 +  "reflp R \<Longrightarrow> reflp (rel_option R)"
    1.61    unfolding reflp_def split_option_all by simp
    1.62  
    1.63 -lemma left_total_option_rel[reflexivity_rule]:
    1.64 -  "left_total R \<Longrightarrow> left_total (option_rel R)"
    1.65 +lemma left_total_rel_option[reflexivity_rule]:
    1.66 +  "left_total R \<Longrightarrow> left_total (rel_option R)"
    1.67    unfolding left_total_def split_option_all split_option_ex by simp
    1.68  
    1.69 -lemma left_unique_option_rel [reflexivity_rule]:
    1.70 -  "left_unique R \<Longrightarrow> left_unique (option_rel R)"
    1.71 +lemma left_unique_rel_option [reflexivity_rule]:
    1.72 +  "left_unique R \<Longrightarrow> left_unique (rel_option R)"
    1.73    unfolding left_unique_def split_option_all by simp
    1.74  
    1.75 -lemma right_total_option_rel [transfer_rule]:
    1.76 -  "right_total R \<Longrightarrow> right_total (option_rel R)"
    1.77 +lemma right_total_rel_option [transfer_rule]:
    1.78 +  "right_total R \<Longrightarrow> right_total (rel_option R)"
    1.79    unfolding right_total_def split_option_all split_option_ex by simp
    1.80  
    1.81 -lemma right_unique_option_rel [transfer_rule]:
    1.82 -  "right_unique R \<Longrightarrow> right_unique (option_rel R)"
    1.83 +lemma right_unique_rel_option [transfer_rule]:
    1.84 +  "right_unique R \<Longrightarrow> right_unique (rel_option R)"
    1.85    unfolding right_unique_def split_option_all by simp
    1.86  
    1.87 -lemma bi_total_option_rel [transfer_rule]:
    1.88 -  "bi_total R \<Longrightarrow> bi_total (option_rel R)"
    1.89 +lemma bi_total_rel_option [transfer_rule]:
    1.90 +  "bi_total R \<Longrightarrow> bi_total (rel_option R)"
    1.91    unfolding bi_total_def split_option_all split_option_ex by simp
    1.92  
    1.93 -lemma bi_unique_option_rel [transfer_rule]:
    1.94 -  "bi_unique R \<Longrightarrow> bi_unique (option_rel R)"
    1.95 +lemma bi_unique_rel_option [transfer_rule]:
    1.96 +  "bi_unique R \<Longrightarrow> bi_unique (rel_option R)"
    1.97    unfolding bi_unique_def split_option_all by simp
    1.98  
    1.99  lemma option_invariant_commute [invariant_commute]:
   1.100 -  "option_rel (Lifting.invariant P) = Lifting.invariant (option_pred P)"
   1.101 +  "rel_option (Lifting.invariant P) = Lifting.invariant (option_pred P)"
   1.102    by (auto simp add: fun_eq_iff Lifting.invariant_def split_option_all)
   1.103  
   1.104  subsection {* Quotient theorem for the Lifting package *}
   1.105  
   1.106  lemma Quotient_option[quot_map]:
   1.107    assumes "Quotient R Abs Rep T"
   1.108 -  shows "Quotient (option_rel R) (map_option Abs)
   1.109 -    (map_option Rep) (option_rel T)"
   1.110 -  using assms unfolding Quotient_alt_def option_rel_def
   1.111 +  shows "Quotient (rel_option R) (map_option Abs)
   1.112 +    (map_option Rep) (rel_option T)"
   1.113 +  using assms unfolding Quotient_alt_def rel_option_iff
   1.114    by (simp split: option.split)
   1.115  
   1.116  subsection {* Transfer rules for the Transfer package *}
   1.117 @@ -94,22 +86,22 @@
   1.118  begin
   1.119  interpretation lifting_syntax .
   1.120  
   1.121 -lemma None_transfer [transfer_rule]: "(option_rel A) None None"
   1.122 -  by simp
   1.123 +lemma None_transfer [transfer_rule]: "(rel_option A) None None"
   1.124 +  by (rule option.rel_inject)
   1.125  
   1.126 -lemma Some_transfer [transfer_rule]: "(A ===> option_rel A) Some Some"
   1.127 +lemma Some_transfer [transfer_rule]: "(A ===> rel_option A) Some Some"
   1.128    unfolding fun_rel_def by simp
   1.129  
   1.130  lemma case_option_transfer [transfer_rule]:
   1.131 -  "(B ===> (A ===> B) ===> option_rel A ===> B) case_option case_option"
   1.132 +  "(B ===> (A ===> B) ===> rel_option A ===> B) case_option case_option"
   1.133    unfolding fun_rel_def split_option_all by simp
   1.134  
   1.135  lemma map_option_transfer [transfer_rule]:
   1.136 -  "((A ===> B) ===> option_rel A ===> option_rel B) map_option map_option"
   1.137 +  "((A ===> B) ===> rel_option A ===> rel_option B) map_option map_option"
   1.138    unfolding map_option_case[abs_def] by transfer_prover
   1.139  
   1.140  lemma option_bind_transfer [transfer_rule]:
   1.141 -  "(option_rel A ===> (A ===> option_rel B) ===> option_rel B)
   1.142 +  "(rel_option A ===> (A ===> rel_option B) ===> rel_option B)
   1.143      Option.bind Option.bind"
   1.144    unfolding fun_rel_def split_option_all by simp
   1.145