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