337
+ − 1
+ − 2
theory BitCoded2
+ − 3
imports "Lexer"
+ − 4
begin
+ − 5
+ − 6
section \<open>Bit-Encodings\<close>
+ − 7
+ − 8
datatype bit = Z | S
+ − 9
+ − 10
fun
+ − 11
code :: "val \<Rightarrow> bit list"
+ − 12
where
+ − 13
"code Void = []"
+ − 14
| "code (Char c) = []"
+ − 15
| "code (Left v) = Z # (code v)"
+ − 16
| "code (Right v) = S # (code v)"
+ − 17
| "code (Seq v1 v2) = (code v1) @ (code v2)"
+ − 18
| "code (Stars []) = [S]"
+ − 19
| "code (Stars (v # vs)) = (Z # code v) @ code (Stars vs)"
+ − 20
+ − 21
+ − 22
fun
+ − 23
Stars_add :: "val \<Rightarrow> val \<Rightarrow> val"
+ − 24
where
+ − 25
"Stars_add v (Stars vs) = Stars (v # vs)"
339
+ − 26
| "Stars_add v _ = Stars [v]"
337
+ − 27
+ − 28
function
+ − 29
decode' :: "bit list \<Rightarrow> rexp \<Rightarrow> (val * bit list)"
+ − 30
where
+ − 31
"decode' ds ZERO = (Void, [])"
+ − 32
| "decode' ds ONE = (Void, ds)"
+ − 33
| "decode' ds (CHAR d) = (Char d, ds)"
+ − 34
| "decode' [] (ALT r1 r2) = (Void, [])"
+ − 35
| "decode' (Z # ds) (ALT r1 r2) = (let (v, ds') = decode' ds r1 in (Left v, ds'))"
+ − 36
| "decode' (S # ds) (ALT r1 r2) = (let (v, ds') = decode' ds r2 in (Right v, ds'))"
+ − 37
| "decode' ds (SEQ r1 r2) = (let (v1, ds') = decode' ds r1 in
+ − 38
let (v2, ds'') = decode' ds' r2 in (Seq v1 v2, ds''))"
+ − 39
| "decode' [] (STAR r) = (Void, [])"
+ − 40
| "decode' (S # ds) (STAR r) = (Stars [], ds)"
+ − 41
| "decode' (Z # ds) (STAR r) = (let (v, ds') = decode' ds r in
+ − 42
let (vs, ds'') = decode' ds' (STAR r)
+ − 43
in (Stars_add v vs, ds''))"
+ − 44
by pat_completeness auto
+ − 45
+ − 46
lemma decode'_smaller:
+ − 47
assumes "decode'_dom (ds, r)"
+ − 48
shows "length (snd (decode' ds r)) \<le> length ds"
+ − 49
using assms
+ − 50
apply(induct ds r)
+ − 51
apply(auto simp add: decode'.psimps split: prod.split)
+ − 52
using dual_order.trans apply blast
+ − 53
by (meson dual_order.trans le_SucI)
+ − 54
+ − 55
termination "decode'"
+ − 56
apply(relation "inv_image (measure(%cs. size cs) <*lex*> measure(%s. size s)) (%(ds,r). (r,ds))")
+ − 57
apply(auto dest!: decode'_smaller)
+ − 58
by (metis less_Suc_eq_le snd_conv)
+ − 59
+ − 60
definition
+ − 61
decode :: "bit list \<Rightarrow> rexp \<Rightarrow> val option"
+ − 62
where
+ − 63
"decode ds r \<equiv> (let (v, ds') = decode' ds r
+ − 64
in (if ds' = [] then Some v else None))"
+ − 65
+ − 66
lemma decode'_code_Stars:
+ − 67
assumes "\<forall>v\<in>set vs. \<Turnstile> v : r \<and> (\<forall>x. decode' (code v @ x) r = (v, x)) \<and> flat v \<noteq> []"
+ − 68
shows "decode' (code (Stars vs) @ ds) (STAR r) = (Stars vs, ds)"
+ − 69
using assms
+ − 70
apply(induct vs)
+ − 71
apply(auto)
+ − 72
done
+ − 73
+ − 74
lemma decode'_code:
+ − 75
assumes "\<Turnstile> v : r"
+ − 76
shows "decode' ((code v) @ ds) r = (v, ds)"
+ − 77
using assms
+ − 78
apply(induct v r arbitrary: ds)
+ − 79
apply(auto)
+ − 80
using decode'_code_Stars by blast
+ − 81
+ − 82
lemma decode_code:
+ − 83
assumes "\<Turnstile> v : r"
+ − 84
shows "decode (code v) r = Some v"
+ − 85
using assms unfolding decode_def
+ − 86
by (smt append_Nil2 decode'_code old.prod.case)
+ − 87
+ − 88
+ − 89
section {* Annotated Regular Expressions *}
+ − 90
+ − 91
datatype arexp =
+ − 92
AZERO
+ − 93
| AONE "bit list"
+ − 94
| ACHAR "bit list" char
+ − 95
| ASEQ "bit list" arexp arexp
+ − 96
| AALTs "bit list" "arexp list"
+ − 97
| ASTAR "bit list" arexp
+ − 98
+ − 99
abbreviation
+ − 100
"AALT bs r1 r2 \<equiv> AALTs bs [r1, r2]"
+ − 101
+ − 102
fun asize :: "arexp \<Rightarrow> nat" where
+ − 103
"asize AZERO = 1"
+ − 104
| "asize (AONE cs) = 1"
+ − 105
| "asize (ACHAR cs c) = 1"
+ − 106
| "asize (AALTs cs rs) = Suc (sum_list (map asize rs))"
+ − 107
| "asize (ASEQ cs r1 r2) = Suc (asize r1 + asize r2)"
+ − 108
| "asize (ASTAR cs r) = Suc (asize r)"
+ − 109
+ − 110
fun
+ − 111
erase :: "arexp \<Rightarrow> rexp"
+ − 112
where
+ − 113
"erase AZERO = ZERO"
+ − 114
| "erase (AONE _) = ONE"
+ − 115
| "erase (ACHAR _ c) = CHAR c"
+ − 116
| "erase (AALTs _ []) = ZERO"
+ − 117
| "erase (AALTs _ [r]) = (erase r)"
+ − 118
| "erase (AALTs bs (r#rs)) = ALT (erase r) (erase (AALTs bs rs))"
+ − 119
| "erase (ASEQ _ r1 r2) = SEQ (erase r1) (erase r2)"
+ − 120
| "erase (ASTAR _ r) = STAR (erase r)"
+ − 121
+ − 122
lemma decode_code_erase:
+ − 123
assumes "\<Turnstile> v : (erase a)"
+ − 124
shows "decode (code v) (erase a) = Some v"
+ − 125
using assms
+ − 126
by (simp add: decode_code)
+ − 127
+ − 128
+ − 129
fun nonalt :: "arexp \<Rightarrow> bool"
+ − 130
where
+ − 131
"nonalt (AALTs bs2 rs) = False"
+ − 132
| "nonalt r = True"
+ − 133
+ − 134
+ − 135
fun good :: "arexp \<Rightarrow> bool" where
+ − 136
"good AZERO = False"
+ − 137
| "good (AONE cs) = True"
+ − 138
| "good (ACHAR cs c) = True"
+ − 139
| "good (AALTs cs []) = False"
+ − 140
| "good (AALTs cs [r]) = False"
+ − 141
| "good (AALTs cs (r1#r2#rs)) = (\<forall>r' \<in> set (r1#r2#rs). good r' \<and> nonalt r')"
+ − 142
| "good (ASEQ _ AZERO _) = False"
+ − 143
| "good (ASEQ _ (AONE _) _) = False"
+ − 144
| "good (ASEQ _ _ AZERO) = False"
+ − 145
| "good (ASEQ cs r1 r2) = (good r1 \<and> good r2)"
+ − 146
| "good (ASTAR cs r) = True"
+ − 147
+ − 148
+ − 149
+ − 150
+ − 151
fun fuse :: "bit list \<Rightarrow> arexp \<Rightarrow> arexp" where
+ − 152
"fuse bs AZERO = AZERO"
+ − 153
| "fuse bs (AONE cs) = AONE (bs @ cs)"
+ − 154
| "fuse bs (ACHAR cs c) = ACHAR (bs @ cs) c"
+ − 155
| "fuse bs (AALTs cs rs) = AALTs (bs @ cs) rs"
+ − 156
| "fuse bs (ASEQ cs r1 r2) = ASEQ (bs @ cs) r1 r2"
+ − 157
| "fuse bs (ASTAR cs r) = ASTAR (bs @ cs) r"
+ − 158
+ − 159
lemma fuse_append:
+ − 160
shows "fuse (bs1 @ bs2) r = fuse bs1 (fuse bs2 r)"
+ − 161
apply(induct r)
+ − 162
apply(auto)
+ − 163
done
+ − 164
+ − 165
+ − 166
fun intern :: "rexp \<Rightarrow> arexp" where
+ − 167
"intern ZERO = AZERO"
+ − 168
| "intern ONE = AONE []"
+ − 169
| "intern (CHAR c) = ACHAR [] c"
+ − 170
| "intern (ALT r1 r2) = AALT [] (fuse [Z] (intern r1))
+ − 171
(fuse [S] (intern r2))"
+ − 172
| "intern (SEQ r1 r2) = ASEQ [] (intern r1) (intern r2)"
359
+ − 173
| "intern (STAR r) = ASTAR [S] (intern r)"
337
+ − 174
+ − 175
+ − 176
fun retrieve :: "arexp \<Rightarrow> val \<Rightarrow> bit list" where
+ − 177
"retrieve (AONE bs) Void = bs"
+ − 178
| "retrieve (ACHAR bs c) (Char d) = bs"
+ − 179
| "retrieve (AALTs bs [r]) v = bs @ retrieve r v"
+ − 180
| "retrieve (AALTs bs (r#rs)) (Left v) = bs @ retrieve r v"
+ − 181
| "retrieve (AALTs bs (r#rs)) (Right v) = bs @ retrieve (AALTs [] rs) v"
+ − 182
| "retrieve (ASEQ bs r1 r2) (Seq v1 v2) = bs @ retrieve r1 v1 @ retrieve r2 v2"
+ − 183
| "retrieve (ASTAR bs r) (Stars []) = bs @ [S]"
+ − 184
| "retrieve (ASTAR bs r) (Stars (v#vs)) =
+ − 185
bs @ [Z] @ retrieve r v @ retrieve (ASTAR [] r) (Stars vs)"
+ − 186
+ − 187
+ − 188
+ − 189
fun
+ − 190
bnullable :: "arexp \<Rightarrow> bool"
+ − 191
where
+ − 192
"bnullable (AZERO) = False"
+ − 193
| "bnullable (AONE bs) = True"
+ − 194
| "bnullable (ACHAR bs c) = False"
+ − 195
| "bnullable (AALTs bs rs) = (\<exists>r \<in> set rs. bnullable r)"
+ − 196
| "bnullable (ASEQ bs r1 r2) = (bnullable r1 \<and> bnullable r2)"
+ − 197
| "bnullable (ASTAR bs r) = True"
+ − 198
+ − 199
fun
+ − 200
bmkeps :: "arexp \<Rightarrow> bit list"
+ − 201
where
+ − 202
"bmkeps(AONE bs) = bs"
+ − 203
| "bmkeps(ASEQ bs r1 r2) = bs @ (bmkeps r1) @ (bmkeps r2)"
+ − 204
| "bmkeps(AALTs bs [r]) = bs @ (bmkeps r)"
+ − 205
| "bmkeps(AALTs bs (r#rs)) = (if bnullable(r) then bs @ (bmkeps r) else (bmkeps (AALTs bs rs)))"
359
+ − 206
| "bmkeps(ASTAR bs r) = bs"
337
+ − 207
+ − 208
+ − 209
fun
+ − 210
bder :: "char \<Rightarrow> arexp \<Rightarrow> arexp"
+ − 211
where
+ − 212
"bder c (AZERO) = AZERO"
+ − 213
| "bder c (AONE bs) = AZERO"
+ − 214
| "bder c (ACHAR bs d) = (if c = d then AONE bs else AZERO)"
+ − 215
| "bder c (AALTs bs rs) = AALTs bs (map (bder c) rs)"
+ − 216
| "bder c (ASEQ bs r1 r2) =
+ − 217
(if bnullable r1
+ − 218
then AALT bs (ASEQ [] (bder c r1) r2) (fuse (bmkeps r1) (bder c r2))
+ − 219
else ASEQ bs (bder c r1) r2)"
359
+ − 220
| "bder c (ASTAR bs r) = ASEQ (butlast bs) (fuse [Z] (bder c r)) (ASTAR [S] r)"
+ − 221
+ − 222
+ − 223
+ − 224
lemma bder_fuse:
+ − 225
"fuse bs (bder c r) = bder c (fuse bs r)"
+ − 226
apply(induct r arbitrary: bs)
+ − 227
apply(simp_all)
+ − 228
done
337
+ − 229
+ − 230
+ − 231
fun
+ − 232
bders :: "arexp \<Rightarrow> string \<Rightarrow> arexp"
+ − 233
where
+ − 234
"bders r [] = r"
+ − 235
| "bders r (c#s) = bders (bder c r) s"
+ − 236
+ − 237
lemma bders_append:
+ − 238
"bders r (s1 @ s2) = bders (bders r s1) s2"
+ − 239
apply(induct s1 arbitrary: r s2)
+ − 240
apply(simp_all)
+ − 241
done
+ − 242
+ − 243
lemma bnullable_correctness:
+ − 244
shows "nullable (erase r) = bnullable r"
+ − 245
apply(induct r rule: erase.induct)
+ − 246
apply(simp_all)
+ − 247
done
+ − 248
+ − 249
lemma erase_fuse:
+ − 250
shows "erase (fuse bs r) = erase r"
+ − 251
apply(induct r rule: erase.induct)
+ − 252
apply(simp_all)
+ − 253
done
+ − 254
+ − 255
lemma erase_intern [simp]:
+ − 256
shows "erase (intern r) = r"
+ − 257
apply(induct r)
+ − 258
apply(simp_all add: erase_fuse)
+ − 259
done
+ − 260
+ − 261
lemma erase_bder [simp]:
+ − 262
shows "erase (bder a r) = der a (erase r)"
+ − 263
apply(induct r rule: erase.induct)
+ − 264
apply(simp_all add: erase_fuse bnullable_correctness)
+ − 265
done
+ − 266
+ − 267
lemma erase_bders [simp]:
+ − 268
shows "erase (bders r s) = ders s (erase r)"
+ − 269
apply(induct s arbitrary: r )
+ − 270
apply(simp_all)
+ − 271
done
+ − 272
+ − 273
lemma retrieve_encode_STARS:
+ − 274
assumes "\<forall>v\<in>set vs. \<Turnstile> v : r \<and> code v = retrieve (intern r) v"
+ − 275
shows "code (Stars vs) = retrieve (ASTAR [] (intern r)) (Stars vs)"
+ − 276
using assms
+ − 277
apply(induct vs)
+ − 278
apply(simp_all)
+ − 279
done
+ − 280
+ − 281
lemma retrieve_fuse2:
+ − 282
assumes "\<Turnstile> v : (erase r)"
+ − 283
shows "retrieve (fuse bs r) v = bs @ retrieve r v"
+ − 284
using assms
+ − 285
apply(induct r arbitrary: v bs)
+ − 286
apply(auto elim: Prf_elims)[4]
+ − 287
defer
+ − 288
using retrieve_encode_STARS
+ − 289
apply(auto elim!: Prf_elims)[1]
+ − 290
apply(case_tac vs)
+ − 291
apply(simp)
+ − 292
apply(simp)
+ − 293
(* AALTs case *)
+ − 294
apply(simp)
+ − 295
apply(case_tac x2a)
+ − 296
apply(simp)
+ − 297
apply(auto elim!: Prf_elims)[1]
+ − 298
apply(simp)
+ − 299
apply(case_tac list)
+ − 300
apply(simp)
+ − 301
apply(auto)
+ − 302
apply(auto elim!: Prf_elims)[1]
+ − 303
done
+ − 304
+ − 305
lemma retrieve_fuse:
+ − 306
assumes "\<Turnstile> v : r"
+ − 307
shows "retrieve (fuse bs (intern r)) v = bs @ retrieve (intern r) v"
+ − 308
using assms
+ − 309
by (simp_all add: retrieve_fuse2)
+ − 310
+ − 311
+ − 312
lemma r:
+ − 313
assumes "bnullable (AALTs bs (a # rs))"
+ − 314
shows "bnullable a \<or> (\<not> bnullable a \<and> bnullable (AALTs bs rs))"
+ − 315
using assms
+ − 316
apply(induct rs)
+ − 317
apply(auto)
+ − 318
done
+ − 319
+ − 320
lemma r0:
+ − 321
assumes "bnullable a"
+ − 322
shows "bmkeps (AALTs bs (a # rs)) = bs @ (bmkeps a)"
+ − 323
using assms
+ − 324
by (metis bmkeps.simps(3) bmkeps.simps(4) list.exhaust)
+ − 325
+ − 326
lemma r1:
+ − 327
assumes "\<not> bnullable a" "bnullable (AALTs bs rs)"
+ − 328
shows "bmkeps (AALTs bs (a # rs)) = bmkeps (AALTs bs rs)"
+ − 329
using assms
+ − 330
apply(induct rs)
+ − 331
apply(auto)
+ − 332
done
+ − 333
+ − 334
lemma r2:
+ − 335
assumes "x \<in> set rs" "bnullable x"
+ − 336
shows "bnullable (AALTs bs rs)"
+ − 337
using assms
+ − 338
apply(induct rs)
+ − 339
apply(auto)
+ − 340
done
+ − 341
+ − 342
lemma r3:
+ − 343
assumes "\<not> bnullable r"
+ − 344
" \<exists> x \<in> set rs. bnullable x"
+ − 345
shows "retrieve (AALTs bs rs) (mkeps (erase (AALTs bs rs))) =
+ − 346
retrieve (AALTs bs (r # rs)) (mkeps (erase (AALTs bs (r # rs))))"
+ − 347
using assms
+ − 348
apply(induct rs arbitrary: r bs)
+ − 349
apply(auto)[1]
+ − 350
apply(auto)
+ − 351
using bnullable_correctness apply blast
+ − 352
apply(auto simp add: bnullable_correctness mkeps_nullable retrieve_fuse2)
+ − 353
apply(subst retrieve_fuse2[symmetric])
+ − 354
apply (smt bnullable.simps(4) bnullable_correctness erase.simps(5) erase.simps(6) insert_iff list.exhaust list.set(2) mkeps.simps(3) mkeps_nullable)
+ − 355
apply(simp)
+ − 356
apply(case_tac "bnullable a")
+ − 357
apply (smt append_Nil2 bnullable.simps(4) bnullable_correctness erase.simps(5) erase.simps(6) fuse.simps(4) insert_iff list.exhaust list.set(2) mkeps.simps(3) mkeps_nullable retrieve_fuse2)
+ − 358
apply(drule_tac x="a" in meta_spec)
+ − 359
apply(drule_tac x="bs" in meta_spec)
+ − 360
apply(drule meta_mp)
+ − 361
apply(simp)
+ − 362
apply(drule meta_mp)
+ − 363
apply(auto)
+ − 364
apply(subst retrieve_fuse2[symmetric])
+ − 365
apply(case_tac rs)
+ − 366
apply(simp)
+ − 367
apply(auto)[1]
+ − 368
apply (simp add: bnullable_correctness)
+ − 369
apply (metis append_Nil2 bnullable_correctness erase_fuse fuse.simps(4) list.set_intros(1) mkeps.simps(3) mkeps_nullable nullable.simps(4) r2)
+ − 370
apply (simp add: bnullable_correctness)
+ − 371
apply (metis append_Nil2 bnullable_correctness erase.simps(6) erase_fuse fuse.simps(4) list.set_intros(2) mkeps.simps(3) mkeps_nullable r2)
+ − 372
apply(simp)
+ − 373
done
+ − 374
+ − 375
+ − 376
lemma t:
+ − 377
assumes "\<forall>r \<in> set rs. nullable (erase r) \<longrightarrow> bmkeps r = retrieve r (mkeps (erase r))"
+ − 378
"nullable (erase (AALTs bs rs))"
+ − 379
shows " bmkeps (AALTs bs rs) = retrieve (AALTs bs rs) (mkeps (erase (AALTs bs rs)))"
+ − 380
using assms
+ − 381
apply(induct rs arbitrary: bs)
+ − 382
apply(simp)
+ − 383
apply(auto simp add: bnullable_correctness)
+ − 384
apply(case_tac rs)
+ − 385
apply(auto simp add: bnullable_correctness)[2]
+ − 386
apply(subst r1)
+ − 387
apply(simp)
+ − 388
apply(rule r2)
+ − 389
apply(assumption)
+ − 390
apply(simp)
+ − 391
apply(drule_tac x="bs" in meta_spec)
+ − 392
apply(drule meta_mp)
+ − 393
apply(auto)[1]
+ − 394
prefer 2
+ − 395
apply(case_tac "bnullable a")
+ − 396
apply(subst r0)
+ − 397
apply blast
+ − 398
apply(subgoal_tac "nullable (erase a)")
+ − 399
prefer 2
+ − 400
using bnullable_correctness apply blast
+ − 401
apply (metis (no_types, lifting) erase.simps(5) erase.simps(6) list.exhaust mkeps.simps(3) retrieve.simps(3) retrieve.simps(4))
+ − 402
apply(subst r1)
+ − 403
apply(simp)
+ − 404
using r2 apply blast
+ − 405
apply(drule_tac x="bs" in meta_spec)
+ − 406
apply(drule meta_mp)
+ − 407
apply(auto)[1]
+ − 408
apply(simp)
+ − 409
using r3 apply blast
+ − 410
apply(auto)
+ − 411
using r3 by blast
+ − 412
+ − 413
+ − 414
lemma asize0:
+ − 415
shows "0 < asize r"
+ − 416
apply(induct r)
+ − 417
apply(auto)
+ − 418
done
+ − 419
+ − 420
lemma asize_fuse:
+ − 421
shows "asize (fuse bs r) = asize r"
+ − 422
apply(induct r)
+ − 423
apply(auto)
+ − 424
done
+ − 425
359
+ − 426
lemma TESTTEST:
+ − 427
shows "bder c (intern r) = intern (der c r)"
+ − 428
apply(induct r)
+ − 429
apply(simp)
+ − 430
apply(simp)
+ − 431
apply(simp)
+ − 432
prefer 2
+ − 433
apply(simp)
+ − 434
apply (simp add: bder_fuse[symmetric])
+ − 435
prefer 3
+ − 436
apply(simp only: intern.simps)
+ − 437
apply(simp only: der.simps)
+ − 438
apply(simp only: intern.simps)
+ − 439
apply(simp only: bder.simps)
+ − 440
apply(simp)
+ − 441
apply(simp only: intern.simps)
+ − 442
prefer 2
+ − 443
apply(simp)
+ − 444
prefer 2
+ − 445
apply(simp)
+ − 446
apply(auto)
337
+ − 447
+ − 448
+ − 449
fun nonnested :: "arexp \<Rightarrow> bool"
+ − 450
where
+ − 451
"nonnested (AALTs bs2 []) = True"
+ − 452
| "nonnested (AALTs bs2 ((AALTs bs1 rs1) # rs2)) = False"
+ − 453
| "nonnested (AALTs bs2 (r # rs2)) = nonnested (AALTs bs2 rs2)"
+ − 454
| "nonnested r = True"
+ − 455
+ − 456
+ − 457
+ − 458
fun distinctBy :: "'a list \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'b set \<Rightarrow> 'a list"
+ − 459
where
+ − 460
"distinctBy [] f acc = []"
+ − 461
| "distinctBy (x#xs) f acc =
+ − 462
(if (f x) \<in> acc then distinctBy xs f acc
+ − 463
else x # (distinctBy xs f ({f x} \<union> acc)))"
+ − 464
+ − 465
fun flts :: "arexp list \<Rightarrow> arexp list"
+ − 466
where
+ − 467
"flts [] = []"
+ − 468
| "flts (AZERO # rs) = flts rs"
+ − 469
| "flts ((AALTs bs rs1) # rs) = (map (fuse bs) rs1) @ flts rs"
+ − 470
| "flts (r1 # rs) = r1 # flts rs"
+ − 471
+ − 472
+ − 473
fun spill :: "arexp list \<Rightarrow> arexp list"
+ − 474
where
+ − 475
"spill [] = []"
+ − 476
| "spill ((AALTs bs rs1) # rs) = (map (fuse bs) rs1) @ spill rs"
+ − 477
| "spill (r1 # rs) = r1 # spill rs"
+ − 478
+ − 479
lemma spill_Cons:
+ − 480
shows "spill (r # rs1) = spill [r] @ spill rs1"
+ − 481
apply(induct r arbitrary: rs1)
+ − 482
apply(auto)
+ − 483
done
+ − 484
+ − 485
lemma spill_append:
+ − 486
shows "spill (rs1 @ rs2) = spill rs1 @ spill rs2"
+ − 487
apply(induct rs1 arbitrary: rs2)
+ − 488
apply(auto)
+ − 489
by (metis append.assoc spill_Cons)
+ − 490
+ − 491
fun bsimp_ASEQ :: "bit list \<Rightarrow> arexp \<Rightarrow> arexp \<Rightarrow> arexp"
+ − 492
where
+ − 493
"bsimp_ASEQ _ AZERO _ = AZERO"
+ − 494
| "bsimp_ASEQ _ _ AZERO = AZERO"
+ − 495
| "bsimp_ASEQ bs1 (AONE bs2) r2 = fuse (bs1 @ bs2) r2"
+ − 496
| "bsimp_ASEQ bs1 r1 r2 = ASEQ bs1 r1 r2"
+ − 497
+ − 498
+ − 499
fun bsimp_AALTs :: "bit list \<Rightarrow> arexp list \<Rightarrow> arexp"
+ − 500
where
+ − 501
"bsimp_AALTs _ [] = AZERO"
+ − 502
| "bsimp_AALTs bs1 [r] = fuse bs1 r"
+ − 503
| "bsimp_AALTs bs1 rs = AALTs bs1 rs"
+ − 504
+ − 505
+ − 506
fun bsimp :: "arexp \<Rightarrow> arexp"
+ − 507
where
+ − 508
"bsimp (ASEQ bs1 r1 r2) = bsimp_ASEQ bs1 (bsimp r1) (bsimp r2)"
+ − 509
| "bsimp (AALTs bs1 rs) = bsimp_AALTs bs1 (flts (map bsimp rs))"
+ − 510
| "bsimp r = r"
+ − 511
343
+ − 512
+ − 513
inductive contains2 :: "arexp \<Rightarrow> bit list \<Rightarrow> bool" ("_ >>2 _" [51, 50] 50)
+ − 514
where
+ − 515
"AONE bs >>2 bs"
+ − 516
| "ACHAR bs c >>2 bs"
+ − 517
| "\<lbrakk>a1 >>2 bs1; a2 >>2 bs2\<rbrakk> \<Longrightarrow> ASEQ bs a1 a2 >>2 bs @ bs1 @ bs2"
+ − 518
| "r >>2 bs1 \<Longrightarrow> AALTs bs (r#rs) >>2 bs @ bs1"
+ − 519
| "AALTs bs rs >>2 bs @ bs1 \<Longrightarrow> AALTs bs (r#rs) >>2 bs @ bs1"
+ − 520
| "ASTAR bs r >>2 bs @ [S]"
+ − 521
| "\<lbrakk>r >>2 bs1; ASTAR [] r >>2 bs2\<rbrakk> \<Longrightarrow> ASTAR bs r >>2 bs @ Z # bs1 @ bs2"
+ − 522
| "r >>2 bs \<Longrightarrow> (bsimp r) >>2 bs"
+ − 523
+ − 524
337
+ − 525
inductive contains :: "arexp \<Rightarrow> bit list \<Rightarrow> bool" ("_ >> _" [51, 50] 50)
+ − 526
where
+ − 527
"AONE bs >> bs"
+ − 528
| "ACHAR bs c >> bs"
+ − 529
| "\<lbrakk>a1 >> bs1; a2 >> bs2\<rbrakk> \<Longrightarrow> ASEQ bs a1 a2 >> bs @ bs1 @ bs2"
+ − 530
| "r >> bs1 \<Longrightarrow> AALTs bs (r#rs) >> bs @ bs1"
+ − 531
| "AALTs bs rs >> bs @ bs1 \<Longrightarrow> AALTs bs (r#rs) >> bs @ bs1"
+ − 532
| "ASTAR bs r >> bs @ [S]"
+ − 533
| "\<lbrakk>r >> bs1; ASTAR [] r >> bs2\<rbrakk> \<Longrightarrow> ASTAR bs r >> bs @ Z # bs1 @ bs2"
+ − 534
359
+ − 535
+ − 536
337
+ − 537
lemma contains0:
+ − 538
assumes "a >> bs"
+ − 539
shows "(fuse bs1 a) >> bs1 @ bs"
+ − 540
using assms
+ − 541
apply(induct arbitrary: bs1)
+ − 542
apply(auto intro: contains.intros)
+ − 543
apply (metis append.assoc contains.intros(3))
+ − 544
apply (metis append.assoc contains.intros(4))
+ − 545
apply (metis append.assoc contains.intros(5))
+ − 546
apply (metis append.assoc contains.intros(6))
+ − 547
apply (metis append_assoc contains.intros(7))
+ − 548
done
+ − 549
+ − 550
lemma contains1:
+ − 551
assumes "\<forall>v\<in>set vs. \<Turnstile> v : r \<and> intern r >> code v"
+ − 552
shows "ASTAR [] (intern r) >> code (Stars vs)"
+ − 553
using assms
+ − 554
apply(induct vs)
+ − 555
apply(simp)
+ − 556
using contains.simps apply blast
+ − 557
apply(simp)
+ − 558
apply(subst (2) append_Nil[symmetric])
+ − 559
apply(rule contains.intros)
+ − 560
apply(auto)
+ − 561
done
+ − 562
+ − 563
343
+ − 564
+ − 565
+ − 566
337
+ − 567
lemma contains2:
+ − 568
assumes "\<Turnstile> v : r"
+ − 569
shows "(intern r) >> code v"
+ − 570
using assms
+ − 571
apply(induct)
+ − 572
prefer 4
+ − 573
apply(simp)
+ − 574
apply(rule contains.intros)
+ − 575
prefer 4
+ − 576
apply(simp)
+ − 577
apply(rule contains.intros)
+ − 578
apply(simp)
+ − 579
apply(subst (3) append_Nil[symmetric])
+ − 580
apply(rule contains.intros)
+ − 581
apply(simp)
+ − 582
apply(simp)
+ − 583
apply(simp)
+ − 584
apply(subst (9) append_Nil[symmetric])
+ − 585
apply(rule contains.intros)
+ − 586
apply (metis append_Cons append_self_conv2 contains0)
+ − 587
apply(simp)
+ − 588
apply(subst (9) append_Nil[symmetric])
+ − 589
apply(rule contains.intros)
+ − 590
back
+ − 591
apply(rule contains.intros)
+ − 592
apply(drule_tac ?bs1.0="[S]" in contains0)
+ − 593
apply(simp)
+ − 594
apply(simp)
+ − 595
apply(case_tac vs)
+ − 596
apply(simp)
+ − 597
apply (metis append_Nil contains.intros(6))
+ − 598
using contains1 by blast
+ − 599
+ − 600
lemma qq1:
+ − 601
assumes "\<exists>r \<in> set rs. bnullable r"
+ − 602
shows "bmkeps (AALTs bs (rs @ rs1)) = bmkeps (AALTs bs rs)"
+ − 603
using assms
+ − 604
apply(induct rs arbitrary: rs1 bs)
+ − 605
apply(simp)
+ − 606
apply(simp)
+ − 607
by (metis Nil_is_append_conv bmkeps.simps(4) neq_Nil_conv r0 split_list_last)
+ − 608
+ − 609
lemma qq2:
+ − 610
assumes "\<forall>r \<in> set rs. \<not> bnullable r" "\<exists>r \<in> set rs1. bnullable r"
+ − 611
shows "bmkeps (AALTs bs (rs @ rs1)) = bmkeps (AALTs bs rs1)"
+ − 612
using assms
+ − 613
apply(induct rs arbitrary: rs1 bs)
+ − 614
apply(simp)
+ − 615
apply(simp)
+ − 616
by (metis append_assoc in_set_conv_decomp r1 r2)
+ − 617
+ − 618
lemma qq2a:
+ − 619
assumes "\<not> bnullable r" "\<exists>r \<in> set rs1. bnullable r"
+ − 620
shows "bmkeps (AALTs bs (r # rs1)) = bmkeps (AALTs bs rs1)"
+ − 621
using assms
+ − 622
by (simp add: r1)
+ − 623
+ − 624
lemma qq3:
+ − 625
shows "bnullable (AALTs bs rs) = (\<exists>r \<in> set rs. bnullable r)"
+ − 626
apply(induct rs arbitrary: bs)
+ − 627
apply(simp)
+ − 628
apply(simp)
+ − 629
done
+ − 630
+ − 631
lemma qq4:
+ − 632
assumes "bnullable (AALTs bs rs)"
+ − 633
shows "bmkeps (AALTs bs rs) = bs @ bmkeps (AALTs [] rs)"
+ − 634
by (metis append_Nil2 assms bmkeps_retrieve bnullable_correctness erase_fuse fuse.simps(4) mkeps_nullable retrieve_fuse2)
+ − 635
+ − 636
+ − 637
lemma contains3a:
+ − 638
assumes "AALTs bs lst >> bs @ bs1"
+ − 639
shows "AALTs bs (a # lst) >> bs @ bs1"
+ − 640
using assms
+ − 641
apply -
+ − 642
by (simp add: contains.intros(5))
+ − 643
+ − 644
+ − 645
lemma contains3b:
+ − 646
assumes "a >> bs1"
+ − 647
shows "AALTs bs (a # lst) >> bs @ bs1"
+ − 648
using assms
+ − 649
apply -
+ − 650
apply(rule contains.intros)
+ − 651
apply(simp)
+ − 652
done
+ − 653
+ − 654
+ − 655
lemma contains3:
+ − 656
assumes "\<And>x. \<lbrakk>x \<in> set rs; bnullable x\<rbrakk> \<Longrightarrow> x >> bmkeps x" "x \<in> set rs" "bnullable x"
+ − 657
shows "AALTs bs rs >> bmkeps (AALTs bs rs)"
+ − 658
using assms
+ − 659
apply(induct rs arbitrary: bs x)
+ − 660
apply simp
+ − 661
by (metis contains.intros(4) contains.intros(5) list.set_intros(1) list.set_intros(2) qq3 qq4 r r0 r1)
+ − 662
+ − 663
lemma cont1:
+ − 664
assumes "\<And>v. \<Turnstile> v : erase r \<Longrightarrow> r >> retrieve r v"
+ − 665
"\<forall>v\<in>set vs. \<Turnstile> v : erase r \<and> flat v \<noteq> []"
+ − 666
shows "ASTAR bs r >> retrieve (ASTAR bs r) (Stars vs)"
+ − 667
using assms
+ − 668
apply(induct vs arbitrary: bs r)
+ − 669
apply(simp)
+ − 670
using contains.intros(6) apply auto[1]
+ − 671
by (simp add: contains.intros(7))
+ − 672
+ − 673
lemma contains4:
+ − 674
assumes "bnullable a"
+ − 675
shows "a >> bmkeps a"
+ − 676
using assms
+ − 677
apply(induct a rule: bnullable.induct)
+ − 678
apply(auto intro: contains.intros)
+ − 679
using contains3 by blast
+ − 680
+ − 681
lemma contains5:
+ − 682
assumes "\<Turnstile> v : r"
+ − 683
shows "(intern r) >> retrieve (intern r) v"
+ − 684
using contains2[OF assms] retrieve_code[OF assms]
+ − 685
by (simp)
+ − 686
343
+ − 687
337
+ − 688
lemma contains6:
+ − 689
assumes "\<Turnstile> v : (erase r)"
+ − 690
shows "r >> retrieve r v"
+ − 691
using assms
+ − 692
apply(induct r arbitrary: v rule: erase.induct)
+ − 693
apply(auto)[1]
+ − 694
using Prf_elims(1) apply blast
+ − 695
using Prf_elims(4) contains.intros(1) apply force
+ − 696
using Prf_elims(5) contains.intros(2) apply force
+ − 697
apply(auto)[1]
+ − 698
using Prf_elims(1) apply blast
+ − 699
apply(auto)[1]
+ − 700
using contains3b contains3a apply blast
+ − 701
prefer 2
+ − 702
apply(auto)[1]
+ − 703
apply (metis Prf_elims(2) contains.intros(3) retrieve.simps(6))
+ − 704
prefer 2
+ − 705
apply(auto)[1]
+ − 706
apply (metis Prf_elims(6) cont1)
+ − 707
apply(simp)
+ − 708
apply(erule Prf_elims)
+ − 709
apply(auto)
+ − 710
apply (simp add: contains3b)
+ − 711
using retrieve_fuse2 contains3b contains3a
+ − 712
apply(subst retrieve_fuse2[symmetric])
+ − 713
apply (metis append_Nil2 erase_fuse fuse.simps(4))
+ − 714
apply(simp)
+ − 715
by (metis append_Nil2 erase_fuse fuse.simps(4))
+ − 716
+ − 717
lemma contains7:
+ − 718
assumes "\<Turnstile> v : der c (erase r)"
+ − 719
shows "(bder c r) >> retrieve r (injval (erase r) c v)"
+ − 720
using bder_retrieve[OF assms(1)] retrieve_code[OF assms(1)]
+ − 721
by (metis assms contains6 erase_bder)
+ − 722
+ − 723
338
+ − 724
lemma contains7a:
+ − 725
assumes "\<Turnstile> v : der c (erase r)"
+ − 726
shows "r >> retrieve r (injval (erase r) c v)"
+ − 727
using assms
+ − 728
apply -
+ − 729
apply(drule Prf_injval)
+ − 730
apply(drule contains6)
+ − 731
apply(simp)
+ − 732
done
+ − 733
343
+ − 734
lemma contains7b:
+ − 735
assumes "\<Turnstile> v : ders s (erase r)"
+ − 736
shows "(bders r s) >> retrieve r (flex (erase r) id s v)"
+ − 737
using assms
+ − 738
apply(induct s arbitrary: r v)
+ − 739
apply(simp)
+ − 740
apply (simp add: contains6)
+ − 741
apply(simp add: bders_append flex_append ders_append)
+ − 742
apply(drule_tac x="bder a r" in meta_spec)
+ − 743
apply(drule meta_spec)
+ − 744
apply(drule meta_mp)
+ − 745
apply(simp)
+ − 746
apply(simp)
+ − 747
apply(subst (asm) bder_retrieve)
+ − 748
defer
+ − 749
apply (simp add: flex_injval)
+ − 750
by (simp add: Prf_flex)
+ − 751
+ − 752
lemma contains7_iff:
+ − 753
assumes "\<Turnstile> v : der c (erase r)"
+ − 754
shows "(bder c r) >> retrieve r (injval (erase r) c v) \<longleftrightarrow>
+ − 755
r >> retrieve r (injval (erase r) c v)"
+ − 756
by (simp add: assms contains7 contains7a)
+ − 757
+ − 758
lemma contains8_iff:
+ − 759
assumes "\<Turnstile> v : ders s (erase r)"
+ − 760
shows "(bders r s) >> retrieve r (flex (erase r) id s v) \<longleftrightarrow>
+ − 761
r >> retrieve r (flex (erase r) id s v)"
+ − 762
using Prf_flex assms contains6 contains7b by blast
+ − 763
+ − 764
359
+ − 765
+ − 766
337
+ − 767
fun
+ − 768
bders_simp :: "arexp \<Rightarrow> string \<Rightarrow> arexp"
+ − 769
where
+ − 770
"bders_simp r [] = r"
+ − 771
| "bders_simp r (c # s) = bders_simp (bsimp (bder c r)) s"
+ − 772
+ − 773
definition blexer_simp where
+ − 774
"blexer_simp r s \<equiv> if bnullable (bders_simp (intern r) s) then
+ − 775
decode (bmkeps (bders_simp (intern r) s)) r else None"
+ − 776
+ − 777
+ − 778
+ − 779
+ − 780
+ − 781
lemma bders_simp_append:
+ − 782
shows "bders_simp r (s1 @ s2) = bders_simp (bders_simp r s1) s2"
+ − 783
apply(induct s1 arbitrary: r s2)
+ − 784
apply(simp)
+ − 785
apply(simp)
+ − 786
done
+ − 787
+ − 788
lemma bsimp_ASEQ_size:
+ − 789
shows "asize (bsimp_ASEQ bs r1 r2) \<le> Suc (asize r1 + asize r2)"
+ − 790
apply(induct bs r1 r2 rule: bsimp_ASEQ.induct)
+ − 791
apply(auto)
+ − 792
done
+ − 793
+ − 794
+ − 795
+ − 796
lemma flts_size:
+ − 797
shows "sum_list (map asize (flts rs)) \<le> sum_list (map asize rs)"
+ − 798
apply(induct rs rule: flts.induct)
+ − 799
apply(simp_all)
+ − 800
by (simp add: asize_fuse comp_def)
+ − 801
+ − 802
+ − 803
lemma bsimp_AALTs_size:
+ − 804
shows "asize (bsimp_AALTs bs rs) \<le> Suc (sum_list (map asize rs))"
+ − 805
apply(induct rs rule: bsimp_AALTs.induct)
+ − 806
apply(auto simp add: asize_fuse)
+ − 807
done
+ − 808
+ − 809
+ − 810
lemma bsimp_size:
+ − 811
shows "asize (bsimp r) \<le> asize r"
+ − 812
apply(induct r)
+ − 813
apply(simp_all)
+ − 814
apply (meson Suc_le_mono add_mono_thms_linordered_semiring(1) bsimp_ASEQ_size le_trans)
+ − 815
apply(rule le_trans)
+ − 816
apply(rule bsimp_AALTs_size)
+ − 817
apply(simp)
+ − 818
apply(rule le_trans)
+ − 819
apply(rule flts_size)
+ − 820
by (simp add: sum_list_mono)
+ − 821
+ − 822
lemma bsimp_asize0:
+ − 823
shows "(\<Sum>x\<leftarrow>rs. asize (bsimp x)) \<le> sum_list (map asize rs)"
+ − 824
apply(induct rs)
+ − 825
apply(auto)
+ − 826
by (simp add: add_mono bsimp_size)
+ − 827
+ − 828
lemma bsimp_AALTs_size2:
+ − 829
assumes "\<forall>r \<in> set rs. nonalt r"
+ − 830
shows "asize (bsimp_AALTs bs rs) \<ge> sum_list (map asize rs)"
+ − 831
using assms
+ − 832
apply(induct rs rule: bsimp_AALTs.induct)
+ − 833
apply(simp_all add: asize_fuse)
+ − 834
done
+ − 835
+ − 836
+ − 837
lemma qq:
+ − 838
shows "map (asize \<circ> fuse bs) rs = map asize rs"
+ − 839
apply(induct rs)
+ − 840
apply(auto simp add: asize_fuse)
+ − 841
done
+ − 842
+ − 843
lemma flts_size2:
+ − 844
assumes "\<exists>bs rs'. AALTs bs rs' \<in> set rs"
+ − 845
shows "sum_list (map asize (flts rs)) < sum_list (map asize rs)"
+ − 846
using assms
+ − 847
apply(induct rs)
+ − 848
apply(auto simp add: qq)
+ − 849
apply (simp add: flts_size less_Suc_eq_le)
+ − 850
apply(case_tac a)
+ − 851
apply(auto simp add: qq)
+ − 852
prefer 2
+ − 853
apply (simp add: flts_size le_imp_less_Suc)
+ − 854
using less_Suc_eq by auto
+ − 855
+ − 856
lemma bsimp_AALTs_size3:
+ − 857
assumes "\<exists>r \<in> set (map bsimp rs). \<not>nonalt r"
+ − 858
shows "asize (bsimp (AALTs bs rs)) < asize (AALTs bs rs)"
+ − 859
using assms flts_size2
+ − 860
apply -
+ − 861
apply(clarify)
+ − 862
apply(simp)
+ − 863
apply(drule_tac x="map bsimp rs" in meta_spec)
+ − 864
apply(drule meta_mp)
+ − 865
apply (metis list.set_map nonalt.elims(3))
+ − 866
apply(simp)
+ − 867
apply(rule order_class.order.strict_trans1)
+ − 868
apply(rule bsimp_AALTs_size)
+ − 869
apply(simp)
+ − 870
by (smt Suc_leI bsimp_asize0 comp_def le_imp_less_Suc le_trans map_eq_conv not_less_eq)
+ − 871
+ − 872
+ − 873
+ − 874
+ − 875
lemma L_bsimp_ASEQ:
+ − 876
"L (SEQ (erase r1) (erase r2)) = L (erase (bsimp_ASEQ bs r1 r2))"
+ − 877
apply(induct bs r1 r2 rule: bsimp_ASEQ.induct)
+ − 878
apply(simp_all)
+ − 879
by (metis erase_fuse fuse.simps(4))
+ − 880
+ − 881
lemma L_bsimp_AALTs:
+ − 882
"L (erase (AALTs bs rs)) = L (erase (bsimp_AALTs bs rs))"
+ − 883
apply(induct bs rs rule: bsimp_AALTs.induct)
+ − 884
apply(simp_all add: erase_fuse)
+ − 885
done
+ − 886
+ − 887
lemma L_erase_AALTs:
+ − 888
shows "L (erase (AALTs bs rs)) = \<Union> (L ` erase ` (set rs))"
+ − 889
apply(induct rs)
+ − 890
apply(simp)
+ − 891
apply(simp)
+ − 892
apply(case_tac rs)
+ − 893
apply(simp)
+ − 894
apply(simp)
+ − 895
done
+ − 896
+ − 897
lemma L_erase_flts:
+ − 898
shows "\<Union> (L ` erase ` (set (flts rs))) = \<Union> (L ` erase ` (set rs))"
+ − 899
apply(induct rs rule: flts.induct)
+ − 900
apply(simp_all)
+ − 901
apply(auto)
+ − 902
using L_erase_AALTs erase_fuse apply auto[1]
+ − 903
by (simp add: L_erase_AALTs erase_fuse)
+ − 904
+ − 905
+ − 906
lemma L_bsimp_erase:
+ − 907
shows "L (erase r) = L (erase (bsimp r))"
+ − 908
apply(induct r)
+ − 909
apply(simp)
+ − 910
apply(simp)
+ − 911
apply(simp)
+ − 912
apply(auto simp add: Sequ_def)[1]
+ − 913
apply(subst L_bsimp_ASEQ[symmetric])
+ − 914
apply(auto simp add: Sequ_def)[1]
+ − 915
apply(subst (asm) L_bsimp_ASEQ[symmetric])
+ − 916
apply(auto simp add: Sequ_def)[1]
+ − 917
apply(simp)
+ − 918
apply(subst L_bsimp_AALTs[symmetric])
+ − 919
defer
+ − 920
apply(simp)
+ − 921
apply(subst (2)L_erase_AALTs)
+ − 922
apply(subst L_erase_flts)
+ − 923
apply(auto)
+ − 924
apply (simp add: L_erase_AALTs)
+ − 925
using L_erase_AALTs by blast
+ − 926
+ − 927
lemma bsimp_ASEQ0:
+ − 928
shows "bsimp_ASEQ bs r1 AZERO = AZERO"
+ − 929
apply(induct r1)
+ − 930
apply(auto)
+ − 931
done
+ − 932
+ − 933
+ − 934
+ − 935
lemma bsimp_ASEQ1:
+ − 936
assumes "r1 \<noteq> AZERO" "r2 \<noteq> AZERO" "\<forall>bs. r1 \<noteq> AONE bs"
+ − 937
shows "bsimp_ASEQ bs r1 r2 = ASEQ bs r1 r2"
+ − 938
using assms
+ − 939
apply(induct bs r1 r2 rule: bsimp_ASEQ.induct)
+ − 940
apply(auto)
+ − 941
done
+ − 942
+ − 943
lemma bsimp_ASEQ2:
+ − 944
shows "bsimp_ASEQ bs (AONE bs1) r2 = fuse (bs @ bs1) r2"
+ − 945
apply(induct r2)
+ − 946
apply(auto)
+ − 947
done
+ − 948
+ − 949
+ − 950
lemma L_bders_simp:
+ − 951
shows "L (erase (bders_simp r s)) = L (erase (bders r s))"
+ − 952
apply(induct s arbitrary: r rule: rev_induct)
+ − 953
apply(simp)
+ − 954
apply(simp)
+ − 955
apply(simp add: ders_append)
+ − 956
apply(simp add: bders_simp_append)
+ − 957
apply(simp add: L_bsimp_erase[symmetric])
+ − 958
by (simp add: der_correctness)
+ − 959
+ − 960
lemma b1:
+ − 961
"bsimp_ASEQ bs1 (AONE bs) r = fuse (bs1 @ bs) r"
+ − 962
apply(induct r)
+ − 963
apply(auto)
+ − 964
done
+ − 965
+ − 966
lemma b2:
+ − 967
assumes "bnullable r"
+ − 968
shows "bmkeps (fuse bs r) = bs @ bmkeps r"
+ − 969
by (simp add: assms bmkeps_retrieve bnullable_correctness erase_fuse mkeps_nullable retrieve_fuse2)
+ − 970
+ − 971
lemma b3:
+ − 972
shows "bnullable r = bnullable (bsimp r)"
+ − 973
using L_bsimp_erase bnullable_correctness nullable_correctness by auto
+ − 974
+ − 975
+ − 976
lemma b4:
+ − 977
shows "bnullable (bders_simp r s) = bnullable (bders r s)"
+ − 978
by (metis L_bders_simp bnullable_correctness lexer.simps(1) lexer_correct_None option.distinct(1))
+ − 979
+ − 980
lemma q1:
+ − 981
assumes "\<forall>r \<in> set rs. bmkeps(bsimp r) = bmkeps r"
+ − 982
shows "map (\<lambda>r. bmkeps(bsimp r)) rs = map bmkeps rs"
+ − 983
using assms
+ − 984
apply(induct rs)
+ − 985
apply(simp)
+ − 986
apply(simp)
+ − 987
done
+ − 988
+ − 989
lemma q3:
+ − 990
assumes "\<exists>r \<in> set rs. bnullable r"
+ − 991
shows "bmkeps (AALTs bs rs) = bmkeps (bsimp_AALTs bs rs)"
+ − 992
using assms
+ − 993
apply(induct bs rs rule: bsimp_AALTs.induct)
+ − 994
apply(simp)
+ − 995
apply(simp)
+ − 996
apply (simp add: b2)
+ − 997
apply(simp)
+ − 998
done
+ − 999
+ − 1000
+ − 1001
lemma fuse_empty:
+ − 1002
shows "fuse [] r = r"
+ − 1003
apply(induct r)
+ − 1004
apply(auto)
+ − 1005
done
+ − 1006
+ − 1007
lemma flts_fuse:
+ − 1008
shows "map (fuse bs) (flts rs) = flts (map (fuse bs) rs)"
+ − 1009
apply(induct rs arbitrary: bs rule: flts.induct)
+ − 1010
apply(auto simp add: fuse_append)
+ − 1011
done
+ − 1012
+ − 1013
lemma bsimp_ASEQ_fuse:
+ − 1014
shows "fuse bs1 (bsimp_ASEQ bs2 r1 r2) = bsimp_ASEQ (bs1 @ bs2) r1 r2"
+ − 1015
apply(induct r1 r2 arbitrary: bs1 bs2 rule: bsimp_ASEQ.induct)
+ − 1016
apply(auto)
+ − 1017
done
+ − 1018
+ − 1019
lemma bsimp_AALTs_fuse:
+ − 1020
assumes "\<forall>r \<in> set rs. fuse bs1 (fuse bs2 r) = fuse (bs1 @ bs2) r"
+ − 1021
shows "fuse bs1 (bsimp_AALTs bs2 rs) = bsimp_AALTs (bs1 @ bs2) rs"
+ − 1022
using assms
+ − 1023
apply(induct bs2 rs arbitrary: bs1 rule: bsimp_AALTs.induct)
+ − 1024
apply(auto)
+ − 1025
done
+ − 1026
+ − 1027
+ − 1028
+ − 1029
lemma bsimp_fuse:
+ − 1030
shows "fuse bs (bsimp r) = bsimp (fuse bs r)"
+ − 1031
apply(induct r arbitrary: bs)
+ − 1032
apply(simp)
+ − 1033
apply(simp)
+ − 1034
apply(simp)
+ − 1035
prefer 3
+ − 1036
apply(simp)
+ − 1037
apply(simp)
+ − 1038
apply (simp add: bsimp_ASEQ_fuse)
+ − 1039
apply(simp)
+ − 1040
by (simp add: bsimp_AALTs_fuse fuse_append)
+ − 1041
+ − 1042
lemma bsimp_fuse_AALTs:
+ − 1043
shows "fuse bs (bsimp (AALTs [] rs)) = bsimp (AALTs bs rs)"
+ − 1044
apply(subst bsimp_fuse)
+ − 1045
apply(simp)
+ − 1046
done
+ − 1047
+ − 1048
lemma bsimp_fuse_AALTs2:
+ − 1049
shows "fuse bs (bsimp_AALTs [] rs) = bsimp_AALTs bs rs"
+ − 1050
using bsimp_AALTs_fuse fuse_append by auto
+ − 1051
+ − 1052
+ − 1053
lemma bsimp_ASEQ_idem:
+ − 1054
assumes "bsimp (bsimp r1) = bsimp r1" "bsimp (bsimp r2) = bsimp r2"
+ − 1055
shows "bsimp (bsimp_ASEQ x1 (bsimp r1) (bsimp r2)) = bsimp_ASEQ x1 (bsimp r1) (bsimp r2)"
+ − 1056
using assms
+ − 1057
apply(case_tac "bsimp r1 = AZERO")
+ − 1058
apply(simp)
+ − 1059
apply(case_tac "bsimp r2 = AZERO")
+ − 1060
apply(simp)
+ − 1061
apply (metis bnullable.elims(2) bnullable.elims(3) bsimp.simps(3) bsimp_ASEQ.simps(2) bsimp_ASEQ.simps(3) bsimp_ASEQ.simps(4) bsimp_ASEQ.simps(5) bsimp_ASEQ.simps(6))
+ − 1062
apply(case_tac "\<exists>bs. bsimp r1 = AONE bs")
+ − 1063
apply(auto)[1]
+ − 1064
apply(subst bsimp_ASEQ2)
+ − 1065
apply(subst bsimp_ASEQ2)
+ − 1066
apply (metis assms(2) bsimp_fuse)
+ − 1067
apply(subst bsimp_ASEQ1)
+ − 1068
apply(auto)
+ − 1069
done
+ − 1070
+ − 1071
+ − 1072
+ − 1073
lemma k0:
+ − 1074
shows "flts (r # rs1) = flts [r] @ flts rs1"
+ − 1075
apply(induct r arbitrary: rs1)
+ − 1076
apply(auto)
+ − 1077
done
+ − 1078
+ − 1079
lemma k00:
+ − 1080
shows "flts (rs1 @ rs2) = flts rs1 @ flts rs2"
+ − 1081
apply(induct rs1 arbitrary: rs2)
+ − 1082
apply(auto)
+ − 1083
by (metis append.assoc k0)
+ − 1084
+ − 1085
lemma k0a:
+ − 1086
shows "flts [AALTs bs rs] = map (fuse bs) rs"
+ − 1087
apply(simp)
+ − 1088
done
+ − 1089
+ − 1090
+ − 1091
lemma k0b:
+ − 1092
assumes "nonalt r" "r \<noteq> AZERO"
+ − 1093
shows "flts [r] = [r]"
+ − 1094
using assms
+ − 1095
apply(case_tac r)
+ − 1096
apply(simp_all)
+ − 1097
done
+ − 1098
+ − 1099
lemma nn1:
+ − 1100
assumes "nonnested (AALTs bs rs)"
+ − 1101
shows "\<nexists>bs1 rs1. flts rs = [AALTs bs1 rs1]"
+ − 1102
using assms
+ − 1103
apply(induct rs rule: flts.induct)
+ − 1104
apply(auto)
+ − 1105
done
+ − 1106
+ − 1107
lemma nn1q:
+ − 1108
assumes "nonnested (AALTs bs rs)"
+ − 1109
shows "\<nexists>bs1 rs1. AALTs bs1 rs1 \<in> set (flts rs)"
+ − 1110
using assms
+ − 1111
apply(induct rs rule: flts.induct)
+ − 1112
apply(auto)
+ − 1113
done
+ − 1114
+ − 1115
lemma nn1qq:
+ − 1116
assumes "nonnested (AALTs bs rs)"
+ − 1117
shows "\<nexists>bs1 rs1. AALTs bs1 rs1 \<in> set rs"
+ − 1118
using assms
+ − 1119
apply(induct rs rule: flts.induct)
+ − 1120
apply(auto)
+ − 1121
done
+ − 1122
+ − 1123
lemma nn10:
+ − 1124
assumes "nonnested (AALTs cs rs)"
+ − 1125
shows "nonnested (AALTs (bs @ cs) rs)"
+ − 1126
using assms
+ − 1127
apply(induct rs arbitrary: cs bs)
+ − 1128
apply(simp_all)
+ − 1129
apply(case_tac a)
+ − 1130
apply(simp_all)
+ − 1131
done
+ − 1132
+ − 1133
lemma nn11a:
+ − 1134
assumes "nonalt r"
+ − 1135
shows "nonalt (fuse bs r)"
+ − 1136
using assms
+ − 1137
apply(induct r)
+ − 1138
apply(auto)
+ − 1139
done
+ − 1140
+ − 1141
+ − 1142
lemma nn1a:
+ − 1143
assumes "nonnested r"
+ − 1144
shows "nonnested (fuse bs r)"
+ − 1145
using assms
+ − 1146
apply(induct bs r arbitrary: rule: fuse.induct)
+ − 1147
apply(simp_all add: nn10)
+ − 1148
done
+ − 1149
+ − 1150
lemma n0:
+ − 1151
shows "nonnested (AALTs bs rs) \<longleftrightarrow> (\<forall>r \<in> set rs. nonalt r)"
+ − 1152
apply(induct rs arbitrary: bs)
+ − 1153
apply(auto)
+ − 1154
apply (metis list.set_intros(1) nn1qq nonalt.elims(3))
+ − 1155
apply (metis list.set_intros(2) nn1qq nonalt.elims(3))
+ − 1156
by (metis nonalt.elims(2) nonnested.simps(3) nonnested.simps(4) nonnested.simps(5) nonnested.simps(6) nonnested.simps(7))
+ − 1157
+ − 1158
+ − 1159
+ − 1160
+ − 1161
lemma nn1c:
+ − 1162
assumes "\<forall>r \<in> set rs. nonnested r"
+ − 1163
shows "\<forall>r \<in> set (flts rs). nonalt r"
+ − 1164
using assms
+ − 1165
apply(induct rs rule: flts.induct)
+ − 1166
apply(auto)
+ − 1167
apply(rule nn11a)
+ − 1168
by (metis nn1qq nonalt.elims(3))
+ − 1169
+ − 1170
lemma nn1bb:
+ − 1171
assumes "\<forall>r \<in> set rs. nonalt r"
+ − 1172
shows "nonnested (bsimp_AALTs bs rs)"
+ − 1173
using assms
+ − 1174
apply(induct bs rs rule: bsimp_AALTs.induct)
+ − 1175
apply(auto)
+ − 1176
apply (metis nn11a nonalt.simps(1) nonnested.elims(3))
+ − 1177
using n0 by auto
+ − 1178
+ − 1179
lemma nn1b:
+ − 1180
shows "nonnested (bsimp r)"
+ − 1181
apply(induct r)
+ − 1182
apply(simp_all)
+ − 1183
apply(case_tac "bsimp r1 = AZERO")
+ − 1184
apply(simp)
+ − 1185
apply(case_tac "bsimp r2 = AZERO")
+ − 1186
apply(simp)
+ − 1187
apply(subst bsimp_ASEQ0)
+ − 1188
apply(simp)
+ − 1189
apply(case_tac "\<exists>bs. bsimp r1 = AONE bs")
+ − 1190
apply(auto)[1]
+ − 1191
apply(subst bsimp_ASEQ2)
+ − 1192
apply (simp add: nn1a)
+ − 1193
apply(subst bsimp_ASEQ1)
+ − 1194
apply(auto)
+ − 1195
apply(rule nn1bb)
+ − 1196
apply(auto)
+ − 1197
by (metis (mono_tags, hide_lams) imageE nn1c set_map)
+ − 1198
+ − 1199
lemma nn1d:
+ − 1200
assumes "bsimp r = AALTs bs rs"
+ − 1201
shows "\<forall>r1 \<in> set rs. \<forall> bs. r1 \<noteq> AALTs bs rs2"
+ − 1202
using nn1b assms
+ − 1203
by (metis nn1qq)
+ − 1204
+ − 1205
lemma nn_flts:
+ − 1206
assumes "nonnested (AALTs bs rs)"
+ − 1207
shows "\<forall>r \<in> set (flts rs). nonalt r"
+ − 1208
using assms
+ − 1209
apply(induct rs arbitrary: bs rule: flts.induct)
+ − 1210
apply(auto)
+ − 1211
done
+ − 1212
+ − 1213
+ − 1214
+ − 1215
lemma rt:
+ − 1216
shows "sum_list (map asize (flts (map bsimp rs))) \<le> sum_list (map asize rs)"
+ − 1217
apply(induct rs)
+ − 1218
apply(simp)
+ − 1219
apply(simp)
+ − 1220
apply(subst k0)
+ − 1221
apply(simp)
+ − 1222
by (smt add_le_cancel_right add_mono bsimp_size flts.simps(1) flts_size k0 le_iff_add list.simps(9) map_append sum_list.Cons sum_list.append trans_le_add1)
+ − 1223
+ − 1224
lemma bsimp_AALTs_qq:
+ − 1225
assumes "1 < length rs"
+ − 1226
shows "bsimp_AALTs bs rs = AALTs bs rs"
+ − 1227
using assms
+ − 1228
apply(case_tac rs)
+ − 1229
apply(simp)
+ − 1230
apply(case_tac list)
+ − 1231
apply(simp_all)
+ − 1232
done
+ − 1233
+ − 1234
+ − 1235
lemma bsimp_AALTs1:
+ − 1236
assumes "nonalt r"
+ − 1237
shows "bsimp_AALTs bs (flts [r]) = fuse bs r"
+ − 1238
using assms
+ − 1239
apply(case_tac r)
+ − 1240
apply(simp_all)
+ − 1241
done
+ − 1242
+ − 1243
lemma bbbbs:
+ − 1244
assumes "good r" "r = AALTs bs1 rs"
+ − 1245
shows "bsimp_AALTs bs (flts [r]) = AALTs bs (map (fuse bs1) rs)"
+ − 1246
using assms
+ − 1247
by (metis (no_types, lifting) Nil_is_map_conv append.left_neutral append_butlast_last_id bsimp_AALTs.elims butlast.simps(2) good.simps(4) good.simps(5) k0a map_butlast)
+ − 1248
+ − 1249
lemma bbbbs1:
+ − 1250
shows "nonalt r \<or> (\<exists>bs rs. r = AALTs bs rs)"
+ − 1251
using nonalt.elims(3) by auto
+ − 1252
+ − 1253
+ − 1254
lemma good_fuse:
+ − 1255
shows "good (fuse bs r) = good r"
+ − 1256
apply(induct r arbitrary: bs)
+ − 1257
apply(auto)
+ − 1258
apply(case_tac r1)
+ − 1259
apply(simp_all)
+ − 1260
apply(case_tac r2)
+ − 1261
apply(simp_all)
+ − 1262
apply(case_tac r2)
+ − 1263
apply(simp_all)
+ − 1264
apply(case_tac r2)
+ − 1265
apply(simp_all)
+ − 1266
apply(case_tac r2)
+ − 1267
apply(simp_all)
+ − 1268
apply(case_tac r1)
+ − 1269
apply(simp_all)
+ − 1270
apply(case_tac r2)
+ − 1271
apply(simp_all)
+ − 1272
apply(case_tac r2)
+ − 1273
apply(simp_all)
+ − 1274
apply(case_tac r2)
+ − 1275
apply(simp_all)
+ − 1276
apply(case_tac r2)
+ − 1277
apply(simp_all)
+ − 1278
apply(case_tac x2a)
+ − 1279
apply(simp_all)
+ − 1280
apply(case_tac list)
+ − 1281
apply(simp_all)
+ − 1282
apply(case_tac x2a)
+ − 1283
apply(simp_all)
+ − 1284
apply(case_tac list)
+ − 1285
apply(simp_all)
+ − 1286
done
+ − 1287
+ − 1288
lemma good0:
+ − 1289
assumes "rs \<noteq> Nil" "\<forall>r \<in> set rs. nonalt r"
+ − 1290
shows "good (bsimp_AALTs bs rs) \<longleftrightarrow> (\<forall>r \<in> set rs. good r)"
+ − 1291
using assms
+ − 1292
apply(induct bs rs rule: bsimp_AALTs.induct)
+ − 1293
apply(auto simp add: good_fuse)
+ − 1294
done
+ − 1295
+ − 1296
lemma good0a:
+ − 1297
assumes "flts (map bsimp rs) \<noteq> Nil" "\<forall>r \<in> set (flts (map bsimp rs)). nonalt r"
+ − 1298
shows "good (bsimp (AALTs bs rs)) \<longleftrightarrow> (\<forall>r \<in> set (flts (map bsimp rs)). good r)"
+ − 1299
using assms
+ − 1300
apply(simp)
+ − 1301
apply(auto)
+ − 1302
apply(subst (asm) good0)
+ − 1303
apply(simp)
+ − 1304
apply(auto)
+ − 1305
apply(subst good0)
+ − 1306
apply(simp)
+ − 1307
apply(auto)
+ − 1308
done
+ − 1309
+ − 1310
lemma flts0:
+ − 1311
assumes "r \<noteq> AZERO" "nonalt r"
+ − 1312
shows "flts [r] \<noteq> []"
+ − 1313
using assms
+ − 1314
apply(induct r)
+ − 1315
apply(simp_all)
+ − 1316
done
+ − 1317
+ − 1318
lemma flts1:
+ − 1319
assumes "good r"
+ − 1320
shows "flts [r] \<noteq> []"
+ − 1321
using assms
+ − 1322
apply(induct r)
+ − 1323
apply(simp_all)
+ − 1324
apply(case_tac x2a)
+ − 1325
apply(simp)
+ − 1326
apply(simp)
+ − 1327
done
+ − 1328
+ − 1329
lemma flts2:
+ − 1330
assumes "good r"
+ − 1331
shows "\<forall>r' \<in> set (flts [r]). good r' \<and> nonalt r'"
+ − 1332
using assms
+ − 1333
apply(induct r)
+ − 1334
apply(simp)
+ − 1335
apply(simp)
+ − 1336
apply(simp)
+ − 1337
prefer 2
+ − 1338
apply(simp)
+ − 1339
apply(auto)[1]
+ − 1340
apply (metis bsimp_AALTs.elims good.simps(4) good.simps(5) good.simps(6) good_fuse)
+ − 1341
apply (metis bsimp_AALTs.elims good.simps(4) good.simps(5) good.simps(6) nn11a)
+ − 1342
apply fastforce
+ − 1343
apply(simp)
+ − 1344
done
+ − 1345
+ − 1346
+ − 1347
lemma flts3:
+ − 1348
assumes "\<forall>r \<in> set rs. good r \<or> r = AZERO"
+ − 1349
shows "\<forall>r \<in> set (flts rs). good r"
+ − 1350
using assms
+ − 1351
apply(induct rs arbitrary: rule: flts.induct)
+ − 1352
apply(simp_all)
+ − 1353
by (metis UnE flts2 k0a set_map)
+ − 1354
+ − 1355
lemma flts3b:
+ − 1356
assumes "\<exists>r\<in>set rs. good r"
+ − 1357
shows "flts rs \<noteq> []"
+ − 1358
using assms
+ − 1359
apply(induct rs arbitrary: rule: flts.induct)
+ − 1360
apply(simp)
+ − 1361
apply(simp)
+ − 1362
apply(simp)
+ − 1363
apply(auto)
+ − 1364
done
+ − 1365
+ − 1366
lemma flts4:
+ − 1367
assumes "bsimp_AALTs bs (flts rs) = AZERO"
+ − 1368
shows "\<forall>r \<in> set rs. \<not> good r"
+ − 1369
using assms
+ − 1370
apply(induct rs arbitrary: bs rule: flts.induct)
+ − 1371
apply(auto)
+ − 1372
defer
+ − 1373
apply (metis (no_types, lifting) Nil_is_append_conv append_self_conv2 bsimp_AALTs.elims butlast.simps(2) butlast_append flts3b nonalt.simps(1) nonalt.simps(2))
+ − 1374
apply (metis arexp.distinct(7) bsimp_AALTs.elims flts2 good.simps(1) good.simps(2) good0 k0b list.distinct(1) list.inject nonalt.simps(3))
+ − 1375
apply (metis arexp.distinct(3) arexp.distinct(7) bsimp_AALTs.elims fuse.simps(3) list.distinct(1) list.inject)
+ − 1376
apply (metis arexp.distinct(7) bsimp_AALTs.elims good.simps(1) good_fuse list.distinct(1) list.inject)
+ − 1377
apply (metis arexp.distinct(7) bsimp_AALTs.elims list.distinct(1) list.inject)
+ − 1378
apply (metis arexp.distinct(7) bsimp_AALTs.elims flts2 good.simps(1) good.simps(33) good0 k0b list.distinct(1) list.inject nonalt.simps(6))
+ − 1379
by (metis (no_types, lifting) Nil_is_append_conv append_Nil2 arexp.distinct(7) bsimp_AALTs.elims butlast.simps(2) butlast_append flts1 flts2 good.simps(1) good0 k0a)
+ − 1380
+ − 1381
+ − 1382
lemma flts_nil:
+ − 1383
assumes "\<forall>y. asize y < Suc (sum_list (map asize rs)) \<longrightarrow>
+ − 1384
good (bsimp y) \<or> bsimp y = AZERO"
+ − 1385
and "\<forall>r\<in>set rs. \<not> good (bsimp r)"
+ − 1386
shows "flts (map bsimp rs) = []"
+ − 1387
using assms
+ − 1388
apply(induct rs)
+ − 1389
apply(simp)
+ − 1390
apply(simp)
+ − 1391
apply(subst k0)
+ − 1392
apply(simp)
+ − 1393
by force
+ − 1394
+ − 1395
lemma flts_nil2:
+ − 1396
assumes "\<forall>y. asize y < Suc (sum_list (map asize rs)) \<longrightarrow>
+ − 1397
good (bsimp y) \<or> bsimp y = AZERO"
+ − 1398
and "bsimp_AALTs bs (flts (map bsimp rs)) = AZERO"
+ − 1399
shows "flts (map bsimp rs) = []"
+ − 1400
using assms
+ − 1401
apply(induct rs arbitrary: bs)
+ − 1402
apply(simp)
+ − 1403
apply(simp)
+ − 1404
apply(subst k0)
+ − 1405
apply(simp)
+ − 1406
apply(subst (asm) k0)
+ − 1407
apply(auto)
+ − 1408
apply (metis flts.simps(1) flts.simps(2) flts4 k0 less_add_Suc1 list.set_intros(1))
+ − 1409
by (metis flts.simps(2) flts4 k0 less_add_Suc1 list.set_intros(1))
+ − 1410
+ − 1411
+ − 1412
+ − 1413
lemma good_SEQ:
+ − 1414
assumes "r1 \<noteq> AZERO" "r2 \<noteq> AZERO" "\<forall>bs. r1 \<noteq> AONE bs"
+ − 1415
shows "good (ASEQ bs r1 r2) = (good r1 \<and> good r2)"
+ − 1416
using assms
+ − 1417
apply(case_tac r1)
+ − 1418
apply(simp_all)
+ − 1419
apply(case_tac r2)
+ − 1420
apply(simp_all)
+ − 1421
apply(case_tac r2)
+ − 1422
apply(simp_all)
+ − 1423
apply(case_tac r2)
+ − 1424
apply(simp_all)
+ − 1425
apply(case_tac r2)
+ − 1426
apply(simp_all)
+ − 1427
done
+ − 1428
+ − 1429
lemma good1:
+ − 1430
shows "good (bsimp a) \<or> bsimp a = AZERO"
+ − 1431
apply(induct a taking: asize rule: measure_induct)
+ − 1432
apply(case_tac x)
+ − 1433
apply(simp)
+ − 1434
apply(simp)
+ − 1435
apply(simp)
+ − 1436
prefer 3
+ − 1437
apply(simp)
+ − 1438
prefer 2
+ − 1439
(* AALTs case *)
+ − 1440
apply(simp only:)
+ − 1441
apply(case_tac "x52")
+ − 1442
apply(simp)
+ − 1443
thm good0a
+ − 1444
(* AALTs list at least one - case *)
+ − 1445
apply(simp only: )
+ − 1446
apply(frule_tac x="a" in spec)
+ − 1447
apply(drule mp)
+ − 1448
apply(simp)
+ − 1449
(* either first element is good, or AZERO *)
+ − 1450
apply(erule disjE)
+ − 1451
prefer 2
+ − 1452
apply(simp)
+ − 1453
(* in the AZERO case, the size is smaller *)
+ − 1454
apply(drule_tac x="AALTs x51 list" in spec)
+ − 1455
apply(drule mp)
+ − 1456
apply(simp add: asize0)
+ − 1457
apply(subst (asm) bsimp.simps)
+ − 1458
apply(subst (asm) bsimp.simps)
+ − 1459
apply(assumption)
+ − 1460
(* in the good case *)
+ − 1461
apply(frule_tac x="AALTs x51 list" in spec)
+ − 1462
apply(drule mp)
+ − 1463
apply(simp add: asize0)
+ − 1464
apply(erule disjE)
+ − 1465
apply(rule disjI1)
+ − 1466
apply(simp add: good0)
+ − 1467
apply(subst good0)
+ − 1468
apply (metis Nil_is_append_conv flts1 k0)
+ − 1469
apply (metis ex_map_conv list.simps(9) nn1b nn1c)
+ − 1470
apply(simp)
+ − 1471
apply(subst k0)
+ − 1472
apply(simp)
+ − 1473
apply(auto)[1]
+ − 1474
using flts2 apply blast
+ − 1475
apply(subst (asm) good0)
+ − 1476
prefer 3
+ − 1477
apply(auto)[1]
+ − 1478
apply auto[1]
+ − 1479
apply (metis ex_map_conv nn1b nn1c)
+ − 1480
(* in the AZERO case *)
+ − 1481
apply(simp)
+ − 1482
apply(frule_tac x="a" in spec)
+ − 1483
apply(drule mp)
+ − 1484
apply(simp)
+ − 1485
apply(erule disjE)
+ − 1486
apply(rule disjI1)
+ − 1487
apply(subst good0)
+ − 1488
apply(subst k0)
+ − 1489
using flts1 apply blast
+ − 1490
apply(auto)[1]
+ − 1491
apply (metis (no_types, hide_lams) ex_map_conv list.simps(9) nn1b nn1c)
+ − 1492
apply(auto)[1]
+ − 1493
apply(subst (asm) k0)
+ − 1494
apply(auto)[1]
+ − 1495
using flts2 apply blast
+ − 1496
apply(frule_tac x="AALTs x51 list" in spec)
+ − 1497
apply(drule mp)
+ − 1498
apply(simp add: asize0)
+ − 1499
apply(erule disjE)
+ − 1500
apply(simp)
+ − 1501
apply(simp)
+ − 1502
apply (metis add.left_commute flts_nil2 less_add_Suc1 less_imp_Suc_add list.distinct(1) list.set_cases nat.inject)
+ − 1503
apply(subst (2) k0)
+ − 1504
apply(simp)
+ − 1505
(* SEQ case *)
+ − 1506
apply(simp)
+ − 1507
apply(case_tac "bsimp x42 = AZERO")
+ − 1508
apply(simp)
+ − 1509
apply(case_tac "bsimp x43 = AZERO")
+ − 1510
apply(simp)
+ − 1511
apply(subst (2) bsimp_ASEQ0)
+ − 1512
apply(simp)
+ − 1513
apply(case_tac "\<exists>bs. bsimp x42 = AONE bs")
+ − 1514
apply(auto)[1]
+ − 1515
apply(subst bsimp_ASEQ2)
+ − 1516
using good_fuse apply force
+ − 1517
apply(subst bsimp_ASEQ1)
+ − 1518
apply(auto)
+ − 1519
apply(subst good_SEQ)
+ − 1520
apply(simp)
+ − 1521
apply(simp)
+ − 1522
apply(simp)
+ − 1523
using less_add_Suc1 less_add_Suc2 by blast
+ − 1524
+ − 1525
lemma good1a:
+ − 1526
assumes "L(erase a) \<noteq> {}"
+ − 1527
shows "good (bsimp a)"
+ − 1528
using good1 assms
+ − 1529
using L_bsimp_erase by force
+ − 1530
+ − 1531
+ − 1532
+ − 1533
lemma flts_append:
+ − 1534
"flts (xs1 @ xs2) = flts xs1 @ flts xs2"
+ − 1535
apply(induct xs1 arbitrary: xs2 rule: rev_induct)
+ − 1536
apply(auto)
+ − 1537
apply(case_tac xs)
+ − 1538
apply(auto)
+ − 1539
apply(case_tac x)
+ − 1540
apply(auto)
+ − 1541
apply(case_tac x)
+ − 1542
apply(auto)
+ − 1543
done
+ − 1544
+ − 1545
lemma g1:
+ − 1546
assumes "good (bsimp_AALTs bs rs)"
+ − 1547
shows "bsimp_AALTs bs rs = AALTs bs rs \<or> (\<exists>r. rs = [r] \<and> bsimp_AALTs bs [r] = fuse bs r)"
+ − 1548
using assms
+ − 1549
apply(induct rs arbitrary: bs)
+ − 1550
apply(simp)
+ − 1551
apply(case_tac rs)
+ − 1552
apply(simp only:)
+ − 1553
apply(simp)
+ − 1554
apply(case_tac list)
+ − 1555
apply(simp)
+ − 1556
by simp
+ − 1557
+ − 1558
lemma flts_0:
+ − 1559
assumes "nonnested (AALTs bs rs)"
+ − 1560
shows "\<forall>r \<in> set (flts rs). r \<noteq> AZERO"
+ − 1561
using assms
+ − 1562
apply(induct rs arbitrary: bs rule: flts.induct)
+ − 1563
apply(simp)
+ − 1564
apply(simp)
+ − 1565
defer
+ − 1566
apply(simp)
+ − 1567
apply(simp)
+ − 1568
apply(simp)
+ − 1569
apply(simp)
+ − 1570
apply(rule ballI)
+ − 1571
apply(simp)
+ − 1572
done
+ − 1573
+ − 1574
lemma flts_0a:
+ − 1575
assumes "nonnested (AALTs bs rs)"
+ − 1576
shows "AZERO \<notin> set (flts rs)"
+ − 1577
using assms
+ − 1578
using flts_0 by blast
+ − 1579
+ − 1580
lemma qqq1:
+ − 1581
shows "AZERO \<notin> set (flts (map bsimp rs))"
+ − 1582
by (metis ex_map_conv flts3 good.simps(1) good1)
+ − 1583
+ − 1584
+ − 1585
fun nonazero :: "arexp \<Rightarrow> bool"
+ − 1586
where
+ − 1587
"nonazero AZERO = False"
+ − 1588
| "nonazero r = True"
+ − 1589
+ − 1590
lemma flts_concat:
+ − 1591
shows "flts rs = concat (map (\<lambda>r. flts [r]) rs)"
+ − 1592
apply(induct rs)
+ − 1593
apply(auto)
+ − 1594
apply(subst k0)
+ − 1595
apply(simp)
+ − 1596
done
+ − 1597
+ − 1598
lemma flts_single1:
+ − 1599
assumes "nonalt r" "nonazero r"
+ − 1600
shows "flts [r] = [r]"
+ − 1601
using assms
+ − 1602
apply(induct r)
+ − 1603
apply(auto)
+ − 1604
done
+ − 1605
+ − 1606
lemma flts_qq:
+ − 1607
assumes "\<forall>y. asize y < Suc (sum_list (map asize rs)) \<longrightarrow> good y \<longrightarrow> bsimp y = y"
+ − 1608
"\<forall>r'\<in>set rs. good r' \<and> nonalt r'"
+ − 1609
shows "flts (map bsimp rs) = rs"
+ − 1610
using assms
+ − 1611
apply(induct rs)
+ − 1612
apply(simp)
+ − 1613
apply(simp)
+ − 1614
apply(subst k0)
+ − 1615
apply(subgoal_tac "flts [bsimp a] = [a]")
+ − 1616
prefer 2
+ − 1617
apply(drule_tac x="a" in spec)
+ − 1618
apply(drule mp)
+ − 1619
apply(simp)
+ − 1620
apply(auto)[1]
+ − 1621
using good.simps(1) k0b apply blast
+ − 1622
apply(auto)[1]
+ − 1623
done
+ − 1624
+ − 1625
lemma test:
+ − 1626
assumes "good r"
+ − 1627
shows "bsimp r = r"
+ − 1628
using assms
+ − 1629
apply(induct r taking: "asize" rule: measure_induct)
+ − 1630
apply(erule good.elims)
+ − 1631
apply(simp_all)
+ − 1632
apply(subst k0)
+ − 1633
apply(subst (2) k0)
+ − 1634
apply(subst flts_qq)
+ − 1635
apply(auto)[1]
+ − 1636
apply(auto)[1]
+ − 1637
apply (metis append_Cons append_Nil bsimp_AALTs.simps(3) good.simps(1) k0b)
+ − 1638
apply force+
+ − 1639
apply (metis (no_types, lifting) add_Suc add_Suc_right asize.simps(5) bsimp.simps(1) bsimp_ASEQ.simps(19) less_add_Suc1 less_add_Suc2)
+ − 1640
apply (metis add_Suc add_Suc_right arexp.distinct(5) arexp.distinct(7) asize.simps(4) asize.simps(5) bsimp.simps(1) bsimp.simps(2) bsimp_ASEQ1 good.simps(21) good.simps(8) less_add_Suc1 less_add_Suc2)
+ − 1641
apply force+
+ − 1642
apply (metis (no_types, lifting) add_Suc add_Suc_right arexp.distinct(5) arexp.distinct(7) asize.simps(4) asize.simps(5) bsimp.simps(1) bsimp.simps(2) bsimp_ASEQ1 good.simps(25) good.simps(8) less_add_Suc1 less_add_Suc2)
+ − 1643
apply (metis add_Suc add_Suc_right arexp.distinct(7) asize.simps(4) bsimp.simps(2) bsimp_ASEQ1 good.simps(26) good.simps(8) less_add_Suc1 less_add_Suc2)
+ − 1644
apply force+
+ − 1645
done
+ − 1646
+ − 1647
lemma test2:
+ − 1648
assumes "good r"
+ − 1649
shows "bsimp r = r"
+ − 1650
using assms
+ − 1651
apply(induct r taking: "asize" rule: measure_induct)
+ − 1652
apply(case_tac x)
+ − 1653
apply(simp_all)
+ − 1654
defer
+ − 1655
(* AALT case *)
+ − 1656
apply(subgoal_tac "1 < length x52")
+ − 1657
prefer 2
+ − 1658
apply(case_tac x52)
+ − 1659
apply(simp)
+ − 1660
apply(simp)
+ − 1661
apply(case_tac list)
+ − 1662
apply(simp)
+ − 1663
apply(simp)
+ − 1664
apply(subst bsimp_AALTs_qq)
+ − 1665
prefer 2
+ − 1666
apply(subst flts_qq)
+ − 1667
apply(auto)[1]
+ − 1668
apply(auto)[1]
+ − 1669
apply(case_tac x52)
+ − 1670
apply(simp)
+ − 1671
apply(simp)
+ − 1672
apply(case_tac list)
+ − 1673
apply(simp)
+ − 1674
apply(simp)
+ − 1675
apply(auto)[1]
+ − 1676
apply (metis (no_types, lifting) bsimp_AALTs.elims good.simps(6) length_Cons length_pos_if_in_set list.size(3) nat_neq_iff)
+ − 1677
apply(simp)
+ − 1678
apply(case_tac x52)
+ − 1679
apply(simp)
+ − 1680
apply(simp)
+ − 1681
apply(case_tac list)
+ − 1682
apply(simp)
+ − 1683
apply(simp)
+ − 1684
apply(subst k0)
+ − 1685
apply(simp)
+ − 1686
apply(subst (2) k0)
+ − 1687
apply(simp)
+ − 1688
apply (simp add: Suc_lessI flts1 one_is_add)
+ − 1689
(* SEQ case *)
+ − 1690
apply(case_tac "bsimp x42 = AZERO")
+ − 1691
apply simp
+ − 1692
apply (metis asize.elims good.simps(10) good.simps(11) good.simps(12) good.simps(2) good.simps(7) good.simps(9) good_SEQ less_add_Suc1)
+ − 1693
apply(case_tac "\<exists>bs'. bsimp x42 = AONE bs'")
+ − 1694
apply(auto)[1]
+ − 1695
defer
+ − 1696
apply(case_tac "bsimp x43 = AZERO")
+ − 1697
apply(simp)
+ − 1698
apply (metis bsimp.elims bsimp.simps(3) good.simps(10) good.simps(11) good.simps(12) good.simps(8) good.simps(9) good_SEQ less_add_Suc2)
+ − 1699
apply(auto)
+ − 1700
apply (subst bsimp_ASEQ1)
+ − 1701
apply(auto)[3]
+ − 1702
apply(auto)[1]
+ − 1703
apply (metis bsimp.simps(3) good.simps(2) good_SEQ less_add_Suc1)
+ − 1704
apply (metis bsimp.simps(3) good.simps(2) good_SEQ less_add_Suc1 less_add_Suc2)
+ − 1705
apply (subst bsimp_ASEQ2)
+ − 1706
apply(drule_tac x="x42" in spec)
+ − 1707
apply(drule mp)
+ − 1708
apply(simp)
+ − 1709
apply(drule mp)
+ − 1710
apply (metis bsimp.elims bsimp.simps(3) good.simps(10) good.simps(11) good.simps(2) good_SEQ)
+ − 1711
apply(simp)
+ − 1712
done
+ − 1713
+ − 1714
+ − 1715
lemma bsimp_idem:
+ − 1716
shows "bsimp (bsimp r) = bsimp r"
+ − 1717
using test good1
+ − 1718
by force
+ − 1719
+ − 1720
+ − 1721
+ − 1722
lemma contains48:
+ − 1723
assumes "\<And>x2aa bs bs1. \<lbrakk>x2aa \<in> set x2a; fuse bs x2aa >> bs @ bs1\<rbrakk> \<Longrightarrow> x2aa >> bs1"
+ − 1724
"AALTs (bs @ x1) x2a >> bs @ bs1"
+ − 1725
shows "AALTs x1 x2a >> bs1"
+ − 1726
using assms
+ − 1727
apply(induct x2a arbitrary: bs x1 bs1)
+ − 1728
apply(auto)
+ − 1729
apply(erule contains.cases)
+ − 1730
apply(auto)
+ − 1731
apply(erule contains.cases)
+ − 1732
apply(auto)
+ − 1733
apply (simp add: contains.intros(4))
+ − 1734
using contains.intros(5) by blast
+ − 1735
+ − 1736
+ − 1737
lemma contains49:
+ − 1738
assumes "fuse bs a >> bs @ bs1"
+ − 1739
shows "a >> bs1"
+ − 1740
using assms
+ − 1741
apply(induct a arbitrary: bs bs1)
+ − 1742
apply(auto)
+ − 1743
using contains.simps apply blast
+ − 1744
apply(erule contains.cases)
+ − 1745
apply(auto)
+ − 1746
apply(rule contains.intros)
+ − 1747
apply(erule contains.cases)
+ − 1748
apply(auto)
+ − 1749
apply(rule contains.intros)
+ − 1750
apply(erule contains.cases)
+ − 1751
apply(auto)
+ − 1752
apply(rule contains.intros)
+ − 1753
apply(auto)[2]
+ − 1754
prefer 2
+ − 1755
apply(erule contains.cases)
+ − 1756
apply(auto)
+ − 1757
apply (simp add: contains.intros(6))
+ − 1758
using contains.intros(7) apply blast
+ − 1759
using contains48 by blast
+ − 1760
357
+ − 1761
+ − 1762
lemma contains50_IFF2:
+ − 1763
shows "bsimp_AALTs bs [a] >> bs @ bs1 \<longleftrightarrow> fuse bs a >> bs @ bs1"
+ − 1764
by simp
+ − 1765
+ − 1766
lemma contains50_IFF3:
+ − 1767
shows "bsimp_AALTs bs as >> bs @ bs1 \<longleftrightarrow> (\<exists>a \<in> set as. fuse bs a >> bs @ bs1)"
+ − 1768
apply(induct as arbitrary: bs bs1)
+ − 1769
apply(simp)
+ − 1770
apply(auto elim: contains.cases simp add: contains0)
+ − 1771
apply(case_tac as)
+ − 1772
apply(auto)
+ − 1773
apply(case_tac list)
+ − 1774
apply(auto)
+ − 1775
apply(erule contains.cases)
+ − 1776
apply(auto)
+ − 1777
apply (simp add: contains0)
+ − 1778
apply(erule contains.cases)
+ − 1779
apply(auto)
+ − 1780
using contains0 apply auto[1]
+ − 1781
apply(erule contains.cases)
+ − 1782
apply(auto)
+ − 1783
apply(erule contains.cases)
+ − 1784
apply(auto)
+ − 1785
using contains0 apply blast
+ − 1786
apply (metis bsimp_AALTs.simps(2) bsimp_AALTs.simps(3) contains.intros(4) contains49 list.exhaust)
+ − 1787
by (smt bsimp_AALTs.simps(3) contains.intros(4) contains.intros(5) contains49 list.set_cases)
+ − 1788
+ − 1789
lemma contains50_IFF4:
+ − 1790
shows "bsimp_AALTs bs as >> bs @ bs1 \<longleftrightarrow> (\<exists>a \<in> set as. a >> bs1)"
+ − 1791
by (meson contains0 contains49 contains50_IFF3)
+ − 1792
+ − 1793
337
+ − 1794
lemma contains50:
+ − 1795
assumes "bsimp_AALTs bs rs2 >> bs @ bs1"
+ − 1796
shows "bsimp_AALTs bs (rs1 @ rs2) >> bs @ bs1"
+ − 1797
using assms
+ − 1798
apply(induct rs1 arbitrary: bs rs2 bs1)
+ − 1799
apply(simp)
+ − 1800
apply(auto)
+ − 1801
apply(case_tac rs1)
+ − 1802
apply(simp)
+ − 1803
apply(case_tac rs2)
+ − 1804
apply(simp)
+ − 1805
using contains.simps apply blast
+ − 1806
apply(simp)
+ − 1807
apply(case_tac list)
+ − 1808
apply(simp)
+ − 1809
apply(rule contains.intros)
+ − 1810
back
+ − 1811
apply(rule contains.intros)
+ − 1812
using contains49 apply blast
+ − 1813
apply(simp)
+ − 1814
using contains.intros(5) apply blast
+ − 1815
apply(simp)
+ − 1816
by (metis bsimp_AALTs.elims contains.intros(4) contains.intros(5) contains49 list.distinct(1))
+ − 1817
+ − 1818
lemma contains51:
+ − 1819
assumes "bsimp_AALTs bs [r] >> bs @ bs1"
+ − 1820
shows "bsimp_AALTs bs ([r] @ rs2) >> bs @ bs1"
+ − 1821
using assms
+ − 1822
apply(induct rs2 arbitrary: bs r bs1)
+ − 1823
apply(simp)
+ − 1824
apply(auto)
+ − 1825
using contains.intros(4) contains49 by blast
+ − 1826
+ − 1827
lemma contains51a:
+ − 1828
assumes "bsimp_AALTs bs rs2 >> bs @ bs1"
+ − 1829
shows "bsimp_AALTs bs (rs2 @ [r]) >> bs @ bs1"
+ − 1830
using assms
+ − 1831
apply(induct rs2 arbitrary: bs r bs1)
+ − 1832
apply(simp)
+ − 1833
apply(auto)
+ − 1834
using contains.simps apply blast
+ − 1835
apply(case_tac rs2)
+ − 1836
apply(auto)
+ − 1837
using contains3b contains49 apply blast
+ − 1838
apply(case_tac list)
+ − 1839
apply(auto)
+ − 1840
apply(erule contains.cases)
+ − 1841
apply(auto)
+ − 1842
using contains.intros(4) apply auto[1]
+ − 1843
apply(erule contains.cases)
+ − 1844
apply(auto)
+ − 1845
apply (simp add: contains.intros(4) contains.intros(5))
+ − 1846
apply (simp add: contains.intros(5))
+ − 1847
apply(erule contains.cases)
+ − 1848
apply(auto)
+ − 1849
apply (simp add: contains.intros(4))
+ − 1850
apply(erule contains.cases)
+ − 1851
apply(auto)
+ − 1852
using contains.intros(4) contains.intros(5) apply blast
+ − 1853
using contains.intros(5) by blast
+ − 1854
+ − 1855
lemma contains51b:
+ − 1856
assumes "bsimp_AALTs bs rs >> bs @ bs1"
+ − 1857
shows "bsimp_AALTs bs (rs @ rs2) >> bs @ bs1"
+ − 1858
using assms
+ − 1859
apply(induct rs2 arbitrary: bs rs bs1)
+ − 1860
apply(simp)
+ − 1861
using contains51a by fastforce
+ − 1862
+ − 1863
lemma contains51c:
+ − 1864
assumes "AALTs (bs @ bs2) rs >> bs @ bs1"
+ − 1865
shows "bsimp_AALTs bs (map (fuse bs2) rs) >> bs @ bs1"
+ − 1866
using assms
+ − 1867
apply(induct rs arbitrary: bs bs1 bs2)
+ − 1868
apply(auto)
+ − 1869
apply(erule contains.cases)
+ − 1870
apply(auto)
+ − 1871
apply(erule contains.cases)
+ − 1872
apply(auto)
+ − 1873
using contains0 contains51 apply auto[1]
+ − 1874
by (metis append.left_neutral append_Cons contains50 list.simps(9))
+ − 1875
+ − 1876
+ − 1877
lemma contains51d:
+ − 1878
assumes "fuse bs r >> bs @ bs1"
+ − 1879
shows "bsimp_AALTs bs (flts [r]) >> bs @ bs1"
+ − 1880
using assms
+ − 1881
apply(induct r arbitrary: bs bs1)
+ − 1882
apply(auto)
+ − 1883
by (simp add: contains51c)
+ − 1884
+ − 1885
lemma contains52:
+ − 1886
assumes "\<exists>r \<in> set rs. (fuse bs r) >> bs @ bs1"
+ − 1887
shows "bsimp_AALTs bs (flts rs) >> bs @ bs1"
+ − 1888
using assms
+ − 1889
apply(induct rs arbitrary: bs bs1)
+ − 1890
apply(simp)
+ − 1891
apply(auto)
+ − 1892
defer
+ − 1893
apply (metis contains50 k0)
+ − 1894
apply(subst k0)
+ − 1895
apply(rule contains51b)
+ − 1896
using contains51d by blast
+ − 1897
+ − 1898
lemma contains55:
+ − 1899
assumes "a >> bs"
+ − 1900
shows "bsimp a >> bs"
+ − 1901
using assms
+ − 1902
apply(induct a bs arbitrary:)
+ − 1903
apply(auto intro: contains.intros)
+ − 1904
apply(case_tac "bsimp a1 = AZERO")
+ − 1905
apply(simp)
+ − 1906
using contains.simps apply blast
+ − 1907
apply(case_tac "bsimp a2 = AZERO")
+ − 1908
apply(simp)
+ − 1909
using contains.simps apply blast
+ − 1910
apply(case_tac "\<exists>bs. bsimp a1 = AONE bs")
+ − 1911
apply(auto)[1]
+ − 1912
apply(rotate_tac 1)
+ − 1913
apply(erule contains.cases)
+ − 1914
apply(auto)
+ − 1915
apply (simp add: b1 contains0 fuse_append)
+ − 1916
apply (simp add: bsimp_ASEQ1 contains.intros(3))
+ − 1917
prefer 2
+ − 1918
apply(case_tac rs)
+ − 1919
apply(simp)
+ − 1920
using contains.simps apply blast
+ − 1921
apply (metis contains50 k0)
+ − 1922
(* AALTS case *)
+ − 1923
apply(rule contains52)
+ − 1924
apply(rule_tac x="bsimp r" in bexI)
+ − 1925
apply(auto)
+ − 1926
using contains0 by blast
+ − 1927
359
+ − 1928
lemma test1:
+ − 1929
shows "AALT [] (ACHAR [Z] c) (ACHAR [S] c) >> [S]"
+ − 1930
by (metis contains.intros(2) contains.intros(4) contains.intros(5) self_append_conv2)
+ − 1931
+ − 1932
lemma test1a:
+ − 1933
shows "bsimp (AALT [] (ACHAR [Z] c) (ACHAR [S] c)) = AALT [] (ACHAR [Z] c) (ACHAR [S] c)"
+ − 1934
apply(simp)
+ − 1935
done
337
+ − 1936
+ − 1937
lemma q3a:
+ − 1938
assumes "\<exists>r \<in> set rs. bnullable r"
+ − 1939
shows "bmkeps (AALTs bs (map (fuse bs1) rs)) = bmkeps (AALTs (bs@bs1) rs)"
+ − 1940
using assms
+ − 1941
apply(induct rs arbitrary: bs bs1)
+ − 1942
apply(simp)
+ − 1943
apply(simp)
+ − 1944
apply(auto)
+ − 1945
apply (metis append_assoc b2 bnullable_correctness erase_fuse r0)
+ − 1946
apply(case_tac "bnullable a")
+ − 1947
apply (metis append.assoc b2 bnullable_correctness erase_fuse r0)
+ − 1948
apply(case_tac rs)
+ − 1949
apply(simp)
+ − 1950
apply(simp)
+ − 1951
apply(auto)[1]
+ − 1952
apply (metis bnullable_correctness erase_fuse)+
+ − 1953
done
+ − 1954
338
+ − 1955
+ − 1956
+ − 1957
lemma qq4a:
337
+ − 1958
assumes "\<exists>x\<in>set list. bnullable x"
+ − 1959
shows "\<exists>x\<in>set (flts list). bnullable x"
+ − 1960
using assms
+ − 1961
apply(induct list rule: flts.induct)
+ − 1962
apply(auto)
+ − 1963
by (metis UnCI bnullable_correctness erase_fuse imageI)
+ − 1964
+ − 1965
+ − 1966
lemma qs3:
+ − 1967
assumes "\<exists>r \<in> set rs. bnullable r"
+ − 1968
shows "bmkeps (AALTs bs rs) = bmkeps (AALTs bs (flts rs))"
+ − 1969
using assms
+ − 1970
apply(induct rs arbitrary: bs taking: size rule: measure_induct)
+ − 1971
apply(case_tac x)
+ − 1972
apply(simp)
+ − 1973
apply(simp)
+ − 1974
apply(case_tac a)
+ − 1975
apply(simp)
+ − 1976
apply (simp add: r1)
+ − 1977
apply(simp)
+ − 1978
apply (simp add: r0)
+ − 1979
apply(simp)
+ − 1980
apply(case_tac "flts list")
+ − 1981
apply(simp)
+ − 1982
apply (metis L_erase_AALTs L_erase_flts L_flat_Prf1 L_flat_Prf2 Prf_elims(1) bnullable_correctness erase.simps(4) mkeps_nullable r2)
+ − 1983
apply(simp)
+ − 1984
apply (simp add: r1)
+ − 1985
prefer 3
+ − 1986
apply(simp)
+ − 1987
apply (simp add: r0)
+ − 1988
prefer 2
+ − 1989
apply(simp)
+ − 1990
apply(case_tac "\<exists>x\<in>set x52. bnullable x")
+ − 1991
apply(case_tac "list")
+ − 1992
apply(simp)
+ − 1993
apply (metis b2 fuse.simps(4) q3a r2)
+ − 1994
apply(erule disjE)
+ − 1995
apply(subst qq1)
+ − 1996
apply(auto)[1]
+ − 1997
apply (metis bnullable_correctness erase_fuse)
+ − 1998
apply(simp)
+ − 1999
apply (metis b2 fuse.simps(4) q3a r2)
+ − 2000
apply(simp)
+ − 2001
apply(auto)[1]
+ − 2002
apply(subst qq1)
+ − 2003
apply (metis bnullable_correctness erase_fuse image_eqI set_map)
+ − 2004
apply (metis b2 fuse.simps(4) q3a r2)
+ − 2005
apply(subst qq1)
+ − 2006
apply (metis bnullable_correctness erase_fuse image_eqI set_map)
+ − 2007
apply (metis b2 fuse.simps(4) q3a r2)
+ − 2008
apply(simp)
+ − 2009
apply(subst qq2)
+ − 2010
apply (metis bnullable_correctness erase_fuse imageE set_map)
+ − 2011
prefer 2
+ − 2012
apply(case_tac "list")
+ − 2013
apply(simp)
+ − 2014
apply(simp)
338
+ − 2015
apply (simp add: qq4a)
337
+ − 2016
apply(simp)
+ − 2017
apply(auto)
+ − 2018
apply(case_tac list)
+ − 2019
apply(simp)
+ − 2020
apply(simp)
+ − 2021
apply (simp add: r0)
+ − 2022
apply(case_tac "bnullable (ASEQ x41 x42 x43)")
+ − 2023
apply(case_tac list)
+ − 2024
apply(simp)
+ − 2025
apply(simp)
+ − 2026
apply (simp add: r0)
+ − 2027
apply(simp)
338
+ − 2028
using qq4a r1 r2 by auto
337
+ − 2029
+ − 2030
+ − 2031
+ − 2032
lemma k1:
+ − 2033
assumes "\<And>x2aa. \<lbrakk>x2aa \<in> set x2a; bnullable x2aa\<rbrakk> \<Longrightarrow> bmkeps x2aa = bmkeps (bsimp x2aa)"
+ − 2034
"\<exists>x\<in>set x2a. bnullable x"
+ − 2035
shows "bmkeps (AALTs x1 (flts x2a)) = bmkeps (AALTs x1 (flts (map bsimp x2a)))"
+ − 2036
using assms
+ − 2037
apply(induct x2a)
+ − 2038
apply fastforce
+ − 2039
apply(simp)
+ − 2040
apply(subst k0)
+ − 2041
apply(subst (2) k0)
+ − 2042
apply(auto)[1]
+ − 2043
apply (metis b3 k0 list.set_intros(1) qs3 r0)
+ − 2044
by (smt b3 imageI insert_iff k0 list.set(2) qq3 qs3 r0 r1 set_map)
+ − 2045
+ − 2046
+ − 2047
+ − 2048
lemma bmkeps_simp:
+ − 2049
assumes "bnullable r"
+ − 2050
shows "bmkeps r = bmkeps (bsimp r)"
+ − 2051
using assms
+ − 2052
apply(induct r)
+ − 2053
apply(simp)
+ − 2054
apply(simp)
+ − 2055
apply(simp)
+ − 2056
apply(simp)
+ − 2057
prefer 3
+ − 2058
apply(simp)
+ − 2059
apply(case_tac "bsimp r1 = AZERO")
+ − 2060
apply(simp)
+ − 2061
apply(auto)[1]
+ − 2062
apply (metis L_bsimp_erase L_flat_Prf1 L_flat_Prf2 Prf_elims(1) bnullable_correctness erase.simps(1) mkeps_nullable)
+ − 2063
apply(case_tac "bsimp r2 = AZERO")
+ − 2064
apply(simp)
+ − 2065
apply(auto)[1]
+ − 2066
apply (metis L_bsimp_erase L_flat_Prf1 L_flat_Prf2 Prf_elims(1) bnullable_correctness erase.simps(1) mkeps_nullable)
+ − 2067
apply(case_tac "\<exists>bs. bsimp r1 = AONE bs")
+ − 2068
apply(auto)[1]
+ − 2069
apply(subst b1)
+ − 2070
apply(subst b2)
+ − 2071
apply(simp add: b3[symmetric])
+ − 2072
apply(simp)
+ − 2073
apply(subgoal_tac "bsimp_ASEQ x1 (bsimp r1) (bsimp r2) = ASEQ x1 (bsimp r1) (bsimp r2)")
+ − 2074
prefer 2
+ − 2075
apply (smt b3 bnullable.elims(2) bsimp_ASEQ.simps(17) bsimp_ASEQ.simps(19) bsimp_ASEQ.simps(20) bsimp_ASEQ.simps(21) bsimp_ASEQ.simps(22) bsimp_ASEQ.simps(24) bsimp_ASEQ.simps(25) bsimp_ASEQ.simps(26) bsimp_ASEQ.simps(27) bsimp_ASEQ.simps(29) bsimp_ASEQ.simps(30) bsimp_ASEQ.simps(31))
+ − 2076
apply(simp)
+ − 2077
apply(simp)
+ − 2078
thm q3
+ − 2079
apply(subst q3[symmetric])
+ − 2080
apply simp
338
+ − 2081
using b3 qq4a apply auto[1]
337
+ − 2082
apply(subst qs3)
+ − 2083
apply simp
+ − 2084
using k1 by blast
+ − 2085
+ − 2086
thm bmkeps_retrieve bmkeps_simp bder_retrieve
+ − 2087
+ − 2088
lemma bmkeps_bder_AALTs:
+ − 2089
assumes "\<exists>r \<in> set rs. bnullable (bder c r)"
+ − 2090
shows "bmkeps (bder c (bsimp_AALTs bs rs)) = bmkeps (bsimp_AALTs bs (map (bder c) rs))"
+ − 2091
using assms
+ − 2092
apply(induct rs)
+ − 2093
apply(simp)
+ − 2094
apply(simp)
+ − 2095
apply(auto)
+ − 2096
apply(case_tac rs)
+ − 2097
apply(simp)
+ − 2098
apply (metis (full_types) Prf_injval bder_retrieve bmkeps_retrieve bnullable_correctness erase_bder erase_fuse mkeps_nullable retrieve_fuse2)
+ − 2099
apply(simp)
+ − 2100
apply(case_tac rs)
+ − 2101
apply(simp_all)
+ − 2102
done
+ − 2103
+ − 2104
lemma bbs0:
+ − 2105
shows "blexer_simp r [] = blexer r []"
+ − 2106
apply(simp add: blexer_def blexer_simp_def)
+ − 2107
done
+ − 2108
+ − 2109
lemma bbs1:
+ − 2110
shows "blexer_simp r [c] = blexer r [c]"
+ − 2111
apply(simp add: blexer_def blexer_simp_def)
+ − 2112
apply(auto)
+ − 2113
defer
+ − 2114
using b3 apply auto[1]
+ − 2115
using b3 apply auto[1]
+ − 2116
apply(subst bmkeps_simp[symmetric])
+ − 2117
apply(simp)
+ − 2118
apply(simp)
+ − 2119
done
+ − 2120
+ − 2121
lemma oo:
+ − 2122
shows "(case (blexer (der c r) s) of None \<Rightarrow> None | Some v \<Rightarrow> Some (injval r c v)) = blexer r (c # s)"
+ − 2123
apply(simp add: blexer_correctness)
+ − 2124
done
+ − 2125
+ − 2126
lemma XXX2_helper:
+ − 2127
assumes "\<forall>y. asize y < Suc (sum_list (map asize rs)) \<longrightarrow> good y \<longrightarrow> bsimp y = y"
+ − 2128
"\<forall>r'\<in>set rs. good r' \<and> nonalt r'"
+ − 2129
shows "flts (map (bsimp \<circ> bder c) (flts (map bsimp rs))) = flts (map (bsimp \<circ> bder c) rs)"
+ − 2130
using assms
+ − 2131
apply(induct rs arbitrary: c)
+ − 2132
apply(simp)
+ − 2133
apply(simp)
+ − 2134
apply(subst k0)
+ − 2135
apply(simp add: flts_append)
+ − 2136
apply(subst (2) k0)
+ − 2137
apply(simp add: flts_append)
+ − 2138
apply(subgoal_tac "flts [a] = [a]")
+ − 2139
prefer 2
+ − 2140
using good.simps(1) k0b apply blast
+ − 2141
apply(simp)
+ − 2142
done
+ − 2143
+ − 2144
lemma bmkeps_good:
+ − 2145
assumes "good a"
+ − 2146
shows "bmkeps (bsimp a) = bmkeps a"
+ − 2147
using assms
+ − 2148
using test2 by auto
+ − 2149
+ − 2150
+ − 2151
lemma xxx_bder:
+ − 2152
assumes "good r"
+ − 2153
shows "L (erase r) \<noteq> {}"
+ − 2154
using assms
+ − 2155
apply(induct r rule: good.induct)
+ − 2156
apply(auto simp add: Sequ_def)
+ − 2157
done
+ − 2158
+ − 2159
lemma xxx_bder2:
+ − 2160
assumes "L (erase (bsimp r)) = {}"
+ − 2161
shows "bsimp r = AZERO"
+ − 2162
using assms xxx_bder test2 good1
+ − 2163
by blast
+ − 2164
+ − 2165
lemma XXX2aa:
+ − 2166
assumes "good a"
+ − 2167
shows "bsimp (bder c (bsimp a)) = bsimp (bder c a)"
+ − 2168
using assms
+ − 2169
by (simp add: test2)
+ − 2170
+ − 2171
lemma XXX2aa_ders:
+ − 2172
assumes "good a"
+ − 2173
shows "bsimp (bders (bsimp a) s) = bsimp (bders a s)"
+ − 2174
using assms
+ − 2175
by (simp add: test2)
+ − 2176
+ − 2177
lemma XXX4a:
+ − 2178
shows "good (bders_simp (bsimp r) s) \<or> bders_simp (bsimp r) s = AZERO"
+ − 2179
apply(induct s arbitrary: r rule: rev_induct)
+ − 2180
apply(simp)
+ − 2181
apply (simp add: good1)
+ − 2182
apply(simp add: bders_simp_append)
+ − 2183
apply (simp add: good1)
+ − 2184
done
+ − 2185
+ − 2186
lemma XXX4a_good:
+ − 2187
assumes "good a"
+ − 2188
shows "good (bders_simp a s) \<or> bders_simp a s = AZERO"
+ − 2189
using assms
+ − 2190
apply(induct s arbitrary: a rule: rev_induct)
+ − 2191
apply(simp)
+ − 2192
apply(simp add: bders_simp_append)
+ − 2193
apply (simp add: good1)
+ − 2194
done
+ − 2195
+ − 2196
lemma XXX4a_good_cons:
+ − 2197
assumes "s \<noteq> []"
+ − 2198
shows "good (bders_simp a s) \<or> bders_simp a s = AZERO"
+ − 2199
using assms
+ − 2200
apply(case_tac s)
+ − 2201
apply(auto)
+ − 2202
using XXX4a by blast
+ − 2203
+ − 2204
lemma XXX4b:
+ − 2205
assumes "good a" "L (erase (bders_simp a s)) \<noteq> {}"
+ − 2206
shows "good (bders_simp a s)"
+ − 2207
using assms
+ − 2208
apply(induct s arbitrary: a)
+ − 2209
apply(simp)
+ − 2210
apply(simp)
+ − 2211
apply(subgoal_tac "L (erase (bder a aa)) = {} \<or> L (erase (bder a aa)) \<noteq> {}")
+ − 2212
prefer 2
+ − 2213
apply(auto)[1]
+ − 2214
apply(erule disjE)
+ − 2215
apply(subgoal_tac "bsimp (bder a aa) = AZERO")
+ − 2216
prefer 2
+ − 2217
using L_bsimp_erase xxx_bder2 apply auto[1]
+ − 2218
apply(simp)
+ − 2219
apply (metis L.simps(1) XXX4a erase.simps(1))
+ − 2220
apply(drule_tac x="bsimp (bder a aa)" in meta_spec)
+ − 2221
apply(drule meta_mp)
+ − 2222
apply simp
+ − 2223
apply(rule good1a)
+ − 2224
apply(auto)
+ − 2225
done
+ − 2226
+ − 2227
lemma bders_AZERO:
+ − 2228
shows "bders AZERO s = AZERO"
+ − 2229
and "bders_simp AZERO s = AZERO"
+ − 2230
apply (induct s)
+ − 2231
apply(auto)
+ − 2232
done
+ − 2233
+ − 2234
lemma LA:
+ − 2235
assumes "\<Turnstile> v : ders s (erase r)"
+ − 2236
shows "retrieve (bders r s) v = retrieve r (flex (erase r) id s v)"
+ − 2237
using assms
+ − 2238
apply(induct s arbitrary: r v rule: rev_induct)
+ − 2239
apply(simp)
+ − 2240
apply(simp add: bders_append ders_append)
+ − 2241
apply(subst bder_retrieve)
+ − 2242
apply(simp)
+ − 2243
apply(drule Prf_injval)
+ − 2244
by (simp add: flex_append)
+ − 2245
+ − 2246
+ − 2247
lemma LB:
+ − 2248
assumes "s \<in> (erase r) \<rightarrow> v"
+ − 2249
shows "retrieve r v = retrieve r (flex (erase r) id s (mkeps (ders s (erase r))))"
+ − 2250
using assms
+ − 2251
apply(induct s arbitrary: r v rule: rev_induct)
+ − 2252
apply(simp)
+ − 2253
apply(subgoal_tac "v = mkeps (erase r)")
+ − 2254
prefer 2
+ − 2255
apply (simp add: Posix1(1) Posix_determ Posix_mkeps nullable_correctness)
+ − 2256
apply(simp)
+ − 2257
apply(simp add: flex_append ders_append)
+ − 2258
by (metis Posix_determ Posix_flex Posix_injval Posix_mkeps ders_snoc lexer_correctness(2) lexer_flex)
+ − 2259
+ − 2260
lemma LB_sym:
+ − 2261
assumes "s \<in> (erase r) \<rightarrow> v"
+ − 2262
shows "retrieve r v = retrieve r (flex (erase r) id s (mkeps (erase (bders r s))))"
+ − 2263
using assms
+ − 2264
by (simp add: LB)
+ − 2265
+ − 2266
+ − 2267
lemma LC:
+ − 2268
assumes "s \<in> (erase r) \<rightarrow> v"
+ − 2269
shows "retrieve r v = retrieve (bders r s) (mkeps (erase (bders r s)))"
+ − 2270
apply(simp)
+ − 2271
by (metis LA LB Posix1(1) assms lexer_correct_None lexer_flex mkeps_nullable)
+ − 2272
+ − 2273
+ − 2274
lemma L0:
+ − 2275
assumes "bnullable a"
+ − 2276
shows "retrieve (bsimp a) (mkeps (erase (bsimp a))) = retrieve a (mkeps (erase a))"
343
+ − 2277
using assms b3 bmkeps_retrieve bmkeps_simp bnullable_correctness
337
+ − 2278
by (metis b3 bmkeps_retrieve bmkeps_simp bnullable_correctness)
+ − 2279
+ − 2280
thm bmkeps_retrieve
+ − 2281
+ − 2282
lemma L0a:
+ − 2283
assumes "s \<in> L(erase a)"
+ − 2284
shows "retrieve (bsimp (bders a s)) (mkeps (erase (bsimp (bders a s)))) =
+ − 2285
retrieve (bders a s) (mkeps (erase (bders a s)))"
+ − 2286
using assms
+ − 2287
by (metis L0 bnullable_correctness erase_bders lexer_correct_None lexer_flex)
+ − 2288
+ − 2289
lemma L0aa:
+ − 2290
assumes "s \<in> L (erase a)"
+ − 2291
shows "[] \<in> erase (bsimp (bders a s)) \<rightarrow> mkeps (erase (bsimp (bders a s)))"
+ − 2292
using assms
+ − 2293
by (metis Posix_mkeps b3 bnullable_correctness erase_bders lexer_correct_None lexer_flex)
+ − 2294
+ − 2295
lemma L0aaa:
+ − 2296
assumes "[c] \<in> L (erase a)"
+ − 2297
shows "[c] \<in> (erase a) \<rightarrow> flex (erase a) id [c] (mkeps (erase (bder c a)))"
+ − 2298
using assms
+ − 2299
by (metis bders.simps(1) bders.simps(2) erase_bders lexer_correct_None lexer_correct_Some lexer_flex option.inject)
+ − 2300
+ − 2301
lemma L0aaaa:
+ − 2302
assumes "[c] \<in> L (erase a)"
+ − 2303
shows "[c] \<in> (erase a) \<rightarrow> flex (erase a) id [c] (mkeps (erase (bders a [c])))"
+ − 2304
using assms
+ − 2305
using L0aaa by auto
+ − 2306
+ − 2307
+ − 2308
lemma L02:
+ − 2309
assumes "bnullable (bder c a)"
+ − 2310
shows "retrieve (bsimp a) (flex (erase (bsimp a)) id [c] (mkeps (erase (bder c (bsimp a))))) =
+ − 2311
retrieve (bder c (bsimp a)) (mkeps (erase (bder c (bsimp a))))"
+ − 2312
using assms
+ − 2313
apply(simp)
+ − 2314
using bder_retrieve L0 bmkeps_simp bmkeps_retrieve L0 LA LB
+ − 2315
apply(subst bder_retrieve[symmetric])
+ − 2316
apply (metis L_bsimp_erase bnullable_correctness der_correctness erase_bder mkeps_nullable nullable_correctness)
+ − 2317
apply(simp)
+ − 2318
done
+ − 2319
+ − 2320
lemma L02_bders:
+ − 2321
assumes "bnullable (bders a s)"
+ − 2322
shows "retrieve (bsimp a) (flex (erase (bsimp a)) id s (mkeps (erase (bders (bsimp a) s)))) =
+ − 2323
retrieve (bders (bsimp a) s) (mkeps (erase (bders (bsimp a) s)))"
+ − 2324
using assms
+ − 2325
by (metis LA L_bsimp_erase bnullable_correctness ders_correctness erase_bders mkeps_nullable nullable_correctness)
+ − 2326
+ − 2327
+ − 2328
+ − 2329
+ − 2330
lemma L03:
+ − 2331
assumes "bnullable (bder c a)"
+ − 2332
shows "retrieve (bder c (bsimp a)) (mkeps (erase (bder c (bsimp a)))) =
+ − 2333
bmkeps (bsimp (bder c (bsimp a)))"
+ − 2334
using assms
+ − 2335
by (metis L0 L_bsimp_erase bmkeps_retrieve bnullable_correctness der_correctness erase_bder nullable_correctness)
+ − 2336
+ − 2337
lemma L04:
+ − 2338
assumes "bnullable (bder c a)"
+ − 2339
shows "retrieve (bder c (bsimp a)) (mkeps (erase (bder c (bsimp a)))) =
+ − 2340
retrieve (bsimp (bder c (bsimp a))) (mkeps (erase (bsimp (bder c (bsimp a)))))"
+ − 2341
using assms
+ − 2342
by (metis L0 L_bsimp_erase bnullable_correctness der_correctness erase_bder nullable_correctness)
+ − 2343
+ − 2344
lemma L05:
+ − 2345
assumes "bnullable (bder c a)"
+ − 2346
shows "retrieve (bder c (bsimp a)) (mkeps (erase (bder c (bsimp a)))) =
+ − 2347
retrieve (bsimp (bder c (bsimp a))) (mkeps (erase (bsimp (bder c (bsimp a)))))"
+ − 2348
using assms
+ − 2349
using L04 by auto
+ − 2350
+ − 2351
lemma L06:
+ − 2352
assumes "bnullable (bder c a)"
+ − 2353
shows "bmkeps (bder c (bsimp a)) = bmkeps (bsimp (bder c (bsimp a)))"
+ − 2354
using assms
+ − 2355
by (metis L03 L_bsimp_erase bmkeps_retrieve bnullable_correctness der_correctness erase_bder nullable_correctness)
+ − 2356
+ − 2357
lemma L07:
+ − 2358
assumes "s \<in> L (erase r)"
+ − 2359
shows "retrieve r (flex (erase r) id s (mkeps (ders s (erase r))))
+ − 2360
= retrieve (bders r s) (mkeps (erase (bders r s)))"
+ − 2361
using assms
+ − 2362
using LB LC lexer_correct_Some by auto
+ − 2363
+ − 2364
lemma L06_2:
+ − 2365
assumes "bnullable (bders a [c,d])"
+ − 2366
shows "bmkeps (bders (bsimp a) [c,d]) = bmkeps (bsimp (bders (bsimp a) [c,d]))"
+ − 2367
using assms
+ − 2368
apply(simp)
+ − 2369
by (metis L_bsimp_erase bmkeps_simp bnullable_correctness der_correctness erase_bder nullable_correctness)
+ − 2370
+ − 2371
lemma L06_bders:
+ − 2372
assumes "bnullable (bders a s)"
+ − 2373
shows "bmkeps (bders (bsimp a) s) = bmkeps (bsimp (bders (bsimp a) s))"
+ − 2374
using assms
+ − 2375
by (metis L_bsimp_erase bmkeps_simp bnullable_correctness ders_correctness erase_bders nullable_correctness)
+ − 2376
+ − 2377
lemma LLLL:
+ − 2378
shows "L (erase a) = L (erase (bsimp a))"
+ − 2379
and "L (erase a) = {flat v | v. \<Turnstile> v: (erase a)}"
+ − 2380
and "L (erase a) = {flat v | v. \<Turnstile> v: (erase (bsimp a))}"
+ − 2381
using L_bsimp_erase apply(blast)
+ − 2382
apply (simp add: L_flat_Prf)
+ − 2383
using L_bsimp_erase L_flat_Prf apply(auto)[1]
+ − 2384
done
+ − 2385
+ − 2386
+ − 2387
+ − 2388
lemma L07XX:
+ − 2389
assumes "s \<in> L (erase a)"
+ − 2390
shows "s \<in> erase a \<rightarrow> flex (erase a) id s (mkeps (ders s (erase a)))"
+ − 2391
using assms
+ − 2392
by (meson lexer_correct_None lexer_correctness(1) lexer_flex)
+ − 2393
+ − 2394
lemma LX0:
+ − 2395
assumes "s \<in> L r"
+ − 2396
shows "decode (bmkeps (bders (intern r) s)) r = Some(flex r id s (mkeps (ders s r)))"
+ − 2397
by (metis assms blexer_correctness blexer_def lexer_correct_None lexer_flex)
+ − 2398
+ − 2399
lemma L1:
+ − 2400
assumes "s \<in> r \<rightarrow> v"
+ − 2401
shows "decode (bmkeps (bders (intern r) s)) r = Some v"
+ − 2402
using assms
+ − 2403
by (metis blexer_correctness blexer_def lexer_correctness(1) option.distinct(1))
+ − 2404
+ − 2405
lemma L2:
+ − 2406
assumes "s \<in> (der c r) \<rightarrow> v"
+ − 2407
shows "decode (bmkeps (bders (intern r) (c # s))) r = Some (injval r c v)"
+ − 2408
using assms
+ − 2409
apply(subst bmkeps_retrieve)
+ − 2410
using Posix1(1) lexer_correct_None lexer_flex apply fastforce
+ − 2411
using MAIN_decode
+ − 2412
apply(subst MAIN_decode[symmetric])
+ − 2413
apply(simp)
+ − 2414
apply (meson Posix1(1) lexer_correct_None lexer_flex mkeps_nullable)
+ − 2415
apply(simp)
+ − 2416
apply(subgoal_tac "v = flex (der c r) id s (mkeps (ders s (der c r)))")
+ − 2417
prefer 2
+ − 2418
apply (metis Posix_determ lexer_correctness(1) lexer_flex option.distinct(1))
+ − 2419
apply(simp)
+ − 2420
apply(subgoal_tac "injval r c (flex (der c r) id s (mkeps (ders s (der c r)))) =
+ − 2421
(flex (der c r) ((\<lambda>v. injval r c v) o id) s (mkeps (ders s (der c r))))")
+ − 2422
apply(simp)
+ − 2423
using flex_fun_apply by blast
+ − 2424
+ − 2425
lemma L3:
+ − 2426
assumes "s2 \<in> (ders s1 r) \<rightarrow> v"
+ − 2427
shows "decode (bmkeps (bders (intern r) (s1 @ s2))) r = Some (flex r id s1 v)"
+ − 2428
using assms
+ − 2429
apply(induct s1 arbitrary: r s2 v rule: rev_induct)
+ − 2430
apply(simp)
+ − 2431
using L1 apply blast
+ − 2432
apply(simp add: ders_append)
+ − 2433
apply(drule_tac x="r" in meta_spec)
+ − 2434
apply(drule_tac x="x # s2" in meta_spec)
+ − 2435
apply(drule_tac x="injval (ders xs r) x v" in meta_spec)
+ − 2436
apply(drule meta_mp)
+ − 2437
defer
+ − 2438
apply(simp)
+ − 2439
apply(simp add: flex_append)
+ − 2440
by (simp add: Posix_injval)
+ − 2441
+ − 2442
+ − 2443
+ − 2444
lemma bders_snoc:
+ − 2445
"bder c (bders a s) = bders a (s @ [c])"
+ − 2446
apply(simp add: bders_append)
+ − 2447
done
+ − 2448
+ − 2449
+ − 2450
lemma QQ1:
+ − 2451
shows "bsimp (bders (bsimp a) []) = bders_simp (bsimp a) []"
+ − 2452
apply(simp)
+ − 2453
apply(simp add: bsimp_idem)
+ − 2454
done
+ − 2455
+ − 2456
lemma QQ2:
+ − 2457
shows "bsimp (bders (bsimp a) [c]) = bders_simp (bsimp a) [c]"
+ − 2458
apply(simp)
+ − 2459
done
+ − 2460
+ − 2461
lemma XXX2a_long:
+ − 2462
assumes "good a"
+ − 2463
shows "bsimp (bder c (bsimp a)) = bsimp (bder c a)"
+ − 2464
using assms
+ − 2465
apply(induct a arbitrary: c taking: asize rule: measure_induct)
+ − 2466
apply(case_tac x)
+ − 2467
apply(simp)
+ − 2468
apply(simp)
+ − 2469
apply(simp)
+ − 2470
prefer 3
+ − 2471
apply(simp)
+ − 2472
apply(simp)
+ − 2473
apply(auto)[1]
+ − 2474
apply(case_tac "x42 = AZERO")
+ − 2475
apply(simp)
+ − 2476
apply(case_tac "x43 = AZERO")
+ − 2477
apply(simp)
+ − 2478
using test2 apply force
+ − 2479
apply(case_tac "\<exists>bs. x42 = AONE bs")
+ − 2480
apply(clarify)
+ − 2481
apply(simp)
+ − 2482
apply(subst bsimp_ASEQ1)
+ − 2483
apply(simp)
+ − 2484
using b3 apply force
+ − 2485
using bsimp_ASEQ0 test2 apply force
+ − 2486
thm good_SEQ test2
+ − 2487
apply (simp add: good_SEQ test2)
+ − 2488
apply (simp add: good_SEQ test2)
+ − 2489
apply(case_tac "x42 = AZERO")
+ − 2490
apply(simp)
+ − 2491
apply(case_tac "x43 = AZERO")
+ − 2492
apply(simp)
+ − 2493
apply (simp add: bsimp_ASEQ0)
+ − 2494
apply(case_tac "\<exists>bs. x42 = AONE bs")
+ − 2495
apply(clarify)
+ − 2496
apply(simp)
+ − 2497
apply(subst bsimp_ASEQ1)
+ − 2498
apply(simp)
+ − 2499
using bsimp_ASEQ0 test2 apply force
+ − 2500
apply (simp add: good_SEQ test2)
+ − 2501
apply (simp add: good_SEQ test2)
+ − 2502
apply (simp add: good_SEQ test2)
+ − 2503
(* AALTs case *)
+ − 2504
apply(simp)
+ − 2505
using test2 by fastforce
+ − 2506
+ − 2507
+ − 2508
lemma bder_bsimp_AALTs:
+ − 2509
shows "bder c (bsimp_AALTs bs rs) = bsimp_AALTs bs (map (bder c) rs)"
+ − 2510
apply(induct bs rs rule: bsimp_AALTs.induct)
+ − 2511
apply(simp)
+ − 2512
apply(simp)
+ − 2513
apply (simp add: bder_fuse)
+ − 2514
apply(simp)
+ − 2515
done
+ − 2516
357
+ − 2517
lemma bders_bsimp_AALTs:
+ − 2518
shows "bders (bsimp_AALTs bs rs) s = bsimp_AALTs bs (map (\<lambda>a. bders a s) rs)"
+ − 2519
apply(induct s arbitrary: bs rs rule: rev_induct)
+ − 2520
apply(simp)
+ − 2521
apply(simp add: bders_append)
+ − 2522
apply(simp add: bder_bsimp_AALTs)
+ − 2523
apply(simp add: comp_def)
+ − 2524
done
+ − 2525
337
+ − 2526
lemma flts_nothing:
+ − 2527
assumes "\<forall>r \<in> set rs. r \<noteq> AZERO" "\<forall>r \<in> set rs. nonalt r"
+ − 2528
shows "flts rs = rs"
+ − 2529
using assms
+ − 2530
apply(induct rs rule: flts.induct)
+ − 2531
apply(auto)
+ − 2532
done
+ − 2533
+ − 2534
lemma flts_flts:
+ − 2535
assumes "\<forall>r \<in> set rs. good r"
+ − 2536
shows "flts (flts rs) = flts rs"
+ − 2537
using assms
+ − 2538
apply(induct rs taking: "\<lambda>rs. sum_list (map asize rs)" rule: measure_induct)
+ − 2539
apply(case_tac x)
+ − 2540
apply(simp)
+ − 2541
apply(simp)
+ − 2542
apply(case_tac a)
+ − 2543
apply(simp_all add: bder_fuse flts_append)
+ − 2544
apply(subgoal_tac "\<forall>r \<in> set x52. r \<noteq> AZERO")
+ − 2545
prefer 2
+ − 2546
apply (metis Nil_is_append_conv bsimp_AALTs.elims good.simps(1) good.simps(5) good0 list.distinct(1) n0 nn1b split_list_last test2)
+ − 2547
apply(subgoal_tac "\<forall>r \<in> set x52. nonalt r")
+ − 2548
prefer 2
+ − 2549
apply (metis n0 nn1b test2)
+ − 2550
by (metis flts_fuse flts_nothing)
+ − 2551
+ − 2552
+ − 2553
lemma iii:
+ − 2554
assumes "bsimp_AALTs bs rs \<noteq> AZERO"
+ − 2555
shows "rs \<noteq> []"
+ − 2556
using assms
+ − 2557
apply(induct bs rs rule: bsimp_AALTs.induct)
+ − 2558
apply(auto)
+ − 2559
done
+ − 2560
+ − 2561
lemma CT1_SEQ:
+ − 2562
shows "bsimp (ASEQ bs a1 a2) = bsimp (ASEQ bs (bsimp a1) (bsimp a2))"
+ − 2563
apply(simp add: bsimp_idem)
+ − 2564
done
+ − 2565
+ − 2566
lemma CT1:
+ − 2567
shows "bsimp (AALTs bs as) = bsimp (AALTs bs (map bsimp as))"
+ − 2568
apply(induct as arbitrary: bs)
+ − 2569
apply(simp)
+ − 2570
apply(simp)
+ − 2571
by (simp add: bsimp_idem comp_def)
+ − 2572
+ − 2573
lemma CT1a:
+ − 2574
shows "bsimp (AALT bs a1 a2) = bsimp(AALT bs (bsimp a1) (bsimp a2))"
+ − 2575
by (metis CT1 list.simps(8) list.simps(9))
+ − 2576
+ − 2577
lemma WWW2:
+ − 2578
shows "bsimp (bsimp_AALTs bs1 (flts (map bsimp as1))) =
+ − 2579
bsimp_AALTs bs1 (flts (map bsimp as1))"
+ − 2580
by (metis bsimp.simps(2) bsimp_idem)
+ − 2581
+ − 2582
lemma CT1b:
+ − 2583
shows "bsimp (bsimp_AALTs bs as) = bsimp (bsimp_AALTs bs (map bsimp as))"
+ − 2584
apply(induct bs as rule: bsimp_AALTs.induct)
+ − 2585
apply(auto simp add: bsimp_idem)
+ − 2586
apply (simp add: bsimp_fuse bsimp_idem)
+ − 2587
by (metis bsimp_idem comp_apply)
+ − 2588
+ − 2589
+ − 2590
+ − 2591
+ − 2592
(* CT *)
+ − 2593
+ − 2594
lemma CTa:
+ − 2595
assumes "\<forall>r \<in> set as. nonalt r \<and> r \<noteq> AZERO"
+ − 2596
shows "flts as = as"
+ − 2597
using assms
+ − 2598
apply(induct as)
+ − 2599
apply(simp)
+ − 2600
apply(case_tac as)
+ − 2601
apply(simp)
+ − 2602
apply (simp add: k0b)
+ − 2603
using flts_nothing by auto
+ − 2604
+ − 2605
lemma CT0:
+ − 2606
assumes "\<forall>r \<in> set as1. nonalt r \<and> r \<noteq> AZERO"
+ − 2607
shows "flts [bsimp_AALTs bs1 as1] = flts (map (fuse bs1) as1)"
+ − 2608
using assms CTa
+ − 2609
apply(induct as1 arbitrary: bs1)
+ − 2610
apply(simp)
+ − 2611
apply(simp)
+ − 2612
apply(case_tac as1)
+ − 2613
apply(simp)
+ − 2614
apply(simp)
+ − 2615
proof -
+ − 2616
fix a :: arexp and as1a :: "arexp list" and bs1a :: "bit list" and aa :: arexp and list :: "arexp list"
+ − 2617
assume a1: "nonalt a \<and> a \<noteq> AZERO \<and> nonalt aa \<and> aa \<noteq> AZERO \<and> (\<forall>r\<in>set list. nonalt r \<and> r \<noteq> AZERO)"
+ − 2618
assume a2: "\<And>as. \<forall>r\<in>set as. nonalt r \<and> r \<noteq> AZERO \<Longrightarrow> flts as = as"
+ − 2619
assume a3: "as1a = aa # list"
+ − 2620
have "flts [a] = [a]"
+ − 2621
using a1 k0b by blast
+ − 2622
then show "fuse bs1a a # fuse bs1a aa # map (fuse bs1a) list = flts (fuse bs1a a # fuse bs1a aa # map (fuse bs1a) list)"
+ − 2623
using a3 a2 a1 by (metis (no_types) append.left_neutral append_Cons flts_fuse k00 k0b list.simps(9))
+ − 2624
qed
+ − 2625
+ − 2626
+ − 2627
lemma CT01:
+ − 2628
assumes "\<forall>r \<in> set as1. nonalt r \<and> r \<noteq> AZERO" "\<forall>r \<in> set as2. nonalt r \<and> r \<noteq> AZERO"
+ − 2629
shows "flts [bsimp_AALTs bs1 as1, bsimp_AALTs bs2 as2] = flts ((map (fuse bs1) as1) @ (map (fuse bs2) as2))"
+ − 2630
using assms CT0
+ − 2631
by (metis k0 k00)
+ − 2632
+ − 2633
+ − 2634
+ − 2635
lemma CT_exp:
+ − 2636
assumes "\<forall>a \<in> set as. bsimp (bder c (bsimp a)) = bsimp (bder c a)"
+ − 2637
shows "map bsimp (map (bder c) as) = map bsimp (map (bder c) (map bsimp as))"
+ − 2638
using assms
+ − 2639
apply(induct as)
+ − 2640
apply(auto)
+ − 2641
done
+ − 2642
+ − 2643
lemma asize_set:
+ − 2644
assumes "a \<in> set as"
+ − 2645
shows "asize a < Suc (sum_list (map asize as))"
+ − 2646
using assms
+ − 2647
apply(induct as arbitrary: a)
+ − 2648
apply(auto)
+ − 2649
using le_add2 le_less_trans not_less_eq by blast
+ − 2650
339
+ − 2651
lemma L_erase_bder_simp:
+ − 2652
shows "L (erase (bsimp (bder a r))) = L (der a (erase (bsimp r)))"
+ − 2653
using L_bsimp_erase der_correctness by auto
+ − 2654
+ − 2655
lemma PPP0:
+ − 2656
assumes "s \<in> r \<rightarrow> v"
+ − 2657
shows "(bders (intern r) s) >> code v"
+ − 2658
using assms
+ − 2659
by (smt L07 L1 LX0 Posix1(1) Posix_Prf contains6 erase_bders erase_intern lexer_correct_None lexer_flex mkeps_nullable option.inject retrieve_code)
+ − 2660
+ − 2661
thm L07 L1 LX0 Posix1(1) Posix_Prf contains6 erase_bders erase_intern lexer_correct_None lexer_flex mkeps_nullable option.inject retrieve_code
+ − 2662
+ − 2663
+ − 2664
lemma PPP0_isar:
+ − 2665
assumes "s \<in> r \<rightarrow> v"
+ − 2666
shows "(bders (intern r) s) >> code v"
+ − 2667
proof -
+ − 2668
from assms have a1: "\<Turnstile> v : r" using Posix_Prf by simp
+ − 2669
+ − 2670
from assms have "s \<in> L r" using Posix1(1) by auto
+ − 2671
then have "[] \<in> L (ders s r)" by (simp add: ders_correctness Ders_def)
+ − 2672
then have a2: "\<Turnstile> mkeps (ders s r) : ders s r"
+ − 2673
by (simp add: mkeps_nullable nullable_correctness)
+ − 2674
+ − 2675
have "retrieve (bders (intern r) s) (mkeps (ders s r)) =
+ − 2676
retrieve (intern r) (flex r id s (mkeps (ders s r)))" using a2 LA LB bder_retrieve by simp
+ − 2677
also have "... = retrieve (intern r) v"
+ − 2678
using LB assms by auto
+ − 2679
also have "... = code v" using a1 by (simp add: retrieve_code)
+ − 2680
finally have "retrieve (bders (intern r) s) (mkeps (ders s r)) = code v" by simp
+ − 2681
moreover
+ − 2682
have "\<Turnstile> mkeps (ders s r) : erase (bders (intern r) s)" using a2 by simp
+ − 2683
then have "bders (intern r) s >> retrieve (bders (intern r) s) (mkeps (ders s r))"
+ − 2684
by (rule contains6)
+ − 2685
ultimately
+ − 2686
show "(bders (intern r) s) >> code v" by simp
+ − 2687
qed
+ − 2688
+ − 2689
lemma PPP0b:
+ − 2690
assumes "s \<in> r \<rightarrow> v"
+ − 2691
shows "(intern r) >> code v"
+ − 2692
using assms
+ − 2693
using Posix_Prf contains2 by auto
+ − 2694
+ − 2695
lemma PPP0_eq:
+ − 2696
assumes "s \<in> r \<rightarrow> v"
+ − 2697
shows "(intern r >> code v) = (bders (intern r) s >> code v)"
+ − 2698
using assms
+ − 2699
using PPP0_isar PPP0b by blast
+ − 2700
+ − 2701
lemma f_cont1:
+ − 2702
assumes "fuse bs1 a >> bs"
+ − 2703
shows "\<exists>bs2. bs = bs1 @ bs2"
+ − 2704
using assms
+ − 2705
apply(induct a arbitrary: bs1 bs)
+ − 2706
apply(auto elim: contains.cases)
+ − 2707
done
+ − 2708
+ − 2709
+ − 2710
lemma f_cont2:
+ − 2711
assumes "bsimp_AALTs bs1 as >> bs"
+ − 2712
shows "\<exists>bs2. bs = bs1 @ bs2"
+ − 2713
using assms
+ − 2714
apply(induct bs1 as arbitrary: bs rule: bsimp_AALTs.induct)
+ − 2715
apply(auto elim: contains.cases f_cont1)
+ − 2716
done
+ − 2717
+ − 2718
lemma contains_SEQ1:
+ − 2719
assumes "bsimp_ASEQ bs r1 r2 >> bsX"
+ − 2720
shows "\<exists>bs1 bs2. r1 >> bs1 \<and> r2 >> bs2 \<and> bsX = bs @ bs1 @ bs2"
+ − 2721
using assms
+ − 2722
apply(auto)
+ − 2723
apply(case_tac "r1 = AZERO")
+ − 2724
apply(auto)
+ − 2725
using contains.simps apply blast
+ − 2726
apply(case_tac "r2 = AZERO")
+ − 2727
apply(auto)
+ − 2728
apply(simp add: bsimp_ASEQ0)
+ − 2729
using contains.simps apply blast
+ − 2730
apply(case_tac "\<exists>bsX. r1 = AONE bsX")
+ − 2731
apply(auto)
+ − 2732
apply(simp add: bsimp_ASEQ2)
+ − 2733
apply (metis append_assoc contains.intros(1) contains49 f_cont1)
+ − 2734
apply(simp add: bsimp_ASEQ1)
+ − 2735
apply(erule contains.cases)
+ − 2736
apply(auto)
+ − 2737
done
+ − 2738
+ − 2739
lemma contains59:
+ − 2740
assumes "AALTs bs rs >> bs2"
+ − 2741
shows "\<exists>r \<in> set rs. (fuse bs r) >> bs2"
+ − 2742
using assms
+ − 2743
apply(induct rs arbitrary: bs bs2)
+ − 2744
apply(auto)
+ − 2745
apply(erule contains.cases)
+ − 2746
apply(auto)
+ − 2747
apply(erule contains.cases)
+ − 2748
apply(auto)
+ − 2749
using contains0 by blast
+ − 2750
+ − 2751
lemma contains60:
+ − 2752
assumes "\<exists>r \<in> set rs. fuse bs r >> bs2"
+ − 2753
shows "AALTs bs rs >> bs2"
+ − 2754
using assms
+ − 2755
apply(induct rs arbitrary: bs bs2)
+ − 2756
apply(auto)
+ − 2757
apply (metis contains3b contains49 f_cont1)
+ − 2758
using contains.intros(5) f_cont1 by blast
+ − 2759
+ − 2760
+ − 2761
+ − 2762
lemma contains61:
+ − 2763
assumes "bsimp_AALTs bs rs >> bs2"
+ − 2764
shows "\<exists>r \<in> set rs. (fuse bs r) >> bs2"
+ − 2765
using assms
+ − 2766
apply(induct arbitrary: bs2 rule: bsimp_AALTs.induct)
+ − 2767
apply(auto)
+ − 2768
using contains.simps apply blast
+ − 2769
using contains59 by fastforce
+ − 2770
+ − 2771
lemma contains61b:
+ − 2772
assumes "bsimp_AALTs bs rs >> bs2"
+ − 2773
shows "\<exists>r \<in> set (flts rs). (fuse bs r) >> bs2"
+ − 2774
using assms
+ − 2775
apply(induct bs rs arbitrary: bs2 rule: bsimp_AALTs.induct)
+ − 2776
apply(auto)
+ − 2777
using contains.simps apply blast
+ − 2778
using contains51d contains61 f_cont1 apply blast
+ − 2779
by (metis bsimp_AALTs.simps(3) contains52 contains61 f_cont2)
+ − 2780
+ − 2781
+ − 2782
+ − 2783
lemma contains61a:
+ − 2784
assumes "\<exists>r \<in> set rs. (fuse bs r) >> bs2"
+ − 2785
shows "bsimp_AALTs bs rs >> bs2"
+ − 2786
using assms
+ − 2787
apply(induct rs arbitrary: bs2 bs)
+ − 2788
apply(auto)
+ − 2789
apply (metis bsimp_AALTs.elims contains60 list.distinct(1) list.inject list.set_intros(1))
+ − 2790
by (metis append_Cons append_Nil contains50 f_cont2)
+ − 2791
+ − 2792
lemma contains62:
+ − 2793
assumes "bsimp_AALTs bs (rs1 @ rs2) >> bs2"
+ − 2794
shows "bsimp_AALTs bs rs1 >> bs2 \<or> bsimp_AALTs bs rs2 >> bs2"
+ − 2795
using assms
+ − 2796
apply -
+ − 2797
apply(drule contains61)
+ − 2798
apply(auto)
+ − 2799
apply(case_tac rs1)
+ − 2800
apply(auto)
+ − 2801
apply(case_tac list)
+ − 2802
apply(auto)
+ − 2803
apply (simp add: contains60)
+ − 2804
apply(case_tac list)
+ − 2805
apply(auto)
+ − 2806
apply (simp add: contains60)
+ − 2807
apply (meson contains60 list.set_intros(2))
+ − 2808
apply(case_tac rs2)
+ − 2809
apply(auto)
+ − 2810
apply(case_tac list)
+ − 2811
apply(auto)
+ − 2812
apply (simp add: contains60)
+ − 2813
apply(case_tac list)
+ − 2814
apply(auto)
+ − 2815
apply (simp add: contains60)
+ − 2816
apply (meson contains60 list.set_intros(2))
+ − 2817
done
+ − 2818
+ − 2819
lemma contains63:
+ − 2820
assumes "AALTs bs (map (fuse bs1) rs) >> bs3"
+ − 2821
shows "AALTs (bs @ bs1) rs >> bs3"
+ − 2822
using assms
+ − 2823
apply(induct rs arbitrary: bs bs1 bs3)
+ − 2824
apply(auto elim: contains.cases)
+ − 2825
apply(erule contains.cases)
+ − 2826
apply(auto)
+ − 2827
apply (simp add: contains0 contains60 fuse_append)
+ − 2828
by (metis contains.intros(5) contains59 f_cont1)
+ − 2829
+ − 2830
lemma contains64:
+ − 2831
assumes "bsimp_AALTs bs (flts rs1 @ flts rs2) >> bs2" "\<forall>r \<in> set rs2. \<not> fuse bs r >> bs2"
+ − 2832
shows "bsimp_AALTs bs (flts rs1) >> bs2"
+ − 2833
using assms
+ − 2834
apply(induct rs2 arbitrary: rs1 bs bs2)
+ − 2835
apply(auto)
+ − 2836
apply(drule_tac x="rs1" in meta_spec)
+ − 2837
apply(drule_tac x="bs" in meta_spec)
+ − 2838
apply(drule_tac x="bs2" in meta_spec)
+ − 2839
apply(drule meta_mp)
+ − 2840
apply(drule contains61)
+ − 2841
apply(auto)
+ − 2842
using contains51b contains61a f_cont1 apply blast
+ − 2843
apply(subst (asm) k0)
+ − 2844
apply(auto)
+ − 2845
prefer 2
+ − 2846
using contains50 contains61a f_cont1 apply blast
+ − 2847
apply(case_tac a)
+ − 2848
apply(auto)
+ − 2849
by (metis contains60 fuse_append)
+ − 2850
+ − 2851
+ − 2852
+ − 2853
lemma contains65:
+ − 2854
assumes "bsimp_AALTs bs (flts rs) >> bs2"
+ − 2855
shows "\<exists>r \<in> set rs. (fuse bs r) >> bs2"
+ − 2856
using assms
+ − 2857
apply(induct rs arbitrary: bs bs2 taking: "\<lambda>rs. sum_list (map asize rs)" rule: measure_induct)
+ − 2858
apply(case_tac x)
+ − 2859
apply(auto elim: contains.cases)
+ − 2860
apply(case_tac list)
+ − 2861
apply(auto elim: contains.cases)
+ − 2862
apply(case_tac a)
+ − 2863
apply(auto elim: contains.cases)
+ − 2864
apply(drule contains61)
+ − 2865
apply(auto)
+ − 2866
apply (metis contains60 fuse_append)
+ − 2867
apply(case_tac lista)
+ − 2868
apply(auto elim: contains.cases)
+ − 2869
apply(subst (asm) k0)
+ − 2870
apply(drule contains62)
+ − 2871
apply(auto)
+ − 2872
apply(case_tac a)
+ − 2873
apply(auto elim: contains.cases)
+ − 2874
apply(case_tac x52)
+ − 2875
apply(auto elim: contains.cases)
+ − 2876
apply(case_tac list)
+ − 2877
apply(auto elim: contains.cases)
+ − 2878
apply (simp add: contains60 fuse_append)
+ − 2879
apply(erule contains.cases)
+ − 2880
apply(auto)
+ − 2881
apply (metis append.left_neutral contains0 contains60 fuse.simps(4) in_set_conv_decomp)
+ − 2882
apply(erule contains.cases)
+ − 2883
apply(auto)
+ − 2884
apply (metis contains0 contains60 fuse.simps(4) list.set_intros(1) list.set_intros(2))
+ − 2885
apply (simp add: contains.intros(5) contains63)
+ − 2886
apply(case_tac aa)
+ − 2887
apply(auto)
+ − 2888
apply (meson contains60 contains61 contains63)
+ − 2889
apply(subst (asm) k0)
+ − 2890
apply(drule contains64)
+ − 2891
apply(auto)[1]
+ − 2892
by (metis append_Nil2 bsimp_AALTs.simps(2) contains50 contains61a contains64 f_cont2 flts.simps(1))
+ − 2893
+ − 2894
+ − 2895
lemma contains55a:
+ − 2896
assumes "bsimp r >> bs"
+ − 2897
shows "r >> bs"
+ − 2898
using assms
+ − 2899
apply(induct r arbitrary: bs)
+ − 2900
apply(auto)
+ − 2901
apply(frule contains_SEQ1)
+ − 2902
apply(auto)
+ − 2903
apply (simp add: contains.intros(3))
+ − 2904
apply(frule f_cont2)
+ − 2905
apply(auto)
+ − 2906
apply(drule contains65)
+ − 2907
apply(auto)
+ − 2908
using contains0 contains49 contains60 by blast
+ − 2909
+ − 2910
+ − 2911
lemma PPP1_eq:
+ − 2912
shows "bsimp r >> bs \<longleftrightarrow> r >> bs"
+ − 2913
using contains55 contains55a by blast
+ − 2914
359
+ − 2915
+ − 2916
definition "SET a \<equiv> {bs . a >> bs}"
+ − 2917
+ − 2918
lemma "SET(bsimp a) \<subseteq> SET(a)"
+ − 2919
unfolding SET_def
+ − 2920
apply(auto simp add: PPP1_eq)
+ − 2921
done
+ − 2922
339
+ − 2923
lemma retrieve_code_bder:
+ − 2924
assumes "\<Turnstile> v : der c r"
+ − 2925
shows "code (injval r c v) = retrieve (bder c (intern r)) v"
+ − 2926
using assms
+ − 2927
by (simp add: Prf_injval bder_retrieve retrieve_code)
+ − 2928
+ − 2929
lemma Etrans:
+ − 2930
assumes "a >> s" "s = t"
+ − 2931
shows "a >> t"
+ − 2932
using assms by simp
+ − 2933
+ − 2934
+ − 2935
+ − 2936
lemma retrieve_code_bders:
+ − 2937
assumes "\<Turnstile> v : ders s r"
+ − 2938
shows "code (flex r id s v) = retrieve (bders (intern r) s) v"
+ − 2939
using assms
+ − 2940
apply(induct s arbitrary: v r rule: rev_induct)
+ − 2941
apply(auto simp add: ders_append flex_append bders_append)
+ − 2942
apply (simp add: retrieve_code)
+ − 2943
apply(frule Prf_injval)
+ − 2944
apply(drule_tac meta_spec)+
+ − 2945
apply(drule meta_mp)
+ − 2946
apply(assumption)
+ − 2947
apply(simp)
+ − 2948
apply(subst bder_retrieve)
+ − 2949
apply(simp)
+ − 2950
apply(simp)
+ − 2951
done
+ − 2952
+ − 2953
lemma contains70:
+ − 2954
assumes "s \<in> L(r)"
+ − 2955
shows "bders (intern r) s >> code (flex r id s (mkeps (ders s r)))"
+ − 2956
apply(subst PPP0_eq[symmetric])
+ − 2957
apply (meson assms lexer_correct_None lexer_correctness(1) lexer_flex)
+ − 2958
by (metis L07XX PPP0b assms erase_intern)
+ − 2959
+ − 2960
+ − 2961
359
+ − 2962
lemma PPP:
+ − 2963
assumes "\<Turnstile> v : r"
+ − 2964
shows "intern r >> (retrieve (intern r) v)"
+ − 2965
using assms
+ − 2966
using contains5 by blast
343
+ − 2967
+ − 2968
359
+ − 2969
+ − 2970
343
+ − 2971
+ − 2972
+ − 2973
+ − 2974
+ − 2975
definition FC where
+ − 2976
"FC a s v = retrieve a (flex (erase a) id s v)"
+ − 2977
+ − 2978
definition FE where
+ − 2979
"FE a s = retrieve a (flex (erase a) id s (mkeps (ders s (erase a))))"
339
+ − 2980
+ − 2981
definition PV where
+ − 2982
"PV r s v = flex r id s v"
+ − 2983
+ − 2984
definition PX where
+ − 2985
"PX r s = PV r s (mkeps (ders s r))"
+ − 2986
357
+ − 2987
343
+ − 2988
lemma FE_PX:
+ − 2989
shows "FE r s = retrieve r (PX (erase r) s)"
+ − 2990
unfolding FE_def PX_def PV_def by(simp)
+ − 2991
+ − 2992
lemma FE_PX_code:
+ − 2993
assumes "s \<in> L r"
+ − 2994
shows "FE (intern r) s = code (PX r s)"
+ − 2995
unfolding FE_def PX_def PV_def
+ − 2996
using assms
+ − 2997
by (metis L07XX Posix_Prf erase_intern retrieve_code)
+ − 2998
+ − 2999
339
+ − 3000
lemma PV_id[simp]:
+ − 3001
shows "PV r [] v = v"
+ − 3002
by (simp add: PV_def)
+ − 3003
+ − 3004
lemma PX_id[simp]:
+ − 3005
shows "PX r [] = mkeps r"
+ − 3006
by (simp add: PX_def)
+ − 3007
+ − 3008
lemma PV_cons:
+ − 3009
shows "PV r (c # s) v = injval r c (PV (der c r) s v)"
+ − 3010
apply(simp add: PV_def flex_fun_apply)
+ − 3011
done
+ − 3012
+ − 3013
lemma PX_cons:
+ − 3014
shows "PX r (c # s) = injval r c (PX (der c r) s)"
+ − 3015
apply(simp add: PX_def PV_cons)
+ − 3016
done
+ − 3017
+ − 3018
lemma PV_append:
+ − 3019
shows "PV r (s1 @ s2) v = PV r s1 (PV (ders s1 r) s2 v)"
+ − 3020
apply(simp add: PV_def flex_append)
+ − 3021
by (simp add: flex_fun_apply2)
+ − 3022
+ − 3023
lemma PX_append:
+ − 3024
shows "PX r (s1 @ s2) = PV r s1 (PX (ders s1 r) s2)"
+ − 3025
by (simp add: PV_append PX_def ders_append)
+ − 3026
+ − 3027
lemma code_PV0:
+ − 3028
shows "PV r (c # s) v = injval r c (PV (der c r) s v)"
+ − 3029
unfolding PX_def PV_def
+ − 3030
apply(simp)
+ − 3031
by (simp add: flex_injval)
+ − 3032
+ − 3033
lemma code_PX0:
+ − 3034
shows "PX r (c # s) = injval r c (PX (der c r) s)"
+ − 3035
unfolding PX_def
+ − 3036
apply(simp add: code_PV0)
+ − 3037
done
+ − 3038
+ − 3039
lemma Prf_PV:
+ − 3040
assumes "\<Turnstile> v : ders s r"
+ − 3041
shows "\<Turnstile> PV r s v : r"
+ − 3042
using assms unfolding PX_def PV_def
+ − 3043
apply(induct s arbitrary: v r)
+ − 3044
apply(simp)
+ − 3045
apply(simp)
+ − 3046
by (simp add: Prf_injval flex_injval)
+ − 3047
+ − 3048
+ − 3049
lemma Prf_PX:
+ − 3050
assumes "s \<in> L r"
+ − 3051
shows "\<Turnstile> PX r s : r"
+ − 3052
using assms unfolding PX_def PV_def
+ − 3053
using L1 LX0 Posix_Prf lexer_correct_Some by fastforce
+ − 3054
+ − 3055
lemma PV1:
+ − 3056
assumes "\<Turnstile> v : ders s r"
+ − 3057
shows "(intern r) >> code (PV r s v)"
+ − 3058
using assms
+ − 3059
by (simp add: Prf_PV contains2)
+ − 3060
+ − 3061
lemma PX1:
+ − 3062
assumes "s \<in> L r"
+ − 3063
shows "(intern r) >> code (PX r s)"
+ − 3064
using assms
+ − 3065
by (simp add: Prf_PX contains2)
+ − 3066
+ − 3067
lemma PX2:
+ − 3068
assumes "s \<in> L (der c r)"
+ − 3069
shows "bder c (intern r) >> code (injval r c (PX (der c r) s))"
+ − 3070
using assms
+ − 3071
by (simp add: Prf_PX contains6 retrieve_code_bder)
+ − 3072
+ − 3073
lemma PX2a:
+ − 3074
assumes "c # s \<in> L r"
+ − 3075
shows "bder c (intern r) >> code (injval r c (PX (der c r) s))"
+ − 3076
using assms
+ − 3077
using PX2 lexer_correct_None by force
+ − 3078
+ − 3079
lemma PX2b:
+ − 3080
assumes "c # s \<in> L r"
+ − 3081
shows "bder c (intern r) >> code (PX r (c # s))"
+ − 3082
using assms unfolding PX_def PV_def
+ − 3083
by (metis Der_def L07XX PV_def PX2a PX_def Posix_determ Posix_injval der_correctness erase_intern mem_Collect_eq)
+ − 3084
+ − 3085
lemma PV3:
+ − 3086
assumes "\<Turnstile> v : ders s r"
+ − 3087
shows "bders (intern r) s >> code (PV r s v)"
+ − 3088
using assms
+ − 3089
using PX_def PV_def contains70
+ − 3090
by (simp add: contains6 retrieve_code_bders)
+ − 3091
+ − 3092
lemma PX3:
+ − 3093
assumes "s \<in> L r"
+ − 3094
shows "bders (intern r) s >> code (PX r s)"
+ − 3095
using assms
+ − 3096
using PX_def PV_def contains70 by auto
+ − 3097
343
+ − 3098
339
+ − 3099
lemma PV_bders_iff:
+ − 3100
assumes "\<Turnstile> v : ders s r"
+ − 3101
shows "bders (intern r) s >> code (PV r s v) \<longleftrightarrow> (intern r) >> code (PV r s v)"
+ − 3102
by (simp add: PV1 PV3 assms)
+ − 3103
+ − 3104
lemma PX_bders_iff:
+ − 3105
assumes "s \<in> L r"
+ − 3106
shows "bders (intern r) s >> code (PX r s) \<longleftrightarrow> (intern r) >> code (PX r s)"
+ − 3107
by (simp add: PX1 PX3 assms)
+ − 3108
+ − 3109
lemma PX4:
+ − 3110
assumes "(s1 @ s2) \<in> L r"
+ − 3111
shows "bders (intern r) (s1 @ s2) >> code (PX r (s1 @ s2))"
+ − 3112
using assms
+ − 3113
by (simp add: PX3)
+ − 3114
+ − 3115
lemma PX_bders_iff2:
+ − 3116
assumes "(s1 @ s2) \<in> L r"
+ − 3117
shows "bders (intern r) (s1 @ s2) >> code (PX r (s1 @ s2)) \<longleftrightarrow>
+ − 3118
(intern r) >> code (PX r (s1 @ s2))"
+ − 3119
by (simp add: PX1 PX3 assms)
+ − 3120
+ − 3121
lemma PV_bders_iff3:
+ − 3122
assumes "\<Turnstile> v : ders (s1 @ s2) r"
+ − 3123
shows "bders (intern r) (s1 @ s2) >> code (PV r (s1 @ s2) v) \<longleftrightarrow>
+ − 3124
bders (intern r) s1 >> code (PV r (s1 @ s2) v)"
+ − 3125
by (metis PV3 PV_append Prf_PV assms ders_append)
+ − 3126
+ − 3127
+ − 3128
+ − 3129
lemma PX_bders_iff3:
+ − 3130
assumes "(s1 @ s2) \<in> L r"
+ − 3131
shows "bders (intern r) (s1 @ s2) >> code (PX r (s1 @ s2)) \<longleftrightarrow>
+ − 3132
bders (intern r) s1 >> code (PX r (s1 @ s2))"
+ − 3133
by (metis Ders_def L07XX PV_append PV_def PX4 PX_def Posix_Prf assms contains6 ders_append ders_correctness erase_bders erase_intern mem_Collect_eq retrieve_code_bders)
+ − 3134
+ − 3135
lemma PV_bder_iff:
+ − 3136
assumes "\<Turnstile> v : ders (s1 @ [c]) r"
+ − 3137
shows "bder c (bders (intern r) s1) >> code (PV r (s1 @ [c]) v) \<longleftrightarrow>
+ − 3138
bders (intern r) s1 >> code (PV r (s1 @ [c]) v)"
+ − 3139
by (simp add: PV_bders_iff3 assms bders_snoc)
+ − 3140
+ − 3141
lemma PV_bder_IFF:
+ − 3142
assumes "\<Turnstile> v : ders (s1 @ c # s2) r"
+ − 3143
shows "bder c (bders (intern r) s1) >> code (PV r (s1 @ c # s2) v) \<longleftrightarrow>
+ − 3144
bders (intern r) s1 >> code (PV r (s1 @ c # s2) v)"
+ − 3145
by (metis LA PV3 PV_def Prf_PV assms bders_append code_PV0 contains7 ders.simps(2) erase_bders erase_intern retrieve_code_bders)
+ − 3146
+ − 3147
+ − 3148
lemma PX_bder_iff:
+ − 3149
assumes "(s1 @ [c]) \<in> L r"
+ − 3150
shows "bder c (bders (intern r) s1) >> code (PX r (s1 @ [c])) \<longleftrightarrow>
+ − 3151
bders (intern r) s1 >> code (PX r (s1 @ [c]))"
+ − 3152
by (simp add: PX_bders_iff3 assms bders_snoc)
+ − 3153
+ − 3154
lemma PV_bder_iff2:
+ − 3155
assumes "\<Turnstile> v : ders (c # s1) r"
+ − 3156
shows "bders (bder c (intern r)) s1 >> code (PV r (c # s1) v) \<longleftrightarrow>
+ − 3157
bder c (intern r) >> code (PV r (c # s1) v)"
+ − 3158
by (metis PV3 Prf_PV assms bders.simps(2) code_PV0 contains7 ders.simps(2) erase_intern retrieve_code)
+ − 3159
+ − 3160
+ − 3161
lemma PX_bder_iff2:
+ − 3162
assumes "(c # s1) \<in> L r"
+ − 3163
shows "bders (bder c (intern r)) s1 >> code (PX r (c # s1)) \<longleftrightarrow>
+ − 3164
bder c (intern r) >> code (PX r (c # s1))"
+ − 3165
using PX2b PX3 assms by force
+ − 3166
343
+ − 3167
+ − 3168
lemma FC_id:
+ − 3169
shows "FC r [] v = retrieve r v"
+ − 3170
by (simp add: FC_def)
+ − 3171
+ − 3172
lemma FC_char:
+ − 3173
shows "FC r [c] v = retrieve r (injval (erase r) c v)"
+ − 3174
by (simp add: FC_def)
+ − 3175
+ − 3176
lemma FC_char2:
+ − 3177
assumes "\<Turnstile> v : der c (erase r)"
+ − 3178
shows "FC r [c] v = FC (bder c r) [] v"
+ − 3179
using assms
+ − 3180
by (simp add: FC_char FC_id bder_retrieve)
339
+ − 3181
343
+ − 3182
+ − 3183
lemma FC_bders_iff:
+ − 3184
assumes "\<Turnstile> v : ders s (erase r)"
+ − 3185
shows "bders r s >> FC r s v \<longleftrightarrow> r >> FC r s v"
+ − 3186
unfolding FC_def
+ − 3187
by (simp add: assms contains8_iff)
+ − 3188
+ − 3189
+ − 3190
lemma FC_bder_iff:
+ − 3191
assumes "\<Turnstile> v : der c (erase r)"
+ − 3192
shows "bder c r >> FC r [c] v \<longleftrightarrow> r >> FC r [c] v"
+ − 3193
apply(subst FC_bders_iff[symmetric])
+ − 3194
apply(simp add: assms)
+ − 3195
apply(simp)
+ − 3196
done
+ − 3197
357
+ − 3198
lemma FC_bders_iff2:
+ − 3199
assumes "\<Turnstile> v : ders (c # s) (erase r)"
+ − 3200
shows "bders r (c # s) >> FC r (c # s) v \<longleftrightarrow> bders (bder c r) s >> FC (bder c r) s v"
+ − 3201
apply(subst FC_bders_iff)
+ − 3202
using assms apply simp
+ − 3203
by (metis FC_def assms contains7b contains8_iff ders.simps(2) erase_bder)
+ − 3204
+ − 3205
343
+ − 3206
lemma FC_bnullable0:
+ − 3207
assumes "bnullable r"
+ − 3208
shows "FC r [] (mkeps (erase r)) = FC (bsimp r) [] (mkeps (erase (bsimp r)))"
+ − 3209
unfolding FC_def
+ − 3210
by (simp add: L0 assms)
+ − 3211
+ − 3212
+ − 3213
lemma FC_nullable2:
+ − 3214
assumes "bnullable (bders a s)"
+ − 3215
shows "FC (bsimp a) s (mkeps (erase (bders (bsimp a) s))) =
+ − 3216
FC (bders (bsimp a) s) [] (mkeps (erase (bders (bsimp a) s)))"
+ − 3217
unfolding FC_def
+ − 3218
using L02_bders assms by auto
+ − 3219
+ − 3220
lemma FC_nullable3:
+ − 3221
assumes "bnullable (bders a s)"
+ − 3222
shows "FC a s (mkeps (erase (bders a s))) =
+ − 3223
FC (bders a s) [] (mkeps (erase (bders a s)))"
+ − 3224
unfolding FC_def
+ − 3225
using LA assms bnullable_correctness mkeps_nullable by fastforce
+ − 3226
+ − 3227
+ − 3228
lemma FE_contains0:
+ − 3229
assumes "bnullable r"
+ − 3230
shows "r >> FE r []"
+ − 3231
by (simp add: FE_def assms bnullable_correctness contains6 mkeps_nullable)
+ − 3232
+ − 3233
lemma FE_contains1:
+ − 3234
assumes "bnullable (bders r s)"
+ − 3235
shows "r >> FE r s"
+ − 3236
by (metis FE_def Prf_flex assms bnullable_correctness contains6 erase_bders mkeps_nullable)
+ − 3237
+ − 3238
lemma FE_bnullable0:
+ − 3239
assumes "bnullable r"
+ − 3240
shows "FE r [] = FE (bsimp r) []"
+ − 3241
unfolding FE_def
+ − 3242
by (simp add: L0 assms)
+ − 3243
+ − 3244
+ − 3245
lemma FE_nullable1:
+ − 3246
assumes "bnullable (bders r s)"
+ − 3247
shows "FE r s = FE (bders r s) []"
+ − 3248
unfolding FE_def
+ − 3249
using LA assms bnullable_correctness mkeps_nullable by fastforce
+ − 3250
+ − 3251
lemma FE_contains2:
+ − 3252
assumes "bnullable (bders r s)"
+ − 3253
shows "r >> FE (bders r s) []"
+ − 3254
by (metis FE_contains1 FE_nullable1 assms)
+ − 3255
+ − 3256
lemma FE_contains3:
+ − 3257
assumes "bnullable (bder c r)"
+ − 3258
shows "r >> FE (bsimp (bder c r)) []"
+ − 3259
by (metis FE_def L0 assms bder_retrieve bders.simps(1) bnullable_correctness contains7a erase_bder erase_bders flex.simps(1) id_apply mkeps_nullable)
+ − 3260
+ − 3261
lemma FE_contains4:
+ − 3262
assumes "bnullable (bders r s)"
+ − 3263
shows "r >> FE (bsimp (bders r s)) []"
+ − 3264
using FE_bnullable0 FE_contains2 assms by auto
339
+ − 3265
343
+ − 3266
lemma FC4:
+ − 3267
assumes "\<Turnstile> v : ders s (erase a)"
+ − 3268
shows "FC a s v = FC (bders a s) [] v"
+ − 3269
unfolding FC_def by (simp add: LA assms)
+ − 3270
+ − 3271
lemma FC5:
+ − 3272
assumes "nullable (erase a)"
+ − 3273
shows "FC a [] (mkeps (erase a)) = FC (bsimp a) [] (mkeps (erase (bsimp a)))"
+ − 3274
unfolding FC_def
+ − 3275
using L0 assms bnullable_correctness by auto
+ − 3276
+ − 3277
+ − 3278
lemma in1:
+ − 3279
assumes "AALTs bsX rsX \<in> set rs"
+ − 3280
shows "\<forall>r \<in> set rsX. fuse bsX r \<in> set (flts rs)"
+ − 3281
using assms
+ − 3282
apply(induct rs arbitrary: bsX rsX)
+ − 3283
apply(auto)
+ − 3284
by (metis append_assoc in_set_conv_decomp k0)
+ − 3285
+ − 3286
lemma in2a:
+ − 3287
assumes "nonnested (bsimp r)" "\<not>nonalt(bsimp r)"
+ − 3288
shows "(\<exists>bsX rsX. r = AALTs bsX rsX) \<or> (\<exists>bsX rX1 rX2. r = ASEQ bsX rX1 rX2 \<and> bnullable rX1)"
+ − 3289
using assms
+ − 3290
apply(induct r)
+ − 3291
apply(auto)
+ − 3292
by (metis arexp.distinct(25) b3 bnullable.simps(2) bsimp_ASEQ.simps(1) bsimp_ASEQ0 bsimp_ASEQ1 nonalt.elims(3) nonalt.simps(2))
356
+ − 3293
+ − 3294
+ − 3295
lemma [simp]:
+ − 3296
shows "size (fuse bs r) = size r"
+ − 3297
by (induct r) (auto)
+ − 3298
+ − 3299
fun AALTs_subs where
+ − 3300
"AALTs_subs (AZERO) = {}"
+ − 3301
| "AALTs_subs (AONE bs) = {AONE bs}"
+ − 3302
| "AALTs_subs (ACHAR bs c) = {ACHAR bs c}"
+ − 3303
| "AALTs_subs (ASEQ bs r1 r2) = {ASEQ bs r1 r2}"
+ − 3304
| "AALTs_subs (ASTAR bs r) = {ASTAR bs r}"
+ − 3305
| "AALTs_subs (AALTs bs []) = {}"
+ − 3306
| "AALTs_subs (AALTs bs (r#rs)) = AALTs_subs (fuse bs r) \<union> AALTs_subs (AALTs bs rs)"
+ − 3307
+ − 3308
lemma nonalt_10:
+ − 3309
assumes "nonalt r" "r \<noteq> AZERO"
+ − 3310
shows "r \<in> AALTs_subs r"
+ − 3311
using assms
+ − 3312
apply(induct r)
+ − 3313
apply(auto)
+ − 3314
done
+ − 3315
+ − 3316
lemma flt_fuse:
+ − 3317
shows "flts (map (fuse bs) rs) = map (fuse bs) (flts rs)"
+ − 3318
apply(induct rs arbitrary: bs rule: flts.induct)
+ − 3319
apply(auto)
+ − 3320
by (simp add: fuse_append)
+ − 3321
+ − 3322
lemma AALTs_subs_fuse:
+ − 3323
shows "AALTs_subs (fuse bs r) = (fuse bs) ` (AALTs_subs r)"
+ − 3324
apply(induct r arbitrary: bs rule: AALTs_subs.induct)
+ − 3325
apply(auto)
+ − 3326
apply (simp add: fuse_append)
+ − 3327
apply blast
+ − 3328
by (simp add: fuse_append)
+ − 3329
+ − 3330
lemma AALTs_subs_fuse2:
+ − 3331
shows "AALTs_subs (AALTs bs rs) = AALTs_subs (AALTs [] (map (fuse bs) rs))"
+ − 3332
apply(induct rs arbitrary: bs)
+ − 3333
apply(auto)
+ − 3334
apply (auto simp add: fuse_empty)
+ − 3335
done
+ − 3336
+ − 3337
lemma fuse_map:
+ − 3338
shows "map (fuse (bs1 @ bs2)) rs = map (fuse bs1) (map (fuse bs2) rs)"
+ − 3339
apply(induct rs)
+ − 3340
apply(auto)
+ − 3341
using fuse_append by blast
343
+ − 3342
+ − 3343
356
+ − 3344
+ − 3345
lemma contains59_2:
+ − 3346
assumes "AALTs bs rs >> bs2"
+ − 3347
shows "\<exists>r\<in>AALTs_subs (AALTs bs rs). r >> bs2"
+ − 3348
using assms
+ − 3349
apply(induct rs arbitrary: bs bs2 taking: "\<lambda>rs. sum_list (map asize rs)" rule: measure_induct)
+ − 3350
apply(case_tac x)
+ − 3351
apply(auto)
+ − 3352
using contains59 apply force
+ − 3353
apply(erule contains.cases)
+ − 3354
apply(auto)
+ − 3355
apply(case_tac "r = AZERO")
+ − 3356
apply(simp)
+ − 3357
apply (metis bsimp_AALTs.simps(1) contains61 empty_iff empty_set)
+ − 3358
apply(case_tac "nonalt r")
+ − 3359
apply (metis UnCI bsimp_AALTs.simps(1) contains0 contains61 empty_iff empty_set nn11a nonalt_10)
+ − 3360
apply(subgoal_tac "\<exists>bsX rsX. r = AALTs bsX rsX")
+ − 3361
prefer 2
+ − 3362
using bbbbs1 apply blast
+ − 3363
apply(auto)
+ − 3364
apply (metis UnCI contains0 fuse.simps(4) less_add_Suc1)
+ − 3365
apply(drule_tac x="rs" in spec)
+ − 3366
apply(drule mp)
+ − 3367
apply(simp add: asize0)
+ − 3368
apply(drule_tac x="bsa" in spec)
+ − 3369
apply(drule_tac x="bsa @ bs1" in spec)
+ − 3370
apply(auto)
+ − 3371
done
+ − 3372
+ − 3373
lemma TEMPLATE_contains61a:
+ − 3374
assumes "\<exists>r \<in> set rs. (fuse bs r) >> bs2"
+ − 3375
shows "bsimp_AALTs bs rs >> bs2"
+ − 3376
using assms
+ − 3377
apply(induct rs arbitrary: bs2 bs)
+ − 3378
apply(auto)
+ − 3379
apply (metis bsimp_AALTs.elims contains60 list.distinct(1) list.inject list.set_intros(1))
+ − 3380
by (metis append_Cons append_Nil contains50 f_cont2)
+ − 3381
+ − 3382
+ − 3383
+ − 3384
+ − 3385
lemma H1:
+ − 3386
assumes "r >> bs2" "r \<in> AALTs_subs a"
+ − 3387
shows "a >> bs2"
+ − 3388
using assms
+ − 3389
apply(induct a arbitrary: r bs2 rule: AALTs_subs.induct)
+ − 3390
apply(auto)
+ − 3391
apply (simp add: contains60)
+ − 3392
by (simp add: contains59 contains60)
+ − 3393
+ − 3394
lemma H3:
+ − 3395
assumes "a >> bs"
+ − 3396
shows "\<exists>r \<in> AALTs_subs a. r >> bs"
+ − 3397
using assms
+ − 3398
apply(induct a bs)
+ − 3399
apply(auto intro: contains.intros)
+ − 3400
using contains.intros(4) contains59_2 by fastforce
+ − 3401
+ − 3402
lemma H4:
+ − 3403
shows "AALTs_subs (AALTs bs rs1) \<subseteq> AALTs_subs (AALTs bs (rs1 @ rs2))"
+ − 3404
apply(induct rs1)
+ − 3405
apply(auto)
+ − 3406
done
+ − 3407
+ − 3408
lemma H5:
+ − 3409
shows "AALTs_subs (AALTs bs rs2) \<subseteq> AALTs_subs (AALTs bs (rs1 @ rs2))"
+ − 3410
apply(induct rs1)
+ − 3411
apply(auto)
+ − 3412
done
+ − 3413
+ − 3414
lemma H7:
+ − 3415
shows "AALTs_subs (AALTs bs (rs1 @ rs2)) = AALTs_subs (AALTs bs rs1) \<union> AALTs_subs (AALTs bs rs2)"
+ − 3416
apply(induct rs1)
+ − 3417
apply(auto)
+ − 3418
done
+ − 3419
+ − 3420
lemma H10:
+ − 3421
shows "AALTs_subs (AALTs bs rs) = (\<Union>r \<in> set rs. AALTs_subs (fuse bs r))"
+ − 3422
apply(induct rs arbitrary: bs)
+ − 3423
apply(auto)
+ − 3424
done
+ − 3425
+ − 3426
lemma H6:
+ − 3427
shows "AALTs_subs (AALTs bs (flts rs)) = AALTs_subs (AALTs bs rs)"
+ − 3428
apply(induct rs arbitrary: bs rule: flts.induct)
+ − 3429
apply(auto)
+ − 3430
apply (metis AALTs_subs_fuse2 H7 Un_iff fuse_map)
+ − 3431
apply (metis AALTs_subs_fuse2 H7 UnCI fuse_map)
+ − 3432
by (simp add: H7)
+ − 3433
357
+ − 3434
356
+ − 3435
+ − 3436
lemma H2:
+ − 3437
assumes "r >> bs2" "r \<in> AALTs_subs (AALTs bs rs)"
+ − 3438
shows "r \<in> AALTs_subs (AALTs bs (flts rs))"
+ − 3439
using assms
+ − 3440
apply(induct rs arbitrary: r bs bs2 rule: flts.induct)
+ − 3441
apply(auto)
+ − 3442
apply (metis AALTs_subs_fuse2 H4 fuse_map in_mono)
+ − 3443
using H7 by blast
+ − 3444
+ − 3445
lemma HH1:
+ − 3446
assumes "r \<in> AALTs_subs (fuse bs a)" "r >> bs2"
+ − 3447
shows "\<exists>bs3. bs2 = bs @ bs3"
+ − 3448
using assms
+ − 3449
using H1 f_cont1 by blast
+ − 3450
+ − 3451
lemma fuse_inj:
+ − 3452
assumes "fuse bs a = fuse bs b"
+ − 3453
shows "a = b"
+ − 3454
using assms
+ − 3455
apply(induct a arbitrary: bs b)
+ − 3456
apply(auto)
+ − 3457
apply(case_tac b)
+ − 3458
apply(auto)
+ − 3459
apply(case_tac b)
+ − 3460
apply(auto)
+ − 3461
apply(case_tac b)
+ − 3462
apply(auto)
+ − 3463
apply(case_tac b)
+ − 3464
apply(auto)
+ − 3465
apply(case_tac b)
+ − 3466
apply(auto)
+ − 3467
apply(case_tac b)
+ − 3468
apply(auto)
+ − 3469
done
+ − 3470
+ − 3471
lemma HH11:
+ − 3472
assumes "r \<in> AALTs_subs (fuse bs1 a)"
+ − 3473
shows "fuse bs r \<in> AALTs_subs (fuse (bs @ bs1) a)"
+ − 3474
using assms
+ − 3475
apply(induct a arbitrary: r bs bs1)
+ − 3476
apply(auto)
+ − 3477
apply(subst (asm) H10)
+ − 3478
apply(auto)
+ − 3479
apply(drule_tac x="x" in meta_spec)
+ − 3480
apply(simp)
+ − 3481
apply(drule_tac x="r" in meta_spec)
+ − 3482
apply(drule_tac x="bs" in meta_spec)
+ − 3483
apply(drule_tac x="bs1 @ x1" in meta_spec)
+ − 3484
apply(simp)
+ − 3485
apply(subst H10)
+ − 3486
apply(auto)
+ − 3487
done
+ − 3488
+ − 3489
lemma HH12:
+ − 3490
assumes "r \<in> AALTs_subs a"
+ − 3491
shows "fuse bs r \<in> AALTs_subs (fuse bs a)"
+ − 3492
using AALTs_subs_fuse assms by blast
+ − 3493
+ − 3494
lemma HH13:
+ − 3495
assumes "r \<in> (\<Union>r \<in> set rs. AALTs_subs r)"
+ − 3496
shows "fuse bs r \<in> AALTs_subs (AALTs bs rs)"
+ − 3497
using assms
+ − 3498
using H10 HH12 by blast
+ − 3499
+ − 3500
+ − 3501
lemma contains61a_2:
+ − 3502
assumes "\<exists>r\<in>AALTs_subs (AALTs bs rs). r >> bs2"
+ − 3503
shows "bsimp_AALTs bs rs >> bs2"
+ − 3504
using assms
+ − 3505
apply(induct rs arbitrary: bs2 bs)
+ − 3506
apply(auto)
+ − 3507
apply (simp add: H1 TEMPLATE_contains61a)
+ − 3508
by (metis append_Cons append_Nil contains50 f_cont2)
+ − 3509
+ − 3510
lemma contains_equiv_def2:
+ − 3511
shows " (AALTs bs as >> bs@bs1) \<longleftrightarrow> (\<exists>a\<in>(\<Union> (AALTs_subs ` set as)). a >> bs1)"
+ − 3512
by (metis H1 H3 UN_E UN_I contains0 contains49 contains59 contains60)
+ − 3513
+ − 3514
lemma contains_equiv_def:
357
+ − 3515
shows "(AALTs bs as >> bs@bs1) \<longleftrightarrow> (\<exists>a\<in>set as. a >> bs1)"
356
+ − 3516
by (meson contains0 contains49 contains59 contains60)
+ − 3517
357
+ − 3518
lemma map_fuse2:
+ − 3519
shows "map (bder c) (map (fuse bs) as) = map (fuse bs) (map (bder c) as)"
+ − 3520
by (simp add: map_bder_fuse)
+ − 3521
+ − 3522
lemma map_fuse3:
+ − 3523
shows "map (\<lambda>a. bders a s) (map (fuse bs) as) = map (fuse bs) (map (\<lambda>a. bders a s) as)"
+ − 3524
apply(induct s arbitrary: bs as rule: rev_induct)
+ − 3525
apply(auto simp add: bders_append map_fuse2)
+ − 3526
using bder_fuse by blast
+ − 3527
+ − 3528
lemma bders_AALTs:
+ − 3529
shows "bders (AALTs bs2 as) s = AALTs bs2 (map (\<lambda>a. bders a s) as)"
+ − 3530
apply(induct s arbitrary: bs2 as rule: rev_induct)
+ − 3531
apply(auto simp add: bders_append)
+ − 3532
done
+ − 3533
+ − 3534
lemma bders_AALTs_contains:
+ − 3535
shows "bders (AALTs bs2 as) s >> bs2 @ bs \<longleftrightarrow>
+ − 3536
AALTs bs2 (map (\<lambda>a. bders a s) as) >> bs2 @ bs"
+ − 3537
apply(induct s arbitrary: bs bs2 as)
+ − 3538
apply(auto)[1]
+ − 3539
apply(simp)
+ − 3540
by (smt comp_apply map_eq_conv)
+ − 3541
+ − 3542
+ − 3543
lemma derc_alt00_Urb:
+ − 3544
shows "bder c (bsimp_AALTs bs2 (flts [bsimp a])) >> bs2 @ bs \<longleftrightarrow>
+ − 3545
fuse bs2 (bder c (bsimp a)) >> bs2 @ bs"
356
+ − 3546
apply(case_tac "bsimp a")
357
+ − 3547
apply(auto)
+ − 3548
apply(subst (asm) bder_bsimp_AALTs)
+ − 3549
apply(subst (asm) map_fuse2)
+ − 3550
using contains60 contains61 contains63 apply blast
+ − 3551
by (metis bder_bsimp_AALTs contains51c map_bder_fuse map_map)
+ − 3552
+ − 3553
lemma ders_alt00_Urb:
+ − 3554
shows "bders (bsimp_AALTs bs2 (flts [bsimp a])) s >> bs2 @ bs \<longleftrightarrow>
+ − 3555
fuse bs2 (bders (bsimp a) s) >> bs2 @ bs"
+ − 3556
apply(case_tac "bsimp a")
+ − 3557
apply (simp add: bders_AZERO(1))
+ − 3558
using bders_fuse bsimp_AALTs.simps(2) flts.simps(1) flts.simps(4) apply presburger
+ − 3559
using bders_fuse bsimp_AALTs.simps(2) flts.simps(1) flts.simps(5) apply presburger
+ − 3560
using bders_fuse bsimp_AALTs.simps(2) flts.simps(1) flts.simps(6) apply presburger
+ − 3561
prefer 2
+ − 3562
using bders_fuse bsimp_AALTs.simps(2) flts.simps(1) flts.simps(7) apply presburger
+ − 3563
apply(auto simp add: bders_bsimp_AALTs)
+ − 3564
apply(drule contains61)
+ − 3565
apply(auto simp add: bders_AALTs)
+ − 3566
apply(rule contains63)
+ − 3567
apply(rule contains60)
+ − 3568
apply(auto)
+ − 3569
using bders_fuse apply auto[1]
+ − 3570
by (metis contains51c map_fuse3 map_map)
+ − 3571
+ − 3572
lemma derc_alt00_Urb2a:
+ − 3573
shows "bder c (bsimp_AALTs bs2 (flts [bsimp a])) >> bs2 @ bs \<longleftrightarrow>
+ − 3574
bder c (bsimp a) >> bs"
+ − 3575
using contains0 contains49 derc_alt00_Urb by blast
+ − 3576
+ − 3577
+ − 3578
lemma derc_alt00_Urb2:
+ − 3579
assumes "fuse bs2 (bder c (bsimp a)) >> bs2 @ bs" "a \<in> set as"
+ − 3580
shows "bder c (bsimp_AALTs bs2 (flts (map bsimp as))) >> bs2 @ bs"
356
+ − 3581
using assms
+ − 3582
apply(subgoal_tac "\<exists>list1 list2. as = list1 @ [a] @ list2")
+ − 3583
prefer 2
+ − 3584
using split_list_last apply fastforce
+ − 3585
apply(erule exE)+
357
+ − 3586
apply(simp add: flts_append del: append.simps)
+ − 3587
using bder_bsimp_AALTs contains50 contains51b derc_alt00_Urb by auto
+ − 3588
+ − 3589
lemma ders_alt00_Urb2:
+ − 3590
assumes "fuse bs2 (bders (bsimp a) s) >> bs2 @ bs" "a \<in> set as"
+ − 3591
shows "bders (bsimp_AALTs bs2 (flts (map bsimp as))) s >> bs2 @ bs"
+ − 3592
using assms
+ − 3593
apply(subgoal_tac "\<exists>list1 list2. as = list1 @ [a] @ list2")
+ − 3594
prefer 2
+ − 3595
using split_list_last apply fastforce
+ − 3596
apply(erule exE)+
+ − 3597
apply(simp add: flts_append del: append.simps)
+ − 3598
apply(simp add: bders_bsimp_AALTs)
+ − 3599
apply(rule contains50)
+ − 3600
apply(rule contains51b)
+ − 3601
using bders_bsimp_AALTs ders_alt00_Urb by auto
+ − 3602
+ − 3603
356
+ − 3604
lemma derc_alt2:
+ − 3605
assumes "bder c (AALTs bs2 as) >> bs2 @ bs"
+ − 3606
and "\<forall>a \<in> set as. ((bder c a >> bs) \<longrightarrow> (bder c (bsimp a) >> bs))"
+ − 3607
shows "bder c (bsimp (AALTs bs2 as)) >> bs2 @ bs"
+ − 3608
using assms
357
+ − 3609
apply -
+ − 3610
apply(simp)
+ − 3611
apply(subst (asm) contains_equiv_def)
+ − 3612
apply(simp)
+ − 3613
apply(erule bexE)
+ − 3614
using contains0 derc_alt00_Urb2 by blast
+ − 3615
+ − 3616
+ − 3617
+ − 3618
lemma ders_alt2:
+ − 3619
assumes "bders (AALTs bs2 as) s >> bs2 @ bs"
+ − 3620
and "\<forall>a \<in> set as. ((bders a s >> bs) \<longrightarrow> (bders (bsimp a) s >> bs))"
+ − 3621
shows "bders (bsimp (AALTs bs2 as)) s >> bs2 @ bs"
356
+ − 3622
using assms
357
+ − 3623
apply -
+ − 3624
apply(simp add: bders_AALTs)
+ − 3625
thm contains_equiv_def
+ − 3626
apply(subst (asm) contains_equiv_def)
+ − 3627
apply(simp)
+ − 3628
apply(erule bexE)
+ − 3629
using contains0 ders_alt00_Urb2 by blast
+ − 3630
+ − 3631
+ − 3632
356
+ − 3633
+ − 3634
lemma bder_simp_contains:
343
+ − 3635
assumes "bder c a >> bs"
+ − 3636
shows "bder c (bsimp a) >> bs"
+ − 3637
using assms
+ − 3638
apply(induct a arbitrary: c bs)
+ − 3639
apply(auto elim: contains.cases)
+ − 3640
apply(case_tac "bnullable a1")
+ − 3641
apply(simp)
+ − 3642
prefer 2
+ − 3643
apply(simp)
+ − 3644
apply(erule contains.cases)
+ − 3645
apply(auto)
+ − 3646
apply(case_tac "(bsimp a1) = AZERO")
+ − 3647
apply(simp)
+ − 3648
apply (metis append_Nil2 contains0 contains49 fuse.simps(1))
+ − 3649
apply(case_tac "(bsimp a2a) = AZERO")
+ − 3650
apply(simp)
+ − 3651
apply (metis bder.simps(1) bsimp.simps(1) bsimp_ASEQ0 contains.intros(3) contains55)
+ − 3652
apply(case_tac "\<exists>bsX. (bsimp a1) = AONE bsX")
+ − 3653
apply(auto)[1]
+ − 3654
using b3 apply fastforce
+ − 3655
apply(subst bsimp_ASEQ1)
+ − 3656
apply(auto)[3]
+ − 3657
apply(simp)
+ − 3658
apply(subgoal_tac "\<not> bnullable (bsimp a1)")
+ − 3659
prefer 2
+ − 3660
using b3 apply blast
+ − 3661
apply(simp)
+ − 3662
apply (simp add: contains.intros(3) contains55)
+ − 3663
(* SEQ nullable case *)
+ − 3664
apply(erule contains.cases)
+ − 3665
apply(auto)
+ − 3666
apply(erule contains.cases)
+ − 3667
apply(auto)
+ − 3668
apply(case_tac "(bsimp a1) = AZERO")
+ − 3669
apply(simp)
+ − 3670
apply (metis append_Nil2 contains0 contains49 fuse.simps(1))
+ − 3671
apply(case_tac "(bsimp a2a) = AZERO")
+ − 3672
apply(simp)
+ − 3673
apply (metis bder.simps(1) bsimp.simps(1) bsimp_ASEQ0 contains.intros(3) contains55)
+ − 3674
apply(case_tac "\<exists>bsX. (bsimp a1) = AONE bsX")
+ − 3675
apply(auto)[1]
+ − 3676
using contains.simps apply blast
+ − 3677
apply(subst bsimp_ASEQ1)
+ − 3678
apply(auto)[3]
+ − 3679
apply(simp)
+ − 3680
apply(subgoal_tac "bnullable (bsimp a1)")
+ − 3681
prefer 2
+ − 3682
using b3 apply blast
+ − 3683
apply(simp)
+ − 3684
apply (metis contains.intros(3) contains.intros(4) contains55 self_append_conv2)
+ − 3685
apply(erule contains.cases)
+ − 3686
apply(auto)
+ − 3687
apply(case_tac "(bsimp a1) = AZERO")
+ − 3688
apply(simp)
+ − 3689
using b3 apply force
+ − 3690
apply(case_tac "(bsimp a2) = AZERO")
+ − 3691
apply(simp)
+ − 3692
apply (metis bder.simps(1) bsimp_ASEQ0 bsimp_ASEQ_fuse contains0 contains49 f_cont1)
+ − 3693
apply(case_tac "\<exists>bsX. (bsimp a1) = AONE bsX")
+ − 3694
apply(auto)[1]
+ − 3695
apply (metis append_assoc bder_fuse bmkeps.simps(1) bmkeps_simp bsimp_ASEQ2 contains0 contains49 f_cont1)
+ − 3696
apply(subst bsimp_ASEQ1)
+ − 3697
apply(auto)[3]
+ − 3698
apply(simp)
+ − 3699
apply(subgoal_tac "bnullable (bsimp a1)")
+ − 3700
prefer 2
+ − 3701
using b3 apply blast
+ − 3702
apply(simp)
+ − 3703
apply (metis bmkeps_simp contains.intros(4) contains.intros(5) contains0 contains49 f_cont1)
+ − 3704
apply(erule contains.cases)
+ − 3705
apply(auto)
+ − 3706
(* ALT case *)
356
+ − 3707
apply(subgoal_tac "\<exists>bsX. bs = x1 @ bsX")
+ − 3708
prefer 2
+ − 3709
using contains59 f_cont1 apply blast
343
+ − 3710
apply(auto)
356
+ − 3711
apply(rule derc_alt2[simplified])
+ − 3712
apply(simp)
+ − 3713
by blast
357
+ − 3714
356
+ − 3715
357
+ − 3716
+ − 3717
lemma bder_simp_containsA:
+ − 3718
assumes "bder c a >> bs"
+ − 3719
shows "bsimp (bder c (bsimp a)) >> bs"
+ − 3720
using assms
+ − 3721
by (simp add: bder_simp_contains contains55)
+ − 3722
+ − 3723
lemma bder_simp_containsB:
+ − 3724
assumes "bsimp (bder c a) >> bs"
+ − 3725
shows "bder c (bsimp a) >> bs"
+ − 3726
using assms
+ − 3727
by (simp add: PPP1_eq bder_simp_contains)
+ − 3728
+ − 3729
lemma bder_simp_contains_IFF:
+ − 3730
assumes "good a"
+ − 3731
shows "bsimp (bder c a) >> bs \<longleftrightarrow> bder c (bsimp a) >> bs"
+ − 3732
using assms
+ − 3733
by (simp add: PPP1_eq test2)
+ − 3734
+ − 3735
+ − 3736
lemma ders_seq:
+ − 3737
assumes "bders (ASEQ bs a1 a2) s >> bs @ bs2"
+ − 3738
and "\<And>s bs. bders a1 s >> bs \<Longrightarrow> bders (bsimp a1) s >> bs"
+ − 3739
"\<And>s bs. bders a2 s >> bs \<Longrightarrow> bders (bsimp a2) s >> bs"
+ − 3740
shows "bders (ASEQ bs (bsimp a1) (bsimp a2)) s >> bs @ bs2"
+ − 3741
using assms(1)
+ − 3742
apply(induct s arbitrary: a1 a2 bs bs2 rule: rev_induct)
+ − 3743
apply(auto)[1]
+ − 3744
thm CT1_SEQ PPP1_eq
+ − 3745
apply (metis CT1_SEQ PPP1_eq)
+ − 3746
apply(auto simp add: bders_append)
+ − 3747
apply(drule bder_simp_contains)
+ − 3748
oops
+ − 3749
+ − 3750
+ − 3751
lemma bders_simp_contains:
+ − 3752
assumes "bders a s >> bs"
+ − 3753
shows "bders (bsimp a) s >> bs"
+ − 3754
using assms
+ − 3755
apply(induct a arbitrary: s bs)
+ − 3756
apply(auto elim: contains.cases)[4]
+ − 3757
prefer 2
+ − 3758
apply(subgoal_tac "\<exists>bsX. bs = x1 @ bsX")
+ − 3759
prefer 2
+ − 3760
apply (metis bders_AALTs contains59 f_cont1)
+ − 3761
apply(clarify)
+ − 3762
apply(rule ders_alt2)
+ − 3763
apply(assumption)
+ − 3764
apply(auto)[1]
+ − 3765
prefer 2
+ − 3766
apply simp
+ − 3767
(* SEQ case *)
+ − 3768
apply(case_tac "bsimp a1 = AZERO")
+ − 3769
apply(simp)
+ − 3770
apply (metis LLLL(1) bders_AZERO(1) bsimp.simps(1) bsimp.simps(3) bsimp_ASEQ.simps(1) contains55 ders_correctness erase_bders good.simps(1) good1a xxx_bder2)
+ − 3771
apply(case_tac "bsimp a2 = AZERO")
+ − 3772
apply(simp)
+ − 3773
apply (metis LLLL(1) bders_AZERO(1) bsimp.simps(1) bsimp.simps(3) bsimp_ASEQ0 contains55 ders_correctness erase_bders good.simps(1) good1a xxx_bder2)
+ − 3774
apply(case_tac "\<exists>bsX. bsimp a1 = AONE bsX")
+ − 3775
apply(auto)
+ − 3776
apply(subst bsimp_ASEQ2)
+ − 3777
apply(case_tac s)
+ − 3778
apply(simp)
+ − 3779
apply (metis b1 bsimp.simps(1) contains55)
+ − 3780
apply(simp)
+ − 3781
apply(subgoal_tac "bnullable a1")
+ − 3782
prefer 2
+ − 3783
using b3 apply fastforce
+ − 3784
apply(auto)
+ − 3785
apply(subst (asm) bders_AALTs)
+ − 3786
apply(erule contains.cases)
+ − 3787
apply(auto)
+ − 3788
prefer 2
+ − 3789
apply(erule contains.cases)
+ − 3790
apply(auto)
+ − 3791
apply(simp add: fuse_append)
+ − 3792
apply(simp add: bder_fuse bders_fuse)
+ − 3793
apply (metis bders.simps(2) bmkeps.simps(1) bmkeps_simp contains0 contains49 f_cont1)
+ − 3794
using contains_equiv_def apply auto[1]
+ − 3795
apply(simp add: bder_fuse bders_fuse fuse_append)
+ − 3796
apply(rule contains0)
+ − 3797
oops
+ − 3798
+ − 3799
+ − 3800
lemma T0:
+ − 3801
assumes "s = []"
+ − 3802
shows "bders (bsimp r) s >> bs \<longleftrightarrow> bders r s >> bs"
+ − 3803
using assms
+ − 3804
by (simp add: PPP1_eq test2)
+ − 3805
+ − 3806
lemma T1:
+ − 3807
assumes "s = [a]" "bders r s >> bs"
+ − 3808
shows "bders (bsimp r) s >> bs"
343
+ − 3809
using assms
357
+ − 3810
apply(simp)
+ − 3811
by (simp add: bder_simp_contains)
+ − 3812
+ − 3813
lemma TX:
+ − 3814
assumes "\<Turnstile> v : ders s (erase r)" "\<Turnstile> v : ders s (erase (bsimp r))"
+ − 3815
shows "bders r s >> FC r s v \<longleftrightarrow> bders (bsimp r) s >> FC (bsimp r) s v"
+ − 3816
using FC_def contains7b
+ − 3817
using assms by metis
+ − 3818
+ − 3819
lemma mkeps1:
+ − 3820
assumes "s \<in> L (erase r)"
+ − 3821
shows "\<Turnstile> mkeps (ders s (erase r)) : ders s (erase r)"
+ − 3822
using assms
+ − 3823
by (meson lexer_correct_None lexer_flex mkeps_nullable)
+ − 3824
+ − 3825
lemma mkeps2:
+ − 3826
assumes "s \<in> L (erase r)"
+ − 3827
shows "\<Turnstile> mkeps (ders s (erase (bsimp r))) : ders s (erase (bsimp r))"
+ − 3828
using assms
+ − 3829
by (metis LLLL(1) lexer_correct_None lexer_flex mkeps_nullable)
+ − 3830
+ − 3831
thm FC_def FE_def PX_def PV_def
+ − 3832
+ − 3833
+ − 3834
lemma TX2:
+ − 3835
assumes "s \<in> L (erase r)"
+ − 3836
shows "bders r s >> FE r s \<longleftrightarrow> bders (bsimp r) s >> FE (bsimp r) s"
+ − 3837
using assms
+ − 3838
by (simp add: FE_def contains7b mkeps1 mkeps2)
+ − 3839
+ − 3840
lemma TX3:
+ − 3841
assumes "s \<in> L (erase r)"
+ − 3842
shows "bders r s >> FE r s \<longleftrightarrow> bders (bsimp r) s >> FE (bders (bsimp r) s) []"
343
+ − 3843
using assms
357
+ − 3844
by (metis FE_PX FE_def L07 LLLL(1) PX_id TX2)
+ − 3845
+ − 3846
find_theorems "FE _ _ = _"
+ − 3847
find_theorems "FC _ _ _ = _"
+ − 3848
find_theorems "(bder _ _ >> _ _ _ _) = _"
+ − 3849
+ − 3850
+ − 3851
(* HERE *)
+ − 3852
+ − 3853
lemma PX:
359
+ − 3854
assumes "s \<in> L r" "bders (intern r) s >> code (PX r s)"
+ − 3855
shows "bders (bsimp (intern r)) s >> code (PX r s)"
+ − 3856
using assms
+ − 3857
apply(induct s arbitrary: r rule: rev_induct)
357
+ − 3858
apply(simp)
359
+ − 3859
apply (simp add: PPP1_eq)
+ − 3860
apply (simp add: bders_append bders_simp_append)
+ − 3861
thm PX_bder_iff PX_bders_iff
+ − 3862
apply(subst (asm) PX_bder_iff)
+ − 3863
apply(assumption)
+ − 3864
apply(subst (asm) (2) PX_bders_iff)
+ − 3865
find_theorems "_ >> code (PX _ _)"
+ − 3866
find_theorems "PX _ _ = _"
+ − 3867
find_theorems "(intern _) >> _"
357
+ − 3868
apply (simp add: contains55)
+ − 3869
apply (simp add: bders_append bders_simp_append)
+ − 3870
apply (simp add: PPP1_eq)
+ − 3871
find_theorems "(bder _ _ >> _) = _"
+ − 3872
apply(rule contains50)
+ − 3873
+ − 3874
apply(case_tac "bders a xs = AZERO")
+ − 3875
apply(simp)
+ − 3876
apply(subgoal_tac "bders_simp a xs = AZERO")
+ − 3877
prefer 2
+ − 3878
apply (metis L_bders_simp XXX4a_good_cons bders.simps(1) bders_simp.simps(1) bsimp.simps(3) good.simps(1) good1a test2 xxx_bder2)
+ − 3879
apply(simp)
+ − 3880
apply(case_tac xs)
+ − 3881
apply(simp)
+ − 3882
apply (simp add: PPP1_eq)
+ − 3883
apply(simp)
+ − 3884
apply(subgoal_tac "good (bders_simp a (aa # list)) \<or> (bders_simp a (aa # list) = AZERO)")
+ − 3885
apply(auto)
+ − 3886
apply(subst (asm) bder_simp_contains_IFF)
+ − 3887
apply(simp)
+ − 3888
358
+ − 3889
(* TOBE PROVED *)
343
+ − 3890
lemma
357
+ − 3891
assumes "s \<in> L (erase r)"
+ − 3892
shows "bders_simp r s >> bs \<longleftrightarrow> bders r s >> bs"
343
+ − 3893
using assms
+ − 3894
apply(induct s arbitrary: r bs)
+ − 3895
apply(simp)
357
+ − 3896
apply(simp add: bders_append bders_simp_append)
+ − 3897
apply(rule iffI)
+ − 3898
apply(drule_tac x="bsimp (bder a r)" in meta_spec)
+ − 3899
apply(drule_tac x="bs" in meta_spec)
+ − 3900
apply(drule meta_mp)
+ − 3901
using L_bsimp_erase lexer_correct_None apply fastforce
343
+ − 3902
apply(simp)
357
+ − 3903
+ − 3904
+ − 3905
prefer 2
+ − 3906
+ − 3907
343
+ − 3908
oops
+ − 3909
339
+ − 3910
+ − 3911
lemma
+ − 3912
assumes "s \<in> L r"
+ − 3913
shows "(bders_simp (intern r) s >> code (PX r s)) \<longleftrightarrow> ((intern r) >> code (PX r s))"
+ − 3914
using assms
+ − 3915
apply(induct s arbitrary: r rule: rev_induct)
+ − 3916
apply(simp)
+ − 3917
apply(simp add: bders_simp_append)
+ − 3918
apply(simp add: PPP1_eq)
+ − 3919
+ − 3920
+ − 3921
find_theorems "retrieve (bders _ _) _"
+ − 3922
find_theorems "_ >> retrieve _ _"
+ − 3923
find_theorems "bsimp _ >> _"
343
+ − 3924
oops
339
+ − 3925
+ − 3926
+ − 3927
lemma PX4a:
+ − 3928
assumes "(s1 @ s2) \<in> L r"
+ − 3929
shows "bders (intern r) (s1 @ s2) >> code (PV r s1 (PX (ders s1 r) s2))"
+ − 3930
using PX4[OF assms]
+ − 3931
apply(simp add: PX_append)
+ − 3932
done
+ − 3933
+ − 3934
lemma PV5:
+ − 3935
assumes "s2 \<in> (ders s1 r) \<rightarrow> v"
+ − 3936
shows "bders (intern r) (s1 @ s2) >> code (PV r s1 v)"
+ − 3937
by (simp add: PPP0_isar PV_def Posix_flex assms)
+ − 3938
+ − 3939
lemma PV6:
+ − 3940
assumes "s2 \<in> (ders s1 r) \<rightarrow> v"
+ − 3941
shows "bders (bders (intern r) s1) s2 >> code (PV r s1 v)"
+ − 3942
using PV5 assms bders_append by auto
+ − 3943
+ − 3944
find_theorems "retrieve (bders _ _) _"
+ − 3945
find_theorems "_ >> retrieve _ _"
+ − 3946
find_theorems "bder _ _ >> _"
+ − 3947
+ − 3948
+ − 3949
lemma OO0_PX:
+ − 3950
assumes "s \<in> L r"
+ − 3951
shows "bders (intern r) s >> code (PX r s)"
+ − 3952
using assms
+ − 3953
by (simp add: PX3)
+ − 3954
+ − 3955
+ − 3956
lemma OO1:
+ − 3957
assumes "[c] \<in> r \<rightarrow> v"
+ − 3958
shows "bder c (intern r) >> code v"
+ − 3959
using assms
+ − 3960
using PPP0_isar by force
+ − 3961
+ − 3962
lemma OO1a:
+ − 3963
assumes "[c] \<in> L r"
+ − 3964
shows "bder c (intern r) >> code (PX r [c])"
+ − 3965
using assms unfolding PX_def PV_def
+ − 3966
using contains70 by fastforce
+ − 3967
+ − 3968
lemma OO12:
+ − 3969
assumes "[c1, c2] \<in> L r"
+ − 3970
shows "bders (intern r) [c1, c2] >> code (PX r [c1, c2])"
+ − 3971
using assms
+ − 3972
using PX_def PV_def contains70 by presburger
+ − 3973
+ − 3974
lemma OO2:
+ − 3975
assumes "[c] \<in> L r"
+ − 3976
shows "bders_simp (intern r) [c] >> code (PX r [c])"
+ − 3977
using assms
+ − 3978
using OO1a Posix1(1) contains55 by auto
+ − 3979
+ − 3980
+ − 3981
thm L07XX PPP0b erase_intern
+ − 3982
+ − 3983
find_theorems "retrieve (bders _ _) _"
+ − 3984
find_theorems "_ >> retrieve _ _"
+ − 3985
find_theorems "bder _ _ >> _"
+ − 3986
+ − 3987
+ − 3988
lemma PPP3:
+ − 3989
assumes "\<Turnstile> v : ders s (erase a)"
+ − 3990
shows "bders a s >> retrieve a (flex (erase a) id s v)"
+ − 3991
using LA[OF assms] contains6 erase_bders assms by metis
+ − 3992
+ − 3993
+ − 3994
find_theorems "bder _ _ >> _"
+ − 3995
337
+ − 3996
+ − 3997
lemma
+ − 3998
fixes n :: nat
+ − 3999
shows "(\<Sum>i \<in> {0..n}. i) = n * (n + 1) div 2"
+ − 4000
apply(induct n)
+ − 4001
apply(simp)
+ − 4002
apply(simp)
+ − 4003
done
+ − 4004
344
+ − 4005
lemma COUNTEREXAMPLE:
+ − 4006
assumes "r = AALTs [S] [ASEQ [S] (AALTs [S] [AONE [S], ACHAR [S] c]) (ACHAR [S] c)]"
+ − 4007
shows "bsimp (bder c (bsimp r)) = bsimp (bder c r)"
+ − 4008
apply(simp_all add: assms)
+ − 4009
oops
+ − 4010
+ − 4011
lemma COUNTEREXAMPLE:
+ − 4012
assumes "r = AALTs [S] [ASEQ [S] (AALTs [S] [AONE [S], ACHAR [S] c]) (ACHAR [S] c)]"
+ − 4013
shows "bsimp r = r"
+ − 4014
apply(simp_all add: assms)
+ − 4015
oops
+ − 4016
+ − 4017
lemma COUNTEREXAMPLE:
+ − 4018
assumes "r = AALTs [S] [ASEQ [S] (AALTs [S] [AONE [S], ACHAR [S] c]) (ACHAR [S] c)]"
+ − 4019
shows "bsimp r = XXX"
+ − 4020
and "bder c r = XXX"
345
+ − 4021
and "bder c (bsimp r) = XXX"
344
+ − 4022
and "bsimp (bder c (bsimp r)) = XXX"
+ − 4023
and "bsimp (bder c r) = XXX"
+ − 4024
apply(simp_all add: assms)
+ − 4025
oops
+ − 4026
+ − 4027
lemma COUNTEREXAMPLE_contains1:
+ − 4028
assumes "r = AALTs [S] [ASEQ [S] (AALTs [S] [AONE [S], ACHAR [S] c]) (ACHAR [S] c)]"
+ − 4029
and "bsimp (bder c r) >> bs"
+ − 4030
shows "bsimp (bder c (bsimp r)) >> bs"
+ − 4031
using assms
+ − 4032
apply(auto elim!: contains.cases)
+ − 4033
apply(rule Etrans)
+ − 4034
apply(rule contains.intros)
+ − 4035
apply(rule contains.intros)
+ − 4036
apply(simp)
+ − 4037
apply(rule Etrans)
+ − 4038
apply(rule contains.intros)
+ − 4039
apply(rule contains.intros)
+ − 4040
apply(simp)
+ − 4041
done
+ − 4042
+ − 4043
lemma COUNTEREXAMPLE_contains2:
+ − 4044
assumes "r = AALTs [S] [ASEQ [S] (AALTs [S] [AONE [S], ACHAR [S] c]) (ACHAR [S] c)]"
+ − 4045
and "bsimp (bder c (bsimp r)) >> bs"
+ − 4046
shows "bsimp (bder c r) >> bs"
+ − 4047
using assms
+ − 4048
apply(auto elim!: contains.cases)
+ − 4049
apply(rule Etrans)
+ − 4050
apply(rule contains.intros)
+ − 4051
apply(rule contains.intros)
+ − 4052
apply(simp)
+ − 4053
apply(rule Etrans)
+ − 4054
apply(rule contains.intros)
+ − 4055
apply(rule contains.intros)
+ − 4056
apply(simp)
+ − 4057
done
337
+ − 4058
+ − 4059
+ − 4060
end