author | wenzelm |
Sun, 16 Jul 2000 20:49:13 +0200 | |
changeset 9353 | 93cd32adc402 |
parent 9270 | 7eff23d0b380 |
child 10338 | 291ce4c4b50e |
permissions | -rw-r--r-- |
1465 | 1 |
(* Title: HOL/Lex/AutoChopper.ML |
1344 | 2 |
ID: $Id$ |
1465 | 3 |
Author: Richard Mayr & Tobias Nipkow |
1344 | 4 |
Copyright 1995 TUM |
5 |
||
6 |
Main result: auto_chopper satisfies the is_auto_chopper specification. |
|
7 |
*) |
|
8 |
||
1950
97f1c6bf3ace
Miniscoping rules are deleted, as these brittle proofs
paulson
parents:
1894
diff
changeset
|
9 |
Delsimps (ex_simps @ all_simps); |
5609 | 10 |
Delsimps [split_paired_All]; |
1344 | 11 |
|
12 |
Addsimps [Let_def]; |
|
13 |
||
5069 | 14 |
Goalw [acc_prefix_def] "~acc_prefix A [] s"; |
4832 | 15 |
by (Simp_tac 1); |
16 |
qed"acc_prefix_Nil"; |
|
17 |
Addsimps [acc_prefix_Nil]; |
|
18 |
||
5069 | 19 |
Goalw [acc_prefix_def] |
4832 | 20 |
"acc_prefix A (x#xs) s = (fin A (next A x s) | acc_prefix A xs (next A x s))"; |
21 |
by (simp_tac (simpset() addsimps [prefix_Cons]) 1); |
|
22 |
by Safe_tac; |
|
23 |
by (Asm_full_simp_tac 1); |
|
24 |
by (case_tac "zs=[]" 1); |
|
25 |
by (hyp_subst_tac 1); |
|
26 |
by (Asm_full_simp_tac 1); |
|
27 |
by (Fast_tac 1); |
|
28 |
by (res_inst_tac [("x","[x]")] exI 1); |
|
29 |
by (asm_simp_tac (simpset() addsimps [eq_sym_conv]) 1); |
|
30 |
by (res_inst_tac [("x","x#us")] exI 1); |
|
31 |
by (Asm_simp_tac 1); |
|
32 |
qed"acc_prefix_Cons"; |
|
33 |
Addsimps [acc_prefix_Cons]; |
|
34 |
||
5069 | 35 |
Goal "!st us p y ys. acc A st p (ys@[y]) xs us ~= ([],zs)"; |
4931 | 36 |
by (induct_tac "xs" 1); |
1344 | 37 |
by (Simp_tac 1); |
4686 | 38 |
by (Asm_simp_tac 1); |
5609 | 39 |
qed_spec_mp "accept_not_Nil"; |
1344 | 40 |
Addsimps [accept_not_Nil]; |
41 |
||
5069 | 42 |
Goal |
4955 | 43 |
"!st us. acc A st ([],ys) [] xs us = ([], zs) --> \ |
4832 | 44 |
\ zs = ys & (!ys. ys ~= [] & ys<=xs --> ~fin A (delta A ys st))"; |
4931 | 45 |
by (induct_tac "xs" 1); |
4089 | 46 |
by (simp_tac (simpset() addcongs [conj_cong]) 1); |
4686 | 47 |
by (Simp_tac 1); |
1344 | 48 |
by (strip_tac 1); |
1465 | 49 |
by (rtac conjI 1); |
1894 | 50 |
by (Fast_tac 1); |
4089 | 51 |
by (simp_tac (simpset() addsimps [prefix_Cons] addcongs [conj_cong]) 1); |
1344 | 52 |
by (strip_tac 1); |
2056
93c093620c28
Removed commands made redundant by new one-point rules
paulson
parents:
1950
diff
changeset
|
53 |
by (REPEAT(eresolve_tac [conjE,exE] 1)); |
93c093620c28
Removed commands made redundant by new one-point rules
paulson
parents:
1950
diff
changeset
|
54 |
by (hyp_subst_tac 1); |
1344 | 55 |
by (Simp_tac 1); |
56 |
by (case_tac "zsa = []" 1); |
|
57 |
by (Asm_simp_tac 1); |
|
1894 | 58 |
by (Fast_tac 1); |
4931 | 59 |
qed_spec_mp "no_acc"; |
1344 | 60 |
|
61 |
||
3842 | 62 |
val [prem] = goal HOL.thy "? x. P(f(x)) ==> ? y. P(y)"; |
1344 | 63 |
by (cut_facts_tac [prem] 1); |
1894 | 64 |
by (Fast_tac 1); |
1344 | 65 |
val ex_special = result(); |
66 |
||
67 |
||
5069 | 68 |
Goal |
1344 | 69 |
"! r erk l rst st ys yss zs::'a list. \ |
4955 | 70 |
\ acc A st (l,rst) erk xs r = (ys#yss, zs) --> \ |
4832 | 71 |
\ ys@concat(yss)@zs = (if acc_prefix A xs st then r@xs else erk@concat(l)@rst)"; |
4931 | 72 |
by (induct_tac "xs" 1); |
4686 | 73 |
by (simp_tac (simpset() addcongs [conj_cong]) 1); |
74 |
by (Asm_simp_tac 1); |
|
4955 | 75 |
by (res_inst_tac [("p","acc A (start A) ([],list) [] list []")] PairE 1); |
2056
93c093620c28
Removed commands made redundant by new one-point rules
paulson
parents:
1950
diff
changeset
|
76 |
by (rename_tac "vss lrst" 1); |
4686 | 77 |
by (Asm_simp_tac 1); |
9270 | 78 |
by (case_tac "vss" 1); |
2056
93c093620c28
Removed commands made redundant by new one-point rules
paulson
parents:
1950
diff
changeset
|
79 |
by (hyp_subst_tac 1); |
93c093620c28
Removed commands made redundant by new one-point rules
paulson
parents:
1950
diff
changeset
|
80 |
by (Simp_tac 1); |
4089 | 81 |
by (fast_tac (claset() addSDs [no_acc]) 1); |
2056
93c093620c28
Removed commands made redundant by new one-point rules
paulson
parents:
1950
diff
changeset
|
82 |
by (hyp_subst_tac 1); |
4686 | 83 |
by (Asm_simp_tac 1); |
5609 | 84 |
qed_spec_mp "step2_a"; |
1344 | 85 |
|
86 |
||
5069 | 87 |
Goal |
1344 | 88 |
"! st erk r l rest ys yss zs.\ |
4955 | 89 |
\ acc A st (l,rest) erk xs r = (ys#yss, zs) --> \ |
4832 | 90 |
\ (if acc_prefix A xs st \ |
1344 | 91 |
\ then ys ~= [] \ |
92 |
\ else ys ~= [] | (erk=[] & (l,rest) = (ys#yss,zs)))"; |
|
4686 | 93 |
by (Simp_tac 1); |
4931 | 94 |
by (induct_tac "xs" 1); |
4686 | 95 |
by (simp_tac (simpset() addcongs [conj_cong]) 1); |
1894 | 96 |
by (Fast_tac 1); |
4686 | 97 |
by (asm_simp_tac (simpset() addcongs [conj_cong]) 1); |
4955 | 98 |
by (res_inst_tac [("p","acc A (start A) ([],list) [] list []")] PairE 1); |
2056
93c093620c28
Removed commands made redundant by new one-point rules
paulson
parents:
1950
diff
changeset
|
99 |
by (rename_tac "vss lrst" 1); |
93c093620c28
Removed commands made redundant by new one-point rules
paulson
parents:
1950
diff
changeset
|
100 |
by (Asm_simp_tac 1); |
1344 | 101 |
by (strip_tac 1); |
4832 | 102 |
by (case_tac "acc_prefix A list (next A a st)" 1); |
2056
93c093620c28
Removed commands made redundant by new one-point rules
paulson
parents:
1950
diff
changeset
|
103 |
by (Asm_simp_tac 1); |
1344 | 104 |
by (subgoal_tac "r @ [a] ~= []" 1); |
1894 | 105 |
by (Fast_tac 1); |
1344 | 106 |
by (Simp_tac 1); |
5609 | 107 |
qed_spec_mp "step2_b"; |
1344 | 108 |
|
109 |
||
5069 | 110 |
Goal |
1344 | 111 |
"! st erk r l rest ys yss zs. \ |
4955 | 112 |
\ acc A st (l,rest) erk xs r = (ys#yss, zs) --> \ |
4832 | 113 |
\ (if acc_prefix A xs st \ |
114 |
\ then ? g. ys=r@g & fin A (delta A g st) \ |
|
1344 | 115 |
\ else (erk~=[] & erk=ys) | (erk=[] & (l,rest) = (ys#yss,zs)))"; |
4686 | 116 |
by (Simp_tac 1); |
4931 | 117 |
by (induct_tac "xs" 1); |
4686 | 118 |
by (simp_tac (simpset() addcongs [conj_cong]) 1); |
1894 | 119 |
by (Fast_tac 1); |
4686 | 120 |
by (asm_simp_tac (simpset() addcongs [conj_cong]) 1); |
1344 | 121 |
by (strip_tac 1); |
1465 | 122 |
by (rtac conjI 1); |
4955 | 123 |
by (res_inst_tac [("p","acc A (start A) ([],list) [] list []")] PairE 1); |
2056
93c093620c28
Removed commands made redundant by new one-point rules
paulson
parents:
1950
diff
changeset
|
124 |
by (rename_tac "vss lrst" 1); |
93c093620c28
Removed commands made redundant by new one-point rules
paulson
parents:
1950
diff
changeset
|
125 |
by (Asm_simp_tac 1); |
4832 | 126 |
by (case_tac "acc_prefix A list (next A a st)" 1); |
1344 | 127 |
by (strip_tac 1); |
3842 | 128 |
by (res_inst_tac [("f","%k. a#k")] ex_special 1); |
1344 | 129 |
by (Simp_tac 1); |
3842 | 130 |
by (res_inst_tac [("t","%k. ys=r@a#k"),("s","%k. ys=(r@[a])@k")] subst 1); |
1344 | 131 |
by (Simp_tac 1); |
1894 | 132 |
by (Fast_tac 1); |
1344 | 133 |
by (strip_tac 1); |
134 |
by (res_inst_tac [("x","[a]")] exI 1); |
|
135 |
by (Asm_simp_tac 1); |
|
136 |
by (subgoal_tac "r @ [a] ~= []" 1); |
|
2056
93c093620c28
Removed commands made redundant by new one-point rules
paulson
parents:
1950
diff
changeset
|
137 |
by (rtac sym 1); |
1894 | 138 |
by (Fast_tac 1); |
1344 | 139 |
by (Simp_tac 1); |
140 |
by (strip_tac 1); |
|
3842 | 141 |
by (res_inst_tac [("f","%k. a#k")] ex_special 1); |
1344 | 142 |
by (Simp_tac 1); |
3842 | 143 |
by (res_inst_tac [("t","%k. ys=r@a#k"),("s","%k. ys=(r@[a])@k")] subst 1); |
1344 | 144 |
by (Simp_tac 1); |
1894 | 145 |
by (Fast_tac 1); |
5609 | 146 |
qed_spec_mp "step2_c"; |
1344 | 147 |
|
148 |
||
5069 | 149 |
Goal |
1344 | 150 |
"! st erk r l rest ys yss zs. \ |
4955 | 151 |
\ acc A st (l,rest) erk xs r = (ys#yss, zs) --> \ |
4832 | 152 |
\ (if acc_prefix A xs st \ |
4955 | 153 |
\ then acc A (start A) ([],concat(yss)@zs) [] (concat(yss)@zs) [] = (yss,zs) \ |
1344 | 154 |
\ else (erk~=[] & (l,rest)=(yss,zs)) | (erk=[] & (l, rest)=(ys#yss,zs)))"; |
4686 | 155 |
by (Simp_tac 1); |
4931 | 156 |
by (induct_tac "xs" 1); |
4686 | 157 |
by (simp_tac (simpset() addcongs [conj_cong]) 1); |
1894 | 158 |
by (Fast_tac 1); |
4686 | 159 |
by (asm_simp_tac (simpset() addcongs [conj_cong]) 1); |
4955 | 160 |
by (res_inst_tac [("p","acc A (start A) ([],list) [] list []")] PairE 1); |
2056
93c093620c28
Removed commands made redundant by new one-point rules
paulson
parents:
1950
diff
changeset
|
161 |
by (rename_tac "vss lrst" 1); |
93c093620c28
Removed commands made redundant by new one-point rules
paulson
parents:
1950
diff
changeset
|
162 |
by (Asm_simp_tac 1); |
1344 | 163 |
by (strip_tac 1); |
4832 | 164 |
by (case_tac "acc_prefix A list (next A a st)" 1); |
1344 | 165 |
by (Asm_simp_tac 1); |
4955 | 166 |
by (subgoal_tac "acc A (start A) ([],list) [] list [] = (yss,zs)" 1); |
1344 | 167 |
by (Asm_simp_tac 2); |
168 |
by (subgoal_tac "r@[a] ~= []" 2); |
|
1894 | 169 |
by (Fast_tac 2); |
1344 | 170 |
by (Simp_tac 2); |
2609 | 171 |
by (subgoal_tac "concat(yss) @ zs = list" 1); |
2056
93c093620c28
Removed commands made redundant by new one-point rules
paulson
parents:
1950
diff
changeset
|
172 |
by (hyp_subst_tac 1); |
93c093620c28
Removed commands made redundant by new one-point rules
paulson
parents:
1950
diff
changeset
|
173 |
by (atac 1); |
1344 | 174 |
by (case_tac "yss = []" 1); |
175 |
by (Asm_simp_tac 1); |
|
176 |
by (hyp_subst_tac 1); |
|
4089 | 177 |
by (fast_tac (claset() addSDs [no_acc]) 1); |
1465 | 178 |
by (etac ((neq_Nil_conv RS iffD1) RS exE) 1); |
179 |
by (etac exE 1); |
|
1344 | 180 |
by (hyp_subst_tac 1); |
181 |
by (Simp_tac 1); |
|
1465 | 182 |
by (rtac trans 1); |
2056
93c093620c28
Removed commands made redundant by new one-point rules
paulson
parents:
1950
diff
changeset
|
183 |
by (etac step2_a 1); |
4686 | 184 |
by (Simp_tac 1); |
5609 | 185 |
qed_spec_mp "step2_d"; |
1344 | 186 |
|
5069 | 187 |
Goal |
1344 | 188 |
"! st erk r p ys yss zs. \ |
4955 | 189 |
\ acc A st p erk xs r = (ys#yss, zs) --> \ |
4832 | 190 |
\ (if acc_prefix A xs st \ |
191 |
\ then ? g. ys=r@g & (!as. as<=xs & g<=as & g~=as --> ~fin A (delta A as st))\ |
|
1344 | 192 |
\ else (erk~=[] & ys=erk) | (erk=[] & (ys#yss,zs)=p))"; |
4686 | 193 |
by (Simp_tac 1); |
4931 | 194 |
by (induct_tac "xs" 1); |
4686 | 195 |
by (simp_tac (simpset() addcongs [conj_cong]) 1); |
1894 | 196 |
by (Fast_tac 1); |
4686 | 197 |
by (asm_simp_tac (simpset() addcongs [conj_cong]) 1); |
1344 | 198 |
by (strip_tac 1); |
4832 | 199 |
by (case_tac "acc_prefix A list (next A a st)" 1); |
2056
93c093620c28
Removed commands made redundant by new one-point rules
paulson
parents:
1950
diff
changeset
|
200 |
by (rtac conjI 1); |
1344 | 201 |
by (strip_tac 1); |
3842 | 202 |
by (res_inst_tac [("f","%k. a#k")] ex_special 1); |
203 |
by (res_inst_tac [("t","%k. ys=r@a#k"),("s","%k. ys=(r@[a])@k")] subst 1); |
|
1344 | 204 |
by (Simp_tac 1); |
4832 | 205 |
by (res_inst_tac [("P","%k. ys = (r@[a])@k & (!as. as<=list & k<=as & k ~= as --> ~ fin A (delta A as (next A a st)))")] exE 1); |
1344 | 206 |
by (asm_simp_tac HOL_ss 1); |
207 |
by (res_inst_tac [("x","x")] exI 1); |
|
208 |
by (Asm_simp_tac 1); |
|
9270 | 209 |
by(rtac allI 1); |
210 |
by(case_tac "as" 1); |
|
211 |
by (Asm_simp_tac 1); |
|
4089 | 212 |
by (asm_simp_tac (simpset() addcongs[conj_cong]) 1); |
1344 | 213 |
by (strip_tac 1); |
3842 | 214 |
by (res_inst_tac [("f","%k. a#k")] ex_special 1); |
215 |
by (res_inst_tac [("t","%k. ys=r@a#k"),("s","%k. ys=(r@[a])@k")] subst 1); |
|
1344 | 216 |
by (Simp_tac 1); |
4832 | 217 |
by (res_inst_tac [("P","%k. ys=(r@[a])@k & (!as. as<=list & k<=as & k~=as --> ~ fin A (delta A as (next A a st)))")] exE 1); |
1344 | 218 |
by (asm_simp_tac HOL_ss 1); |
219 |
by (res_inst_tac [("x","x")] exI 1); |
|
220 |
by (Asm_simp_tac 1); |
|
9270 | 221 |
by(rtac allI 1); |
222 |
by(case_tac "as" 1); |
|
223 |
by (Asm_simp_tac 1); |
|
4089 | 224 |
by (asm_simp_tac (simpset() addcongs[conj_cong]) 1); |
1344 | 225 |
by (Asm_simp_tac 1); |
226 |
by (strip_tac 1); |
|
227 |
by (res_inst_tac [("x","[a]")] exI 1); |
|
1465 | 228 |
by (rtac conjI 1); |
1344 | 229 |
by (subgoal_tac "r @ [a] ~= []" 1); |
1894 | 230 |
by (Fast_tac 1); |
1344 | 231 |
by (Simp_tac 1); |
9270 | 232 |
by(rtac allI 1); |
233 |
by(case_tac "as" 1); |
|
234 |
by (Asm_simp_tac 1); |
|
4089 | 235 |
by (asm_full_simp_tac (simpset() addsimps [acc_prefix_def] addcongs[conj_cong]) 1); |
1465 | 236 |
by (etac thin_rl 1); (* speed up *) |
1894 | 237 |
by (Fast_tac 1); |
5609 | 238 |
qed_spec_mp "step2_e"; |
239 |
||
1344 | 240 |
Addsimps[split_paired_All]; |
241 |
||
5069 | 242 |
Goalw [accepts_def, is_auto_chopper_def, auto_chopper_def, |
4832 | 243 |
Chopper.is_longest_prefix_chopper_def] |
1344 | 244 |
"is_auto_chopper(auto_chopper)"; |
245 |
by (REPEAT(ares_tac [no_acc,allI,impI,conjI] 1)); |
|
2056
93c093620c28
Removed commands made redundant by new one-point rules
paulson
parents:
1950
diff
changeset
|
246 |
by (rtac mp 1); |
93c093620c28
Removed commands made redundant by new one-point rules
paulson
parents:
1950
diff
changeset
|
247 |
by (etac step2_b 2); |
4686 | 248 |
by (Simp_tac 1); |
1465 | 249 |
by (rtac conjI 1); |
2056
93c093620c28
Removed commands made redundant by new one-point rules
paulson
parents:
1950
diff
changeset
|
250 |
by (rtac mp 1); |
93c093620c28
Removed commands made redundant by new one-point rules
paulson
parents:
1950
diff
changeset
|
251 |
by (etac step2_c 2); |
4686 | 252 |
by (Simp_tac 1); |
1465 | 253 |
by (rtac conjI 1); |
4686 | 254 |
by (asm_simp_tac (simpset() addsimps [step2_a]) 1); |
1465 | 255 |
by (rtac conjI 1); |
2056
93c093620c28
Removed commands made redundant by new one-point rules
paulson
parents:
1950
diff
changeset
|
256 |
by (rtac mp 1); |
93c093620c28
Removed commands made redundant by new one-point rules
paulson
parents:
1950
diff
changeset
|
257 |
by (etac step2_d 2); |
4686 | 258 |
by (Simp_tac 1); |
1465 | 259 |
by (rtac mp 1); |
2056
93c093620c28
Removed commands made redundant by new one-point rules
paulson
parents:
1950
diff
changeset
|
260 |
by (etac step2_e 2); |
4686 | 261 |
by (Simp_tac 1); |
1344 | 262 |
qed"auto_chopper_is_auto_chopper"; |