src/HOL/FunDef.thy
changeset 21404 eb85850d3eb7
parent 21364 3baf57a27269
child 21512 3786eb1b69d6
equal deleted inserted replaced
21403:dd58f13a8eb4 21404:eb85850d3eb7
   106 
   106 
   107 
   107 
   108 section {* Definitions with default value *}
   108 section {* Definitions with default value *}
   109 
   109 
   110 definition
   110 definition
   111   THE_default :: "'a \<Rightarrow> ('a \<Rightarrow> bool) \<Rightarrow> 'a"
   111   THE_default :: "'a \<Rightarrow> ('a \<Rightarrow> bool) \<Rightarrow> 'a" where
   112   "THE_default d P = (if (\<exists>!x. P x) then (THE x. P x) else d)"
   112   "THE_default d P = (if (\<exists>!x. P x) then (THE x. P x) else d)"
   113 
   113 
   114 lemma THE_defaultI': "\<exists>!x. P x \<Longrightarrow> P (THE_default d P)"
   114 lemma THE_defaultI': "\<exists>!x. P x \<Longrightarrow> P (THE_default d P)"
   115   by (simp add:theI' THE_default_def)
   115   by (simp add:theI' THE_default_def)
   116 
   116 
   176 intros
   176 intros
   177   "(Inl x, x) : lpg"
   177   "(Inl x, x) : lpg"
   178 inductive rpg
   178 inductive rpg
   179 intros
   179 intros
   180   "(Inr y, y) : rpg"
   180   "(Inr y, y) : rpg"
   181 definition
   181 
   182   "lproj x = (THE y. (x,y) : lpg)"
   182 definition "lproj x = (THE y. (x,y) : lpg)"
   183   "rproj x = (THE y. (x,y) : rpg)"
   183 definition "rproj x = (THE y. (x,y) : rpg)"
   184 
   184 
   185 lemma lproj_inl:
   185 lemma lproj_inl:
   186   "lproj (Inl x) = x"
   186   "lproj (Inl x) = x"
   187   by (auto simp:lproj_def intro: the_equality lpg.intros elim: lpg.cases)
   187   by (auto simp:lproj_def intro: the_equality lpg.intros elim: lpg.cases)
   188 lemma rproj_inr:
   188 lemma rproj_inr: