src/HOL/Library/Quotient_Option.thy
changeset 47634 091bcd569441
parent 47624 16d433895d2e
child 47635 ebb79474262c
equal deleted inserted replaced
47627:2b1d3eda59eb 47634:091bcd569441
   108   using assms unfolding Quotient_alt_def option_rel_unfold
   108   using assms unfolding Quotient_alt_def option_rel_unfold
   109   by (simp split: option.split)
   109   by (simp split: option.split)
   110 
   110 
   111 declare [[map option = (option_rel, Quotient_option)]]
   111 declare [[map option = (option_rel, Quotient_option)]]
   112 
   112 
       
   113 fun option_pred :: "('a \<Rightarrow> bool) \<Rightarrow> 'a option \<Rightarrow> bool"
       
   114 where
       
   115   "option_pred R None = True"
       
   116 | "option_pred R (Some x) = R x"
       
   117 
       
   118 lemma option_invariant_commute [invariant_commute]:
       
   119   "option_rel (Lifting.invariant P) = Lifting.invariant (option_pred P)"
       
   120   apply (simp add: fun_eq_iff Lifting.invariant_def)
       
   121   apply (intro allI) 
       
   122   apply (case_tac x rule: option.exhaust)
       
   123   apply (case_tac xa rule: option.exhaust)
       
   124   apply auto[2]
       
   125   apply (case_tac xa rule: option.exhaust)
       
   126   apply auto
       
   127 done
       
   128 
   113 subsection {* Rules for quotient package *}
   129 subsection {* Rules for quotient package *}
   114 
   130 
   115 lemma option_quotient [quot_thm]:
   131 lemma option_quotient [quot_thm]:
   116   assumes "Quotient3 R Abs Rep"
   132   assumes "Quotient3 R Abs Rep"
   117   shows "Quotient3 (option_rel R) (Option.map Abs) (Option.map Rep)"
   133   shows "Quotient3 (option_rel R) (Option.map Abs) (Option.map Rep)"