# HG changeset patch # User krauss # Date 1256596017 -3600 # Node ID 7c61bc5d731039b265c6de4b498b23f21330428b # Parent 6fd85372981e2d3b52d756ec031e723da2650ca7 point-free characterization of well-foundedness diff -r 6fd85372981e -r 7c61bc5d7310 src/HOL/Wellfounded.thy --- a/src/HOL/Wellfounded.thy Mon Oct 26 23:26:18 2009 +0100 +++ b/src/HOL/Wellfounded.thy Mon Oct 26 23:26:57 2009 +0100 @@ -84,7 +84,62 @@ subsection {* Basic Results *} -text{*transitive closure of a well-founded relation is well-founded! *} +text {* Point-free characterization of well-foundedness *} + +lemma wfE_pf: + assumes wf: "wf R" + assumes a: "A \ R `` A" + shows "A = {}" +proof - + { fix x + from wf have "x \ A" + proof induct + fix x assume "\y. (y, x) \ R \ y \ A" + then have "x \ R `` A" by blast + with a show "x \ A" by blast + qed + } thus ?thesis by auto +qed + +lemma wfI_pf: + assumes a: "\A. A \ R `` A \ A = {}" + shows "wf R" +proof (rule wfUNIVI) + fix P :: "'a \ bool" and x + let ?A = "{x. \ P x}" + assume "\x. (\y. (y, x) \ R \ P y) \ P x" + then have "?A \ R `` ?A" by blast + with a show "P x" by blast +qed + +text{*Minimal-element characterization of well-foundedness*} + +lemma wfE_min: + assumes wf: "wf R" and Q: "x \ Q" + obtains z where "z \ Q" "\y. (y, z) \ R \ y \ Q" + using Q wfE_pf[OF wf, of Q] by blast + +lemma wfI_min: + assumes a: "\x Q. x \ Q \ \z\Q. \y. (y, z) \ R \ y \ Q" + shows "wf R" +proof (rule wfI_pf) + fix A assume b: "A \ R `` A" + { fix x assume "x \ A" + from a[OF this] b have "False" by blast + } + thus "A = {}" by blast +qed + +lemma wf_eq_minimal: "wf r = (\Q x. x\Q --> (\z\Q. \y. (y,z)\r --> y\Q))" +apply auto +apply (erule wfE_min, assumption, blast) +apply (rule wfI_min, auto) +done + +lemmas wfP_eq_minimal = wf_eq_minimal [to_pred] + +text{* Well-foundedness of transitive closure *} + lemma wf_trancl: assumes "wf r" shows "wf (r^+)" @@ -124,43 +179,8 @@ apply (erule wf_trancl) done +text {* Well-foundedness of subsets *} -text{*Minimal-element characterization of well-foundedness*} -lemma wf_eq_minimal: "wf r = (\Q x. x\Q --> (\z\Q. \y. (y,z)\r --> y\Q))" -proof (intro iffI strip) - fix Q :: "'a set" and x - assume "wf r" and "x \ Q" - then show "\z\Q. \y. (y, z) \ r \ y \ Q" - unfolding wf_def - by (blast dest: spec [of _ "%x. x\Q \ (\z\Q. \y. (y,z) \ r \ y\Q)"]) -next - assume 1: "\Q x. x \ Q \ (\z\Q. \y. (y, z) \ r \ y \ Q)" - show "wf r" - proof (rule wfUNIVI) - fix P :: "'a \ bool" and x - assume 2: "\x. (\y. (y, x) \ r \ P y) \ P x" - let ?Q = "{x. \ P x}" - have "x \ ?Q \ (\z \ ?Q. \y. (y, z) \ r \ y \ ?Q)" - by (rule 1 [THEN spec, THEN spec]) - then have "\ P x \ (\z. \ P z \ (\y. (y, z) \ r \ P y))" by simp - with 2 have "\ P x \ (\z. \ P z \ P z)" by fast - then show "P x" by simp - qed -qed - -lemma wfE_min: - assumes "wf R" "x \ Q" - obtains z where "z \ Q" "\y. (y, z) \ R \ y \ Q" - using assms unfolding wf_eq_minimal by blast - -lemma wfI_min: - "(\x Q. x \ Q \ \z\Q. \y. (y, z) \ R \ y \ Q) - \ wf R" - unfolding wf_eq_minimal by blast - -lemmas wfP_eq_minimal = wf_eq_minimal [to_pred] - -text {* Well-foundedness of subsets *} lemma wf_subset: "[| wf(r); p<=r |] ==> wf(p)" apply (simp (no_asm_use) add: wf_eq_minimal) apply fast @@ -169,7 +189,8 @@ lemmas wfP_subset = wf_subset [to_pred] text {* Well-foundedness of the empty relation *} -lemma wf_empty [iff]: "wf({})" + +lemma wf_empty [iff]: "wf {}" by (simp add: wf_def) lemma wfP_empty [iff]: @@ -189,7 +210,20 @@ apply (rule Int_lower2) done -text{*Well-foundedness of insert*} +text {* Exponentiation *} + +lemma wf_exp: + assumes "wf (R ^^ n)" + shows "wf R" +proof (rule wfI_pf) + fix A assume "A \ R `` A" + then have "A \ (R ^^ n) `` A" by (induct n) force+ + with `wf (R ^^ n)` + show "A = {}" by (rule wfE_pf) +qed + +text {* Well-foundedness of insert *} + lemma wf_insert [iff]: "wf(insert (y,x) r) = (wf(r) & (x,y) ~: r^*)" apply (rule iffI) apply (blast elim: wf_trancl [THEN wf_irrefl] @@ -212,6 +246,7 @@ done text{*Well-foundedness of image*} + lemma wf_prod_fun_image: "[| wf r; inj f |] ==> wf(prod_fun f f ` r)" apply (simp only: wf_eq_minimal, clarify) apply (case_tac "EX p. f p : Q")