# HG changeset patch # User wenzelm # Date 1435586875 -7200 # Node ID c5cbd90bd94e4c98fe4697113715083915546d73 # Parent d440af2e584f43cce1030def02ecbd9a4cf47e0d tuned proofs; diff -r d440af2e584f -r c5cbd90bd94e src/HOL/Library/Multiset.thy --- a/src/HOL/Library/Multiset.thy Mon Jun 29 15:41:16 2015 +0200 +++ b/src/HOL/Library/Multiset.thy Mon Jun 29 16:07:55 2015 +0200 @@ -1509,19 +1509,19 @@ lemma not_less_empty [iff]: "(M, {#}) \ mult1 r" by (simp add: mult1_def) -lemma less_add: "(N, M0 + {#a#}) \ mult1 r \ - (\M. (M, M0) \ mult1 r \ N = M + {#a#}) \ - (\K. (\b. b \# K \ (b, a) \ r) \ N = M0 + K)" - (is "_ \ ?case1 (mult1 r) \ ?case2") -proof (unfold mult1_def) +lemma less_add: + assumes mult1: "(N, M0 + {#a#}) \ mult1 r" + shows + "(\M. (M, M0) \ mult1 r \ N = M + {#a#}) \ + (\K. (\b. b \# K \ (b, a) \ r) \ N = M0 + K)" +proof - let ?r = "\K a. \b. b \# K \ (b, a) \ r" let ?R = "\N M. \a M0 K. M = M0 + {#a#} \ N = M0 + K \ ?r K a" - let ?case1 = "?case1 {(N, M). ?R N M}" - - assume "(N, M0 + {#a#}) \ {(N, M). ?R N M}" - then obtain a' M0' K where M0: "M0 + {#a#} = M0' + {#a'#}" and N: "N = M0' + K" and r: "?r K a'" - by auto - show "?case1 \ ?case2" + obtain a' M0' K where M0: "M0 + {#a#} = M0' + {#a'#}" + and N: "N = M0' + K" + and r: "?r K a'" + using mult1 unfolding mult1_def by auto + show ?thesis (is "?case1 \ ?case2") proof - from M0 consider "M0 = M0'" "a = a'" | K' where "M0 = K' + {#a'#}" "M0' = K' + {#a#}" @@ -1536,13 +1536,15 @@ case 2 from N 2(2) have n: "N = K' + K + {#a#}" by (simp add: ac_simps) with r 2(1) have "?R (K' + K) M0" by blast - with n have ?case1 by simp + with n have ?case1 by (simp add: mult1_def) then show ?thesis .. qed qed qed -lemma all_accessible: "wf r \ \M. M \ Wellfounded.acc (mult1 r)" +lemma all_accessible: + assumes "wf r" + shows "\M. M \ Wellfounded.acc (mult1 r)" proof let ?R = "mult1 r" let ?W = "Wellfounded.acc ?R" @@ -1555,20 +1557,18 @@ proof (rule accI [of "M0 + {#a#}"]) fix N assume "(N, M0 + {#a#}) \ ?R" - then have "((\M. (M, M0) \ ?R \ N = M + {#a#}) \ - (\K. (\b. b \# K \ (b, a) \ r) \ N = M0 + K))" - by (rule less_add) + then consider M where "(M, M0) \ ?R" "N = M + {#a#}" + | K where "\b. b \# K \ (b, a) \ r" "N = M0 + K" + by atomize_elim (rule less_add) then show "N \ ?W" - proof (elim exE disjE conjE) - fix M assume "(M, M0) \ ?R" and N: "N = M + {#a#}" + proof cases + case 1 from acc_hyp have "(M, M0) \ ?R \ M + {#a#} \ ?W" .. from this and \(M, M0) \ ?R\ have "M + {#a#} \ ?W" .. - then show "N \ ?W" by (simp only: N) + then show "N \ ?W" by (simp only: \N = M + {#a#}\) next - fix K - assume N: "N = M0 + K" - assume "\b. b \# K \ (b, a) \ r" - then have "M0 + K \ ?W" + case 2 + from this(1) have "M0 + K \ ?W" proof (induct K) case empty from M0 show "M0 + {#} \ ?W" by simp @@ -1580,14 +1580,12 @@ ultimately have "(M0 + K) + {#x#} \ ?W" .. then show "M0 + (K + {#x#}) \ ?W" by (simp only: add.assoc) qed - then show "N \ ?W" by (simp only: N) + then show "N \ ?W" by (simp only: 2(2)) qed qed } note tedious_reasoning = this - assume wf: "wf r" - fix M - show "M \ ?W" + show "M \ ?W" for M proof (induct M) show "{#} \ ?W" proof (rule accI) @@ -1596,7 +1594,7 @@ qed fix M a assume "M \ ?W" - from wf have "\M \ ?W. M + {#a#} \ ?W" + from \wf r\ have "\M \ ?W. M + {#a#} \ ?W" proof induct fix a assume r: "\b. (b, a) \ r \ (\M \ ?W. M + {#b#} \ ?W)"