Theory Functions_Restrict

✐‹creator "Kevin Kappelmann"›
theory Functions_Restrict
  imports HOL_Basics_Base
begin

consts fun_restrict :: "'a  'b  'a"

bundle fun_restrict_syntax
begin
notation fun_restrict ("(_)(_)" [1000])
end
bundle no_fun_restrict_syntax
begin
no_notation fun_restrict ("(_)(_)" [1000])
end

definition "fun_restrict_pred f P x  if P x then f x else undefined"
adhoc_overloading fun_restrict fun_restrict_pred

context
  includes fun_restrict_syntax
begin

lemma fun_restrict_eq [simp]:
  assumes "P x"
  shows "fPx = f x"
  using assms unfolding fun_restrict_pred_def by auto

lemma fun_restrict_eq_if_not [simp]:
  assumes "¬(P x)"
  shows "fPx = undefined"
  using assms unfolding fun_restrict_pred_def by auto

lemma fun_restrict_eq_if: "fPx = (if P x then f x else undefined)"
  by auto

lemma fun_restrict_cong [cong]:
  assumes "x. P x  P' x"
  and "x. P' x  f x = g x"
  shows "fP= gP'⇙"
  using assms by (intro ext) (auto simp: fun_restrict_eq_if)

end


end