definition finfun_single :: "'a ==> 'a predf" where"finfun_single x = finfun_empty(x $:= True)"
lemma finfun_single_apply [simp]: "finfun_single x $ y ⟷ x = y" by(simp add: finfun_single_def finfun_upd_apply)
lemma [iff]: shows finfun_single_neq_bot: "finfun_single x ≠ bot" and bot_neq_finfun_single: "bot ≠ finfun_single x" by(simp_all add: expand_finfun_eq fun_eq_iff)
lemma finfun_leI [intro!]: "(!!x. A $ x ==> B $ x) ==> A ≤ B" by(simp add: le_finfun_def)
lemma finfun_leD [elim]: "[ A ≤ B; A $ x ]==> B $ x" by(simp add: le_finfun_def)
text‹Bounded quantification.
Warning: ‹finfun_Ball› and ‹finfun_Ex› may raise an exception, they should not be used for quickcheck ›
definition finfun_Ball_except :: "'a list ==> 'a predf==> ('a ==> bool) ==> bool" where"finfun_Ball_except xs A P = (∀a. A $ a ⟶ a ∈ set xs ∨ P a)"
lemma finfun_Ball_except_const: "finfun_Ball_except xs (K$ b) P ⟷¬ b ∨ set xs = UNIV ∨ Code.abort (STR ''finfun_ball_except'') (λu. finfun_Ball_except xs (K$ b) P)" by(auto simp add: finfun_Ball_except_def)
lemma finfun_Ball_except_const_finfun_UNIV_code [code]: "finfun_Ball_except xs (K$ b) P ⟷¬ b ∨ is_list_UNIV xs ∨ Code.abort (STR ''finfun_ball_except'') (λu. finfun_Ball_except xs (K$ b) P)" by(auto simp add: finfun_Ball_except_def is_list_UNIV_iff)
lemma finfun_Ball_except_update: "finfun_Ball_except xs (A(a $:= b)) P = ((a ∈ set xs ∨ (b ⟶ P a)) ∧ finfun_Ball_except (a # xs) A P)" by(fastforce simp add: finfun_Ball_except_def finfun_upd_apply split: if_split_asm)
lemma finfun_Ball_except_update_code [code]: fixes a :: "'a :: card_UNIV" shows"finfun_Ball_except xs (finfun_update_code f a b) P = ((a ∈ set xs ∨ (b ⟶ P a)) ∧ finfun_Ball_except (a # xs) f P)" by(simp add: finfun_Ball_except_update)
definition finfun_Ball :: "'a predf==> ('a ==> bool) ==> bool" where"finfun_Ball A P = Ball {x. A $ x} P"
definition finfun_Bex_except :: "'a list ==> 'a predf==> ('a ==> bool) ==> bool" where"finfun_Bex_except xs A P = (∃a. A $ a ∧ a ∉ set xs ∧ P a)"
lemma finfun_Bex_except_const: "finfun_Bex_except xs (K$ b) P ⟷ b ∧ set xs ≠ UNIV ∧ Code.abort (STR ''finfun_Bex_except'') (λu. finfun_Bex_except xs (K$ b) P)" by(auto simp add: finfun_Bex_except_def)
lemma finfun_Bex_except_const_finfun_UNIV_code [code]: "finfun_Bex_except xs (K$ b) P ⟷ b ∧¬ is_list_UNIV xs ∧ Code.abort (STR ''finfun_Bex_except'') (λu. finfun_Bex_except xs (K$ b) P)" by(auto simp add: finfun_Bex_except_def is_list_UNIV_iff)
lemma finfun_Bex_except_update: "finfun_Bex_except xs (A(a $:= b)) P ⟷ (a ∉ set xs ∧ b ∧ P a) ∨ finfun_Bex_except (a # xs) A P" by(fastforce simp add: finfun_Bex_except_def finfun_upd_apply dest: bspec split: if_split_asm)
lemma finfun_Bex_except_update_code [code]: fixes a :: "'a :: card_UNIV" shows"finfun_Bex_except xs (finfun_update_code f a b) P ⟷ ((a ∉ set xs ∧ b ∧ P a) ∨ finfun_Bex_except (a # xs) f P)" by(simp add: finfun_Bex_except_update)
definition finfun_Bex :: "'a predf==> ('a ==> bool) ==> bool" where"finfun_Bex A P = Bex {x. A $ x} P"
text‹Automatically replace predicate operations by finfun predicate operations where possible›
lemma iso_finfun_le [code_unfold]: "($) A ≤ ($) B ⟷ A ≤ B" by (metis le_finfun_def le_funD le_funI)
lemma iso_finfun_less [code_unfold]: "($) A < ($) B ⟷ A < B" by (metis iso_finfun_le less_finfun_def less_fun_def)
lemma iso_finfun_eq [code_unfold]: "($) A = ($) B ⟷ A = B" by(simp only: expand_finfun_eq)
lemma iso_finfun_sup [code_unfold]: "sup (($) A) (($) B) = ($) (sup A B)" by(simp)
lemma iso_finfun_disj [code_unfold]: "A $ x ∨ B $ x ⟷ sup A B $ x" by(simp add: sup_fun_def)
lemma iso_finfun_inf [code_unfold]: "inf (($) A) (($) B) = ($) (inf A B)" by(simp)
lemma iso_finfun_conj [code_unfold]: "A $ x ∧ B $ x ⟷ inf A B $ x" by(simp add: inf_fun_def)
lemma iso_finfun_empty_conv [code_unfold]: "(λ_. False) = ($) {}f" by simp
lemma iso_finfun_UNIV_conv [code_unfold]: "(λ_. True) = ($) finfun_UNIV" by simp
lemma iso_finfun_upd [code_unfold]: fixes A :: "'a predf" shows"(($) A)(x := b) = ($) (A(x $:= b))" by(simp add: fun_eq_iff)
lemma iso_finfun_uminus [code_unfold]: fixes A :: "'a predf" shows"- ($) A = ($) (- A)" by(simp)
lemma iso_finfun_minus [code_unfold]: fixes A :: "'a predf" shows"($) A - ($) B = ($) (A - B)" by(simp)
text‹
Do not declare the following two theorems as ‹[code_unfold]›,
because this causes quickcheck to fail frequently when bounded quantification is used which raises an exception.
For code generation, the same problems occur, but then, no randomly generated FinFun is usually around. ›
lemma iso_finfun_Ball_Ball: "(∀x. A $ x ⟶ P x) ⟷ finfun_Ball A P" by(simp add: finfun_Ball_def)
lemma iso_finfun_Bex_Bex: "(∃x. A $ x ∧ P x) ⟷ finfun_Bex A P" by(simp add: finfun_Bex_def)
declare iso_finfun_Ball_Ball[code_unfold]
notepad begin have"(∀x. ((λ_ :: nat. False)(1 := True, 2 := True)) x ⟶ x < 3)" by eval end declare iso_finfun_Ball_Ball[code_unfold del]
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.