changeset 290 | 6e1c03614d36 |
parent 288 | a9003e6d0463 |
child 291 | 93db7414931d |
289:4e50ff177348 | 290:6e1c03614d36 |
---|---|
283 The lemmas in this section lead to the correctness of |
283 The lemmas in this section lead to the correctness of |
284 the compilation of @{text "Inc n"} instruction. |
284 the compilation of @{text "Inc n"} instruction. |
285 *} |
285 *} |
286 |
286 |
287 declare abc_step_l.simps[simp del] abc_steps_l.simps[simp del] |
287 declare abc_step_l.simps[simp del] abc_steps_l.simps[simp del] |
288 lemma [simp]: "start_of ly as > 0" |
288 lemma start_of_nonzero[simp]: "start_of ly as > 0" "(start_of ly as = 0) = False" |
289 apply(simp add: start_of.simps) |
289 apply(auto simp: start_of.simps) |
290 done |
290 done |
291 |
291 |
292 lemma abc_steps_l_0: "abc_steps_l ac ap 0 = ac" |
292 lemma abc_steps_l_0: "abc_steps_l ac ap 0 = ac" |
293 by(case_tac ac, simp add: abc_steps_l.simps) |
293 by(case_tac ac, simp add: abc_steps_l.simps) |
294 |
294 |
459 declare append_assoc[simp] |
459 declare append_assoc[simp] |
460 |
460 |
461 lemma map_of: "n < length xs \<Longrightarrow> (map f xs) ! n = f (xs ! n)" |
461 lemma map_of: "n < length xs \<Longrightarrow> (map f xs) ! n = f (xs ! n)" |
462 by(auto) |
462 by(auto) |
463 |
463 |
464 lemma [simp]: "length (tms_of aprog) = length aprog" |
464 lemma length_tms_of[simp]: "length (tms_of aprog) = length aprog" |
465 apply(auto simp: tms_of.simps tpairs_of.simps) |
465 apply(auto simp: tms_of.simps tpairs_of.simps) |
466 done |
466 done |
467 |
467 |
468 lemma ci_nth: |
468 lemma ci_nth: |
469 "\<lbrakk>ly = layout_of aprog; |
469 "\<lbrakk>ly = layout_of aprog; |
502 |
502 |
503 lemma div_apart_iff: "\<lbrakk>x mod (2::nat) = 0; y mod 2 = 0\<rbrakk> \<Longrightarrow> |
503 lemma div_apart_iff: "\<lbrakk>x mod (2::nat) = 0; y mod 2 = 0\<rbrakk> \<Longrightarrow> |
504 (x + y) mod 2 = 0" |
504 (x + y) mod 2 = 0" |
505 by(auto) |
505 by(auto) |
506 |
506 |
507 lemma [simp]: "length (layout_of aprog) = length aprog" |
507 lemma length_layout_of[simp]: "length (layout_of aprog) = length aprog" |
508 by(auto simp: layout_of.simps) |
508 by(auto simp: layout_of.simps) |
509 |
509 |
510 lemma start_of_ind: "\<lbrakk>as < length aprog; ly = layout_of aprog\<rbrakk> \<Longrightarrow> |
510 lemma start_of_ind: "\<lbrakk>as < length aprog; ly = layout_of aprog\<rbrakk> \<Longrightarrow> |
511 start_of ly (Suc as) = start_of ly as + |
511 start_of ly (Suc as) = start_of ly as + |
512 length ((tms_of aprog) ! as) div 2" |
512 length ((tms_of aprog) ! as) div 2" |
515 |
515 |
516 lemma concat_take_suc: "Suc n \<le> length xs \<Longrightarrow> |
516 lemma concat_take_suc: "Suc n \<le> length xs \<Longrightarrow> |
517 concat (take (Suc n) xs) = concat (take n xs) @ (xs ! n)" |
517 concat (take (Suc n) xs) = concat (take n xs) @ (xs ! n)" |
518 using concat_suc. |
518 using concat_suc. |
519 |
519 |
520 lemma [simp]: |
520 lemma ci_in_set[simp]: |
521 "\<lbrakk>as < length aprog; (abc_fetch as aprog) = Some ins\<rbrakk> |
521 "\<lbrakk>as < length aprog; (abc_fetch as aprog) = Some ins\<rbrakk> |
522 \<Longrightarrow> ci (layout_of aprog) |
522 \<Longrightarrow> ci (layout_of aprog) |
523 (start_of (layout_of aprog) as) (ins) \<in> set (tms_of aprog)" |
523 (start_of (layout_of aprog) as) (ins) \<in> set (tms_of aprog)" |
524 by(insert ci_nth[of "layout_of aprog" aprog as], simp) |
524 by(insert ci_nth[of "layout_of aprog" aprog as], simp) |
525 |
525 |
526 lemma [simp]: "length (tms_of ap) = length ap" |
526 lemma length_tms_of_elem_even[intro]: "n < length ap \<Longrightarrow> length (tms_of ap ! n) mod 2 = 0" |
527 by(auto simp: tms_of.simps tpairs_of.simps) |
|
528 |
|
529 lemma [intro]: "n < length ap \<Longrightarrow> length (tms_of ap ! n) mod 2 = 0" |
|
530 apply(cases "ap ! n") |
527 apply(cases "ap ! n") |
531 by (auto simp: tms_of.simps tpairs_of.simps ci.simps length_findnth tinc_b_def tdec_b_def) |
528 by (auto simp: tms_of.simps tpairs_of.simps ci.simps length_findnth tinc_b_def tdec_b_def) |
532 |
529 |
533 lemma compile_mod2: "length (concat (take n (tms_of ap))) mod 2 = 0" |
530 lemma compile_mod2: "length (concat (take n (tms_of ap))) mod 2 = 0" |
534 proof(induct n) |
531 proof(induct n) |
1123 lemma wf_findnth_LE: "wf findnth_LE" |
1120 lemma wf_findnth_LE: "wf findnth_LE" |
1124 by(auto simp: findnth_LE_def lex_pair_def) |
1121 by(auto simp: findnth_LE_def lex_pair_def) |
1125 |
1122 |
1126 declare findnth_inv.simps[simp del] |
1123 declare findnth_inv.simps[simp del] |
1127 |
1124 |
1128 lemma [simp]: |
1125 lemma x_is_2n_arith[simp]: |
1129 "\<lbrakk>x < Suc (Suc (2 * n)); Suc x mod 2 = Suc 0; \<not> x < 2 * n\<rbrakk> |
1126 "\<lbrakk>x < Suc (Suc (2 * n)); Suc x mod 2 = Suc 0; \<not> x < 2 * n\<rbrakk> |
1130 \<Longrightarrow> x = 2*n" |
1127 \<Longrightarrow> x = 2*n" |
1131 by arith |
1128 by arith |
1132 |
1129 |
1133 lemma [simp]: |
1130 |
1134 "\<lbrakk>0 < a; a < Suc (2 * n); a mod 2 = Suc 0\<rbrakk> |
1131 lemma between_sucs:"x < Suc n \<Longrightarrow> \<not> x < n \<Longrightarrow> x = n" by auto |
1135 \<Longrightarrow> fetch (findnth n) a Bk = (W1, a)" |
1132 |
1136 apply(case_tac a, simp_all) |
1133 lemma fetch_findnth[simp]: |
1137 apply(induct n, auto simp: findnth.simps length_findnth nth_append) |
1134 "\<lbrakk>0 < a; a < Suc (2 * n); a mod 2 = Suc 0\<rbrakk> \<Longrightarrow> fetch (findnth n) a Oc = (R, Suc a)" |
1138 apply arith |
1135 "\<lbrakk>0 < a; a < Suc (2 * n); a mod 2 \<noteq> Suc 0\<rbrakk> \<Longrightarrow> fetch (findnth n) a Oc = (R, a)" |
1139 done |
1136 "\<lbrakk>0 < a; a < Suc (2 * n); a mod 2 \<noteq> Suc 0\<rbrakk> \<Longrightarrow> fetch (findnth n) a Bk = (R, Suc a)" |
1140 |
1137 "\<lbrakk>0 < a; a < Suc (2 * n); a mod 2 = Suc 0\<rbrakk> \<Longrightarrow> fetch (findnth n) a Bk = (W1, a)" |
1141 lemma [simp]: |
1138 by(cases a;induct n;force simp: length_findnth nth_append dest!:between_sucs)+ |
1142 "\<lbrakk>0 < a; a < Suc (2 * n); a mod 2 = Suc 0\<rbrakk> |
|
1143 \<Longrightarrow> fetch (findnth n) a Oc = (R, Suc a)" |
|
1144 apply(case_tac a, simp_all) |
|
1145 apply(induct n, auto simp: findnth.simps length_findnth nth_append) |
|
1146 apply(subgoal_tac "nat = 2 * n", simp) |
|
1147 by arith |
|
1148 |
|
1149 lemma [simp]: |
|
1150 "\<lbrakk>0 < a; a < Suc (2*n); a mod 2 \<noteq> Suc 0\<rbrakk> |
|
1151 \<Longrightarrow> fetch (findnth n) a Oc = (R, a)" |
|
1152 apply(case_tac a, simp_all) |
|
1153 apply(induct n, auto simp: findnth.simps length_findnth nth_append) |
|
1154 apply(subgoal_tac "nat = Suc (2 * n)", simp) |
|
1155 apply arith |
|
1156 done |
|
1157 |
|
1158 lemma [simp]: |
|
1159 "\<lbrakk>0 < a; a < Suc (2*n); a mod 2 \<noteq> Suc 0\<rbrakk> |
|
1160 \<Longrightarrow> fetch (findnth n) a Bk = (R, Suc a)" |
|
1161 apply(case_tac a, simp_all) |
|
1162 apply(induct n, auto simp: findnth.simps length_findnth nth_append) |
|
1163 apply(subgoal_tac "nat = Suc (2 * n)", simp) |
|
1164 by arith |
|
1165 |
1139 |
1166 declare at_begin_norm.simps[simp del] at_begin_fst_bwtn.simps[simp del] |
1140 declare at_begin_norm.simps[simp del] at_begin_fst_bwtn.simps[simp del] |
1167 at_begin_fst_awtn.simps[simp del] in_middle.simps[simp del] |
1141 at_begin_fst_awtn.simps[simp del] in_middle.simps[simp del] |
1168 abc_lm_s.simps[simp del] abc_lm_v.simps[simp del] |
1142 abc_lm_s.simps[simp del] abc_lm_v.simps[simp del] |
1169 ci.simps[simp del] inv_after_move.simps[simp del] |
1143 ci.simps[simp del] inv_after_move.simps[simp del] |
1177 inv_check_left_moving_on_leftmost.simps[simp del] |
1151 inv_check_left_moving_on_leftmost.simps[simp del] |
1178 inv_after_left_moving.simps[simp del] |
1152 inv_after_left_moving.simps[simp del] |
1179 inv_stop.simps[simp del] inv_locate_a.simps[simp del] |
1153 inv_stop.simps[simp del] inv_locate_a.simps[simp del] |
1180 inv_locate_b.simps[simp del] |
1154 inv_locate_b.simps[simp del] |
1181 |
1155 |
1182 lemma [intro]: "\<exists>rn. [Bk] = Bk \<up> rn" |
1156 lemma replicate_once[intro]: "\<exists>rn. [Bk] = Bk \<up> rn" |
1183 by (metis replicate_0 replicate_Suc) |
1157 by (metis replicate.simps) |
1184 |
1158 |
1185 lemma [intro]: "at_begin_norm (as, am) (q, aaa, []) ires |
1159 lemma at_begin_norm_Bk[intro]: "at_begin_norm (as, am) (q, aaa, []) ires |
1186 \<Longrightarrow> at_begin_norm (as, am) (q, aaa, [Bk]) ires" |
1160 \<Longrightarrow> at_begin_norm (as, am) (q, aaa, [Bk]) ires" |
1187 apply(simp add: at_begin_norm.simps, erule_tac exE, erule_tac exE) |
1161 apply(simp add: at_begin_norm.simps, erule_tac exE, erule_tac exE) |
1188 apply(rule_tac x = lm1 in exI, simp, auto) |
1162 apply(rule_tac x = lm1 in exI, simp, auto) |
1189 done |
1163 done |
1190 |
1164 |
1191 lemma [intro]: "at_begin_fst_bwtn (as, am) (q, aaa, []) ires |
1165 lemma at_begin_fst_bwtn_Bk[intro]: "at_begin_fst_bwtn (as, am) (q, aaa, []) ires |
1192 \<Longrightarrow> at_begin_fst_bwtn (as, am) (q, aaa, [Bk]) ires" |
1166 \<Longrightarrow> at_begin_fst_bwtn (as, am) (q, aaa, [Bk]) ires" |
1193 apply(simp only: at_begin_fst_bwtn.simps, erule_tac exE, erule_tac exE, erule_tac exE) |
1167 apply(simp only: at_begin_fst_bwtn.simps, erule_tac exE, erule_tac exE, erule_tac exE) |
1194 apply(rule_tac x = "am @ 0\<up>tn" in exI, auto) |
1168 apply(rule_tac x = "am @ 0\<up>tn" in exI, auto) |
1195 done |
1169 done |
1196 |
1170 |
1197 lemma [intro]: "at_begin_fst_awtn (as, am) (q, aaa, []) ires |
1171 lemma at_begin_fst_awtn_Bk[intro]: "at_begin_fst_awtn (as, am) (q, aaa, []) ires |
1198 \<Longrightarrow> at_begin_fst_awtn (as, am) (q, aaa, [Bk]) ires" |
1172 \<Longrightarrow> at_begin_fst_awtn (as, am) (q, aaa, [Bk]) ires" |
1199 apply(auto simp: at_begin_fst_awtn.simps) |
1173 apply(auto simp: at_begin_fst_awtn.simps) |
1200 done |
1174 done |
1201 |
1175 |
1202 lemma [intro]: "inv_locate_a (as, am) (q, aaa, []) ires |
1176 lemma inv_locate_a_Bk[intro]: "inv_locate_a (as, am) (q, aaa, []) ires |
1203 \<Longrightarrow> inv_locate_a (as, am) (q, aaa, [Bk]) ires" |
1177 \<Longrightarrow> inv_locate_a (as, am) (q, aaa, [Bk]) ires" |
1204 apply(simp only: inv_locate_a.simps) |
1178 apply(simp only: inv_locate_a.simps) |
1205 apply(erule disj_forward) |
1179 apply(erule disj_forward) |
1206 defer |
1180 defer |
1207 apply(erule disj_forward, auto) |
1181 apply(erule disj_forward, auto) |
1293 apply(case_tac mr, simp_all) |
1267 apply(case_tac mr, simp_all) |
1294 apply(case_tac lm2, simp_all add: tape_of_nl_cons split: if_splits, auto) |
1268 apply(case_tac lm2, simp_all add: tape_of_nl_cons split: if_splits, auto) |
1295 apply(case_tac [!] n, simp_all) |
1269 apply(case_tac [!] n, simp_all) |
1296 done |
1270 done |
1297 |
1271 |
1298 lemma [simp]: "(Oc # r = Bk \<up> rn) = False" |
1272 lemma repeat_Bk_no_Oc[simp]: "(Oc # r = Bk \<up> rn) = False" |
1299 apply(case_tac rn, simp_all) |
1273 apply(case_tac rn, simp_all) |
1300 done |
1274 done |
1301 |
1275 |
1302 lemma [simp]: "(\<exists>rna. Bk \<up> rn = Bk # Bk \<up> rna) \<or> rn = 0" |
1276 lemma repeat_Bk[simp]: "(\<exists>rna. Bk \<up> rn = Bk # Bk \<up> rna) \<or> rn = 0" |
1303 apply(case_tac rn, auto) |
1277 apply(case_tac rn, auto) |
1304 done |
1278 done |
1305 |
1279 |
1306 lemma [simp]: "(\<forall> x. a \<noteq> x) = False" |
1280 lemma inv_locate_b_Oc_via_a[simp]: |
1307 by auto |
|
1308 |
|
1309 lemma exp_ind: "a\<up>(Suc x) = a\<up>x @ [a]" |
|
1310 apply(induct x, auto) |
|
1311 done |
|
1312 |
|
1313 lemma [simp]: |
|
1314 "inv_locate_a (as, lm) (q, l, Oc # r) ires |
1281 "inv_locate_a (as, lm) (q, l, Oc # r) ires |
1315 \<Longrightarrow> inv_locate_b (as, lm) (q, Oc # l, r) ires" |
1282 \<Longrightarrow> inv_locate_b (as, lm) (q, Oc # l, r) ires" |
1316 apply(simp only: inv_locate_a.simps inv_locate_b.simps in_middle.simps |
1283 apply(simp only: inv_locate_a.simps inv_locate_b.simps in_middle.simps |
1317 at_begin_norm.simps at_begin_fst_bwtn.simps |
1284 at_begin_norm.simps at_begin_fst_bwtn.simps |
1318 at_begin_fst_awtn.simps) |
1285 at_begin_fst_awtn.simps) |
1332 done |
1299 done |
1333 |
1300 |
1334 lemma length_equal: "xs = ys \<Longrightarrow> length xs = length ys" |
1301 lemma length_equal: "xs = ys \<Longrightarrow> length xs = length ys" |
1335 by auto |
1302 by auto |
1336 |
1303 |
1337 lemma [simp]: "\<lbrakk>inv_locate_b (as, am) (q, aaa, Bk # xs) ires; |
1304 lemma inv_locate_a_Bk_via_b[simp]: "\<lbrakk>inv_locate_b (as, am) (q, aaa, Bk # xs) ires; |
1338 \<not> (\<exists>n. xs = Bk\<up>n)\<rbrakk> |
1305 \<not> (\<exists>n. xs = Bk\<up>n)\<rbrakk> |
1339 \<Longrightarrow> inv_locate_a (as, am) (Suc q, Bk # aaa, xs) ires" |
1306 \<Longrightarrow> inv_locate_a (as, am) (Suc q, Bk # aaa, xs) ires" |
1340 apply(simp add: inv_locate_b.simps inv_locate_a.simps) |
1307 apply(simp add: inv_locate_b.simps inv_locate_a.simps) |
1341 apply(rule_tac disjI1) |
1308 apply(rule_tac disjI1) |
1342 apply(simp only: in_middle.simps at_begin_norm.simps) |
1309 apply(simp only: in_middle.simps at_begin_norm.simps) |
1357 \<Longrightarrow> inv_locate_a (as, am) (Suc q, Bk # aaa, xs) ires" |
1324 \<Longrightarrow> inv_locate_a (as, am) (Suc q, Bk # aaa, xs) ires" |
1358 apply(case_tac "\<exists> n. xs = Bk\<up>n", simp, simp) |
1325 apply(case_tac "\<exists> n. xs = Bk\<up>n", simp, simp) |
1359 done |
1326 done |
1360 |
1327 |
1361 |
1328 |
1362 lemma [simp]: "inv_locate_b (as, am) (q, l, []) ires |
1329 lemma inv_locate_b_Bk[simp]: "inv_locate_b (as, am) (q, l, []) ires |
1363 \<Longrightarrow> inv_locate_b (as, am) (q, l, [Bk]) ires" |
1330 \<Longrightarrow> inv_locate_b (as, am) (q, l, [Bk]) ires" |
1364 apply(simp only: inv_locate_b.simps in_middle.simps) |
1331 apply(simp only: inv_locate_b.simps in_middle.simps) |
1365 apply(erule exE)+ |
1332 apply(erule exE)+ |
1366 apply(rule_tac x = lm1 in exI, rule_tac x = lm2 in exI, |
1333 apply(rule_tac x = lm1 in exI, rule_tac x = lm2 in exI, |
1367 rule_tac x = tn in exI, rule_tac x = m in exI, |
1334 rule_tac x = tn in exI, rule_tac x = m in exI, |
1369 apply(auto) |
1336 apply(auto) |
1370 done |
1337 done |
1371 |
1338 |
1372 (*inv: from locate_b to after_write*) |
1339 (*inv: from locate_b to after_write*) |
1373 |
1340 |
1374 lemma [simp]: "(a mod 2 \<noteq> Suc 0) = (a mod 2 = 0) " |
1341 lemma not_even_then_odd[simp]: "(a mod 2 \<noteq> 0) = (a mod 2 = Suc 0) " |
1375 by arith |
1342 by arith |
1376 |
1343 |
1377 lemma [simp]: "(a mod 2 \<noteq> 0) = (a mod 2 = Suc 0) " |
1344 lemma div_rounding_down[simp]: "(2*q - Suc 0) div 2 = (q - 1)" "(Suc (2*q)) div 2 = q" |
1345 by arith+ |
|
1346 |
|
1347 lemma even_plus_one_odd[simp]: "x mod 2 = 0 \<Longrightarrow> Suc x mod 2 = Suc 0" |
|
1378 by arith |
1348 by arith |
1379 |
1349 |
1380 lemma mod_ex1: "(a mod 2 = Suc 0) = (\<exists> q. a = Suc (2 * q))" |
1350 lemma odd_plus_one_even[simp]: "x mod 2 = Suc 0 \<Longrightarrow> Suc x mod 2 = 0" |
1381 by arith |
1351 by arith |
1382 |
|
1383 lemma mod_ex2: "(a mod (2::nat) = 0) = (\<exists> q. a = 2 * q)" |
|
1384 by arith |
|
1385 |
|
1386 lemma [simp]: "(2*q - Suc 0) div 2 = (q - 1)" |
|
1387 by arith |
|
1388 |
|
1389 lemma [simp]: "(Suc (2*q)) div 2 = q" |
|
1390 by arith |
|
1391 |
|
1392 lemma mod_2: "x mod 2 = 0 \<or> x mod 2 = Suc 0" |
|
1393 by arith |
|
1394 |
|
1395 lemma [simp]: "x mod 2 = 0 \<Longrightarrow> Suc x mod 2 = Suc 0" |
|
1396 by arith |
|
1397 |
|
1398 lemma [simp]: "x mod 2 = Suc 0 \<Longrightarrow> Suc x mod 2 = 0" |
|
1399 by arith |
|
1400 |
|
1401 lemma [simp]: "inv_locate_b (as, am) (q, l, []) ires |
|
1402 \<Longrightarrow> inv_locate_b (as, am) (q, l, [Bk]) ires" |
|
1403 apply(simp only: inv_locate_b.simps in_middle.simps) |
|
1404 apply(erule exE)+ |
|
1405 apply(rule_tac x = lm1 in exI, rule_tac x = lm2 in exI, |
|
1406 rule_tac x = tn in exI, rule_tac x = m in exI, |
|
1407 rule_tac x = ml in exI, rule_tac x = mr in exI) |
|
1408 apply(auto) |
|
1409 done |
|
1410 |
1352 |
1411 lemma locate_b_2_locate_a[simp]: |
1353 lemma locate_b_2_locate_a[simp]: |
1412 "\<lbrakk>q > 0; inv_locate_b (as, am) (q - Suc 0, aaa, Bk # xs) ires\<rbrakk> |
1354 "\<lbrakk>q > 0; inv_locate_b (as, am) (q - Suc 0, aaa, Bk # xs) ires\<rbrakk> |
1413 \<Longrightarrow> inv_locate_a (as, am) (q, Bk # aaa, xs) ires" |
1355 \<Longrightarrow> inv_locate_a (as, am) (q, Bk # aaa, xs) ires" |
1414 apply(insert locate_b_2_a [of as am "q - 1" aaa xs ires], simp) |
1356 apply(insert locate_b_2_a [of as am "q - 1" aaa xs ires], simp) |
1415 done |
1357 done |
1416 |
|
1417 |
|
1418 lemma [simp]: "inv_locate_b (as, am) (q, l, []) ires |
|
1419 \<Longrightarrow> inv_locate_b (as, am) (q, l, [Bk]) ires" |
|
1420 apply(simp only: inv_locate_b.simps in_middle.simps) |
|
1421 apply(erule exE)+ |
|
1422 apply(rule_tac x = lm1 in exI, rule_tac x = lm2 in exI, |
|
1423 rule_tac x = tn in exI, rule_tac x = m in exI, |
|
1424 rule_tac x = ml in exI, rule_tac x = mr in exI) |
|
1425 apply(auto) |
|
1426 done |
|
1427 |
1358 |
1428 (*inv: from locate_b to after_write*) |
1359 (*inv: from locate_b to after_write*) |
1429 |
1360 |
1430 lemma [simp]: |
1361 lemma findnth_inv_layout_of_via_crsp[simp]: |
1431 "crsp (layout_of ap) (as, lm) (s, l, r) ires |
1362 "crsp (layout_of ap) (as, lm) (s, l, r) ires |
1432 \<Longrightarrow> findnth_inv (layout_of ap) n (as, lm) (Suc 0, l, r) ires" |
1363 \<Longrightarrow> findnth_inv (layout_of ap) n (as, lm) (Suc 0, l, r) ires" |
1433 apply(auto simp: crsp.simps findnth_inv.simps inv_locate_a.simps |
1364 by(auto simp: crsp.simps findnth_inv.simps inv_locate_a.simps |
1434 at_begin_norm.simps at_begin_fst_awtn.simps at_begin_fst_bwtn.simps) |
1365 at_begin_norm.simps at_begin_fst_awtn.simps at_begin_fst_bwtn.simps) |
1435 done |
|
1436 |
1366 |
1437 lemma findnth_correct_pre: |
1367 lemma findnth_correct_pre: |
1438 assumes layout: "ly = layout_of ap" |
1368 assumes layout: "ly = layout_of ap" |
1439 and crsp: "crsp ly (as, lm) (s, l, r) ires" |
1369 and crsp: "crsp ly (as, lm) (s, l, r) ires" |
1440 and not0: "n > 0" |
1370 and not0: "n > 0" |
1468 apply(auto simp: mod_ex1 mod_ex2) |
1398 apply(auto simp: mod_ex1 mod_ex2) |
1469 done |
1399 done |
1470 qed |
1400 qed |
1471 qed |
1401 qed |
1472 |
1402 |
1473 lemma [intro]: "inv_locate_a (as, lm) (0, Bk # Bk # ires, <lm> @ Bk \<up> x) ires" |
1403 lemma inv_locate_aI[intro]: "inv_locate_a (as, lm) (0, Bk # Bk # ires, <lm> @ Bk \<up> x) ires" |
1474 apply(auto simp: crsp.simps inv_locate_a.simps at_begin_norm.simps) |
1404 apply(auto simp: crsp.simps inv_locate_a.simps at_begin_norm.simps) |
1475 done |
1405 done |
1476 lemma [simp]: "crsp ly (as, lm) (s, l, r) ires \<Longrightarrow> inv_locate_a (as, lm) (0, l, r) ires" |
1406 lemma inv_locate_a_via_crsp[simp]: |
1407 "crsp ly (as, lm) (s, l, r) ires \<Longrightarrow> inv_locate_a (as, lm) (0, l, r) ires" |
|
1477 apply(auto simp: crsp.simps inv_locate_a.simps at_begin_norm.simps) |
1408 apply(auto simp: crsp.simps inv_locate_a.simps at_begin_norm.simps) |
1478 done |
1409 done |
1479 |
1410 |
1480 lemma findnth_correct: |
1411 lemma findnth_correct: |
1481 assumes layout: "ly = layout_of ap" |
1412 assumes layout: "ly = layout_of ap" |
1576 declare inc_inv.simps[simp del] |
1507 declare inc_inv.simps[simp del] |
1577 |
1508 |
1578 lemma wf_inc_le[intro]: "wf inc_LE" |
1509 lemma wf_inc_le[intro]: "wf inc_LE" |
1579 by(auto intro:wf_inv_image simp: inc_LE_def lex_triple_def lex_pair_def) |
1510 by(auto intro:wf_inv_image simp: inc_LE_def lex_triple_def lex_pair_def) |
1580 |
1511 |
1581 lemma numeral_5_eq_5: "5 = Suc (Suc (Suc (Suc (Suc 0))))" |
|
1582 by arith |
|
1583 |
|
1584 lemma numeral_6_eq_6: "6 = Suc (Suc (Suc (Suc (Suc 1))))" |
|
1585 by arith |
|
1586 |
|
1587 lemma numeral_7_eq_7: "7 = Suc (Suc (Suc (Suc (Suc 2))))" |
|
1588 by arith |
|
1589 |
|
1590 lemma numeral_8_eq_8: "8 = Suc (Suc (Suc (Suc (Suc 3))))" |
|
1591 by arith |
|
1592 |
|
1593 lemma numeral_9_eq_9: "9 = Suc (Suc (Suc (Suc (Suc (Suc 3)))))" |
|
1594 by arith |
|
1595 |
|
1596 lemma numeral_10_eq_10: "10 = Suc (Suc (Suc (Suc (Suc (Suc (Suc 3))))))" |
|
1597 by arith |
|
1598 |
|
1599 lemma inv_locate_b_2_after_write[simp]: |
1512 lemma inv_locate_b_2_after_write[simp]: |
1600 "inv_locate_b (as, am) (n, aaa, Bk # xs) ires |
1513 "inv_locate_b (as, am) (n, aaa, Bk # xs) ires |
1601 \<Longrightarrow> inv_after_write (as, abc_lm_s am n (Suc (abc_lm_v am n))) |
1514 \<Longrightarrow> inv_after_write (as, abc_lm_s am n (Suc (abc_lm_v am n))) |
1602 (s, aaa, Oc # xs) ires" |
1515 (s, aaa, Oc # xs) ires" |
1603 apply(auto simp: in_middle.simps inv_after_write.simps |
1516 apply(auto simp: in_middle.simps inv_after_write.simps |
1609 apply(simp only: Suc_diff_le exp_ind) |
1522 apply(simp only: Suc_diff_le exp_ind) |
1610 apply(subgoal_tac "lm2 = []", simp) |
1523 apply(subgoal_tac "lm2 = []", simp) |
1611 apply(drule_tac length_equal, simp) |
1524 apply(drule_tac length_equal, simp) |
1612 by (metis (no_types, lifting) add_diff_inverse_nat append.assoc append_eq_append_conv length_append length_replicate list.inject) |
1525 by (metis (no_types, lifting) add_diff_inverse_nat append.assoc append_eq_append_conv length_append length_replicate list.inject) |
1613 |
1526 |
1614 lemma [simp]: "inv_locate_b (as, am) (n, aaa, []) ires \<Longrightarrow> |
1527 lemma inv_after_write_via_locate_b[simp]: "inv_locate_b (as, am) (n, aaa, []) ires \<Longrightarrow> |
1615 inv_after_write (as, abc_lm_s am n (Suc (abc_lm_v am n))) |
1528 inv_after_write (as, abc_lm_s am n (Suc (abc_lm_v am n))) |
1616 (s, aaa, [Oc]) ires" |
1529 (s, aaa, [Oc]) ires" |
1617 apply(insert inv_locate_b_2_after_write [of as am n aaa "[]"]) |
1530 apply(insert inv_locate_b_2_after_write [of as am n aaa "[]"]) |
1618 by(simp) |
1531 by(simp) |
1619 |
1532 |
1620 |
1533 |
1621 |
1534 |
1622 (*inv: from after_write to after_move*) |
1535 (*inv: from after_write to after_move*) |
1623 lemma [simp]: "inv_after_write (as, lm) (x, l, Oc # r) ires |
1536 lemma inv_after_move_Oc_via_write[simp]: "inv_after_write (as, lm) (x, l, Oc # r) ires |
1624 \<Longrightarrow> inv_after_move (as, lm) (y, Oc # l, r) ires" |
1537 \<Longrightarrow> inv_after_move (as, lm) (y, Oc # l, r) ires" |
1625 apply(auto simp:inv_after_move.simps inv_after_write.simps split: if_splits) |
1538 apply(auto simp:inv_after_move.simps inv_after_write.simps split: if_splits) |
1626 done |
1539 done |
1627 |
1540 |
1628 lemma [simp]: "inv_after_write (as, abc_lm_s am n (Suc (abc_lm_v am n) |
1541 lemma inv_after_write_Suc[simp]: "inv_after_write (as, abc_lm_s am n (Suc (abc_lm_v am n) |
1629 )) (x, aaa, Bk # xs) ires = False" |
1542 )) (x, aaa, Bk # xs) ires = False" |
1630 apply(simp add: inv_after_write.simps ) |
|
1631 done |
|
1632 |
|
1633 lemma [simp]: |
|
1634 "inv_after_write (as, abc_lm_s am n (Suc (abc_lm_v am n))) |
1543 "inv_after_write (as, abc_lm_s am n (Suc (abc_lm_v am n))) |
1635 (x, aaa, []) ires = False" |
1544 (x, aaa, []) ires = False" |
1636 apply(simp add: inv_after_write.simps ) |
1545 apply(auto simp: inv_after_write.simps ) |
1637 done |
1546 done |
1638 |
1547 |
1639 (*inv: from after_move to after_clear*) |
1548 (*inv: from after_move to after_clear*) |
1640 lemma [simp]: "inv_after_move (as, lm) (s, l, Oc # r) ires |
1549 lemma inv_after_clear_Bk_via_Oc[simp]: "inv_after_move (as, lm) (s, l, Oc # r) ires |
1641 \<Longrightarrow> inv_after_clear (as, lm) (s', l, Bk # r) ires" |
1550 \<Longrightarrow> inv_after_clear (as, lm) (s', l, Bk # r) ires" |
1642 apply(auto simp: inv_after_move.simps inv_after_clear.simps split: if_splits) |
1551 apply(auto simp: inv_after_move.simps inv_after_clear.simps split: if_splits) |
1643 done |
1552 done |
1644 |
1553 |
1645 (*inv: from after_move to on_leftmoving*) |
|
1646 lemma [intro]: "Bk \<up> rn = Bk # Bk \<up> (rn - Suc 0) \<or> rn = 0" |
|
1647 apply(case_tac rn, auto) |
|
1648 done |
|
1649 |
1554 |
1650 lemma inv_after_move_2_inv_on_left_moving[simp]: |
1555 lemma inv_after_move_2_inv_on_left_moving[simp]: |
1651 "inv_after_move (as, lm) (s, l, Bk # r) ires |
1556 assumes "inv_after_move (as, lm) (s, l, Bk # r) ires" |
1652 \<Longrightarrow> (l = [] \<longrightarrow> |
1557 shows "(l = [] \<longrightarrow> |
1653 inv_on_left_moving (as, lm) (s', [], Bk # Bk # r) ires) \<and> |
1558 inv_on_left_moving (as, lm) (s', [], Bk # Bk # r) ires) \<and> |
1654 (l \<noteq> [] \<longrightarrow> |
1559 (l \<noteq> [] \<longrightarrow> |
1655 inv_on_left_moving (as, lm) (s', tl l, hd l # Bk # r) ires)" |
1560 inv_on_left_moving (as, lm) (s', tl l, hd l # Bk # r) ires)" |
1656 apply(simp only: inv_after_move.simps inv_on_left_moving.simps) |
1561 proof (cases l) |
1657 apply(subgoal_tac "l \<noteq> []", rule conjI, simp, rule impI, |
1562 case (Cons a list) |
1658 rule disjI1, simp only: inv_on_left_moving_norm.simps) |
1563 from assms Cons show ?thesis |
1659 apply(erule exE)+ |
1564 apply(simp only: inv_after_move.simps inv_on_left_moving.simps) |
1660 apply(subgoal_tac "lm2 = []") |
1565 apply(rule conjI, force, rule impI, rule disjI1, simp only: inv_on_left_moving_norm.simps) |
1661 apply(rule_tac x = lm1 in exI, rule_tac x = lm2 in exI, |
1566 apply(erule exE)+ |
1662 rule_tac x = m in exI, rule_tac x = m in exI, |
1567 apply(subgoal_tac "lm2 = []") |
1663 rule_tac x = 1 in exI, |
1568 apply(rule_tac x = lm1 in exI, rule_tac x = lm2 in exI, |
1664 rule_tac x = "rn - 1" in exI, auto) |
1569 rule_tac x = m in exI, rule_tac x = m in exI, |
1665 apply(auto split: if_splits) |
1570 rule_tac x = 1 in exI, |
1666 apply(case_tac [1-2] rn, simp_all) |
1571 rule_tac x = "rn - 1" in exI) apply (auto split:if_splits) |
1667 apply(case_tac [!] lm2, simp_all add: tape_of_nl_cons split: if_splits) |
1572 apply(case_tac [1-2] rn, simp_all) |
1668 done |
1573 by(case_tac [!] lm2, simp_all add: tape_of_nl_cons split: if_splits) |
1574 next |
|
1575 case Nil thus ?thesis using assms |
|
1576 unfolding inv_after_move.simps inv_on_left_moving.simps |
|
1577 by (auto split:if_splits) |
|
1578 qed |
|
1669 |
1579 |
1670 |
1580 |
1671 lemma inv_after_move_2_inv_on_left_moving_B[simp]: |
1581 lemma inv_after_move_2_inv_on_left_moving_B[simp]: |
1672 "inv_after_move (as, lm) (s, l, []) ires |
1582 "inv_after_move (as, lm) (s, l, []) ires |
1673 \<Longrightarrow> (l = [] \<longrightarrow> inv_on_left_moving (as, lm) (s', [], [Bk]) ires) \<and> |
1583 \<Longrightarrow> (l = [] \<longrightarrow> inv_on_left_moving (as, lm) (s', [], [Bk]) ires) \<and> |
1682 rule_tac x = 1 in exI, rule_tac x = "rn - 1" in exI, simp, case_tac rn) |
1592 rule_tac x = 1 in exI, rule_tac x = "rn - 1" in exI, simp, case_tac rn) |
1683 apply(auto split: if_splits) |
1593 apply(auto split: if_splits) |
1684 apply(case_tac [!] lm2, auto simp: tape_of_nl_cons split: if_splits) |
1594 apply(case_tac [!] lm2, auto simp: tape_of_nl_cons split: if_splits) |
1685 done |
1595 done |
1686 |
1596 |
1687 (*inv: from after_clear to on_right_moving*) |
|
1688 lemma [simp]: "Oc # r = replicate rn Bk = False" |
|
1689 apply(case_tac rn, simp, simp) |
|
1690 done |
|
1691 |
|
1692 lemma inv_after_clear_2_inv_on_right_moving[simp]: |
1597 lemma inv_after_clear_2_inv_on_right_moving[simp]: |
1693 "inv_after_clear (as, lm) (x, l, Bk # r) ires |
1598 "inv_after_clear (as, lm) (x, l, Bk # r) ires |
1694 \<Longrightarrow> inv_on_right_moving (as, lm) (y, Bk # l, r) ires" |
1599 \<Longrightarrow> inv_on_right_moving (as, lm) (y, Bk # l, r) ires" |
1695 apply(auto simp: inv_after_clear.simps inv_on_right_moving.simps ) |
1600 apply(auto simp: inv_after_clear.simps inv_on_right_moving.simps ) |
1696 apply(subgoal_tac "lm2 \<noteq> []") |
1601 apply(subgoal_tac "lm2 \<noteq> []") |
1701 apply(case_tac [!] "lm2::nat list", auto) |
1606 apply(case_tac [!] "lm2::nat list", auto) |
1702 apply(case_tac rn, auto split: if_splits simp: tape_of_nl_cons) |
1607 apply(case_tac rn, auto split: if_splits simp: tape_of_nl_cons) |
1703 apply(case_tac [!] rn, simp_all) |
1608 apply(case_tac [!] rn, simp_all) |
1704 done |
1609 done |
1705 |
1610 |
1706 lemma [simp]: "inv_after_clear (as, lm) (x, l, []) ires\<Longrightarrow> |
1611 lemma inv_after_clear_singleton_Bk[simp]: "inv_after_clear (as, lm) (x, l, []) ires\<Longrightarrow> |
1707 inv_after_clear (as, lm) (y, l, [Bk]) ires" |
1612 inv_after_clear (as, lm) (y, l, [Bk]) ires" |
1708 by(auto simp: inv_after_clear.simps) |
1613 by(auto simp: inv_after_clear.simps) |
1709 |
1614 |
1710 lemma [simp]: "inv_after_clear (as, lm) (x, l, []) ires |
1615 lemma inv_on_right_moving_Bk[simp]: "inv_after_clear (as, lm) (x, l, []) ires |
1711 \<Longrightarrow> inv_on_right_moving (as, lm) (y, Bk # l, []) ires" |
1616 \<Longrightarrow> inv_on_right_moving (as, lm) (y, Bk # l, []) ires" |
1712 by(insert |
1617 by(insert |
1713 inv_after_clear_2_inv_on_right_moving[of as lm n l "[]"], simp) |
1618 inv_after_clear_2_inv_on_right_moving[of as lm n l "[]"], simp) |
1714 |
1619 |
1715 (*inv: from on_right_moving to on_right_movign*) |
1620 (*inv: from on_right_moving to on_right_movign*) |
1716 lemma [simp]: "inv_on_right_moving (as, lm) (x, l, Oc # r) ires |
1621 lemma inv_on_right_moving_Oc[simp]: "inv_on_right_moving (as, lm) (x, l, Oc # r) ires |
1717 \<Longrightarrow> inv_on_right_moving (as, lm) (y, Oc # l, r) ires" |
1622 \<Longrightarrow> inv_on_right_moving (as, lm) (y, Oc # l, r) ires" |
1718 apply(auto simp: inv_on_right_moving.simps) |
1623 apply(auto simp: inv_on_right_moving.simps) |
1719 apply(rule_tac x = lm1 in exI, rule_tac x = lm2 in exI, |
1624 apply(rule_tac x = lm1 in exI, rule_tac x = lm2 in exI, |
1720 rule_tac x = "ml + mr" in exI, simp) |
1625 rule_tac x = "ml + mr" in exI, simp) |
1721 apply(rule_tac x = "Suc ml" in exI, |
1626 apply(rule_tac x = "Suc ml" in exI, |
1733 \<Longrightarrow> inv_after_write (as, lm) (y, l, Oc # r) ires" |
1638 \<Longrightarrow> inv_after_write (as, lm) (y, l, Oc # r) ires" |
1734 apply(auto simp: inv_on_right_moving.simps inv_after_write.simps ) |
1639 apply(auto simp: inv_on_right_moving.simps inv_after_write.simps ) |
1735 apply(case_tac mr, auto simp: split: if_splits) |
1640 apply(case_tac mr, auto simp: split: if_splits) |
1736 done |
1641 done |
1737 |
1642 |
1738 lemma [simp]: "inv_on_right_moving (as, lm) (x, l, []) ires\<Longrightarrow> |
1643 lemma inv_on_right_moving_singleton_Bk[simp]: "inv_on_right_moving (as, lm) (x, l, []) ires\<Longrightarrow> |
1739 inv_on_right_moving (as, lm) (y, l, [Bk]) ires" |
1644 inv_on_right_moving (as, lm) (y, l, [Bk]) ires" |
1740 apply(auto simp: inv_on_right_moving.simps) |
1645 apply(auto simp: inv_on_right_moving.simps) |
1741 apply(rule_tac x = lm1 in exI, rule_tac x = "[]" in exI, simp) |
1646 apply(rule_tac x = lm1 in exI, rule_tac x = "[]" in exI, simp) |
1742 done |
1647 done |
1743 |
1648 |
1744 (*inv: from on_right_moving to after_write*) |
1649 (*inv: from on_right_moving to after_write*) |
1745 lemma [simp]: "inv_on_right_moving (as, lm) (x, l, []) ires |
1650 lemma inv_after_write_singleton_Oc[simp]: "inv_on_right_moving (as, lm) (x, l, []) ires |
1746 \<Longrightarrow> inv_after_write (as, lm) (y, l, [Oc]) ires" |
1651 \<Longrightarrow> inv_after_write (as, lm) (y, l, [Oc]) ires" |
1747 apply(rule_tac inv_on_right_moving_2_inv_on_right_moving, simp) |
1652 apply(rule_tac inv_on_right_moving_2_inv_on_right_moving, simp) |
1748 done |
1653 done |
1749 |
1654 |
1750 (*inv: from on_left_moving to on_left_moving*) |
1655 (*inv: from on_left_moving to on_left_moving*) |
1751 lemma [simp]: "inv_on_left_moving_in_middle_B (as, lm) |
1656 lemma no_inv_on_left_moving_in_middle_B_Oc[simp]: "inv_on_left_moving_in_middle_B (as, lm) |
1752 (s, l, Oc # r) ires = False" |
1657 (s, l, Oc # r) ires = False" |
1753 apply(auto simp: inv_on_left_moving_in_middle_B.simps ) |
1658 apply(auto simp: inv_on_left_moving_in_middle_B.simps ) |
1754 done |
1659 done |
1755 |
1660 |
1756 lemma [simp]: "inv_on_left_moving_norm (as, lm) (s, l, Bk # r) ires |
1661 lemma no_inv_on_left_moving_norm_Bk[simp]: "inv_on_left_moving_norm (as, lm) (s, l, Bk # r) ires |
1757 = False" |
1662 = False" |
1758 apply(auto simp: inv_on_left_moving_norm.simps) |
1663 apply(auto simp: inv_on_left_moving_norm.simps) |
1759 apply(case_tac [!] mr, auto simp: ) |
1664 apply(case_tac [!] mr, auto simp: ) |
1760 done |
1665 done |
1761 |
1666 |
1762 lemma [simp]: |
1667 lemma inv_on_left_moving_in_middle_B_Bk[simp]: |
1763 "\<lbrakk>inv_on_left_moving_norm (as, lm) (s, l, Oc # r) ires; |
1668 "\<lbrakk>inv_on_left_moving_norm (as, lm) (s, l, Oc # r) ires; |
1764 hd l = Bk; l \<noteq> []\<rbrakk> \<Longrightarrow> |
1669 hd l = Bk; l \<noteq> []\<rbrakk> \<Longrightarrow> |
1765 inv_on_left_moving_in_middle_B (as, lm) (s, tl l, Bk # Oc # r) ires" |
1670 inv_on_left_moving_in_middle_B (as, lm) (s, tl l, Bk # Oc # r) ires" |
1766 apply(case_tac l, simp, simp) |
1671 apply(case_tac l, simp, simp) |
1767 apply(simp only: inv_on_left_moving_norm.simps |
1672 apply(simp only: inv_on_left_moving_norm.simps |
1771 apply(case_tac [!] ml, auto) |
1676 apply(case_tac [!] ml, auto) |
1772 apply(auto simp: tape_of_nl_cons split: if_splits) |
1677 apply(auto simp: tape_of_nl_cons split: if_splits) |
1773 apply(rule_tac [!] x = "Suc rn" in exI, simp_all) |
1678 apply(rule_tac [!] x = "Suc rn" in exI, simp_all) |
1774 done |
1679 done |
1775 |
1680 |
1776 lemma [simp]: "\<lbrakk>inv_on_left_moving_norm (as, lm) (s, l, Oc # r) ires; |
1681 lemma inv_on_left_moving_norm_Oc_Oc[simp]: "\<lbrakk>inv_on_left_moving_norm (as, lm) (s, l, Oc # r) ires; |
1777 hd l = Oc; l \<noteq> []\<rbrakk> |
1682 hd l = Oc; l \<noteq> []\<rbrakk> |
1778 \<Longrightarrow> inv_on_left_moving_norm (as, lm) |
1683 \<Longrightarrow> inv_on_left_moving_norm (as, lm) |
1779 (s, tl l, Oc # Oc # r) ires" |
1684 (s, tl l, Oc # Oc # r) ires" |
1780 apply(simp only: inv_on_left_moving_norm.simps) |
1685 apply(simp only: inv_on_left_moving_norm.simps) |
1781 apply(erule exE)+ |
1686 apply(erule exE)+ |
1783 rule_tac x = m in exI, rule_tac x = "ml - 1" in exI, |
1688 rule_tac x = m in exI, rule_tac x = "ml - 1" in exI, |
1784 rule_tac x = "Suc mr" in exI, rule_tac x = rn in exI, simp) |
1689 rule_tac x = "Suc mr" in exI, rule_tac x = rn in exI, simp) |
1785 apply(case_tac ml, auto simp: split: if_splits) |
1690 apply(case_tac ml, auto simp: split: if_splits) |
1786 done |
1691 done |
1787 |
1692 |
1788 lemma [simp]: "inv_on_left_moving_norm (as, lm) (s, [], Oc # r) ires |
1693 lemma inv_on_left_moving_in_middle_B_Bk_Oc[simp]: "inv_on_left_moving_norm (as, lm) (s, [], Oc # r) ires |
1789 \<Longrightarrow> inv_on_left_moving_in_middle_B (as, lm) (s, [], Bk # Oc # r) ires" |
1694 \<Longrightarrow> inv_on_left_moving_in_middle_B (as, lm) (s, [], Bk # Oc # r) ires" |
1790 apply(auto simp: inv_on_left_moving_norm.simps |
1695 apply(auto simp: inv_on_left_moving_norm.simps |
1791 inv_on_left_moving_in_middle_B.simps split: if_splits) |
1696 inv_on_left_moving_in_middle_B.simps split: if_splits) |
1792 done |
1697 done |
1793 |
1698 |
1794 lemma [simp]:"inv_on_left_moving (as, lm) (s, l, Oc # r) ires |
1699 lemma inv_on_left_moving_Oc_cases[simp]:"inv_on_left_moving (as, lm) (s, l, Oc # r) ires |
1795 \<Longrightarrow> (l = [] \<longrightarrow> inv_on_left_moving (as, lm) (s, [], Bk # Oc # r) ires) |
1700 \<Longrightarrow> (l = [] \<longrightarrow> inv_on_left_moving (as, lm) (s, [], Bk # Oc # r) ires) |
1796 \<and> (l \<noteq> [] \<longrightarrow> inv_on_left_moving (as, lm) (s, tl l, hd l # Oc # r) ires)" |
1701 \<and> (l \<noteq> [] \<longrightarrow> inv_on_left_moving (as, lm) (s, tl l, hd l # Oc # r) ires)" |
1797 apply(simp add: inv_on_left_moving.simps) |
1702 apply(simp add: inv_on_left_moving.simps) |
1798 apply(case_tac "l \<noteq> []", rule conjI, simp, simp) |
1703 apply(case_tac "l \<noteq> []", rule conjI, simp, simp) |
1799 apply(case_tac "hd l", simp, simp, simp) |
1704 apply(case_tac "hd l", simp, simp, simp) |
1807 inv_check_left_moving_on_leftmost.simps split: if_splits) |
1712 inv_check_left_moving_on_leftmost.simps split: if_splits) |
1808 apply(case_tac [!] "rev lm1", simp_all) |
1713 apply(case_tac [!] "rev lm1", simp_all) |
1809 apply(case_tac [!] lista, simp_all add: tape_of_nat_def tape_of_list_def) |
1714 apply(case_tac [!] lista, simp_all add: tape_of_nat_def tape_of_list_def) |
1810 done |
1715 done |
1811 |
1716 |
1812 lemma [simp]: |
1717 lemma inv_check_left_moving_in_middle_no_Bk[simp]: |
1813 "inv_check_left_moving_in_middle (as, lm) (s, l, Bk # r) ires= False" |
1718 "inv_check_left_moving_in_middle (as, lm) (s, l, Bk # r) ires= False" |
1814 by(auto simp: inv_check_left_moving_in_middle.simps ) |
1719 by(auto simp: inv_check_left_moving_in_middle.simps ) |
1815 |
1720 |
1816 lemma [simp]: |
1721 lemma inv_check_left_moving_on_leftmost_Bk_Bk[simp]: |
1817 "inv_on_left_moving_in_middle_B (as, lm) (s, [], Bk # r) ires\<Longrightarrow> |
1722 "inv_on_left_moving_in_middle_B (as, lm) (s, [], Bk # r) ires\<Longrightarrow> |
1818 inv_check_left_moving_on_leftmost (as, lm) (s', [], Bk # Bk # r) ires" |
1723 inv_check_left_moving_on_leftmost (as, lm) (s', [], Bk # Bk # r) ires" |
1819 apply(auto simp: inv_on_left_moving_in_middle_B.simps |
1724 apply(auto simp: inv_on_left_moving_in_middle_B.simps |
1820 inv_check_left_moving_on_leftmost.simps split: if_splits) |
1725 inv_check_left_moving_on_leftmost.simps split: if_splits) |
1821 done |
1726 done |
1822 |
1727 |
1823 lemma [simp]: "inv_check_left_moving_on_leftmost (as, lm) |
1728 lemma inv_check_left_moving_on_leftmost_no_Oc[simp]: "inv_check_left_moving_on_leftmost (as, lm) |
1824 (s, list, Oc # r) ires= False" |
1729 (s, list, Oc # r) ires= False" |
1825 by(auto simp: inv_check_left_moving_on_leftmost.simps split: if_splits) |
1730 by(auto simp: inv_check_left_moving_on_leftmost.simps split: if_splits) |
1826 |
1731 |
1827 lemma [simp]: "inv_on_left_moving_in_middle_B (as, lm) |
1732 lemma inv_check_left_moving_in_middle_Oc_Bk[simp]: "inv_on_left_moving_in_middle_B (as, lm) |
1828 (s, Oc # list, Bk # r) ires |
1733 (s, Oc # list, Bk # r) ires |
1829 \<Longrightarrow> inv_check_left_moving_in_middle (as, lm) (s', list, Oc # Bk # r) ires" |
1734 \<Longrightarrow> inv_check_left_moving_in_middle (as, lm) (s', list, Oc # Bk # r) ires" |
1830 apply(auto simp: inv_on_left_moving_in_middle_B.simps |
1735 apply(auto simp: inv_on_left_moving_in_middle_B.simps |
1831 inv_check_left_moving_in_middle.simps split: if_splits) |
1736 inv_check_left_moving_in_middle.simps split: if_splits) |
1832 done |
1737 done |
1839 apply(simp add: inv_on_left_moving.simps inv_check_left_moving.simps) |
1744 apply(simp add: inv_on_left_moving.simps inv_check_left_moving.simps) |
1840 apply(case_tac l, simp, simp) |
1745 apply(case_tac l, simp, simp) |
1841 apply(case_tac a, simp, simp) |
1746 apply(case_tac a, simp, simp) |
1842 done |
1747 done |
1843 |
1748 |
1844 lemma [simp]: "inv_on_left_moving_norm (as, lm) (s, l, []) ires = False" |
1749 lemma inv_on_left_moving_norm_no_empty[simp]: "inv_on_left_moving_norm (as, lm) (s, l, []) ires = False" |
1845 apply(auto simp: inv_on_left_moving_norm.simps) |
1750 apply(auto simp: inv_on_left_moving_norm.simps) |
1846 done |
1751 done |
1847 |
1752 |
1848 lemma [simp]: "inv_on_left_moving (as, lm) (s, l, []) ires\<Longrightarrow> |
1753 lemma inv_on_left_moving_Bk[simp]: "inv_on_left_moving (as, lm) (s, l, []) ires\<Longrightarrow> |
1849 inv_on_left_moving (as, lm) (6 + 2 * n, l, [Bk]) ires" |
1754 inv_on_left_moving (as, lm) (6 + 2 * n, l, [Bk]) ires" |
1850 apply(simp add: inv_on_left_moving.simps) |
1755 apply(simp add: inv_on_left_moving.simps) |
1851 apply(auto simp: inv_on_left_moving_in_middle_B.simps) |
1756 apply(auto simp: inv_on_left_moving_in_middle_B.simps) |
1852 done |
1757 done |
1853 |
1758 |
1854 lemma [simp]: "inv_on_left_moving (as, lm) (s, l, []) ires = False" |
1759 lemma inv_on_left_moving_no_empty[simp]: "inv_on_left_moving (as, lm) (s, l, []) ires = False" |
1855 apply(simp add: inv_on_left_moving.simps) |
1760 apply(simp add: inv_on_left_moving.simps) |
1856 apply(simp add: inv_on_left_moving_in_middle_B.simps) |
1761 apply(simp add: inv_on_left_moving_in_middle_B.simps) |
1857 done |
1762 done |
1858 |
1763 |
1859 lemma [simp]: "inv_on_left_moving (as, lm) (s, l, []) ires |
1764 lemma inv_on_left_moving_cases_left[simp]: "inv_on_left_moving (as, lm) (s, l, []) ires |
1860 \<Longrightarrow> (l = [] \<longrightarrow> inv_check_left_moving (as, lm) (s', [], [Bk]) ires) \<and> |
1765 \<Longrightarrow> (l = [] \<longrightarrow> inv_check_left_moving (as, lm) (s', [], [Bk]) ires) \<and> |
1861 (l \<noteq> [] \<longrightarrow> inv_check_left_moving (as, lm) (s', tl l, [hd l]) ires)" |
1766 (l \<noteq> [] \<longrightarrow> inv_check_left_moving (as, lm) (s', tl l, [hd l]) ires)" |
1862 by simp |
1767 by simp |
1863 |
1768 |
1864 lemma [intro]: "\<exists>rna. Bk # Bk \<up> rn = Bk \<up> rna" |
1769 lemma Bk_plus_one[intro]: "\<exists>rna. Bk # Bk \<up> rn = Bk \<up> rna" |
1865 apply(rule_tac x = "Suc rn" in exI, simp) |
1770 apply(rule_tac x = "Suc rn" in exI, simp) |
1866 done |
1771 done |
1867 |
1772 |
1868 lemma |
1773 lemma |
1869 inv_check_left_moving_in_middle_2_on_left_moving_in_middle_B[simp]: |
1774 inv_check_left_moving_in_middle_2_on_left_moving_in_middle_B[simp]: |
1870 "inv_check_left_moving_in_middle (as, lm) (s, Bk # list, Oc # r) ires |
1775 assumes "inv_check_left_moving_in_middle (as, lm) (s, Bk # list, Oc # r) ires" |
1871 \<Longrightarrow> inv_on_left_moving_in_middle_B (as, lm) (s', list, Bk # Oc # r) ires" |
1776 shows "inv_on_left_moving_in_middle_B (as, lm) (s', list, Bk # Oc # r) ires" |
1872 apply(simp only: inv_check_left_moving_in_middle.simps |
1777 using assms |
1873 inv_on_left_moving_in_middle_B.simps) |
1778 apply(simp only: inv_check_left_moving_in_middle.simps |
1874 apply(erule_tac exE)+ |
1779 inv_on_left_moving_in_middle_B.simps) |
1875 apply(rule_tac x = "rev (tl (rev lm1))" in exI, |
1780 apply(erule_tac exE)+ |
1876 rule_tac x = "[hd (rev lm1)] @ lm2" in exI, auto) |
1781 apply(rule_tac x = "rev (tl (rev lm1))" in exI, |
1877 apply(case_tac [!] "rev lm1",simp_all add: tape_of_nat_def tape_of_list_def tape_of_nat_list.simps) |
1782 rule_tac x = "[hd (rev lm1)] @ lm2" in exI, auto) |
1878 apply(case_tac [!] a, simp_all) |
1783 apply(case_tac [!] "rev lm1",simp_all add: tape_of_nat_def tape_of_list_def tape_of_nat_list.simps) |
1879 apply(case_tac [1] lm2, auto simp:tape_of_nat_def) |
1784 apply(case_tac [!] a, simp_all) |
1880 apply(case_tac [3] lm2, auto simp:tape_of_nat_def) |
1785 apply(case_tac [1] lm2, auto simp:tape_of_nat_def) |
1881 apply(case_tac [!] lista, simp_all add: tape_of_nat_def) |
1786 apply(case_tac [3] lm2, auto simp:tape_of_nat_def) |
1882 done |
1787 apply(case_tac [!] lista, simp_all add: tape_of_nat_def) |
1883 |
1788 done |
1884 lemma [simp]: |
1789 |
1790 lemma inv_check_left_moving_in_middle_Bk_Oc[simp]: |
|
1885 "inv_check_left_moving_in_middle (as, lm) (s, [], Oc # r) ires\<Longrightarrow> |
1791 "inv_check_left_moving_in_middle (as, lm) (s, [], Oc # r) ires\<Longrightarrow> |
1886 inv_check_left_moving_in_middle (as, lm) (s', [Bk], Oc # r) ires" |
1792 inv_check_left_moving_in_middle (as, lm) (s', [Bk], Oc # r) ires" |
1887 apply(auto simp: inv_check_left_moving_in_middle.simps ) |
1793 apply(auto simp: inv_check_left_moving_in_middle.simps ) |
1888 done |
1794 done |
1889 |
1795 lemma inv_on_left_moving_in_middle_B_Bk_Oc_via_check[simp]: |
1890 lemma [simp]: |
|
1891 "inv_check_left_moving_in_middle (as, lm) (s, [], Oc # r) ires |
1796 "inv_check_left_moving_in_middle (as, lm) (s, [], Oc # r) ires |
1892 \<Longrightarrow> inv_on_left_moving_in_middle_B (as, lm) (s', [], Bk # Oc # r) ires" |
1797 \<Longrightarrow> inv_on_left_moving_in_middle_B (as, lm) (s', [], Bk # Oc # r) ires" |
1893 apply(insert |
1798 apply(insert |
1894 inv_check_left_moving_in_middle_2_on_left_moving_in_middle_B[of |
1799 inv_check_left_moving_in_middle_2_on_left_moving_in_middle_B[of |
1895 as lm n "[]" r], simp) |
1800 as lm n "[]" r], simp) |
1896 done |
1801 done |
1897 |
1802 |
1898 lemma [simp]: "inv_check_left_moving_in_middle (as, lm) |
1803 lemma inv_on_left_moving_norm_Oc_Oc_via_middle[simp]: "inv_check_left_moving_in_middle (as, lm) |
1899 (s, Oc # list, Oc # r) ires |
1804 (s, Oc # list, Oc # r) ires |
1900 \<Longrightarrow> inv_on_left_moving_norm (as, lm) (s', list, Oc # Oc # r) ires" |
1805 \<Longrightarrow> inv_on_left_moving_norm (as, lm) (s', list, Oc # Oc # r) ires" |
1901 apply(auto simp: inv_check_left_moving_in_middle.simps |
1806 apply(auto simp: inv_check_left_moving_in_middle.simps |
1902 inv_on_left_moving_norm.simps) |
1807 inv_on_left_moving_norm.simps) |
1903 apply(rule_tac x = "rev (tl (rev lm1))" in exI, |
1808 apply(rule_tac x = "rev (tl (rev lm1))" in exI, |
1908 apply(rule_tac [!] x = "Suc (Suc 0)" in exI, simp) |
1813 apply(rule_tac [!] x = "Suc (Suc 0)" in exI, simp) |
1909 apply(case_tac [!] "rev lm1", simp_all) |
1814 apply(case_tac [!] "rev lm1", simp_all) |
1910 apply(case_tac [!] a, simp_all add: tape_of_nl_cons split: if_splits) |
1815 apply(case_tac [!] a, simp_all add: tape_of_nl_cons split: if_splits) |
1911 done |
1816 done |
1912 |
1817 |
1913 lemma [simp]: "inv_check_left_moving (as, lm) (s, l, Oc # r) ires |
1818 lemma inv_check_left_moving_Oc_cases[simp]: "inv_check_left_moving (as, lm) (s, l, Oc # r) ires |
1914 \<Longrightarrow> (l = [] \<longrightarrow> inv_on_left_moving (as, lm) (s', [], Bk # Oc # r) ires) \<and> |
1819 \<Longrightarrow> (l = [] \<longrightarrow> inv_on_left_moving (as, lm) (s', [], Bk # Oc # r) ires) \<and> |
1915 (l \<noteq> [] \<longrightarrow> inv_on_left_moving (as, lm) (s', tl l, hd l # Oc # r) ires)" |
1820 (l \<noteq> [] \<longrightarrow> inv_on_left_moving (as, lm) (s', tl l, hd l # Oc # r) ires)" |
1916 apply(case_tac l, |
1821 apply(case_tac l, |
1917 auto simp: inv_check_left_moving.simps inv_on_left_moving.simps) |
1822 auto simp: inv_check_left_moving.simps inv_on_left_moving.simps) |
1918 apply(case_tac a, simp, simp) |
1823 apply(case_tac a, simp, simp) |
1919 done |
1824 done |
1920 |
1825 |
1921 (*inv: check_left_moving to after_left_moving*) |
1826 (*inv: check_left_moving to after_left_moving*) |
1922 lemma [simp]: "inv_check_left_moving (as, lm) (s, l, Bk # r) ires |
1827 lemma inv_after_left_moving_Bk_via_check[simp]: "inv_check_left_moving (as, lm) (s, l, Bk # r) ires |
1923 \<Longrightarrow> inv_after_left_moving (as, lm) (s', Bk # l, r) ires" |
1828 \<Longrightarrow> inv_after_left_moving (as, lm) (s', Bk # l, r) ires" |
1924 apply(auto simp: inv_check_left_moving.simps |
1829 apply(auto simp: inv_check_left_moving.simps |
1925 inv_check_left_moving_on_leftmost.simps inv_after_left_moving.simps) |
1830 inv_check_left_moving_on_leftmost.simps inv_after_left_moving.simps) |
1926 done |
1831 done |
1927 |
1832 |
1928 |
1833 |
1929 lemma [simp]:"inv_check_left_moving (as, lm) (s, l, []) ires |
1834 lemma inv_after_left_moving_Bk_empty_via_check[simp]:"inv_check_left_moving (as, lm) (s, l, []) ires |
1930 \<Longrightarrow> inv_after_left_moving (as, lm) (s', Bk # l, []) ires" |
1835 \<Longrightarrow> inv_after_left_moving (as, lm) (s', Bk # l, []) ires" |
1931 by(simp add: inv_check_left_moving.simps |
1836 by(simp add: inv_check_left_moving.simps |
1932 inv_check_left_moving_in_middle.simps |
1837 inv_check_left_moving_in_middle.simps |
1933 inv_check_left_moving_on_leftmost.simps) |
1838 inv_check_left_moving_on_leftmost.simps) |
1934 |
1839 |
1935 (*inv: after_left_moving to inv_stop*) |
1840 (*inv: after_left_moving to inv_stop*) |
1936 lemma [simp]: "inv_after_left_moving (as, lm) (s, l, Bk # r) ires |
1841 lemma inv_stop_Bk_move[simp]: "inv_after_left_moving (as, lm) (s, l, Bk # r) ires |
1937 \<Longrightarrow> inv_stop (as, lm) (s', Bk # l, r) ires" |
1842 \<Longrightarrow> inv_stop (as, lm) (s', Bk # l, r) ires" |
1938 apply(auto simp: inv_after_left_moving.simps inv_stop.simps) |
1843 apply(auto simp: inv_after_left_moving.simps inv_stop.simps) |
1939 done |
1844 done |
1940 |
1845 |
1941 lemma [simp]: "inv_after_left_moving (as, lm) (s, l, []) ires |
1846 lemma inv_stop_Bk_empty[simp]: "inv_after_left_moving (as, lm) (s, l, []) ires |
1942 \<Longrightarrow> inv_stop (as, lm) (s', Bk # l, []) ires" |
1847 \<Longrightarrow> inv_stop (as, lm) (s', Bk # l, []) ires" |
1943 by(auto simp: inv_after_left_moving.simps) |
1848 by(auto simp: inv_after_left_moving.simps) |
1944 |
1849 |
1945 (*inv: stop to stop*) |
1850 (*inv: stop to stop*) |
1946 lemma [simp]: "inv_stop (as, lm) (x, l, r) ires \<Longrightarrow> |
1851 lemma inv_stop_indep_fst[simp]: "inv_stop (as, lm) (x, l, r) ires \<Longrightarrow> |
1947 inv_stop (as, lm) (y, l, r) ires" |
1852 inv_stop (as, lm) (y, l, r) ires" |
1948 apply(simp add: inv_stop.simps) |
1853 apply(simp add: inv_stop.simps) |
1949 done |
1854 done |
1950 |
1855 |
1951 lemma [simp]: "inv_after_clear (as, lm) (s, aaa, Oc # xs) ires= False" |
1856 lemma inv_after_clear_no_Oc[simp]: "inv_after_clear (as, lm) (s, aaa, Oc # xs) ires= False" |
1952 apply(auto simp: inv_after_clear.simps ) |
1857 apply(auto simp: inv_after_clear.simps ) |
1953 done |
1858 done |
1954 |
1859 |
1955 lemma [simp]: |
1860 lemma inv_after_left_moving_no_Oc[simp]: |
1956 "inv_after_left_moving (as, lm) (s, aaa, Oc # xs) ires = False" |
1861 "inv_after_left_moving (as, lm) (s, aaa, Oc # xs) ires = False" |
1957 by(auto simp: inv_after_left_moving.simps ) |
1862 by(auto simp: inv_after_left_moving.simps ) |
1958 |
1863 |
1959 lemma [simp]: "inv_after_clear (as, abc_lm_s lm n (Suc (abc_lm_v lm n))) (s, b, []) ires = False" |
1864 lemma inv_after_clear_Suc_nonempty[simp]: |
1865 "inv_after_clear (as, abc_lm_s lm n (Suc (abc_lm_v lm n))) (s, b, []) ires = False" |
|
1960 apply(auto simp: inv_after_clear.simps) |
1866 apply(auto simp: inv_after_clear.simps) |
1961 done |
1867 done |
1962 |
1868 |
1963 lemma [simp]: "inv_on_left_moving (as, abc_lm_s lm n (Suc (abc_lm_v lm n))) |
1869 lemma inv_on_left_moving_Suc_nonempty[simp]: "inv_on_left_moving (as, abc_lm_s lm n (Suc (abc_lm_v lm n))) |
1964 (s, b, Oc # list) ires \<Longrightarrow> b \<noteq> []" |
1870 (s, b, Oc # list) ires \<Longrightarrow> b \<noteq> []" |
1965 apply(auto simp: inv_on_left_moving.simps inv_on_left_moving_norm.simps split: if_splits) |
1871 apply(auto simp: inv_on_left_moving.simps inv_on_left_moving_norm.simps split: if_splits) |
1966 done |
1872 done |
1967 |
1873 |
1968 lemma [simp]: "inv_check_left_moving (as, abc_lm_s lm n (Suc (abc_lm_v lm n))) (s, b, Oc # list) ires \<Longrightarrow> b \<noteq> []" |
1874 lemma inv_check_left_moving_Suc_nonempty[simp]: |
1875 "inv_check_left_moving (as, abc_lm_s lm n (Suc (abc_lm_v lm n))) (s, b, Oc # list) ires \<Longrightarrow> b \<noteq> []" |
|
1969 apply(auto simp: inv_check_left_moving.simps inv_check_left_moving_in_middle.simps split: if_splits) |
1876 apply(auto simp: inv_check_left_moving.simps inv_check_left_moving_in_middle.simps split: if_splits) |
1970 done |
1877 done |
1971 |
|
1972 lemma numeral_4_eq_4: "4 = Suc (Suc (Suc (Suc 0)))" |
|
1973 by arith |
|
1974 |
1878 |
1975 lemma tinc_correct_pre: |
1879 lemma tinc_correct_pre: |
1976 assumes layout: "ly = layout_of ap" |
1880 assumes layout: "ly = layout_of ap" |
1977 and inv_start: "inv_locate_a (as, lm) (n, l, r) ires" |
1881 and inv_start: "inv_locate_a (as, lm) (n, l, r) ires" |
1978 and lm': "lm' = abc_lm_s lm n (Suc (abc_lm_v lm n))" |
1882 and lm': "lm' = abc_lm_s lm n (Suc (abc_lm_v lm n))" |
2001 thus "Q (step (a, b, c) (tinc_b, 0)) \<and> (step (a, b, c) (tinc_b, 0), a, b, c) \<in> inc_LE" |
1905 thus "Q (step (a, b, c) (tinc_b, 0)) \<and> (step (a, b, c) (tinc_b, 0), a, b, c) \<in> inc_LE" |
2002 apply(simp add:Q) |
1906 apply(simp add:Q) |
2003 apply(simp add: inc_inv.simps) |
1907 apply(simp add: inc_inv.simps) |
2004 apply(case_tac c, case_tac [2] aa) |
1908 apply(case_tac c, case_tac [2] aa) |
2005 apply(auto simp: Let_def step.simps tinc_b_def split: if_splits) |
1909 apply(auto simp: Let_def step.simps tinc_b_def split: if_splits) |
2006 apply(simp_all add: inc_inv.simps inc_LE_def lex_triple_def lex_pair_def inc_measure_def numeral_5_eq_5 numeral_2_eq_2 numeral_3_eq_3 |
1910 apply(simp_all add: inc_inv.simps inc_LE_def lex_triple_def lex_pair_def inc_measure_def |
2007 numeral_4_eq_4 numeral_6_eq_6 numeral_7_eq_7 numeral_8_eq_8 numeral_9_eq_9) |
1911 numeral) |
2008 done |
1912 done |
2009 qed |
1913 qed |
2010 qed |
1914 qed |
2011 |
1915 |
2012 lemma tinc_correct: |
1916 lemma tinc_correct: |
2013 assumes layout: "ly = layout_of ap" |
1917 assumes layout: "ly = layout_of ap" |
2014 and inv_start: "inv_locate_a (as, lm) (n, l, r) ires" |
1918 and inv_start: "inv_locate_a (as, lm) (n, l, r) ires" |
2015 and lm': "lm' = abc_lm_s lm n (Suc (abc_lm_v lm n))" |
1919 and lm': "lm' = abc_lm_s lm n (Suc (abc_lm_v lm n))" |
2016 shows "\<exists> stp l' r'. steps (Suc 0, l, r) (tinc_b, 0) stp = (10, l', r') |
1920 shows "\<exists> stp l' r'. steps (Suc 0, l, r) (tinc_b, 0) stp = (10, l', r') |
2022 done |
1926 done |
2023 |
1927 |
2024 declare inv_locate_a.simps[simp del] abc_lm_s.simps[simp del] |
1928 declare inv_locate_a.simps[simp del] abc_lm_s.simps[simp del] |
2025 abc_lm_v.simps[simp del] |
1929 abc_lm_v.simps[simp del] |
2026 |
1930 |
2027 lemma [simp]: "(4::nat) * n mod 2 = 0" |
1931 lemma is_even_4[simp]: "(4::nat) * n mod 2 = 0" |
2028 apply(arith) |
1932 apply(arith) |
2029 done |
1933 done |
2030 |
1934 |
2031 lemma crsp_step_inc_pre: |
1935 lemma crsp_step_inc_pre: |
2032 assumes layout: "ly = layout_of ap" |
1936 assumes layout: "ly = layout_of ap" |
2192 else if s = ss + 2 * n + 15 then |
2096 else if s = ss + 2 * n + 15 then |
2193 inv_after_left_moving (as, am'') (s, l, r) ires |
2097 inv_after_left_moving (as, am'') (s, l, r) ires |
2194 else False)" |
2098 else False)" |
2195 |
2099 |
2196 declare fetch.simps[simp del] |
2100 declare fetch.simps[simp del] |
2197 lemma [simp]: |
2101 |
2102 |
|
2103 lemma x_plus_helpers: |
|
2104 "x + 4 = Suc (x + 3)" |
|
2105 "x + 5 = Suc (x + 4)" |
|
2106 "x + 6 = Suc (x + 5)" |
|
2107 "x + 7 = Suc (x + 6)" |
|
2108 "x + 8 = Suc (x + 7)" |
|
2109 "x + 9 = Suc (x + 8)" |
|
2110 "x + 10 = Suc (x + 9)" |
|
2111 "x + 11 = Suc (x + 10)" |
|
2112 "x + 12 = Suc (x + 11)" |
|
2113 "x + 13 = Suc (x + 12)" |
|
2114 "14 + x = Suc (x + 13)" |
|
2115 "15 + x = Suc (x + 14)" |
|
2116 "16 + x = Suc (x + 15)" |
|
2117 by auto |
|
2118 |
|
2119 lemma fetch_Dec[simp]: |
|
2198 "fetch (ci ly (start_of ly as) (Dec n e)) (Suc (2 * n)) Bk = (W1, start_of ly as + 2 *n)" |
2120 "fetch (ci ly (start_of ly as) (Dec n e)) (Suc (2 * n)) Bk = (W1, start_of ly as + 2 *n)" |
2199 apply(auto simp: fetch.simps length_ci_dec) |
|
2200 apply(auto simp: ci.simps nth_append length_findnth adjust.simps shift.simps tdec_b_def) |
|
2201 using startof_not0[of ly as] by simp |
|
2202 |
|
2203 lemma [simp]: |
|
2204 "fetch (ci ly (start_of ly as) (Dec n e)) (Suc (2 * n)) Oc = (R, Suc (start_of ly as) + 2 *n)" |
2121 "fetch (ci ly (start_of ly as) (Dec n e)) (Suc (2 * n)) Oc = (R, Suc (start_of ly as) + 2 *n)" |
2205 apply(auto simp: fetch.simps length_ci_dec) |
2122 "fetch (ci (ly) (start_of ly as) (Dec n e)) (Suc (Suc (2 * n))) Oc |
2206 apply(auto simp: ci.simps nth_append length_findnth adjust.simps shift.simps tdec_b_def) |
2123 = (R, start_of ly as + 2*n + 2)" |
2207 done |
2124 "fetch (ci (ly) (start_of ly as) (Dec n e)) (Suc (Suc (2 * n))) Bk |
2208 |
2125 = (L, start_of ly as + 2*n + 13)" |
2209 lemma [simp]: |
2126 "fetch (ci (ly) (start_of ly as) (Dec n e)) (Suc (Suc (Suc (2 * n)))) Oc |
2127 = (R, start_of ly as + 2*n + 2)" |
|
2128 "fetch (ci (ly) (start_of ly as) (Dec n e)) (Suc (Suc (Suc (2 * n)))) Bk |
|
2129 = (L, start_of ly as + 2*n + 3)" |
|
2130 "fetch (ci (ly) (start_of ly as) (Dec n e)) (2 * n + 4) Oc = (W0, start_of ly as + 2*n + 3)" |
|
2131 "fetch (ci (ly) (start_of ly as) (Dec n e)) (2 * n + 4) Bk = (R, start_of ly as + 2*n + 4)" |
|
2132 "fetch (ci (ly) (start_of ly as) (Dec n e)) (2 * n + 5) Bk = (R, start_of ly as + 2*n + 5)" |
|
2133 "fetch (ci (ly) (start_of ly as) (Dec n e)) (2 * n + 6) Bk = (L, start_of ly as + 2*n + 6)" |
|
2134 "fetch (ci (ly) (start_of ly as) (Dec n e)) (2 * n + 6) Oc = (L, start_of ly as + 2*n + 7)" |
|
2135 "fetch (ci (ly) (start_of ly as) (Dec n e)) (2 * n + 7) Bk = (L, start_of ly as + 2*n + 10)" |
|
2136 "fetch (ci (ly) (start_of ly as) (Dec n e)) (2 * n + 8) Bk = (W1, start_of ly as + 2*n + 7)" |
|
2137 "fetch (ci (ly) (start_of ly as) (Dec n e)) (2 * n + 8) Oc = (R, start_of ly as + 2*n + 8)" |
|
2138 "fetch (ci (ly) (start_of ly as) (Dec n e)) (2 * n + 9) Bk = (L, start_of ly as + 2*n + 9)" |
|
2139 "fetch (ci (ly) (start_of ly as) (Dec n e)) (2 * n + 9) Oc = (R, start_of ly as + 2*n + 8)" |
|
2140 "fetch (ci (ly) (start_of ly as) (Dec n e)) (2 * n + 10) Bk = (R, start_of ly as + 2*n + 4)" |
|
2141 "fetch (ci (ly) (start_of ly as) (Dec n e)) (2 * n + 10) Oc = (W0, start_of ly as + 2*n + 9)" |
|
2142 "fetch (ci (ly) (start_of ly as) (Dec n e)) (2 * n + 11) Oc = (L, start_of ly as + 2*n + 10)" |
|
2143 "fetch (ci (ly) (start_of ly as) (Dec n e)) (2 * n + 11) Bk = (L, start_of ly as + 2*n + 11)" |
|
2144 "fetch (ci (ly) (start_of ly as) (Dec n e)) (2 * n + 12) Oc = (L, start_of ly as + 2*n + 10)" |
|
2145 "fetch (ci (ly) (start_of ly as) (Dec n e)) (2 * n + 12) Bk = (R, start_of ly as + 2*n + 12)" |
|
2146 "fetch (ci (ly) (start_of ly as) (Dec n e)) (2 * n + 13) Bk = (R, start_of ly as + 2*n + 16)" |
|
2147 "fetch (ci (ly) (start_of ly as) (Dec n e)) (14 + 2 * n) Oc = (L, start_of ly as + 2*n + 13)" |
|
2148 "fetch (ci (ly) (start_of ly as) (Dec n e)) (14 + 2 * n) Bk = (L, start_of ly as + 2*n + 14)" |
|
2149 "fetch (ci (ly) (start_of ly as) (Dec n e)) (15 + 2 * n) Oc = (L, start_of ly as + 2*n + 13)" |
|
2150 "fetch (ci (ly) (start_of ly as) (Dec n e)) (15 + 2 * n) Bk = (R, start_of ly as + 2*n + 15)" |
|
2151 "fetch (ci (ly) (start_of (ly) as) (Dec n e)) (16 + 2 * n) Bk = (R, start_of (ly) e)" |
|
2152 unfolding x_plus_helpers fetch.simps |
|
2153 by(auto simp: ci.simps findnth.simps |
|
2154 nth_of.simps shift.simps nth_append tdec_b_def length_findnth adjust.simps) |
|
2155 |
|
2156 lemma steps_start_of_invb_inv_locate_a1[simp]: |
|
2210 "\<lbrakk>r = [] \<or> hd r = Bk; inv_locate_a (as, lm) (n, l, r) ires\<rbrakk> |
2157 "\<lbrakk>r = [] \<or> hd r = Bk; inv_locate_a (as, lm) (n, l, r) ires\<rbrakk> |
2211 \<Longrightarrow> \<exists>stp la ra. |
2158 \<Longrightarrow> \<exists>stp la ra. |
2212 steps (start_of ly as + 2 * n, l, r) (ci ly (start_of ly as) (Dec n e), |
2159 steps (start_of ly as + 2 * n, l, r) (ci ly (start_of ly as) (Dec n e), |
2213 start_of ly as - Suc 0) stp = (Suc (start_of ly as + 2 * n), la, ra) \<and> |
2160 start_of ly as - Suc 0) stp = (Suc (start_of ly as + 2 * n), la, ra) \<and> |
2214 inv_locate_b (as, lm) (n, la, ra) ires" |
2161 inv_locate_b (as, lm) (n, la, ra) ires" |
2215 apply(rule_tac x = "Suc (Suc 0)" in exI) |
2162 apply(rule_tac x = "Suc (Suc 0)" in exI) |
2216 apply(auto simp: steps.simps step.simps length_ci_dec) |
2163 apply(auto simp: steps.simps step.simps length_ci_dec) |
2217 apply(case_tac r, simp_all) |
2164 apply(case_tac r, simp_all) |
2218 done |
2165 done |
2219 |
2166 |
2220 lemma [simp]: |
2167 lemma steps_start_of_invb_inv_locate_a2[simp]: |
2221 "\<lbrakk>inv_locate_a (as, lm) (n, l, r) ires; r \<noteq> [] \<and> hd r \<noteq> Bk\<rbrakk> |
2168 "\<lbrakk>inv_locate_a (as, lm) (n, l, r) ires; r \<noteq> [] \<and> hd r \<noteq> Bk\<rbrakk> |
2222 \<Longrightarrow> \<exists>stp la ra. |
2169 \<Longrightarrow> \<exists>stp la ra. |
2223 steps (start_of ly as + 2 * n, l, r) (ci ly (start_of ly as) (Dec n e), |
2170 steps (start_of ly as + 2 * n, l, r) (ci ly (start_of ly as) (Dec n e), |
2224 start_of ly as - Suc 0) stp = (Suc (start_of ly as + 2 * n), la, ra) \<and> |
2171 start_of ly as - Suc 0) stp = (Suc (start_of ly as + 2 * n), la, ra) \<and> |
2225 inv_locate_b (as, lm) (n, la, ra) ires" |
2172 inv_locate_b (as, lm) (n, la, ra) ires" |
2331 by(simp add: startof_Suc2) |
2278 by(simp add: startof_Suc2) |
2332 ultimately show "?thesis" |
2279 ultimately show "?thesis" |
2333 by arith |
2280 by arith |
2334 qed |
2281 qed |
2335 |
2282 |
2336 lemma [elim]: "\<lbrakk>abc_fetch as ap = Some (Dec n e); as < e; |
2283 lemma abc_fetch_contrE[elim]: "\<lbrakk>abc_fetch as ap = Some (Dec n e); as < e; |
2337 Suc (start_of (layout_of ap) as + 2 * n) = start_of (layout_of ap) e\<rbrakk> \<Longrightarrow> RR" |
2284 Suc (start_of (layout_of ap) as + 2 * n) = start_of (layout_of ap) e\<rbrakk> \<Longrightarrow> RR" |
2338 apply(drule_tac start_of_ge, simp_all) |
2285 by(drule_tac start_of_ge, auto) |
2339 apply(auto) |
2286 |
2340 done |
2287 lemma abc_fetch_contrE2[elim]: "\<lbrakk>abc_fetch as ap = Some (Dec n e); as > e; |
2341 |
|
2342 lemma [elim]: "\<lbrakk>abc_fetch as ap = Some (Dec n e); as > e; |
|
2343 Suc (start_of (layout_of ap) as + 2 * n) = start_of (layout_of ap) e\<rbrakk> \<Longrightarrow> RR" |
2288 Suc (start_of (layout_of ap) as + 2 * n) = start_of (layout_of ap) e\<rbrakk> \<Longrightarrow> RR" |
2344 apply(drule_tac ly = "layout_of ap" in start_of_less[of]) |
2289 apply(drule_tac ly = "layout_of ap" in start_of_less[of]) |
2345 apply(arith) |
2290 apply(arith) |
2346 done |
2291 done |
2347 |
2292 |
2348 lemma [elim]: "\<lbrakk>abc_fetch as ap = Some (Dec n e); |
2293 lemma abc_fetch_contrE3[elim]: "\<lbrakk>abc_fetch as ap = Some (Dec n e); |
2349 Suc (start_of (layout_of ap) as + 2 * n) = start_of (layout_of ap) e\<rbrakk> \<Longrightarrow> RR" |
2294 Suc (start_of (layout_of ap) as + 2 * n) = start_of (layout_of ap) e\<rbrakk> \<Longrightarrow> RR" |
2350 apply(subgoal_tac "as = e \<or> as < e \<or> as > e", auto) |
2295 apply(subgoal_tac "as = e \<or> as < e \<or> as > e", auto) |
2351 done |
2296 done |
2352 |
2297 |
2353 lemma [simp]:"fetch (ci (ly) (start_of ly as) (Dec n e)) (Suc (2 * n)) Oc |
2298 lemma fetch_c_Oc[simp]:"fetch (ci (ly) (start_of ly as) (Dec n e)) (Suc (2 * n)) Oc |
2354 = (R, start_of ly as + 2*n + 1)" |
2299 = (R, start_of ly as + 2*n + 1)" |
2355 apply(auto simp: ci.simps findnth.simps fetch.simps |
2300 apply(auto simp: ci.simps findnth.simps fetch.simps |
2356 nth_of.simps shift.simps nth_append tdec_b_def length_findnth adjust.simps) |
2301 nth_of.simps shift.simps nth_append tdec_b_def length_findnth adjust.simps) |
2357 done |
2302 done |
2358 |
2303 |
2359 lemma [simp]: "(start_of ly as = 0) = False" |
|
2360 apply(simp add: start_of.simps) |
|
2361 done |
|
2362 |
|
2363 lemma [simp]: "fetch (ci (ly) |
|
2364 (start_of ly as) (Dec n e)) (Suc (2 * n)) Bk |
|
2365 = (W1, start_of ly as + 2*n)" |
|
2366 apply(auto simp: ci.simps findnth.simps fetch.simps |
|
2367 nth_of.simps shift.simps nth_append tdec_b_def length_findnth adjust.simps) |
|
2368 done |
|
2369 |
|
2370 lemma [simp]: |
|
2371 "fetch (ci (ly) |
|
2372 (start_of ly as) (Dec n e)) (Suc (Suc (2 * n))) Oc |
|
2373 = (R, start_of ly as + 2*n + 2)" |
|
2374 apply(auto simp: ci.simps findnth.simps fetch.simps |
|
2375 nth_of.simps shift.simps nth_append tdec_b_def length_findnth adjust.simps) |
|
2376 done |
|
2377 |
|
2378 |
|
2379 lemma [simp]: "fetch (ci (ly) |
|
2380 (start_of ly as) (Dec n e)) (Suc (Suc (2 * n))) Bk |
|
2381 = (L, start_of ly as + 2*n + 13)" |
|
2382 apply(auto simp: ci.simps findnth.simps fetch.simps |
|
2383 nth_of.simps shift.simps nth_append tdec_b_def length_findnth adjust.simps) |
|
2384 done |
|
2385 |
|
2386 |
|
2387 lemma [simp]: "fetch (ci (ly) |
|
2388 (start_of ly as) (Dec n e)) (Suc (Suc (Suc (2 * n)))) Oc |
|
2389 = (R, start_of ly as + 2*n + 2)" |
|
2390 apply(auto simp: ci.simps findnth.simps fetch.simps |
|
2391 nth_of.simps shift.simps nth_append tdec_b_def length_findnth adjust.simps) |
|
2392 done |
|
2393 |
|
2394 |
|
2395 lemma [simp]: "fetch (ci (ly) (start_of ly as) (Dec n e)) |
|
2396 (Suc (Suc (Suc (2 * n)))) Bk |
|
2397 = (L, start_of ly as + 2*n + 3)" |
|
2398 apply(auto simp: ci.simps findnth.simps fetch.simps |
|
2399 nth_of.simps shift.simps nth_append tdec_b_def length_findnth adjust.simps) |
|
2400 done |
|
2401 |
|
2402 lemma [simp]: |
|
2403 "fetch (ci (ly) |
|
2404 (start_of ly as) (Dec n e)) (2 * n + 4) Oc |
|
2405 = (W0, start_of ly as + 2*n + 3)" |
|
2406 apply(subgoal_tac "2*n + 4 = Suc (2*n + 3)", simp only: fetch.simps) |
|
2407 apply(auto simp: ci.simps findnth.simps fetch.simps |
|
2408 nth_of.simps shift.simps nth_append tdec_b_def length_findnth adjust.simps) |
|
2409 done |
|
2410 |
|
2411 lemma [simp]: "fetch (ci (ly) |
|
2412 (start_of ly as) (Dec n e)) (2 * n + 4) Bk |
|
2413 = (R, start_of ly as + 2*n + 4)" |
|
2414 apply(subgoal_tac "2*n + 4 = Suc (2*n + 3)", simp only: fetch.simps) |
|
2415 apply(auto simp: ci.simps findnth.simps fetch.simps |
|
2416 nth_of.simps shift.simps nth_append tdec_b_def length_findnth adjust.simps) |
|
2417 done |
|
2418 |
|
2419 lemma [simp]:"fetch (ci (ly) |
|
2420 (start_of ly as) (Dec n e)) (2 * n + 5) Bk |
|
2421 = (R, start_of ly as + 2*n + 5)" |
|
2422 apply(subgoal_tac "2*n + 5 = Suc (2*n + 4)", simp only: fetch.simps) |
|
2423 apply(auto simp: ci.simps findnth.simps fetch.simps |
|
2424 nth_of.simps shift.simps nth_append tdec_b_def length_findnth adjust.simps) |
|
2425 done |
|
2426 |
|
2427 |
|
2428 lemma [simp]: |
|
2429 "fetch (ci (ly) |
|
2430 (start_of ly as) (Dec n e)) (2 * n + 6) Bk |
|
2431 = (L, start_of ly as + 2*n + 6)" |
|
2432 apply(subgoal_tac "2*n + 6 = Suc (2*n + 5)", simp only: fetch.simps) |
|
2433 apply(auto simp: ci.simps findnth.simps fetch.simps |
|
2434 nth_of.simps shift.simps nth_append tdec_b_def length_findnth adjust.simps) |
|
2435 done |
|
2436 |
|
2437 lemma [simp]: |
|
2438 "fetch (ci (ly) (start_of ly as) |
|
2439 (Dec n e)) (2 * n + 6) Oc |
|
2440 = (L, start_of ly as + 2*n + 7)" |
|
2441 apply(subgoal_tac "2*n + 6 = Suc (2*n + 5)", simp only: fetch.simps) |
|
2442 apply(auto simp: ci.simps findnth.simps fetch.simps |
|
2443 nth_of.simps shift.simps nth_append tdec_b_def length_findnth adjust.simps) |
|
2444 done |
|
2445 |
|
2446 lemma [simp]:"fetch (ci (ly) |
|
2447 (start_of ly as) (Dec n e)) (2 * n + 7) Bk |
|
2448 = (L, start_of ly as + 2*n + 10)" |
|
2449 apply(subgoal_tac "2*n + 7 = Suc (2*n + 6)", simp only: fetch.simps) |
|
2450 apply(auto simp: ci.simps findnth.simps fetch.simps |
|
2451 nth_of.simps shift.simps nth_append tdec_b_def length_findnth adjust.simps) |
|
2452 done |
|
2453 |
|
2454 lemma [simp]: |
|
2455 "fetch (ci (ly) |
|
2456 (start_of ly as) (Dec n e)) (2 * n + 8) Bk |
|
2457 = (W1, start_of ly as + 2*n + 7)" |
|
2458 apply(subgoal_tac "2*n + 8 = Suc (2*n + 7)", simp only: fetch.simps) |
|
2459 apply(auto simp: ci.simps findnth.simps fetch.simps |
|
2460 nth_of.simps shift.simps nth_append tdec_b_def length_findnth adjust.simps) |
|
2461 done |
|
2462 |
|
2463 |
|
2464 lemma [simp]: |
|
2465 "fetch (ci (ly) |
|
2466 (start_of ly as) (Dec n e)) (2 * n + 8) Oc |
|
2467 = (R, start_of ly as + 2*n + 8)" |
|
2468 apply(subgoal_tac "2*n + 8 = Suc (2*n + 7)", simp only: fetch.simps) |
|
2469 apply(auto simp: ci.simps findnth.simps fetch.simps |
|
2470 nth_of.simps shift.simps nth_append tdec_b_def length_findnth adjust.simps) |
|
2471 done |
|
2472 |
|
2473 lemma [simp]: |
|
2474 "fetch (ci (ly) |
|
2475 (start_of ly as) (Dec n e)) (2 * n + 9) Bk |
|
2476 = (L, start_of ly as + 2*n + 9)" |
|
2477 apply(subgoal_tac "2*n + 9 = Suc (2*n + 8)", simp only: fetch.simps) |
|
2478 apply(auto simp: ci.simps findnth.simps fetch.simps |
|
2479 nth_of.simps shift.simps nth_append tdec_b_def length_findnth adjust.simps) |
|
2480 done |
|
2481 |
|
2482 lemma [simp]: |
|
2483 "fetch (ci (ly) |
|
2484 (start_of ly as) (Dec n e)) (2 * n + 9) Oc |
|
2485 = (R, start_of ly as + 2*n + 8)" |
|
2486 apply(subgoal_tac "2*n + 9 = Suc (2*n + 8)", simp only: fetch.simps) |
|
2487 apply(auto simp: ci.simps findnth.simps fetch.simps |
|
2488 nth_of.simps shift.simps nth_append tdec_b_def length_findnth adjust.simps) |
|
2489 done |
|
2490 |
|
2491 |
|
2492 lemma [simp]: |
|
2493 "fetch (ci (ly) |
|
2494 (start_of ly as) (Dec n e)) (2 * n + 10) Bk |
|
2495 = (R, start_of ly as + 2*n + 4)" |
|
2496 apply(subgoal_tac "2*n + 10 = Suc (2*n + 9)", simp only: fetch.simps) |
|
2497 apply(auto simp: ci.simps findnth.simps fetch.simps |
|
2498 nth_of.simps shift.simps nth_append tdec_b_def length_findnth adjust.simps) |
|
2499 done |
|
2500 |
|
2501 lemma [simp]: "fetch (ci (ly) |
|
2502 (start_of ly as) (Dec n e)) (2 * n + 10) Oc |
|
2503 = (W0, start_of ly as + 2*n + 9)" |
|
2504 apply(subgoal_tac "2*n + 10 = Suc (2*n + 9)", simp only: fetch.simps) |
|
2505 apply(auto simp: ci.simps findnth.simps fetch.simps |
|
2506 nth_of.simps shift.simps nth_append tdec_b_def length_findnth adjust.simps) |
|
2507 done |
|
2508 |
|
2509 |
|
2510 lemma [simp]: |
|
2511 "fetch (ci (ly) |
|
2512 (start_of ly as) (Dec n e)) (2 * n + 11) Oc |
|
2513 = (L, start_of ly as + 2*n + 10)" |
|
2514 apply(subgoal_tac "2*n + 11 = Suc (2*n + 10)", simp only: fetch.simps) |
|
2515 apply(auto simp: ci.simps findnth.simps fetch.simps |
|
2516 nth_of.simps shift.simps nth_append tdec_b_def length_findnth adjust.simps) |
|
2517 done |
|
2518 |
|
2519 |
|
2520 lemma [simp]: |
|
2521 "fetch (ci (ly) |
|
2522 (start_of ly as) (Dec n e)) (2 * n + 11) Bk |
|
2523 = (L, start_of ly as + 2*n + 11)" |
|
2524 apply(subgoal_tac "2*n + 11 = Suc (2*n + 10)", simp only: fetch.simps) |
|
2525 apply(auto simp: ci.simps findnth.simps fetch.simps |
|
2526 nth_of.simps shift.simps nth_append tdec_b_def length_findnth adjust.simps) |
|
2527 done |
|
2528 |
|
2529 lemma [simp]: |
|
2530 "fetch (ci (ly) |
|
2531 (start_of ly as) (Dec n e)) (2 * n + 12) Oc |
|
2532 = (L, start_of ly as + 2*n + 10)" |
|
2533 apply(subgoal_tac "2*n + 12 = Suc (2*n + 11)", simp only: fetch.simps) |
|
2534 apply(auto simp: ci.simps findnth.simps fetch.simps |
|
2535 nth_of.simps shift.simps nth_append tdec_b_def length_findnth adjust.simps) |
|
2536 done |
|
2537 |
|
2538 |
|
2539 lemma [simp]: |
|
2540 "fetch (ci (ly) |
|
2541 (start_of ly as) (Dec n e)) (2 * n + 12) Bk |
|
2542 = (R, start_of ly as + 2*n + 12)" |
|
2543 apply(subgoal_tac "2*n + 12 = Suc (2*n + 11)", simp only: fetch.simps) |
|
2544 apply(auto simp: ci.simps findnth.simps fetch.simps |
|
2545 nth_of.simps shift.simps nth_append tdec_b_def length_findnth adjust.simps) |
|
2546 done |
|
2547 |
|
2548 lemma [simp]: |
|
2549 "fetch (ci (ly) |
|
2550 (start_of ly as) (Dec n e)) (2 * n + 13) Bk |
|
2551 = (R, start_of ly as + 2*n + 16)" |
|
2552 apply(subgoal_tac "2*n + 13 = Suc (2*n + 12)", simp only: fetch.simps) |
|
2553 apply(auto simp: ci.simps findnth.simps fetch.simps |
|
2554 nth_of.simps shift.simps nth_append tdec_b_def length_findnth adjust.simps) |
|
2555 done |
|
2556 |
|
2557 |
|
2558 lemma [simp]: |
|
2559 "fetch (ci (ly) |
|
2560 (start_of ly as) (Dec n e)) (14 + 2 * n) Oc |
|
2561 = (L, start_of ly as + 2*n + 13)" |
|
2562 apply(subgoal_tac "14 + 2*n = Suc (2*n + 13)", simp only: fetch.simps) |
|
2563 apply(auto simp: ci.simps findnth.simps fetch.simps |
|
2564 nth_of.simps shift.simps nth_append tdec_b_def length_findnth adjust.simps) |
|
2565 done |
|
2566 |
|
2567 lemma [simp]: |
|
2568 "fetch (ci (ly) |
|
2569 (start_of ly as) (Dec n e)) (14 + 2 * n) Bk |
|
2570 = (L, start_of ly as + 2*n + 14)" |
|
2571 apply(subgoal_tac "14 + 2*n = Suc (2*n + 13)", simp only: fetch.simps) |
|
2572 apply(auto simp: ci.simps findnth.simps fetch.simps |
|
2573 nth_of.simps shift.simps nth_append tdec_b_def length_findnth adjust.simps) |
|
2574 done |
|
2575 |
|
2576 lemma [simp]: |
|
2577 "fetch (ci (ly) |
|
2578 (start_of ly as) (Dec n e)) (15 + 2 * n) Oc |
|
2579 = (L, start_of ly as + 2*n + 13)" |
|
2580 apply(subgoal_tac "15 + 2*n = Suc (2*n + 14)", simp only: fetch.simps) |
|
2581 apply(auto simp: ci.simps findnth.simps fetch.simps |
|
2582 nth_of.simps shift.simps nth_append tdec_b_def length_findnth adjust.simps) |
|
2583 done |
|
2584 |
|
2585 lemma [simp]: |
|
2586 "fetch (ci (ly) |
|
2587 (start_of ly as) (Dec n e)) (15 + 2 * n) Bk |
|
2588 = (R, start_of ly as + 2*n + 15)" |
|
2589 apply(subgoal_tac "15 + 2*n = Suc (2*n + 14)", simp only: fetch.simps) |
|
2590 apply(auto simp: ci.simps findnth.simps fetch.simps |
|
2591 nth_of.simps shift.simps nth_append tdec_b_def length_findnth adjust.simps) |
|
2592 done |
|
2593 |
|
2594 lemma [simp]: |
|
2595 "abc_fetch as aprog = Some (Dec n e) \<Longrightarrow> |
|
2596 fetch (ci (ly) (start_of (ly) as) |
|
2597 (Dec n e)) (16 + 2 * n) Bk |
|
2598 = (R, start_of (ly) e)" |
|
2599 apply(subgoal_tac "16 + 2*n = Suc (2*n + 15)", simp only: fetch.simps) |
|
2600 apply(auto simp: ci.simps findnth.simps fetch.simps |
|
2601 nth_of.simps shift.simps nth_append tdec_b_def length_findnth adjust.simps) |
|
2602 done |
|
2603 |
2304 |
2604 declare dec_inv_1.simps[simp del] |
2305 declare dec_inv_1.simps[simp del] |
2605 |
2306 |
2606 |
2307 |
2607 lemma [simp]: |
2308 lemma start_of_ineq1[simp]: |
2608 "\<lbrakk>abc_fetch as aprog = Some (Dec n e); ly = layout_of aprog\<rbrakk> |
2309 "\<lbrakk>abc_fetch as aprog = Some (Dec n e); ly = layout_of aprog\<rbrakk> |
2609 \<Longrightarrow> (start_of ly e \<noteq> Suc (start_of ly as + 2 * n) \<and> |
2310 \<Longrightarrow> (start_of ly e \<noteq> Suc (start_of ly as + 2 * n) \<and> |
2610 start_of ly e \<noteq> Suc (Suc (start_of ly as + 2 * n)) \<and> |
2311 start_of ly e \<noteq> Suc (Suc (start_of ly as + 2 * n)) \<and> |
2611 start_of ly e \<noteq> start_of ly as + 2 * n + 3 \<and> |
2312 start_of ly e \<noteq> start_of ly as + 2 * n + 3 \<and> |
2612 start_of ly e \<noteq> start_of ly as + 2 * n + 4 \<and> |
2313 start_of ly e \<noteq> start_of ly as + 2 * n + 4 \<and> |
2624 using start_of_ge[of as aprog n e ly] start_of_less[of e as ly] |
2325 using start_of_ge[of as aprog n e ly] start_of_less[of e as ly] |
2625 apply(case_tac "e < as", simp) |
2326 apply(case_tac "e < as", simp) |
2626 apply(case_tac "e = as", simp, simp) |
2327 apply(case_tac "e = as", simp, simp) |
2627 done |
2328 done |
2628 |
2329 |
2629 lemma [simp]: "\<lbrakk>abc_fetch as aprog = Some (Dec n e); ly = layout_of aprog\<rbrakk> |
2330 lemma start_of_ineq2[simp]: "\<lbrakk>abc_fetch as aprog = Some (Dec n e); ly = layout_of aprog\<rbrakk> |
2630 \<Longrightarrow> (Suc (start_of ly as + 2 * n) \<noteq> start_of ly e \<and> |
2331 \<Longrightarrow> (Suc (start_of ly as + 2 * n) \<noteq> start_of ly e \<and> |
2631 Suc (Suc (start_of ly as + 2 * n)) \<noteq> start_of ly e \<and> |
2332 Suc (Suc (start_of ly as + 2 * n)) \<noteq> start_of ly e \<and> |
2632 start_of ly as + 2 * n + 3 \<noteq> start_of ly e \<and> |
2333 start_of ly as + 2 * n + 3 \<noteq> start_of ly e \<and> |
2633 start_of ly as + 2 * n + 4 \<noteq> start_of ly e \<and> |
2334 start_of ly as + 2 * n + 4 \<noteq> start_of ly e \<and> |
2634 start_of ly as + 2 * n + 5 \<noteq>start_of ly e \<and> |
2335 start_of ly as + 2 * n + 5 \<noteq>start_of ly e \<and> |
2645 using start_of_ge[of as aprog n e ly] start_of_less[of e as ly] |
2346 using start_of_ge[of as aprog n e ly] start_of_less[of e as ly] |
2646 apply(case_tac "e < as", simp, simp) |
2347 apply(case_tac "e < as", simp, simp) |
2647 apply(case_tac "e = as", simp, simp) |
2348 apply(case_tac "e = as", simp, simp) |
2648 done |
2349 done |
2649 |
2350 |
2650 lemma [simp]: "inv_locate_b (as, lm) (n, [], []) ires = False" |
2351 lemma inv_locate_b_nonempty[simp]: "inv_locate_b (as, lm) (n, [], []) ires = False" |
2651 apply(auto simp: inv_locate_b.simps in_middle.simps split: if_splits) |
2352 apply(auto simp: inv_locate_b.simps in_middle.simps split: if_splits) |
2652 done |
2353 done |
2653 |
2354 |
2654 lemma [simp]: "inv_locate_b (as, lm) (n, [], Bk # list) ires = False" |
2355 lemma inv_locate_b_no_Bk[simp]: "inv_locate_b (as, lm) (n, [], Bk # list) ires = False" |
2655 apply(auto simp: inv_locate_b.simps in_middle.simps split: if_splits) |
2356 apply(auto simp: inv_locate_b.simps in_middle.simps split: if_splits) |
2656 done |
2357 done |
2657 |
2358 |
2658 lemma [simp]: |
2359 lemma dec_first_on_right_moving_Oc[simp]: |
2659 "\<lbrakk>dec_first_on_right_moving n (as, am) (s, aaa, Oc # xs) ires\<rbrakk> |
2360 "\<lbrakk>dec_first_on_right_moving n (as, am) (s, aaa, Oc # xs) ires\<rbrakk> |
2660 \<Longrightarrow> dec_first_on_right_moving n (as, am) (s', Oc # aaa, xs) ires" |
2361 \<Longrightarrow> dec_first_on_right_moving n (as, am) (s', Oc # aaa, xs) ires" |
2661 apply(simp only: dec_first_on_right_moving.simps) |
2362 apply(simp only: dec_first_on_right_moving.simps) |
2662 apply(erule exE)+ |
2363 apply(erule exE)+ |
2663 apply(rule_tac x = lm1 in exI, rule_tac x = lm2 in exI, |
2364 apply(rule_tac x = lm1 in exI, rule_tac x = lm2 in exI, |
2665 apply(rule_tac x = "Suc ml" in exI, |
2366 apply(rule_tac x = "Suc ml" in exI, |
2666 rule_tac x = "mr - 1" in exI, auto) |
2367 rule_tac x = "mr - 1" in exI, auto) |
2667 apply(case_tac [!] mr, auto) |
2368 apply(case_tac [!] mr, auto) |
2668 done |
2369 done |
2669 |
2370 |
2670 lemma [simp]: |
2371 lemma dec_first_on_right_moving_Bk_nonempty[simp]: |
2671 "dec_first_on_right_moving n (as, am) (s, l, Bk # xs) ires \<Longrightarrow> l \<noteq> []" |
2372 "dec_first_on_right_moving n (as, am) (s, l, Bk # xs) ires \<Longrightarrow> l \<noteq> []" |
2672 apply(auto simp: dec_first_on_right_moving.simps split: if_splits) |
2373 apply(auto simp: dec_first_on_right_moving.simps split: if_splits) |
2673 done |
2374 done |
2674 |
2375 |
2675 lemma [elim]: |
2376 lemma replicateE[elim]: |
2676 "\<lbrakk>\<not> length lm1 < length am; |
2377 "\<lbrakk>\<not> length lm1 < length am; |
2677 am @ replicate (length lm1 - length am) 0 @ [0::nat] = |
2378 am @ replicate (length lm1 - length am) 0 @ [0::nat] = |
2678 lm1 @ m # lm2; |
2379 lm1 @ m # lm2; |
2679 0 < m\<rbrakk> |
2380 0 < m\<rbrakk> |
2680 \<Longrightarrow> RR" |
2381 \<Longrightarrow> RR" |
2681 apply(subgoal_tac "lm2 = []", simp) |
2382 apply(subgoal_tac "lm2 = []", simp) |
2682 apply(drule_tac length_equal, simp) |
2383 apply(drule_tac length_equal, simp) |
2683 done |
2384 done |
2684 |
2385 |
2685 lemma [simp]: |
2386 lemma dec_after_clear_Bk_strip_hd[simp]: |
2686 "\<lbrakk>dec_first_on_right_moving n (as, |
2387 "\<lbrakk>dec_first_on_right_moving n (as, |
2687 abc_lm_s am n (abc_lm_v am n)) (s, l, Bk # xs) ires\<rbrakk> |
2388 abc_lm_s am n (abc_lm_v am n)) (s, l, Bk # xs) ires\<rbrakk> |
2688 \<Longrightarrow> dec_after_clear (as, abc_lm_s am n |
2389 \<Longrightarrow> dec_after_clear (as, abc_lm_s am n |
2689 (abc_lm_v am n - Suc 0)) (s', tl l, hd l # Bk # xs) ires" |
2390 (abc_lm_v am n - Suc 0)) (s', tl l, hd l # Bk # xs) ires" |
2690 apply(simp only: dec_first_on_right_moving.simps |
2391 apply(simp only: dec_first_on_right_moving.simps |
2694 apply(rule_tac x = lm1 in exI, rule_tac x = lm2 in exI, |
2395 apply(rule_tac x = lm1 in exI, rule_tac x = lm2 in exI, |
2695 rule_tac x = "m - 1" in exI, auto simp: ) |
2396 rule_tac x = "m - 1" in exI, auto simp: ) |
2696 apply(case_tac [!] mr, auto) |
2397 apply(case_tac [!] mr, auto) |
2697 done |
2398 done |
2698 |
2399 |
2699 lemma [simp]: |
2400 lemma dec_first_on_right_moving_dec_after_clear_cases[simp]: |
2700 "\<lbrakk>dec_first_on_right_moving n (as, |
2401 "\<lbrakk>dec_first_on_right_moving n (as, |
2701 abc_lm_s am n (abc_lm_v am n)) (s, l, []) ires\<rbrakk> |
2402 abc_lm_s am n (abc_lm_v am n)) (s, l, []) ires\<rbrakk> |
2702 \<Longrightarrow> (l = [] \<longrightarrow> dec_after_clear (as, |
2403 \<Longrightarrow> (l = [] \<longrightarrow> dec_after_clear (as, |
2703 abc_lm_s am n (abc_lm_v am n - Suc 0)) (s', [], [Bk]) ires) \<and> |
2404 abc_lm_s am n (abc_lm_v am n - Suc 0)) (s', [], [Bk]) ires) \<and> |
2704 (l \<noteq> [] \<longrightarrow> dec_after_clear (as, abc_lm_s am n |
2405 (l \<noteq> [] \<longrightarrow> dec_after_clear (as, abc_lm_s am n |
2711 apply(rule_tac x = lm1 in exI, rule_tac x = "m - 1" in exI, auto) |
2412 apply(rule_tac x = lm1 in exI, rule_tac x = "m - 1" in exI, auto) |
2712 apply(case_tac [1-2] m, auto) |
2413 apply(case_tac [1-2] m, auto) |
2713 apply(auto simp: dec_first_on_right_moving.simps split: if_splits) |
2414 apply(auto simp: dec_first_on_right_moving.simps split: if_splits) |
2714 done |
2415 done |
2715 |
2416 |
2716 lemma [simp]: "\<lbrakk>dec_after_clear (as, am) (s, l, Oc # r) ires\<rbrakk> |
2417 lemma dec_after_clear_Bk_via_Oc[simp]: "\<lbrakk>dec_after_clear (as, am) (s, l, Oc # r) ires\<rbrakk> |
2717 \<Longrightarrow> dec_after_clear (as, am) (s', l, Bk # r) ires" |
2418 \<Longrightarrow> dec_after_clear (as, am) (s', l, Bk # r) ires" |
2718 apply(auto simp: dec_after_clear.simps) |
2419 apply(auto simp: dec_after_clear.simps) |
2719 done |
2420 done |
2720 |
2421 |
2721 lemma [simp]: "\<lbrakk>dec_after_clear (as, am) (s, l, Bk # r) ires\<rbrakk> |
2422 lemma dec_right_move_Bk_via_clear_Bk[simp]: "\<lbrakk>dec_after_clear (as, am) (s, l, Bk # r) ires\<rbrakk> |
2722 \<Longrightarrow> dec_right_move (as, am) (s', Bk # l, r) ires" |
2423 \<Longrightarrow> dec_right_move (as, am) (s', Bk # l, r) ires" |
2723 apply(auto simp: dec_after_clear.simps dec_right_move.simps split: if_splits) |
2424 apply(auto simp: dec_after_clear.simps dec_right_move.simps split: if_splits) |
2724 done |
2425 done |
2725 |
2426 |
2726 lemma [simp]: "\<lbrakk>dec_after_clear (as, am) (s, l, []) ires\<rbrakk> |
2427 lemma dec_right_move_Bk_via_clear_empty[simp]: "\<lbrakk>dec_after_clear (as, am) (s, l, []) ires\<rbrakk> |
2727 \<Longrightarrow> dec_right_move (as, am) (s', Bk # l, []) ires" |
2428 \<Longrightarrow> dec_right_move (as, am) (s', Bk # l, []) ires" |
2728 apply(auto simp: dec_after_clear.simps dec_right_move.simps ) |
2429 apply(auto simp: dec_after_clear.simps dec_right_move.simps ) |
2729 done |
2430 done |
2730 |
2431 |
2731 lemma [simp]: "\<lbrakk>dec_after_clear (as, am) (s, l, []) ires\<rbrakk> |
2432 lemma dec_right_move_Bk_Bk_via_clear[simp]: "\<lbrakk>dec_after_clear (as, am) (s, l, []) ires\<rbrakk> |
2732 \<Longrightarrow> dec_right_move (as, am) (s', Bk # l, [Bk]) ires" |
2433 \<Longrightarrow> dec_right_move (as, am) (s', Bk # l, [Bk]) ires" |
2733 apply(auto simp: dec_after_clear.simps dec_right_move.simps split: if_splits) |
2434 apply(auto simp: dec_after_clear.simps dec_right_move.simps split: if_splits) |
2734 done |
2435 done |
2735 |
2436 |
2736 lemma [simp]:"dec_right_move (as, am) (s, l, Oc # r) ires = False" |
2437 lemma dec_right_move_no_Oc[simp]:"dec_right_move (as, am) (s, l, Oc # r) ires = False" |
2737 apply(auto simp: dec_right_move.simps) |
2438 apply(auto simp: dec_right_move.simps) |
2738 done |
2439 done |
2739 |
2440 |
2740 lemma dec_right_move_2_check_right_move[simp]: |
2441 lemma dec_right_move_2_check_right_move[simp]: |
2741 "\<lbrakk>dec_right_move (as, am) (s, l, Bk # r) ires\<rbrakk> |
2442 "\<lbrakk>dec_right_move (as, am) (s, l, Bk # r) ires\<rbrakk> |
2742 \<Longrightarrow> dec_check_right_move (as, am) (s', Bk # l, r) ires" |
2443 \<Longrightarrow> dec_check_right_move (as, am) (s', Bk # l, r) ires" |
2743 apply(auto simp: dec_right_move.simps dec_check_right_move.simps split: if_splits) |
2444 apply(auto simp: dec_right_move.simps dec_check_right_move.simps split: if_splits) |
2744 done |
2445 done |
2745 |
2446 |
2746 lemma [simp]: "(<lm::nat list> = []) = (lm = [])" |
2447 lemma lm_iff_empty[simp]: "(<lm::nat list> = []) = (lm = [])" |
2747 apply(case_tac lm, simp_all add: tape_of_nl_cons) |
2448 apply(case_tac lm, simp_all add: tape_of_nl_cons) |
2748 done |
2449 done |
2749 |
2450 |
2750 lemma [simp]: |
2451 lemma dec_right_move_asif_Bk_singleton[simp]: |
2751 "dec_right_move (as, am) (s, l, []) ires= |
2452 "dec_right_move (as, am) (s, l, []) ires= |
2752 dec_right_move (as, am) (s, l, [Bk]) ires" |
2453 dec_right_move (as, am) (s, l, [Bk]) ires" |
2753 apply(simp add: dec_right_move.simps) |
2454 apply(simp add: dec_right_move.simps) |
2754 done |
2455 done |
2755 |
2456 |
2756 lemma [simp]: "\<lbrakk>dec_right_move (as, am) (s, l, []) ires\<rbrakk> |
2457 lemma dec_check_right_move_Bk_via_move[simp]: "\<lbrakk>dec_right_move (as, am) (s, l, []) ires\<rbrakk> |
2757 \<Longrightarrow> dec_check_right_move (as, am) (s, Bk # l, []) ires" |
2458 \<Longrightarrow> dec_check_right_move (as, am) (s, Bk # l, []) ires" |
2758 apply(insert dec_right_move_2_check_right_move[of as am s l "[]" s'], |
2459 apply(insert dec_right_move_2_check_right_move[of as am s l "[]" s'], |
2759 simp) |
2460 simp) |
2760 done |
2461 done |
2761 |
2462 |
2762 lemma [simp]: "dec_check_right_move (as, am) (s, l, r) ires\<Longrightarrow> l \<noteq> []" |
2463 lemma dec_check_right_move_nonempty[simp]: "dec_check_right_move (as, am) (s, l, r) ires\<Longrightarrow> l \<noteq> []" |
2763 apply(auto simp: dec_check_right_move.simps split: if_splits) |
2464 apply(auto simp: dec_check_right_move.simps split: if_splits) |
2764 done |
2465 done |
2765 |
2466 |
2766 lemma [simp]: "\<lbrakk>dec_check_right_move (as, am) (s, l, Oc # r) ires\<rbrakk> |
2467 lemma dec_check_right_move_Oc_tail[simp]: "\<lbrakk>dec_check_right_move (as, am) (s, l, Oc # r) ires\<rbrakk> |
2767 \<Longrightarrow> dec_after_write (as, am) (s', tl l, hd l # Oc # r) ires" |
2468 \<Longrightarrow> dec_after_write (as, am) (s', tl l, hd l # Oc # r) ires" |
2768 apply(auto simp: dec_check_right_move.simps dec_after_write.simps) |
2469 apply(auto simp: dec_check_right_move.simps dec_after_write.simps) |
2769 apply(rule_tac x = lm1 in exI, rule_tac x = lm2 in exI, |
2470 apply(rule_tac x = lm1 in exI, rule_tac x = lm2 in exI, |
2770 rule_tac x = m in exI, auto) |
2471 rule_tac x = m in exI, auto) |
2771 done |
2472 done |
2772 |
2473 |
2773 |
2474 |
2774 |
2475 |
2775 lemma [simp]: "\<lbrakk>dec_check_right_move (as, am) (s, l, Bk # r) ires\<rbrakk> |
2476 lemma dec_left_move_Bk_tail[simp]: "\<lbrakk>dec_check_right_move (as, am) (s, l, Bk # r) ires\<rbrakk> |
2776 \<Longrightarrow> dec_left_move (as, am) (s', tl l, hd l # Bk # r) ires" |
2477 \<Longrightarrow> dec_left_move (as, am) (s', tl l, hd l # Bk # r) ires" |
2777 apply(auto simp: dec_check_right_move.simps |
2478 apply(auto simp: dec_check_right_move.simps |
2778 dec_left_move.simps inv_after_move.simps) |
2479 dec_left_move.simps inv_after_move.simps) |
2779 apply(rule_tac x = lm1 in exI, rule_tac x = m in exI, auto split: if_splits) |
2480 apply(rule_tac x = lm1 in exI, rule_tac x = m in exI, auto split: if_splits) |
2780 apply(case_tac [!] lm2, simp_all add: tape_of_nl_cons split: if_splits) |
2481 apply(case_tac [!] lm2, simp_all add: tape_of_nl_cons split: if_splits) |
2781 apply(rule_tac [!] x = "(Suc rn)" in exI, simp_all) |
2482 apply(rule_tac [!] x = "(Suc rn)" in exI, simp_all) |
2782 done |
2483 done |
2783 |
2484 |
2784 lemma [simp]: "\<lbrakk>dec_check_right_move (as, am) (s, l, []) ires\<rbrakk> |
2485 lemma dec_left_move_tail[simp]: "\<lbrakk>dec_check_right_move (as, am) (s, l, []) ires\<rbrakk> |
2785 \<Longrightarrow> dec_left_move (as, am) (s', tl l, [hd l]) ires" |
2486 \<Longrightarrow> dec_left_move (as, am) (s', tl l, [hd l]) ires" |
2786 apply(auto simp: dec_check_right_move.simps |
2487 apply(auto simp: dec_check_right_move.simps |
2787 dec_left_move.simps inv_after_move.simps) |
2488 dec_left_move.simps inv_after_move.simps) |
2788 apply(rule_tac x = lm1 in exI, rule_tac x = m in exI, auto) |
2489 apply(rule_tac x = lm1 in exI, rule_tac x = m in exI, auto) |
2789 done |
2490 done |
2790 |
2491 |
2791 lemma [simp]: "dec_left_move (as, am) (s, aaa, Oc # xs) ires = False" |
2492 lemma dec_left_move_no_Oc[simp]: "dec_left_move (as, am) (s, aaa, Oc # xs) ires = False" |
2792 apply(auto simp: dec_left_move.simps inv_after_move.simps) |
2493 apply(auto simp: dec_left_move.simps inv_after_move.simps) |
2793 done |
2494 done |
2794 |
2495 |
2795 lemma [simp]: "dec_left_move (as, am) (s, l, r) ires |
2496 lemma dec_left_move_nonempty[simp]: "dec_left_move (as, am) (s, l, r) ires |
2796 \<Longrightarrow> l \<noteq> []" |
2497 \<Longrightarrow> l \<noteq> []" |
2797 apply(auto simp: dec_left_move.simps split: if_splits) |
2498 apply(auto simp: dec_left_move.simps split: if_splits) |
2798 done |
2499 done |
2799 |
2500 |
2800 lemma [simp]: "inv_on_left_moving_in_middle_B (as, [m]) |
2501 lemma inv_on_left_moving_in_middle_B_Oc_Bk_Bks[simp]: "inv_on_left_moving_in_middle_B (as, [m]) |
2801 (s', Oc # Oc\<up>m @ Bk # Bk # ires, Bk # Bk\<up>rn) ires" |
2502 (s', Oc # Oc\<up>m @ Bk # Bk # ires, Bk # Bk\<up>rn) ires" |
2802 apply(simp add: inv_on_left_moving_in_middle_B.simps) |
2503 apply(simp add: inv_on_left_moving_in_middle_B.simps) |
2803 apply(rule_tac x = "[m]" in exI, auto) |
2504 apply(rule_tac x = "[m]" in exI, auto) |
2804 done |
2505 done |
2805 |
2506 |
2806 lemma [simp]: "inv_on_left_moving_in_middle_B (as, [m]) |
2507 lemma inv_on_left_moving_in_middle_B_Oc_Bk_Bk[simp]: "inv_on_left_moving_in_middle_B (as, [m]) |
2807 (s', Oc # Oc\<up>m @ Bk # Bk # ires, [Bk]) ires" |
2508 (s', Oc # Oc\<up>m @ Bk # Bk # ires, [Bk]) ires" |
2808 apply(simp add: inv_on_left_moving_in_middle_B.simps) |
2509 apply(simp add: inv_on_left_moving_in_middle_B.simps) |
2809 done |
2510 done |
2810 |
2511 |
2811 |
2512 |
2812 lemma [simp]: "lm1 \<noteq> [] \<Longrightarrow> |
2513 lemma inv_on_left_moving_in_middle_B_Oc_Bk_Bks_rev[simp]: "lm1 \<noteq> [] \<Longrightarrow> |
2813 inv_on_left_moving_in_middle_B (as, lm1 @ [m]) (s', |
2514 inv_on_left_moving_in_middle_B (as, lm1 @ [m]) (s', |
2814 Oc # Oc\<up>m @ Bk # <rev lm1> @ Bk # Bk # ires, Bk # Bk\<up>rn) ires" |
2515 Oc # Oc\<up>m @ Bk # <rev lm1> @ Bk # Bk # ires, Bk # Bk\<up>rn) ires" |
2815 apply(simp only: inv_on_left_moving_in_middle_B.simps) |
2516 apply(simp only: inv_on_left_moving_in_middle_B.simps) |
2816 apply(rule_tac x = "lm1 @ [m ]" in exI, rule_tac x = "[]" in exI, simp) |
2517 apply(rule_tac x = "lm1 @ [m ]" in exI, rule_tac x = "[]" in exI, simp) |
2817 apply(simp add: tape_of_nl_cons split: if_splits) |
2518 apply(simp add: tape_of_nl_cons split: if_splits) |
2818 done |
2519 done |
2819 |
2520 |
2820 lemma [simp]: "lm1 \<noteq> [] \<Longrightarrow> |
2521 lemma inv_on_left_moving_in_middle_B_Oc_Bk_Bk_rev[simp]: "lm1 \<noteq> [] \<Longrightarrow> |
2821 inv_on_left_moving_in_middle_B (as, lm1 @ [m]) (s', |
2522 inv_on_left_moving_in_middle_B (as, lm1 @ [m]) (s', |
2822 Oc # Oc\<up> m @ Bk # <rev lm1> @ Bk # Bk # ires, [Bk]) ires" |
2523 Oc # Oc\<up> m @ Bk # <rev lm1> @ Bk # Bk # ires, [Bk]) ires" |
2823 apply(simp only: inv_on_left_moving_in_middle_B.simps) |
2524 apply(simp only: inv_on_left_moving_in_middle_B.simps) |
2824 apply(rule_tac x = "lm1 @ [m ]" in exI, rule_tac x = "[]" in exI, simp) |
2525 apply(rule_tac x = "lm1 @ [m ]" in exI, rule_tac x = "[]" in exI, simp) |
2825 apply(simp add: tape_of_nl_cons split: if_splits) |
2526 apply(simp add: tape_of_nl_cons split: if_splits) |
2826 done |
2527 done |
2827 |
2528 |
2828 lemma [simp]: "dec_left_move (as, am) (s, l, Bk # r) ires |
2529 lemma inv_on_left_moving_Bk_tail[simp]: "dec_left_move (as, am) (s, l, Bk # r) ires |
2829 \<Longrightarrow> inv_on_left_moving (as, am) (s', tl l, hd l # Bk # r) ires" |
2530 \<Longrightarrow> inv_on_left_moving (as, am) (s', tl l, hd l # Bk # r) ires" |
2830 apply(auto simp: dec_left_move.simps inv_on_left_moving.simps split: if_splits) |
2531 apply(auto simp: dec_left_move.simps inv_on_left_moving.simps split: if_splits) |
2831 done |
2532 done |
2832 |
2533 |
2833 lemma [simp]: "dec_left_move (as, am) (s, l, []) ires |
2534 lemma inv_on_left_moving_tail[simp]: "dec_left_move (as, am) (s, l, []) ires |
2834 \<Longrightarrow> inv_on_left_moving (as, am) (s', tl l, [hd l]) ires" |
2535 \<Longrightarrow> inv_on_left_moving (as, am) (s', tl l, [hd l]) ires" |
2835 apply(auto simp: dec_left_move.simps inv_on_left_moving.simps split: if_splits) |
2536 apply(auto simp: dec_left_move.simps inv_on_left_moving.simps split: if_splits) |
2836 done |
2537 done |
2837 |
2538 |
2838 lemma [simp]: "dec_after_write (as, am) (s, l, Oc # r) ires |
2539 lemma dec_on_right_moving_Oc_mv[simp]: "dec_after_write (as, am) (s, l, Oc # r) ires |
2839 \<Longrightarrow> dec_on_right_moving (as, am) (s', Oc # l, r) ires" |
2540 \<Longrightarrow> dec_on_right_moving (as, am) (s', Oc # l, r) ires" |
2840 apply(auto simp: dec_after_write.simps dec_on_right_moving.simps) |
2541 apply(auto simp: dec_after_write.simps dec_on_right_moving.simps) |
2841 apply(rule_tac x = "lm1 @ [m]" in exI, rule_tac x = "tl lm2" in exI, |
2542 apply(rule_tac x = "lm1 @ [m]" in exI, rule_tac x = "tl lm2" in exI, |
2842 rule_tac x = "hd lm2" in exI, simp) |
2543 rule_tac x = "hd lm2" in exI, simp) |
2843 apply(rule_tac x = "Suc 0" in exI,rule_tac x = "Suc (hd lm2)" in exI) |
2544 apply(rule_tac x = "Suc 0" in exI,rule_tac x = "Suc (hd lm2)" in exI) |
2844 apply(case_tac lm2, auto split: if_splits simp: tape_of_nl_cons) |
2545 apply(case_tac lm2, auto split: if_splits simp: tape_of_nl_cons) |
2845 done |
2546 done |
2846 |
2547 |
2847 lemma [simp]: "dec_after_write (as, am) (s, l, Bk # r) ires |
2548 lemma dec_after_write_Oc_via_Bk[simp]: "dec_after_write (as, am) (s, l, Bk # r) ires |
2848 \<Longrightarrow> dec_after_write (as, am) (s', l, Oc # r) ires" |
2549 \<Longrightarrow> dec_after_write (as, am) (s', l, Oc # r) ires" |
2849 apply(auto simp: dec_after_write.simps) |
2550 apply(auto simp: dec_after_write.simps) |
2850 done |
2551 done |
2851 |
2552 |
2852 lemma [simp]: "dec_after_write (as, am) (s, aaa, []) ires |
2553 lemma dec_after_write_Oc_empty[simp]: "dec_after_write (as, am) (s, aaa, []) ires |
2853 \<Longrightarrow> dec_after_write (as, am) (s', aaa, [Oc]) ires" |
2554 \<Longrightarrow> dec_after_write (as, am) (s', aaa, [Oc]) ires" |
2854 apply(auto simp: dec_after_write.simps) |
2555 apply(auto simp: dec_after_write.simps) |
2855 done |
2556 done |
2856 |
2557 |
2857 lemma [simp]: "dec_on_right_moving (as, am) (s, l, Oc # r) ires |
2558 lemma dec_on_right_moving_Oc_move[simp]: "dec_on_right_moving (as, am) (s, l, Oc # r) ires |
2858 \<Longrightarrow> dec_on_right_moving (as, am) (s', Oc # l, r) ires" |
2559 \<Longrightarrow> dec_on_right_moving (as, am) (s', Oc # l, r) ires" |
2859 apply(simp only: dec_on_right_moving.simps) |
2560 apply(simp only: dec_on_right_moving.simps) |
2860 apply(erule_tac exE)+ |
2561 apply(erule_tac exE)+ |
2861 apply(erule conjE)+ |
2562 apply(erule conjE)+ |
2862 apply(rule_tac x = lm1 in exI, rule_tac x = lm2 in exI, |
2563 apply(rule_tac x = lm1 in exI, rule_tac x = lm2 in exI, |
2863 rule_tac x = "m" in exI, rule_tac x = "Suc ml" in exI, |
2564 rule_tac x = "m" in exI, rule_tac x = "Suc ml" in exI, |
2864 rule_tac x = "mr - 1" in exI, simp) |
2565 rule_tac x = "mr - 1" in exI, simp) |
2865 apply(case_tac mr, auto) |
2566 apply(case_tac mr, auto) |
2866 done |
2567 done |
2867 |
2568 |
2868 lemma [simp]: "dec_on_right_moving (as, am) (s, l, r) ires\<Longrightarrow> l \<noteq> []" |
2569 lemma dec_on_right_moving_nonempty[simp]: "dec_on_right_moving (as, am) (s, l, r) ires\<Longrightarrow> l \<noteq> []" |
2869 apply(auto simp: dec_on_right_moving.simps split: if_splits) |
2570 apply(auto simp: dec_on_right_moving.simps split: if_splits) |
2870 done |
2571 done |
2871 |
2572 |
2872 lemma [simp]: "dec_on_right_moving (as, am) (s, l, Bk # r) ires |
2573 lemma dec_after_clear_Bk_tail[simp]: "dec_on_right_moving (as, am) (s, l, Bk # r) ires |
2873 \<Longrightarrow> dec_after_clear (as, am) (s', tl l, hd l # Bk # r) ires" |
2574 \<Longrightarrow> dec_after_clear (as, am) (s', tl l, hd l # Bk # r) ires" |
2874 apply(auto simp: dec_on_right_moving.simps dec_after_clear.simps) |
2575 apply(auto simp: dec_on_right_moving.simps dec_after_clear.simps) |
2875 apply(case_tac [!] mr, auto split: if_splits) |
2576 apply(case_tac [!] mr, auto split: if_splits) |
2876 done |
2577 done |
2877 |
2578 |
2878 lemma [simp]: "dec_on_right_moving (as, am) (s, l, []) ires |
2579 lemma dec_after_clear_tail[simp]: "dec_on_right_moving (as, am) (s, l, []) ires |
2879 \<Longrightarrow> dec_after_clear (as, am) (s', tl l, [hd l]) ires" |
2580 \<Longrightarrow> dec_after_clear (as, am) (s', tl l, [hd l]) ires" |
2880 apply(auto simp: dec_on_right_moving.simps dec_after_clear.simps) |
2581 apply(auto simp: dec_on_right_moving.simps dec_after_clear.simps) |
2881 apply(simp_all split: if_splits) |
2582 apply(simp_all split: if_splits) |
2882 apply(rule_tac x = lm1 in exI, simp) |
2583 apply(rule_tac x = lm1 in exI, simp) |
2883 done |
2584 done |
2884 |
2585 |
2885 lemma [simp]: |
2586 lemma inv_stop_abc_lm_s_nonempty[simp]: |
2886 "inv_stop (as, abc_lm_s am n (abc_lm_v am n)) (s, l, r) ires \<Longrightarrow> l \<noteq> []" |
2587 "inv_stop (as, abc_lm_s am n (abc_lm_v am n)) (s, l, r) ires \<Longrightarrow> l \<noteq> []" |
2887 apply(auto simp: inv_stop.simps) |
2588 apply(auto simp: inv_stop.simps) |
2888 done |
2589 done |
2889 |
2590 |
2890 lemma dec_false_1[simp]: |
2591 lemma dec_false_1[simp]: |
2904 apply(subgoal_tac "Suc (length lm1) - length am = |
2605 apply(subgoal_tac "Suc (length lm1) - length am = |
2905 Suc (length lm1 - length am)", |
2606 Suc (length lm1 - length am)", |
2906 simp add: exp_ind del: replicate.simps, simp) |
2607 simp add: exp_ind del: replicate.simps, simp) |
2907 done |
2608 done |
2908 |
2609 |
2909 lemma [simp]: |
2610 lemma inv_on_left_moving_Bk_tl[simp]: |
2910 "\<lbrakk>inv_locate_b (as, am) (n, aaa, Bk # xs) ires; |
2611 "\<lbrakk>inv_locate_b (as, am) (n, aaa, Bk # xs) ires; |
2911 abc_lm_v am n = 0\<rbrakk> |
2612 abc_lm_v am n = 0\<rbrakk> |
2912 \<Longrightarrow> inv_on_left_moving (as, abc_lm_s am n 0) |
2613 \<Longrightarrow> inv_on_left_moving (as, abc_lm_s am n 0) |
2913 (s, tl aaa, hd aaa # Bk # xs) ires" |
2614 (s, tl aaa, hd aaa # Bk # xs) ires" |
2914 apply(simp add: inv_on_left_moving.simps) |
2615 apply(simp add: inv_on_left_moving.simps) |
2926 apply(simp only: exp_ind[THEN sym] replicate_Suc Nat.Suc_diff_le) |
2627 apply(simp only: exp_ind[THEN sym] replicate_Suc Nat.Suc_diff_le) |
2927 apply(auto simp: inv_on_left_moving_in_middle_B.simps split: if_splits) |
2628 apply(auto simp: inv_on_left_moving_in_middle_B.simps split: if_splits) |
2928 done |
2629 done |
2929 |
2630 |
2930 |
2631 |
2931 lemma [simp]: |
2632 lemma inv_on_left_moving_tl[simp]: |
2932 "\<lbrakk>abc_lm_v am n = 0; inv_locate_b (as, am) (n, aaa, []) ires\<rbrakk> |
2633 "\<lbrakk>abc_lm_v am n = 0; inv_locate_b (as, am) (n, aaa, []) ires\<rbrakk> |
2933 \<Longrightarrow> inv_on_left_moving (as, abc_lm_s am n 0) (s, tl aaa, [hd aaa]) ires" |
2634 \<Longrightarrow> inv_on_left_moving (as, abc_lm_s am n 0) (s, tl aaa, [hd aaa]) ires" |
2934 apply(simp add: inv_on_left_moving.simps) |
2635 apply(simp add: inv_on_left_moving.simps) |
2935 apply(simp only: inv_locate_b.simps in_middle.simps) |
2636 apply(simp only: inv_locate_b.simps in_middle.simps) |
2936 apply(erule_tac exE)+ |
2637 apply(erule_tac exE)+ |
2946 apply(simp_all only: exp_ind Nat.Suc_diff_le del: replicate_Suc, simp_all) |
2647 apply(simp_all only: exp_ind Nat.Suc_diff_le del: replicate_Suc, simp_all) |
2947 apply(auto simp: inv_on_left_moving_in_middle_B.simps split: if_splits) |
2648 apply(auto simp: inv_on_left_moving_in_middle_B.simps split: if_splits) |
2948 apply(case_tac [!] m, simp_all) |
2649 apply(case_tac [!] m, simp_all) |
2949 done |
2650 done |
2950 |
2651 |
2951 lemma [simp]: "\<lbrakk>am ! n = (0::nat); n < length am\<rbrakk> \<Longrightarrow> am[n := 0] = am" |
2652 lemma update_zero_to_zero[simp]: "\<lbrakk>am ! n = (0::nat); n < length am\<rbrakk> \<Longrightarrow> am[n := 0] = am" |
2952 apply(simp add: list_update_same_conv) |
2653 apply(simp add: list_update_same_conv) |
2953 done |
2654 done |
2954 |
2655 |
2955 lemma [intro]: "\<lbrakk>abc_lm_v (a # list) 0 = 0\<rbrakk> \<Longrightarrow> a = 0" |
2656 lemma abc_lm_v_zero: "\<lbrakk>abc_lm_v (a # list) 0 = 0\<rbrakk> \<Longrightarrow> a = 0" |
2956 apply(simp add: abc_lm_v.simps split: if_splits) |
2657 apply(simp add: abc_lm_v.simps split: if_splits) |
2957 done |
2658 done |
2958 |
2659 |
2959 lemma [simp]: |
2660 lemma inv_locate_a_via_stop[simp]: |
2960 "inv_stop (as, abc_lm_s am n 0) |
2661 "inv_stop (as, abc_lm_s am n 0) |
2961 (start_of (layout_of aprog) e, aaa, Oc # xs) ires |
2662 (start_of (layout_of aprog) e, aaa, Oc # xs) ires |
2962 \<Longrightarrow> inv_locate_a (as, abc_lm_s am n 0) (0, aaa, Oc # xs) ires" |
2663 \<Longrightarrow> inv_locate_a (as, abc_lm_s am n 0) (0, aaa, Oc # xs) ires" |
2963 apply(simp add: inv_locate_a.simps) |
2664 apply(simp add: inv_locate_a.simps) |
2964 apply(rule disjI1) |
2665 apply(rule disjI1) |
2965 apply(auto simp: inv_stop.simps at_begin_norm.simps) |
2666 apply(auto simp: inv_stop.simps at_begin_norm.simps) |
2966 done |
2667 done |
2967 |
2668 |
2968 lemma [simp]: |
2669 lemma inv_locate_b_cases_via_stop[simp]: |
2969 "\<lbrakk>inv_stop (as, abc_lm_s am n 0) |
2670 "\<lbrakk>inv_stop (as, abc_lm_s am n 0) |
2970 (start_of (layout_of aprog) e, aaa, Oc # xs) ires\<rbrakk> |
2671 (start_of (layout_of aprog) e, aaa, Oc # xs) ires\<rbrakk> |
2971 \<Longrightarrow> inv_locate_b (as, am) (0, Oc # aaa, xs) ires \<or> |
2672 \<Longrightarrow> inv_locate_b (as, am) (0, Oc # aaa, xs) ires \<or> |
2972 inv_locate_b (as, abc_lm_s am n 0) (0, Oc # aaa, xs) ires" |
2673 inv_locate_b (as, abc_lm_s am n 0) (0, Oc # aaa, xs) ires" |
2973 apply(simp) |
2674 apply(simp) |
2985 "inv_stop (as, abc_lm_s am n 0) |
2686 "inv_stop (as, abc_lm_s am n 0) |
2986 (start_of (layout_of aprog) e, aaa, []) ires = False" |
2687 (start_of (layout_of aprog) e, aaa, []) ires = False" |
2987 apply(auto simp: inv_stop.simps abc_lm_s.simps) |
2688 apply(auto simp: inv_stop.simps abc_lm_s.simps) |
2988 done |
2689 done |
2989 |
2690 |
2990 lemma [simp]: |
|
2991 "fetch (ci (layout_of aprog) |
|
2992 (start_of (layout_of aprog) as) (Dec n e)) 0 b = (Nop, 0)" |
|
2993 by(simp add: fetch.simps) |
|
2994 |
|
2995 declare dec_inv_1.simps[simp del] |
2691 declare dec_inv_1.simps[simp del] |
2996 |
2692 |
2997 declare inv_locate_n_b.simps [simp del] |
2693 declare inv_locate_n_b.simps [simp del] |
2998 |
2694 |
2999 lemma [simp]: |
2695 lemma inv_locate_n_b_Oc_via_at_begin_fst_bwtn[simp]: |
3000 "\<lbrakk>0 < abc_lm_v am n; 0 < n; |
2696 "\<lbrakk>0 < abc_lm_v am n; 0 < n; |
3001 at_begin_fst_bwtn (as, am) (n, aaa, Oc # xs) ires\<rbrakk> |
2697 at_begin_fst_bwtn (as, am) (n, aaa, Oc # xs) ires\<rbrakk> |
3002 \<Longrightarrow> inv_locate_n_b (as, am) (n, Oc # aaa, xs) ires" |
2698 \<Longrightarrow> inv_locate_n_b (as, am) (n, Oc # aaa, xs) ires" |
3003 apply(simp add: at_begin_fst_bwtn.simps inv_locate_n_b.simps ) |
2699 apply(simp add: at_begin_fst_bwtn.simps inv_locate_n_b.simps ) |
3004 done |
2700 done |
3006 lemma Suc_minus:"length am + tn = n |
2702 lemma Suc_minus:"length am + tn = n |
3007 \<Longrightarrow> Suc tn = Suc n - length am " |
2703 \<Longrightarrow> Suc tn = Suc n - length am " |
3008 apply(arith) |
2704 apply(arith) |
3009 done |
2705 done |
3010 |
2706 |
3011 lemma [simp]: |
2707 lemma dec_first_on_right_moving_Oc_via_inv_locate_n_b[simp]: |
3012 "\<lbrakk>0 < abc_lm_v am n; 0 < n; |
|
3013 at_begin_fst_awtn (as, am) (n, aaa, Oc # xs) ires\<rbrakk> |
|
3014 \<Longrightarrow> inv_locate_n_b (as, am) (n, Oc # aaa, xs) ires" |
|
3015 apply(simp only: at_begin_fst_awtn.simps inv_locate_n_b.simps ) |
|
3016 apply(erule exE)+ |
|
3017 apply(erule conjE)+ |
|
3018 apply(rule_tac x = lm1 in exI, rule_tac x = "[]" in exI, |
|
3019 rule_tac x = "Suc tn" in exI, rule_tac x = 0 in exI) |
|
3020 apply(simp add: exp_ind del: replicate.simps) |
|
3021 apply(rule conjI)+ |
|
3022 apply(auto) |
|
3023 done |
|
3024 |
|
3025 lemma [simp]: |
|
3026 "\<lbrakk>inv_locate_n_b (as, am) (n, aaa, Oc # xs) ires\<rbrakk> |
2708 "\<lbrakk>inv_locate_n_b (as, am) (n, aaa, Oc # xs) ires\<rbrakk> |
3027 \<Longrightarrow> dec_first_on_right_moving n (as, abc_lm_s am n (abc_lm_v am n)) |
2709 \<Longrightarrow> dec_first_on_right_moving n (as, abc_lm_s am n (abc_lm_v am n)) |
3028 (s, Oc # aaa, xs) ires" |
2710 (s, Oc # aaa, xs) ires" |
3029 apply(auto simp: inv_locate_n_b.simps dec_first_on_right_moving.simps |
2711 apply(auto simp: inv_locate_n_b.simps dec_first_on_right_moving.simps |
3030 abc_lm_s.simps abc_lm_v.simps) |
2712 abc_lm_s.simps abc_lm_v.simps) |
3047 apply(rule_tac x = lm1 in exI, rule_tac x = lm2 in exI, |
2729 apply(rule_tac x = lm1 in exI, rule_tac x = lm2 in exI, |
3048 rule_tac x = m in exI, |
2730 rule_tac x = m in exI, |
3049 simp add: Suc_diff_le exp_ind del: replicate.simps, simp) |
2731 simp add: Suc_diff_le exp_ind del: replicate.simps, simp) |
3050 done |
2732 done |
3051 |
2733 |
3052 lemma [simp]: "inv_on_left_moving (as, am) (s, [], r) ires |
2734 lemma inv_on_left_moving_nonempty[simp]: "inv_on_left_moving (as, am) (s, [], r) ires |
3053 = False" |
2735 = False" |
3054 apply(simp add: inv_on_left_moving.simps inv_on_left_moving_norm.simps |
2736 apply(simp add: inv_on_left_moving.simps inv_on_left_moving_norm.simps |
3055 inv_on_left_moving_in_middle_B.simps) |
2737 inv_on_left_moving_in_middle_B.simps) |
3056 done |
2738 done |
3057 |
2739 |
3058 lemma [simp]: |
2740 lemma inv_check_left_moving_startof_nonempty[simp]: |
3059 "inv_check_left_moving (as, abc_lm_s am n 0) |
2741 "inv_check_left_moving (as, abc_lm_s am n 0) |
3060 (start_of (layout_of aprog) as + 2 * n + 14, [], Oc # xs) ires |
2742 (start_of (layout_of aprog) as + 2 * n + 14, [], Oc # xs) ires |
3061 = False" |
2743 = False" |
3062 apply(simp add: inv_check_left_moving.simps inv_check_left_moving_in_middle.simps) |
2744 apply(simp add: inv_check_left_moving.simps inv_check_left_moving_in_middle.simps) |
3063 done |
2745 done |
3064 |
2746 |
3065 lemma [simp]: "inv_check_left_moving (as, abc_lm_s lm n (abc_lm_v lm n)) (s, [], Oc # list) ires = False" |
2747 lemma start_of_lessE[elim]: "\<lbrakk>abc_fetch as ap = Some (Dec n e); |
3066 apply(simp add: inv_check_left_moving.simps inv_check_left_moving_in_middle.simps) |
|
3067 done |
|
3068 |
|
3069 lemma [elim]: "\<lbrakk>abc_fetch as ap = Some (Dec n e); |
|
3070 start_of (layout_of ap) as < start_of (layout_of ap) e; |
2748 start_of (layout_of ap) as < start_of (layout_of ap) e; |
3071 start_of (layout_of ap) e \<le> Suc (start_of (layout_of ap) as + 2 * n)\<rbrakk> |
2749 start_of (layout_of ap) e \<le> Suc (start_of (layout_of ap) as + 2 * n)\<rbrakk> |
3072 \<Longrightarrow> RR" |
2750 \<Longrightarrow> RR" |
3073 using start_of_less[of e as "layout_of ap"] start_of_ge[of as ap n e "layout_of ap"] |
2751 using start_of_less[of e as "layout_of ap"] start_of_ge[of as ap n e "layout_of ap"] |
3074 apply(case_tac "as < e", simp) |
2752 apply(case_tac "as < e", simp) |
3139 using assms |
2817 using assms |
3140 apply(drule_tac crsp_step_dec_b_e_pre', auto) |
2818 apply(drule_tac crsp_step_dec_b_e_pre', auto) |
3141 apply(rule_tac x = stp in exI, simp) |
2819 apply(rule_tac x = stp in exI, simp) |
3142 done |
2820 done |
3143 |
2821 |
3144 lemma [simp]: |
2822 lemma crsp_abc_step_via_stop[simp]: |
3145 "\<lbrakk>abc_lm_v lm n = 0; |
2823 "\<lbrakk>abc_lm_v lm n = 0; |
3146 inv_stop (as, abc_lm_s lm n (abc_lm_v lm n)) (start_of ly e, lb, rb) ires\<rbrakk> |
2824 inv_stop (as, abc_lm_s lm n (abc_lm_v lm n)) (start_of ly e, lb, rb) ires\<rbrakk> |
3147 \<Longrightarrow> crsp ly (abc_step_l (as, lm) (Some (Dec n e))) (start_of ly e, lb, rb) ires" |
2825 \<Longrightarrow> crsp ly (abc_step_l (as, lm) (Some (Dec n e))) (start_of ly e, lb, rb) ires" |
3148 apply(auto simp: crsp.simps abc_step_l.simps inv_stop.simps) |
2826 apply(auto simp: crsp.simps abc_step_l.simps inv_stop.simps) |
3149 done |
2827 done |
3299 by(auto intro:wf_inv_image simp:abc_dec_2_LE_def lex_square_def lex_triple_def lex_pair_def) |
2977 by(auto intro:wf_inv_image simp:abc_dec_2_LE_def lex_square_def lex_triple_def lex_pair_def) |
3300 |
2978 |
3301 lemma fix_add: "fetch ap ((x::nat) + 2*n) b = fetch ap (2*n + x) b" |
2979 lemma fix_add: "fetch ap ((x::nat) + 2*n) b = fetch ap (2*n + x) b" |
3302 using Suc_1 add.commute by metis |
2980 using Suc_1 add.commute by metis |
3303 |
2981 |
3304 lemma [elim]: |
2982 lemma inv_locate_n_b_Bk_elim[elim]: |
3305 "\<lbrakk>0 < abc_lm_v am n; inv_locate_n_b (as, am) (n, aaa, Bk # xs) ires\<rbrakk> |
2983 "\<lbrakk>0 < abc_lm_v am n; inv_locate_n_b (as, am) (n, aaa, Bk # xs) ires\<rbrakk> |
3306 \<Longrightarrow> RR" |
2984 \<Longrightarrow> RR" |
3307 apply(auto simp: inv_locate_n_b.simps abc_lm_v.simps split: if_splits) |
2985 apply(auto simp: inv_locate_n_b.simps abc_lm_v.simps split: if_splits) |
3308 apply(case_tac [!] m, auto) |
2986 apply(case_tac [!] m, auto) |
3309 done |
2987 done |
3310 |
2988 |
3311 lemma [elim]: |
2989 lemma inv_locate_n_b_nonemptyE[elim]: |
3312 "\<lbrakk>0 < abc_lm_v am n; inv_locate_n_b (as, am) |
2990 "\<lbrakk>0 < abc_lm_v am n; inv_locate_n_b (as, am) |
3313 (n, aaa, []) ires\<rbrakk> \<Longrightarrow> RR" |
2991 (n, aaa, []) ires\<rbrakk> \<Longrightarrow> RR" |
3314 apply(auto simp: inv_locate_n_b.simps abc_lm_v.simps split: if_splits) |
2992 apply(auto simp: inv_locate_n_b.simps abc_lm_v.simps split: if_splits) |
3315 done |
2993 done |
3316 |
2994 |
3317 lemma [simp]: "dec_after_write (as, am) (s, aa, r) ires |
2995 lemma no_Ocs_dec_after_write[simp]: "dec_after_write (as, am) (s, aa, r) ires |
3318 \<Longrightarrow> takeWhile (\<lambda>a. a = Oc) aa = []" |
2996 \<Longrightarrow> takeWhile (\<lambda>a. a = Oc) aa = []" |
3319 apply(simp only : dec_after_write.simps) |
2997 apply(simp only : dec_after_write.simps) |
3320 apply(erule exE)+ |
2998 apply(erule exE)+ |
3321 apply(erule_tac conjE)+ |
2999 apply(erule_tac conjE)+ |
3322 apply(case_tac aa, simp) |
3000 apply(case_tac aa, simp) |
3323 apply(case_tac a, simp only: takeWhile.simps , simp_all split: if_splits) |
3001 apply(case_tac a, simp only: takeWhile.simps , simp_all split: if_splits) |
3324 done |
3002 done |
3325 |
3003 |
3326 lemma [simp]: |
3004 lemma fewer_Ocs_dec_on_right_moving[simp]: |
3327 "\<lbrakk>dec_on_right_moving (as, lm) (s, aa, []) ires; |
3005 "\<lbrakk>dec_on_right_moving (as, lm) (s, aa, []) ires; |
3328 length (takeWhile (\<lambda>a. a = Oc) (tl aa)) |
3006 length (takeWhile (\<lambda>a. a = Oc) (tl aa)) |
3329 \<noteq> length (takeWhile (\<lambda>a. a = Oc) aa) - Suc 0\<rbrakk> |
3007 \<noteq> length (takeWhile (\<lambda>a. a = Oc) aa) - Suc 0\<rbrakk> |
3330 \<Longrightarrow> length (takeWhile (\<lambda>a. a = Oc) (tl aa)) < |
3008 \<Longrightarrow> length (takeWhile (\<lambda>a. a = Oc) (tl aa)) < |
3331 length (takeWhile (\<lambda>a. a = Oc) aa) - Suc 0" |
3009 length (takeWhile (\<lambda>a. a = Oc) aa) - Suc 0" |
3333 apply(erule_tac exE)+ |
3011 apply(erule_tac exE)+ |
3334 apply(erule_tac conjE)+ |
3012 apply(erule_tac conjE)+ |
3335 apply(case_tac mr, auto split: if_splits) |
3013 apply(case_tac mr, auto split: if_splits) |
3336 done |
3014 done |
3337 |
3015 |
3338 lemma [simp]: |
3016 lemma more_Ocs_dec_after_clear[simp]: |
3339 "dec_after_clear (as, abc_lm_s am n (abc_lm_v am n - Suc 0)) |
3017 "dec_after_clear (as, abc_lm_s am n (abc_lm_v am n - Suc 0)) |
3340 (start_of (layout_of aprog) as + 2 * n + 9, aa, Bk # xs) ires |
3018 (start_of (layout_of aprog) as + 2 * n + 9, aa, Bk # xs) ires |
3341 \<Longrightarrow> length xs - Suc 0 < length xs + |
3019 \<Longrightarrow> length xs - Suc 0 < length xs + |
3342 length (takeWhile (\<lambda>a. a = Oc) aa)" |
3020 length (takeWhile (\<lambda>a. a = Oc) aa)" |
3343 apply(simp only: dec_after_clear.simps) |
3021 apply(simp only: dec_after_clear.simps) |
3344 apply(erule_tac exE)+ |
3022 apply(erule_tac exE)+ |
3345 apply(erule conjE)+ |
3023 apply(erule conjE)+ |
3346 apply(simp split: if_splits ) |
3024 apply(simp split: if_splits ) |
3347 done |
3025 done |
3348 |
3026 |
3349 lemma [simp]: |
3027 lemma more_Ocs_dec_after_clear2[simp]: |
3350 "\<lbrakk>dec_after_clear (as, abc_lm_s am n (abc_lm_v am n - Suc 0)) |
3028 "\<lbrakk>dec_after_clear (as, abc_lm_s am n (abc_lm_v am n - Suc 0)) |
3351 (start_of (layout_of aprog) as + 2 * n + 9, aa, []) ires\<rbrakk> |
3029 (start_of (layout_of aprog) as + 2 * n + 9, aa, []) ires\<rbrakk> |
3352 \<Longrightarrow> Suc 0 < length (takeWhile (\<lambda>a. a = Oc) aa)" |
3030 \<Longrightarrow> Suc 0 < length (takeWhile (\<lambda>a. a = Oc) aa)" |
3353 apply(simp add: dec_after_clear.simps split: if_splits) |
3031 apply(simp add: dec_after_clear.simps split: if_splits) |
3354 done |
3032 done |
3355 |
3033 |
3356 lemma [elim]: |
3034 lemma inv_check_left_moving_nonemptyE[elim]: |
3357 "inv_check_left_moving (as, lm) |
3035 "inv_check_left_moving (as, lm) (s, [], Oc # xs) ires |
3358 (s, [], Oc # xs) ires |
|
3359 \<Longrightarrow> RR" |
3036 \<Longrightarrow> RR" |
3360 apply(simp add: inv_check_left_moving.simps inv_check_left_moving_in_middle.simps) |
3037 apply(simp add: inv_check_left_moving.simps inv_check_left_moving_in_middle.simps) |
3361 done |
3038 done |
3362 |
3039 |
3363 lemma [simp]: |
3040 lemma inv_check_left_moving_nonempty[simp]: |
3041 "inv_check_left_moving (as, lm) (s, [], Oc # list) ires = False" |
|
3042 by auto |
|
3043 |
|
3044 lemma inv_locate_n_b_Oc_via_at_begin_norm[simp]: |
|
3364 "\<lbrakk>0 < abc_lm_v am n; |
3045 "\<lbrakk>0 < abc_lm_v am n; |
3365 at_begin_norm (as, am) (n, aaa, Oc # xs) ires\<rbrakk> |
3046 at_begin_norm (as, am) (n, aaa, Oc # xs) ires\<rbrakk> |
3366 \<Longrightarrow> inv_locate_n_b (as, am) (n, Oc # aaa, xs) ires" |
3047 \<Longrightarrow> inv_locate_n_b (as, am) (n, Oc # aaa, xs) ires" |
3367 apply(simp only: at_begin_norm.simps inv_locate_n_b.simps) |
3048 apply(simp only: at_begin_norm.simps inv_locate_n_b.simps) |
3368 apply(erule_tac exE)+ |
3049 apply(erule_tac exE)+ |
3370 apply(case_tac "length lm2", simp) |
3051 apply(case_tac "length lm2", simp) |
3371 apply(case_tac "lm2", simp, simp) |
3052 apply(case_tac "lm2", simp, simp) |
3372 apply(case_tac "lm2", auto simp: tape_of_nl_cons split: if_splits) |
3053 apply(case_tac "lm2", auto simp: tape_of_nl_cons split: if_splits) |
3373 done |
3054 done |
3374 |
3055 |
3375 lemma [simp]: |
3056 lemma inv_locate_n_b_Oc_via_at_begin_fst_awtn[simp]: |
3376 "\<lbrakk>0 < abc_lm_v am n; |
3057 "\<lbrakk>0 < abc_lm_v am n; |
3377 at_begin_fst_awtn (as, am) (n, aaa, Oc # xs) ires\<rbrakk> |
3058 at_begin_fst_awtn (as, am) (n, aaa, Oc # xs) ires\<rbrakk> |
3378 \<Longrightarrow> inv_locate_n_b (as, am) (n, Oc # aaa, xs) ires" |
3059 \<Longrightarrow> inv_locate_n_b (as, am) (n, Oc # aaa, xs) ires" |
3379 apply(simp only: at_begin_fst_awtn.simps inv_locate_n_b.simps ) |
3060 apply(simp only: at_begin_fst_awtn.simps inv_locate_n_b.simps ) |
3380 apply(erule exE)+ |
3061 apply(erule exE)+ |
3384 apply(simp add: exp_ind del: replicate.simps) |
3065 apply(simp add: exp_ind del: replicate.simps) |
3385 apply(rule conjI)+ |
3066 apply(rule conjI)+ |
3386 apply(auto) |
3067 apply(auto) |
3387 done |
3068 done |
3388 |
3069 |
3389 lemma [simp]: |
3070 lemma inv_locate_n_b_Oc_via_inv_locate_n_a[simp]: |
3390 "\<lbrakk>0 < abc_lm_v am n; inv_locate_a (as, am) (n, aaa, Oc # xs) ires\<rbrakk> |
3071 "\<lbrakk>0 < abc_lm_v am n; inv_locate_a (as, am) (n, aaa, Oc # xs) ires\<rbrakk> |
3391 \<Longrightarrow> inv_locate_n_b (as, am) (n, Oc#aaa, xs) ires" |
3072 \<Longrightarrow> inv_locate_n_b (as, am) (n, Oc#aaa, xs) ires" |
3392 apply(auto simp: inv_locate_a.simps at_begin_fst_bwtn.simps) |
3073 apply(auto simp: inv_locate_a.simps at_begin_fst_bwtn.simps) |
3393 done |
3074 done |
3394 |
3075 |
3395 lemma [simp]: |
3076 lemma more_Oc_dec_on_right_moving[simp]: |
3396 "\<lbrakk>dec_on_right_moving (as, am) (s, aa, Bk # xs) ires; |
3077 "\<lbrakk>dec_on_right_moving (as, am) (s, aa, Bk # xs) ires; |
3397 Suc (length (takeWhile (\<lambda>a. a = Oc) (tl aa))) |
3078 Suc (length (takeWhile (\<lambda>a. a = Oc) (tl aa))) |
3398 \<noteq> length (takeWhile (\<lambda>a. a = Oc) aa)\<rbrakk> |
3079 \<noteq> length (takeWhile (\<lambda>a. a = Oc) aa)\<rbrakk> |
3399 \<Longrightarrow> Suc (length (takeWhile (\<lambda>a. a = Oc) (tl aa))) |
3080 \<Longrightarrow> Suc (length (takeWhile (\<lambda>a. a = Oc) (tl aa))) |
3400 < length (takeWhile (\<lambda>a. a = Oc) aa)" |
3081 < length (takeWhile (\<lambda>a. a = Oc) aa)" |
3456 done |
3137 done |
3457 qed |
3138 qed |
3458 qed |
3139 qed |
3459 qed |
3140 qed |
3460 |
3141 |
3461 lemma [simp]: |
3142 lemma crsp_abc_step_l_start_of[simp]: |
3462 "\<lbrakk>inv_stop (as, abc_lm_s lm n (abc_lm_v lm n - Suc 0)) |
3143 "\<lbrakk>inv_stop (as, abc_lm_s lm n (abc_lm_v lm n - Suc 0)) |
3463 (start_of (layout_of ap) as + 2 * n + 16, a, b) ires; |
3144 (start_of (layout_of ap) as + 2 * n + 16, a, b) ires; |
3464 abc_lm_v lm n > 0; |
3145 abc_lm_v lm n > 0; |
3465 abc_fetch as ap = Some (Dec n e)\<rbrakk> |
3146 abc_fetch as ap = Some (Dec n e)\<rbrakk> |
3466 \<Longrightarrow> crsp (layout_of ap) (abc_step_l (as, lm) (Some (Dec n e))) |
3147 \<Longrightarrow> crsp (layout_of ap) (abc_step_l (as, lm) (Some (Dec n e))) |
3645 |
3326 |
3646 lemma layout_id_cons: "layout_of (ap @ [p]) = layout_of ap @ [length_of p]" |
3327 lemma layout_id_cons: "layout_of (ap @ [p]) = layout_of ap @ [length_of p]" |
3647 apply(simp add: layout_of.simps) |
3328 apply(simp add: layout_of.simps) |
3648 done |
3329 done |
3649 |
3330 |
3650 lemma [simp]: "length (layout_of xs) = length xs" |
3331 lemma map_start_of_layout[simp]: |
3651 by(simp add: layout_of.simps) |
|
3652 |
|
3653 lemma [simp]: |
|
3654 "map (start_of (layout_of xs @ [length_of x])) [0..<length xs] = (map (start_of (layout_of xs)) [0..<length xs])" |
3332 "map (start_of (layout_of xs @ [length_of x])) [0..<length xs] = (map (start_of (layout_of xs)) [0..<length xs])" |
3655 apply(auto) |
3333 apply(auto) |
3656 apply(simp add: layout_of.simps start_of.simps) |
3334 apply(simp add: layout_of.simps start_of.simps) |
3657 done |
3335 done |
3658 |
3336 |
3696 apply(auto simp: ci.simps tinc_b_def tdec_b_def length_findnth adjust.simps length_of.simps |
3374 apply(auto simp: ci.simps tinc_b_def tdec_b_def length_findnth adjust.simps length_of.simps |
3697 split: abc_inst.splits) |
3375 split: abc_inst.splits) |
3698 done |
3376 done |
3699 qed |
3377 qed |
3700 |
3378 |
3701 lemma [simp]: |
3379 lemma fetch_Nops[simp]: |
3702 "\<lbrakk>ly = layout_of ap; tp = tm_of ap\<rbrakk> \<Longrightarrow> |
3380 "\<lbrakk>ly = layout_of ap; tp = tm_of ap\<rbrakk> \<Longrightarrow> |
3703 fetch (tp @ [(Nop, 0), (Nop, 0)]) (start_of ly (length ap)) b = |
3381 fetch (tp @ [(Nop, 0), (Nop, 0)]) (start_of ly (length ap)) b = |
3704 (Nop, 0)" |
3382 (Nop, 0)" |
3705 apply(case_tac b) |
3383 apply(case_tac b) |
3706 apply(simp_all add: start_of.simps fetch.simps nth_append) |
3384 apply(simp_all add: start_of.simps fetch.simps nth_append) |