author | wenzelm |
Sun, 27 Feb 2000 15:25:31 +0100 | |
changeset 8304 | e132d147374b |
parent 8281 | 188e2924433e |
child 8584 | 016314c2fa0a |
permissions | -rw-r--r-- |
7432
c32a0fd117a0
Wellfoundedness proof for the multiset order (preliminary version).
wenzelm
parents:
diff
changeset
|
1 |
(* Title: HOL/Isar_examples/MultisetOrder.thy |
c32a0fd117a0
Wellfoundedness proof for the multiset order (preliminary version).
wenzelm
parents:
diff
changeset
|
2 |
ID: $Id$ |
c32a0fd117a0
Wellfoundedness proof for the multiset order (preliminary version).
wenzelm
parents:
diff
changeset
|
3 |
Author: Markus Wenzel |
c32a0fd117a0
Wellfoundedness proof for the multiset order (preliminary version).
wenzelm
parents:
diff
changeset
|
4 |
|
7442 | 5 |
Wellfoundedness proof for the multiset order. |
7432
c32a0fd117a0
Wellfoundedness proof for the multiset order (preliminary version).
wenzelm
parents:
diff
changeset
|
6 |
*) |
c32a0fd117a0
Wellfoundedness proof for the multiset order (preliminary version).
wenzelm
parents:
diff
changeset
|
7 |
|
7761 | 8 |
header {* Wellfoundedness of multiset ordering *}; |
7432
c32a0fd117a0
Wellfoundedness proof for the multiset order (preliminary version).
wenzelm
parents:
diff
changeset
|
9 |
|
c32a0fd117a0
Wellfoundedness proof for the multiset order (preliminary version).
wenzelm
parents:
diff
changeset
|
10 |
theory MultisetOrder = Multiset:; |
c32a0fd117a0
Wellfoundedness proof for the multiset order (preliminary version).
wenzelm
parents:
diff
changeset
|
11 |
|
7968 | 12 |
text_raw {* |
7982 | 13 |
\footnote{Original tactic script by Tobias Nipkow (see |
7968 | 14 |
\url{http://isabelle.in.tum.de/library/HOL/Induct/Multiset.html}), |
15 |
based on a pen-and-paper proof due to Wilfried Buchholz.} |
|
16 |
*}; |
|
7527 | 17 |
|
8304 | 18 |
(* FIXME move? *) |
19 |
||
20 |
theorems [induct type: multiset] = multiset_induct; |
|
21 |
theorems [induct set: wf] = wf_induct; |
|
22 |
theorems [induct set: acc] = acc_induct; |
|
23 |
||
24 |
||
7761 | 25 |
subsection {* A technical lemma *}; |
26 |
||
7527 | 27 |
lemma less_add: "(N, M0 + {#a#}) : mult1 r ==> |
28 |
(EX M. (M, M0) : mult1 r & N = M + {#a#}) | |
|
29 |
(EX K. (ALL b. elem K b --> (b, a) : r) & N = M0 + K)" |
|
30 |
(concl is "?case1 (mult1 r) | ?case2"); |
|
31 |
proof (unfold mult1_def); |
|
8281 | 32 |
let ?r = "\\<lambda>K a. ALL b. elem K b --> (b, a) : r"; |
33 |
let ?R = "\\<lambda>N M. EX a M0 K. M = M0 + {#a#} & N = M0 + K & ?r K a"; |
|
7527 | 34 |
let ?case1 = "?case1 {(N, M). ?R N M}"; |
35 |
||
36 |
assume "(N, M0 + {#a#}) : {(N, M). ?R N M}"; |
|
7800 | 37 |
hence "EX a' M0' K. |
38 |
M0 + {#a#} = M0' + {#a'#} & N = M0' + K & ?r K a'"; by simp; |
|
7527 | 39 |
thus "?case1 | ?case2"; |
40 |
proof (elim exE conjE); |
|
7874 | 41 |
fix a' M0' K; |
42 |
assume N: "N = M0' + K" and r: "?r K a'"; |
|
7527 | 43 |
assume "M0 + {#a#} = M0' + {#a'#}"; |
7800 | 44 |
hence "M0 = M0' & a = a' | |
45 |
(EX K'. M0 = K' + {#a'#} & M0' = K' + {#a#})"; |
|
7527 | 46 |
by (simp only: add_eq_conv_ex); |
47 |
thus ?thesis; |
|
48 |
proof (elim disjE conjE exE); |
|
49 |
assume "M0 = M0'" "a = a'"; |
|
50 |
with N r; have "?r K a & N = M0 + K"; by simp; |
|
51 |
hence ?case2; ..; thus ?thesis; ..; |
|
52 |
next; |
|
53 |
fix K'; |
|
54 |
assume "M0' = K' + {#a#}"; |
|
55 |
with N; have n: "N = K' + K + {#a#}"; by (simp add: union_ac); |
|
56 |
||
57 |
assume "M0 = K' + {#a'#}"; |
|
7565 | 58 |
with r; have "?R (K' + K) M0"; by blast; |
7527 | 59 |
with n; have ?case1; by simp; thus ?thesis; ..; |
60 |
qed; |
|
61 |
qed; |
|
62 |
qed; |
|
63 |
||
7432
c32a0fd117a0
Wellfoundedness proof for the multiset order (preliminary version).
wenzelm
parents:
diff
changeset
|
64 |
|
7761 | 65 |
subsection {* The key property *}; |
66 |
||
7432
c32a0fd117a0
Wellfoundedness proof for the multiset order (preliminary version).
wenzelm
parents:
diff
changeset
|
67 |
lemma all_accessible: "wf r ==> ALL M. M : acc (mult1 r)"; |
c32a0fd117a0
Wellfoundedness proof for the multiset order (preliminary version).
wenzelm
parents:
diff
changeset
|
68 |
proof; |
7480 | 69 |
let ?R = "mult1 r"; |
70 |
let ?W = "acc ?R"; |
|
7432
c32a0fd117a0
Wellfoundedness proof for the multiset order (preliminary version).
wenzelm
parents:
diff
changeset
|
71 |
{{; |
c32a0fd117a0
Wellfoundedness proof for the multiset order (preliminary version).
wenzelm
parents:
diff
changeset
|
72 |
fix M M0 a; |
7800 | 73 |
assume M0: "M0 : ?W" |
74 |
and wf_hyp: "ALL b. (b, a) : r --> (ALL M:?W. M + {#b#} : ?W)" |
|
7480 | 75 |
and acc_hyp: "ALL M. (M, M0) : ?R --> M + {#a#} : ?W"; |
76 |
have "M0 + {#a#} : ?W"; |
|
7442 | 77 |
proof (rule accI [of "M0 + {#a#}"]); |
7874 | 78 |
fix N; |
79 |
assume "(N, M0 + {#a#}) : ?R"; |
|
7480 | 80 |
hence "((EX M. (M, M0) : ?R & N = M + {#a#}) | |
7800 | 81 |
(EX K. (ALL b. elem K b --> (b, a) : r) & N = M0 + K))"; |
7527 | 82 |
by (rule less_add); |
7480 | 83 |
thus "N : ?W"; |
7432
c32a0fd117a0
Wellfoundedness proof for the multiset order (preliminary version).
wenzelm
parents:
diff
changeset
|
84 |
proof (elim exE disjE conjE); |
7480 | 85 |
fix M; assume "(M, M0) : ?R" and N: "N = M + {#a#}"; |
86 |
from acc_hyp; have "(M, M0) : ?R --> M + {#a#} : ?W"; ..; |
|
87 |
hence "M + {#a#} : ?W"; ..; |
|
88 |
thus "N : ?W"; by (simp only: N); |
|
7432
c32a0fd117a0
Wellfoundedness proof for the multiset order (preliminary version).
wenzelm
parents:
diff
changeset
|
89 |
next; |
7451 | 90 |
fix K; |
91 |
assume N: "N = M0 + K"; |
|
92 |
assume "ALL b. elem K b --> (b, a) : r"; |
|
7480 | 93 |
have "?this --> M0 + K : ?W" (is "?P K"); |
8304 | 94 |
proof (induct K); |
7480 | 95 |
from M0; have "M0 + {#} : ?W"; by simp; |
96 |
thus "?P {#}"; ..; |
|
7442 | 97 |
|
7480 | 98 |
fix K x; assume hyp: "?P K"; |
99 |
show "?P (K + {#x#})"; |
|
7442 | 100 |
proof; |
7451 | 101 |
assume a: "ALL b. elem (K + {#x#}) b --> (b, a) : r"; |
7442 | 102 |
hence "(x, a) : r"; by simp; |
7800 | 103 |
with wf_hyp; have b: "ALL M:?W. M + {#x#} : ?W"; by blast; |
7442 | 104 |
|
7480 | 105 |
from a hyp; have "M0 + K : ?W"; by simp; |
106 |
with b; have "(M0 + K) + {#x#} : ?W"; ..; |
|
107 |
thus "M0 + (K + {#x#}) : ?W"; by (simp only: union_assoc); |
|
7432
c32a0fd117a0
Wellfoundedness proof for the multiset order (preliminary version).
wenzelm
parents:
diff
changeset
|
108 |
qed; |
c32a0fd117a0
Wellfoundedness proof for the multiset order (preliminary version).
wenzelm
parents:
diff
changeset
|
109 |
qed; |
7480 | 110 |
hence "M0 + K : ?W"; ..; |
111 |
thus "N : ?W"; by (simp only: N); |
|
7432
c32a0fd117a0
Wellfoundedness proof for the multiset order (preliminary version).
wenzelm
parents:
diff
changeset
|
112 |
qed; |
c32a0fd117a0
Wellfoundedness proof for the multiset order (preliminary version).
wenzelm
parents:
diff
changeset
|
113 |
qed; |
7442 | 114 |
}}; note tedious_reasoning = this; |
7432
c32a0fd117a0
Wellfoundedness proof for the multiset order (preliminary version).
wenzelm
parents:
diff
changeset
|
115 |
|
c32a0fd117a0
Wellfoundedness proof for the multiset order (preliminary version).
wenzelm
parents:
diff
changeset
|
116 |
assume wf: "wf r"; |
c32a0fd117a0
Wellfoundedness proof for the multiset order (preliminary version).
wenzelm
parents:
diff
changeset
|
117 |
fix M; |
7480 | 118 |
show "M : ?W"; |
8304 | 119 |
proof (induct M); |
7480 | 120 |
show "{#} : ?W"; |
7432
c32a0fd117a0
Wellfoundedness proof for the multiset order (preliminary version).
wenzelm
parents:
diff
changeset
|
121 |
proof (rule accI); |
7480 | 122 |
fix b; assume "(b, {#}) : ?R"; |
123 |
with not_less_empty; show "b : ?W"; by contradiction; |
|
7432
c32a0fd117a0
Wellfoundedness proof for the multiset order (preliminary version).
wenzelm
parents:
diff
changeset
|
124 |
qed; |
c32a0fd117a0
Wellfoundedness proof for the multiset order (preliminary version).
wenzelm
parents:
diff
changeset
|
125 |
|
7480 | 126 |
fix M a; assume "M : ?W"; |
127 |
from wf; have "ALL M:?W. M + {#a#} : ?W"; |
|
8304 | 128 |
proof induct; |
7800 | 129 |
fix a; |
130 |
assume "ALL b. (b, a) : r --> (ALL M:?W. M + {#b#} : ?W)"; |
|
7480 | 131 |
show "ALL M:?W. M + {#a#} : ?W"; |
7432
c32a0fd117a0
Wellfoundedness proof for the multiset order (preliminary version).
wenzelm
parents:
diff
changeset
|
132 |
proof; |
7480 | 133 |
fix M; assume "M : ?W"; |
7800 | 134 |
thus "M + {#a#} : ?W"; |
135 |
by (rule acc_induct) (rule tedious_reasoning); |
|
7432
c32a0fd117a0
Wellfoundedness proof for the multiset order (preliminary version).
wenzelm
parents:
diff
changeset
|
136 |
qed; |
c32a0fd117a0
Wellfoundedness proof for the multiset order (preliminary version).
wenzelm
parents:
diff
changeset
|
137 |
qed; |
7480 | 138 |
thus "M + {#a#} : ?W"; ..; |
7432
c32a0fd117a0
Wellfoundedness proof for the multiset order (preliminary version).
wenzelm
parents:
diff
changeset
|
139 |
qed; |
c32a0fd117a0
Wellfoundedness proof for the multiset order (preliminary version).
wenzelm
parents:
diff
changeset
|
140 |
qed; |
c32a0fd117a0
Wellfoundedness proof for the multiset order (preliminary version).
wenzelm
parents:
diff
changeset
|
141 |
|
c32a0fd117a0
Wellfoundedness proof for the multiset order (preliminary version).
wenzelm
parents:
diff
changeset
|
142 |
|
7761 | 143 |
subsection {* Main result *}; |
144 |
||
7432
c32a0fd117a0
Wellfoundedness proof for the multiset order (preliminary version).
wenzelm
parents:
diff
changeset
|
145 |
theorem wf_mult1: "wf r ==> wf (mult1 r)"; |
c32a0fd117a0
Wellfoundedness proof for the multiset order (preliminary version).
wenzelm
parents:
diff
changeset
|
146 |
by (rule acc_wfI, rule all_accessible); |
c32a0fd117a0
Wellfoundedness proof for the multiset order (preliminary version).
wenzelm
parents:
diff
changeset
|
147 |
|
c32a0fd117a0
Wellfoundedness proof for the multiset order (preliminary version).
wenzelm
parents:
diff
changeset
|
148 |
theorem wf_mult: "wf r ==> wf (mult r)"; |
c32a0fd117a0
Wellfoundedness proof for the multiset order (preliminary version).
wenzelm
parents:
diff
changeset
|
149 |
by (unfold mult_def, rule wf_trancl, rule wf_mult1); |
c32a0fd117a0
Wellfoundedness proof for the multiset order (preliminary version).
wenzelm
parents:
diff
changeset
|
150 |
|
c32a0fd117a0
Wellfoundedness proof for the multiset order (preliminary version).
wenzelm
parents:
diff
changeset
|
151 |
end; |