# HG changeset patch # User nipkow # Date 1106923443 -3600 # Node ID fbc473ea9d3ca11077a75b97580cbb976210e163 # Parent 045647dfca9c95b428bfa10ec250820d8078f69c proof simpification diff -r 045647dfca9c -r fbc473ea9d3c src/HOL/Finite_Set.thy --- a/src/HOL/Finite_Set.thy Fri Jan 28 04:35:51 2005 +0100 +++ b/src/HOL/Finite_Set.thy Fri Jan 28 15:44:03 2005 +0100 @@ -487,6 +487,60 @@ subsubsection{*From @{term foldSet} to @{term fold}*} +(* only used in the next lemma, but in there twice *) +lemma card_lemma: assumes A1: "A = insert b B" and notinB: "b \ B" and + card: "A = h`{i. i(EX k ?r" + proof + fix u assume "u \ B" + hence uinA: "u \ A" and unotb: "u \ b" using A1 notinB by blast+ + then obtain i\<^isub>u where below: "i\<^isub>u < Suc n" and [simp]: "u = h i\<^isub>u" + using card by(auto simp:image_def) + show "u \ ?r" + proof cases + assume "i\<^isub>u < n" + thus ?thesis using unotb by(fastsimp) + next + assume "\ i\<^isub>u < n" + with below have [simp]: "i\<^isub>u = n" by arith + obtain i\<^isub>k where i\<^isub>k: "i\<^isub>k < Suc n" and [simp]: "b = h i\<^isub>k" + using A1 card by blast + have "i\<^isub>k < n" + proof (rule ccontr) + assume "\ i\<^isub>k < n" + hence "i\<^isub>k = n" using i\<^isub>k by arith + thus False using unotb by simp + qed + thus ?thesis by(auto simp add:image_def) + qed + qed + next + show "?r \ B" + proof + fix u assume "u \ ?r" + then obtain i\<^isub>u where below: "i\<^isub>u < n" and + or: "b = h i\<^isub>u \ u = h n \ h i\<^isub>u \ b \ h i\<^isub>u = u" + by(auto simp:image_def) + from or show "u \ B" + proof + assume [simp]: "b = h i\<^isub>u \ u = h n" + have "u \ A" using card by auto + moreover have "u \ b" using new below by auto + ultimately show "u \ B" using A1 by blast + next + assume "h i\<^isub>u \ b \ h i\<^isub>u = u" + moreover hence "u \ A" using card below by auto + ultimately show "u \ B" using A1 by blast + qed + qed + qed +qed + lemma (in ACf) foldSet_determ_aux: "!!A x x' h. \ A = h`{i::nat. i \ x' = x" @@ -523,58 +577,15 @@ assume eq2: "(A,x') = (insert c C, g c \ z)" and z: "(C,z) \ foldSet f g e" and notinC: "c \ C" hence A2: "A = insert c C" and x': "x' = g c \ z" by auto - let ?h = "%i. if h i = b then h n else h i" - have less: "B = ?h`{i. i ?r" - proof - fix u assume "u \ B" - hence uinA: "u \ A" and unotb: "u \ b" using A1 notinB by blast+ - then obtain i\<^isub>u where below: "i\<^isub>u < Suc n" and [simp]: "u = h i\<^isub>u" - using card by(auto simp:image_def) - show "u \ ?r" - proof cases - assume "i\<^isub>u < n" - thus ?thesis using unotb by(fastsimp) - next - assume "\ i\<^isub>u < n" - with below have [simp]: "i\<^isub>u = n" by arith - obtain i\<^isub>k where i\<^isub>k: "i\<^isub>k < Suc n" and [simp]: "b = h i\<^isub>k" - using A1 card by blast - have "i\<^isub>k < n" - proof (rule ccontr) - assume "\ i\<^isub>k < n" - hence "i\<^isub>k = n" using i\<^isub>k by arith - thus False using unotb by simp - qed - thus ?thesis by(auto simp add:image_def) - qed - qed - next - show "?r \ B" - proof - fix u assume "u \ ?r" - then obtain i\<^isub>u where below: "i\<^isub>u < n" and - or: "b = h i\<^isub>u \ u = h n \ h i\<^isub>u \ b \ h i\<^isub>u = u" - by(auto simp:image_def) - from or show "u \ B" - proof - assume [simp]: "b = h i\<^isub>u \ u = h n" - have "u \ A" using card by auto - moreover have "u \ b" using new below by auto - ultimately show "u \ B" using A1 by blast - next - assume "h i\<^isub>u \ b \ h i\<^isub>u = u" - moreover hence "u \ A" using card below by auto - ultimately show "u \ B" using A1 by blast - qed - qed - qed + obtain hB where lessB: "B = hB ` {i. i c" let ?D = "B - {c}" @@ -587,58 +598,9 @@ moreover have cinB: "c \ B" using B by(auto) ultimately have "(B,g c \ d) \ foldSet f g e" by(rule Diff1_foldSet) - hence "g c \ d = y" by(rule IH[OF less y]) + hence "g c \ d = y" by(rule IH[OF lessB y]) moreover have "g b \ d = z" - proof (rule IH[OF _ z]) - let ?h = "%i. if h i = c then h n else h i" - show "C = ?h`{i. i ?r" - proof - fix u assume "u \ C" - hence uinA: "u \ A" and unotc: "u \ c" - using A2 notinC by blast+ - then obtain i\<^isub>u where below: "i\<^isub>u < Suc n" and [simp]: "u = h i\<^isub>u" - using card by(auto simp:image_def) - show "u \ ?r" - proof cases - assume "i\<^isub>u < n" - thus ?thesis using unotc by(fastsimp) - next - assume "\ i\<^isub>u < n" - with below have [simp]: "i\<^isub>u = n" by arith - obtain i\<^isub>k where i\<^isub>k: "i\<^isub>k < Suc n" and [simp]: "c = h i\<^isub>k" - using A2 card by blast - have "i\<^isub>k < n" - proof (rule ccontr) - assume "\ i\<^isub>k < n" - hence "i\<^isub>k = n" using i\<^isub>k by arith - thus False using unotc by simp - qed - thus ?thesis by(auto simp add:image_def) - qed - qed - next - show "?r \ C" - proof - fix u assume "u \ ?r" - then obtain i\<^isub>u where below: "i\<^isub>u < n" and - or: "c = h i\<^isub>u \ u = h n \ h i\<^isub>u \ c \ h i\<^isub>u = u" - by(auto simp:image_def) - from or show "u \ C" - proof - assume [simp]: "c = h i\<^isub>u \ u = h n" - have "u \ A" using card by auto - moreover have "u \ c" using new below by auto - ultimately show "u \ C" using A2 by blast - next - assume "h i\<^isub>u \ c \ h i\<^isub>u = u" - moreover hence "u \ A" using card below by auto - ultimately show "u \ C" using A2 by blast - qed - qed - qed - next + proof (rule IH[OF lessC z]) show "(C,g b \ d) \ foldSet f g e" using C notinB Dfoldd by fastsimp qed