273
+ − 1
+ − 2
theory SpecExt
294
+ − 3
imports Main (*"~~/src/HOL/Library/Sublist"*)
273
+ − 4
begin
+ − 5
+ − 6
section {* Sequential Composition of Languages *}
+ − 7
+ − 8
definition
+ − 9
Sequ :: "string set \<Rightarrow> string set \<Rightarrow> string set" ("_ ;; _" [100,100] 100)
+ − 10
where
+ − 11
"A ;; B = {s1 @ s2 | s1 s2. s1 \<in> A \<and> s2 \<in> B}"
+ − 12
+ − 13
text {* Two Simple Properties about Sequential Composition *}
+ − 14
+ − 15
lemma Sequ_empty_string [simp]:
+ − 16
shows "A ;; {[]} = A"
+ − 17
and "{[]} ;; A = A"
+ − 18
by (simp_all add: Sequ_def)
+ − 19
+ − 20
lemma Sequ_empty [simp]:
+ − 21
shows "A ;; {} = {}"
+ − 22
and "{} ;; A = {}"
+ − 23
by (simp_all add: Sequ_def)
+ − 24
+ − 25
lemma Sequ_assoc:
+ − 26
shows "(A ;; B) ;; C = A ;; (B ;; C)"
+ − 27
apply(auto simp add: Sequ_def)
+ − 28
apply blast
+ − 29
by (metis append_assoc)
+ − 30
+ − 31
lemma Sequ_Union_in:
+ − 32
shows "(A ;; (\<Union>x\<in> B. C x)) = (\<Union>x\<in> B. A ;; C x)"
+ − 33
by (auto simp add: Sequ_def)
+ − 34
+ − 35
section {* Semantic Derivative (Left Quotient) of Languages *}
+ − 36
+ − 37
definition
+ − 38
Der :: "char \<Rightarrow> string set \<Rightarrow> string set"
+ − 39
where
+ − 40
"Der c A \<equiv> {s. c # s \<in> A}"
+ − 41
+ − 42
definition
+ − 43
Ders :: "string \<Rightarrow> string set \<Rightarrow> string set"
+ − 44
where
+ − 45
"Ders s A \<equiv> {s'. s @ s' \<in> A}"
+ − 46
+ − 47
lemma Der_null [simp]:
+ − 48
shows "Der c {} = {}"
+ − 49
unfolding Der_def
+ − 50
by auto
+ − 51
+ − 52
lemma Der_empty [simp]:
+ − 53
shows "Der c {[]} = {}"
+ − 54
unfolding Der_def
+ − 55
by auto
+ − 56
+ − 57
lemma Der_char [simp]:
+ − 58
shows "Der c {[d]} = (if c = d then {[]} else {})"
+ − 59
unfolding Der_def
+ − 60
by auto
+ − 61
+ − 62
lemma Der_union [simp]:
+ − 63
shows "Der c (A \<union> B) = Der c A \<union> Der c B"
+ − 64
unfolding Der_def
+ − 65
by auto
+ − 66
+ − 67
lemma Der_UNION [simp]:
+ − 68
shows "Der c (\<Union>x\<in>A. B x) = (\<Union>x\<in>A. Der c (B x))"
+ − 69
by (auto simp add: Der_def)
+ − 70
+ − 71
lemma Der_Sequ [simp]:
+ − 72
shows "Der c (A ;; B) = (Der c A) ;; B \<union> (if [] \<in> A then Der c B else {})"
+ − 73
unfolding Der_def Sequ_def
280
+ − 74
by (auto simp add: Cons_eq_append_conv)
273
+ − 75
+ − 76
+ − 77
section {* Kleene Star for Languages *}
+ − 78
+ − 79
inductive_set
+ − 80
Star :: "string set \<Rightarrow> string set" ("_\<star>" [101] 102)
+ − 81
for A :: "string set"
+ − 82
where
+ − 83
start[intro]: "[] \<in> A\<star>"
+ − 84
| step[intro]: "\<lbrakk>s1 \<in> A; s2 \<in> A\<star>\<rbrakk> \<Longrightarrow> s1 @ s2 \<in> A\<star>"
+ − 85
+ − 86
(* Arden's lemma *)
+ − 87
+ − 88
lemma Star_cases:
+ − 89
shows "A\<star> = {[]} \<union> A ;; A\<star>"
+ − 90
unfolding Sequ_def
+ − 91
by (auto) (metis Star.simps)
+ − 92
+ − 93
lemma Star_decomp:
+ − 94
assumes "c # x \<in> A\<star>"
+ − 95
shows "\<exists>s1 s2. x = s1 @ s2 \<and> c # s1 \<in> A \<and> s2 \<in> A\<star>"
+ − 96
using assms
+ − 97
by (induct x\<equiv>"c # x" rule: Star.induct)
+ − 98
(auto simp add: append_eq_Cons_conv)
+ − 99
+ − 100
lemma Star_Der_Sequ:
+ − 101
shows "Der c (A\<star>) \<subseteq> (Der c A) ;; A\<star>"
+ − 102
unfolding Der_def Sequ_def
+ − 103
by(auto simp add: Star_decomp)
+ − 104
+ − 105
+ − 106
lemma Der_star [simp]:
+ − 107
shows "Der c (A\<star>) = (Der c A) ;; A\<star>"
+ − 108
proof -
+ − 109
have "Der c (A\<star>) = Der c ({[]} \<union> A ;; A\<star>)"
+ − 110
by (simp only: Star_cases[symmetric])
+ − 111
also have "... = Der c (A ;; A\<star>)"
+ − 112
by (simp only: Der_union Der_empty) (simp)
+ − 113
also have "... = (Der c A) ;; A\<star> \<union> (if [] \<in> A then Der c (A\<star>) else {})"
+ − 114
by simp
+ − 115
also have "... = (Der c A) ;; A\<star>"
+ − 116
using Star_Der_Sequ by auto
+ − 117
finally show "Der c (A\<star>) = (Der c A) ;; A\<star>" .
+ − 118
qed
+ − 119
+ − 120
section {* Power operation for Sets *}
+ − 121
+ − 122
fun
+ − 123
Pow :: "string set \<Rightarrow> nat \<Rightarrow> string set" ("_ \<up> _" [101, 102] 101)
+ − 124
where
+ − 125
"A \<up> 0 = {[]}"
+ − 126
| "A \<up> (Suc n) = A ;; (A \<up> n)"
+ − 127
+ − 128
lemma Pow_empty [simp]:
+ − 129
shows "[] \<in> A \<up> n \<longleftrightarrow> (n = 0 \<or> [] \<in> A)"
+ − 130
by(induct n) (auto simp add: Sequ_def)
+ − 131
+ − 132
lemma Pow_Suc_rev:
+ − 133
"A \<up> (Suc n) = (A \<up> n) ;; A"
+ − 134
apply(induct n arbitrary: A)
+ − 135
apply(simp_all)
+ − 136
by (metis Sequ_assoc)
+ − 137
+ − 138
+ − 139
lemma Pow_decomp:
+ − 140
assumes "c # x \<in> A \<up> n"
+ − 141
shows "\<exists>s1 s2. x = s1 @ s2 \<and> c # s1 \<in> A \<and> s2 \<in> A \<up> (n - 1)"
+ − 142
using assms
+ − 143
apply(induct n)
+ − 144
apply(auto simp add: Cons_eq_append_conv Sequ_def)
+ − 145
apply(case_tac n)
+ − 146
apply(auto simp add: Sequ_def)
+ − 147
apply(blast)
+ − 148
done
+ − 149
+ − 150
lemma Star_Pow:
+ − 151
assumes "s \<in> A\<star>"
+ − 152
shows "\<exists>n. s \<in> A \<up> n"
+ − 153
using assms
+ − 154
apply(induct)
+ − 155
apply(auto)
+ − 156
apply(rule_tac x="Suc n" in exI)
+ − 157
apply(auto simp add: Sequ_def)
+ − 158
done
+ − 159
+ − 160
lemma Pow_Star:
+ − 161
assumes "s \<in> A \<up> n"
+ − 162
shows "s \<in> A\<star>"
+ − 163
using assms
+ − 164
apply(induct n arbitrary: s)
+ − 165
apply(auto simp add: Sequ_def)
+ − 166
done
+ − 167
+ − 168
lemma Der_Pow_0:
+ − 169
shows "Der c (A \<up> 0) = {}"
+ − 170
by(simp add: Der_def)
+ − 171
+ − 172
lemma Der_Pow_Suc:
+ − 173
shows "Der c (A \<up> (Suc n)) = (Der c A) ;; (A \<up> n)"
+ − 174
unfolding Der_def Sequ_def
+ − 175
apply(auto simp add: Cons_eq_append_conv Sequ_def dest!: Pow_decomp)
+ − 176
apply(case_tac n)
+ − 177
apply(force simp add: Sequ_def)+
+ − 178
done
+ − 179
+ − 180
lemma Der_Pow [simp]:
+ − 181
shows "Der c (A \<up> n) = (if n = 0 then {} else (Der c A) ;; (A \<up> (n - 1)))"
+ − 182
apply(case_tac n)
+ − 183
apply(simp_all del: Pow.simps add: Der_Pow_0 Der_Pow_Suc)
+ − 184
done
+ − 185
+ − 186
lemma Der_Pow_Sequ [simp]:
+ − 187
shows "Der c (A ;; A \<up> n) = (Der c A) ;; (A \<up> n)"
+ − 188
by (simp only: Pow.simps[symmetric] Der_Pow) (simp)
+ − 189
+ − 190
+ − 191
lemma Pow_Sequ_Un:
+ − 192
assumes "0 < x"
+ − 193
shows "(\<Union>n \<in> {..x}. (A \<up> n)) = ({[]} \<union> (\<Union>n \<in> {..x - Suc 0}. A ;; (A \<up> n)))"
+ − 194
using assms
+ − 195
apply(auto simp add: Sequ_def)
+ − 196
apply(smt Pow.elims Sequ_def Suc_le_mono Suc_pred atMost_iff empty_iff insert_iff mem_Collect_eq)
+ − 197
apply(rule_tac x="Suc xa" in bexI)
+ − 198
apply(auto simp add: Sequ_def)
+ − 199
done
+ − 200
+ − 201
lemma Pow_Sequ_Un2:
+ − 202
assumes "0 < x"
+ − 203
shows "(\<Union>n \<in> {x..}. (A \<up> n)) = (\<Union>n \<in> {x - Suc 0..}. A ;; (A \<up> n))"
+ − 204
using assms
+ − 205
apply(auto simp add: Sequ_def)
+ − 206
apply(case_tac n)
+ − 207
apply(auto simp add: Sequ_def)
+ − 208
apply fastforce
+ − 209
apply(case_tac x)
+ − 210
apply(auto)
+ − 211
apply(rule_tac x="Suc xa" in bexI)
+ − 212
apply(auto simp add: Sequ_def)
+ − 213
done
+ − 214
+ − 215
section {* Regular Expressions *}
+ − 216
+ − 217
datatype rexp =
+ − 218
ZERO
+ − 219
| ONE
+ − 220
| CHAR char
+ − 221
| SEQ rexp rexp
+ − 222
| ALT rexp rexp
+ − 223
| STAR rexp
+ − 224
| UPNTIMES rexp nat
+ − 225
| NTIMES rexp nat
+ − 226
| FROMNTIMES rexp nat
+ − 227
| NMTIMES rexp nat nat
+ − 228
+ − 229
section {* Semantics of Regular Expressions *}
+ − 230
+ − 231
fun
+ − 232
L :: "rexp \<Rightarrow> string set"
+ − 233
where
+ − 234
"L (ZERO) = {}"
+ − 235
| "L (ONE) = {[]}"
+ − 236
| "L (CHAR c) = {[c]}"
+ − 237
| "L (SEQ r1 r2) = (L r1) ;; (L r2)"
+ − 238
| "L (ALT r1 r2) = (L r1) \<union> (L r2)"
+ − 239
| "L (STAR r) = (L r)\<star>"
280
+ − 240
| "L (UPNTIMES r n) = (\<Union>i\<in>{..n} . (L r) \<up> i)"
273
+ − 241
| "L (NTIMES r n) = (L r) \<up> n"
280
+ − 242
| "L (FROMNTIMES r n) = (\<Union>i\<in>{n..} . (L r) \<up> i)"
273
+ − 243
| "L (NMTIMES r n m) = (\<Union>i\<in>{n..m} . (L r) \<up> i)"
+ − 244
+ − 245
section {* Nullable, Derivatives *}
+ − 246
+ − 247
fun
+ − 248
nullable :: "rexp \<Rightarrow> bool"
+ − 249
where
+ − 250
"nullable (ZERO) = False"
+ − 251
| "nullable (ONE) = True"
+ − 252
| "nullable (CHAR c) = False"
+ − 253
| "nullable (ALT r1 r2) = (nullable r1 \<or> nullable r2)"
+ − 254
| "nullable (SEQ r1 r2) = (nullable r1 \<and> nullable r2)"
+ − 255
| "nullable (STAR r) = True"
+ − 256
| "nullable (UPNTIMES r n) = True"
+ − 257
| "nullable (NTIMES r n) = (if n = 0 then True else nullable r)"
+ − 258
| "nullable (FROMNTIMES r n) = (if n = 0 then True else nullable r)"
+ − 259
| "nullable (NMTIMES r n m) = (if m < n then False else (if n = 0 then True else nullable r))"
+ − 260
+ − 261
fun
+ − 262
der :: "char \<Rightarrow> rexp \<Rightarrow> rexp"
+ − 263
where
+ − 264
"der c (ZERO) = ZERO"
+ − 265
| "der c (ONE) = ZERO"
+ − 266
| "der c (CHAR d) = (if c = d then ONE else ZERO)"
+ − 267
| "der c (ALT r1 r2) = ALT (der c r1) (der c r2)"
+ − 268
| "der c (SEQ r1 r2) =
+ − 269
(if nullable r1
+ − 270
then ALT (SEQ (der c r1) r2) (der c r2)
+ − 271
else SEQ (der c r1) r2)"
+ − 272
| "der c (STAR r) = SEQ (der c r) (STAR r)"
+ − 273
| "der c (UPNTIMES r n) = (if n = 0 then ZERO else SEQ (der c r) (UPNTIMES r (n - 1)))"
+ − 274
| "der c (NTIMES r n) = (if n = 0 then ZERO else SEQ (der c r) (NTIMES r (n - 1)))"
294
+ − 275
| "der c (FROMNTIMES r n) =
277
+ − 276
(if n = 0
+ − 277
then SEQ (der c r) (STAR r)
+ − 278
else SEQ (der c r) (FROMNTIMES r (n - 1)))"
273
+ − 279
| "der c (NMTIMES r n m) =
+ − 280
(if m < n then ZERO
+ − 281
else (if n = 0 then (if m = 0 then ZERO else
+ − 282
SEQ (der c r) (UPNTIMES r (m - 1))) else
+ − 283
SEQ (der c r) (NMTIMES r (n - 1) (m - 1))))"
+ − 284
294
+ − 285
lemma
+ − 286
"L(der c (UPNTIMES r m)) =
+ − 287
L(if (m = 0) then ZERO else ALT ONE (SEQ(der c r) (UPNTIMES r (m - 1))))"
+ − 288
apply(case_tac m)
+ − 289
apply(simp)
+ − 290
apply(simp del: der.simps)
+ − 291
apply(simp only: der.simps)
+ − 292
apply(simp add: Sequ_def)
+ − 293
apply(auto)
+ − 294
defer
+ − 295
apply blast
+ − 296
oops
+ − 297
+ − 298
lemma pow_add:
+ − 299
assumes "s1 \<in> A \<up> n" "s2 \<in> A \<up> m"
+ − 300
shows "s1 @ s2 \<in> A \<up> (n + m)"
+ − 301
using assms
+ − 302
apply(induct n arbitrary: m s1 s2)
+ − 303
apply(auto simp add: Sequ_def)
+ − 304
by blast
+ − 305
+ − 306
lemma pow_add2:
+ − 307
assumes "x \<in> A \<up> (m + n)"
+ − 308
shows "x \<in> A \<up> m ;; A \<up> n"
+ − 309
using assms
+ − 310
apply(induct m arbitrary: n x)
+ − 311
apply(auto simp add: Sequ_def)
+ − 312
by (metis append.assoc)
+ − 313
+ − 314
+ − 315
+ − 316
lemma
+ − 317
"L(FROMNTIMES r n) = L(SEQ (NTIMES r n) (STAR r))"
+ − 318
apply(auto simp add: Sequ_def)
+ − 319
defer
+ − 320
apply(subgoal_tac "\<exists>m. s2 \<in> (L r) \<up> m")
+ − 321
prefer 2
+ − 322
apply (simp add: Star_Pow)
+ − 323
apply(auto)
+ − 324
apply(rule_tac x="n + m" in bexI)
+ − 325
apply (simp add: pow_add)
+ − 326
apply simp
+ − 327
apply(subgoal_tac "\<exists>m. m + n = xa")
+ − 328
apply(auto)
+ − 329
prefer 2
+ − 330
using le_add_diff_inverse2 apply auto[1]
+ − 331
by (smt Pow_Star Sequ_def add.commute mem_Collect_eq pow_add2)
+ − 332
+ − 333
lemma
+ − 334
"L (der c (FROMNTIMES r n)) =
+ − 335
L (SEQ (der c r) (FROMNTIMES r (n - 1)))"
+ − 336
apply(auto simp add: Sequ_def)
+ − 337
using Star_Pow apply blast
+ − 338
using Pow_Star by blast
+ − 339
+ − 340
lemma
+ − 341
"L (der c (UPNTIMES r n)) =
+ − 342
L(if n = 0 then ZERO else
+ − 343
ALT (der c r) (SEQ (der c r) (UPNTIMES r (n - 1))))"
+ − 344
apply(auto simp add: Sequ_def)
+ − 345
using SpecExt.Pow_empty by blast
+ − 346
273
+ − 347
fun
+ − 348
ders :: "string \<Rightarrow> rexp \<Rightarrow> rexp"
+ − 349
where
+ − 350
"ders [] r = r"
+ − 351
| "ders (c # s) r = ders s (der c r)"
+ − 352
+ − 353
+ − 354
lemma nullable_correctness:
+ − 355
shows "nullable r \<longleftrightarrow> [] \<in> (L r)"
+ − 356
by(induct r) (auto simp add: Sequ_def)
+ − 357
+ − 358
+ − 359
lemma der_correctness:
+ − 360
shows "L (der c r) = Der c (L r)"
+ − 361
apply(induct r)
+ − 362
apply(simp add: nullable_correctness del: Der_UNION)
+ − 363
apply(simp add: nullable_correctness del: Der_UNION)
+ − 364
apply(simp add: nullable_correctness del: Der_UNION)
+ − 365
apply(simp add: nullable_correctness del: Der_UNION)
+ − 366
apply(simp add: nullable_correctness del: Der_UNION)
+ − 367
apply(simp add: nullable_correctness del: Der_UNION)
+ − 368
prefer 2
+ − 369
apply(simp add: nullable_correctness del: Der_UNION)
+ − 370
apply(simp add: nullable_correctness del: Der_UNION)
+ − 371
apply(rule impI)
+ − 372
apply(subst Sequ_Union_in)
+ − 373
apply(subst Der_Pow_Sequ[symmetric])
+ − 374
apply(subst Pow.simps[symmetric])
+ − 375
apply(subst Der_UNION[symmetric])
+ − 376
apply(subst Pow_Sequ_Un)
+ − 377
apply(simp)
+ − 378
apply(simp only: Der_union Der_empty)
276
+ − 379
apply(simp)
+ − 380
(* FROMNTIMES *)
+ − 381
apply(simp add: nullable_correctness del: Der_UNION)
277
+ − 382
apply(rule conjI)
+ − 383
prefer 2
273
+ − 384
apply(subst Sequ_Union_in)
+ − 385
apply(subst Der_Pow_Sequ[symmetric])
+ − 386
apply(subst Pow.simps[symmetric])
+ − 387
apply(case_tac x2)
+ − 388
prefer 2
+ − 389
apply(subst Pow_Sequ_Un2)
+ − 390
apply(simp)
+ − 391
apply(simp)
277
+ − 392
apply(auto simp add: Sequ_def Der_def)[1]
+ − 393
apply(auto simp add: Sequ_def split: if_splits)[1]
+ − 394
using Star_Pow apply fastforce
+ − 395
using Pow_Star apply blast
276
+ − 396
(* NMTIMES *)
273
+ − 397
apply(simp add: nullable_correctness del: Der_UNION)
+ − 398
apply(rule impI)
+ − 399
apply(rule conjI)
+ − 400
apply(rule impI)
+ − 401
apply(subst Sequ_Union_in)
+ − 402
apply(subst Der_Pow_Sequ[symmetric])
+ − 403
apply(subst Pow.simps[symmetric])
+ − 404
apply(subst Der_UNION[symmetric])
+ − 405
apply(case_tac x3a)
+ − 406
apply(simp)
+ − 407
apply(clarify)
+ − 408
apply(auto simp add: Sequ_def Der_def Cons_eq_append_conv)[1]
+ − 409
apply(rule_tac x="Suc xa" in bexI)
+ − 410
apply(auto simp add: Sequ_def)[2]
+ − 411
apply (metis append_Cons)
+ − 412
apply (metis (no_types, hide_lams) Pow_decomp atMost_iff diff_Suc_eq_diff_pred diff_is_0_eq)
+ − 413
apply(rule impI)+
+ − 414
apply(subst Sequ_Union_in)
+ − 415
apply(subst Der_Pow_Sequ[symmetric])
+ − 416
apply(subst Pow.simps[symmetric])
+ − 417
apply(subst Der_UNION[symmetric])
+ − 418
apply(case_tac x2)
+ − 419
apply(simp)
+ − 420
apply(simp del: Pow.simps)
+ − 421
apply(auto simp add: Sequ_def Der_def)
+ − 422
apply (metis One_nat_def Suc_le_D Suc_le_mono atLeastAtMost_iff diff_Suc_1 not_le)
+ − 423
by fastforce
+ − 424
+ − 425
+ − 426
+ − 427
lemma ders_correctness:
+ − 428
shows "L (ders s r) = Ders s (L r)"
+ − 429
by (induct s arbitrary: r)
+ − 430
(simp_all add: Ders_def der_correctness Der_def)
+ − 431
+ − 432
+ − 433
section {* Values *}
+ − 434
+ − 435
datatype val =
+ − 436
Void
+ − 437
| Char char
+ − 438
| Seq val val
+ − 439
| Right val
+ − 440
| Left val
+ − 441
| Stars "val list"
+ − 442
+ − 443
+ − 444
section {* The string behind a value *}
+ − 445
+ − 446
fun
+ − 447
flat :: "val \<Rightarrow> string"
+ − 448
where
+ − 449
"flat (Void) = []"
+ − 450
| "flat (Char c) = [c]"
+ − 451
| "flat (Left v) = flat v"
+ − 452
| "flat (Right v) = flat v"
+ − 453
| "flat (Seq v1 v2) = (flat v1) @ (flat v2)"
+ − 454
| "flat (Stars []) = []"
+ − 455
| "flat (Stars (v#vs)) = (flat v) @ (flat (Stars vs))"
+ − 456
+ − 457
abbreviation
+ − 458
"flats vs \<equiv> concat (map flat vs)"
+ − 459
+ − 460
lemma flat_Stars [simp]:
+ − 461
"flat (Stars vs) = flats vs"
+ − 462
by (induct vs) (auto)
+ − 463
+ − 464
lemma Star_concat:
+ − 465
assumes "\<forall>s \<in> set ss. s \<in> A"
+ − 466
shows "concat ss \<in> A\<star>"
+ − 467
using assms by (induct ss) (auto)
+ − 468
+ − 469
lemma Star_cstring:
+ − 470
assumes "s \<in> A\<star>"
+ − 471
shows "\<exists>ss. concat ss = s \<and> (\<forall>s \<in> set ss. s \<in> A \<and> s \<noteq> [])"
+ − 472
using assms
+ − 473
apply(induct rule: Star.induct)
+ − 474
apply(auto)[1]
+ − 475
apply(rule_tac x="[]" in exI)
+ − 476
apply(simp)
+ − 477
apply(erule exE)
+ − 478
apply(clarify)
+ − 479
apply(case_tac "s1 = []")
+ − 480
apply(rule_tac x="ss" in exI)
+ − 481
apply(simp)
+ − 482
apply(rule_tac x="s1#ss" in exI)
+ − 483
apply(simp)
+ − 484
done
+ − 485
+ − 486
lemma Aux:
+ − 487
assumes "\<forall>s\<in>set ss. s = []"
+ − 488
shows "concat ss = []"
+ − 489
using assms
+ − 490
by (induct ss) (auto)
+ − 491
+ − 492
lemma Pow_cstring_nonempty:
+ − 493
assumes "s \<in> A \<up> n"
+ − 494
shows "\<exists>ss. concat ss = s \<and> length ss \<le> n \<and> (\<forall>s \<in> set ss. s \<in> A \<and> s \<noteq> [])"
+ − 495
using assms
+ − 496
apply(induct n arbitrary: s)
+ − 497
apply(auto)
+ − 498
apply(simp add: Sequ_def)
+ − 499
apply(erule exE)+
+ − 500
apply(clarify)
+ − 501
apply(drule_tac x="s2" in meta_spec)
+ − 502
apply(simp)
+ − 503
apply(clarify)
+ − 504
apply(case_tac "s1 = []")
+ − 505
apply(simp)
+ − 506
apply(rule_tac x="ss" in exI)
+ − 507
apply(simp)
+ − 508
apply(rule_tac x="s1 # ss" in exI)
+ − 509
apply(simp)
+ − 510
done
+ − 511
+ − 512
lemma Pow_cstring:
+ − 513
assumes "s \<in> A \<up> n"
+ − 514
shows "\<exists>ss1 ss2. concat (ss1 @ ss2) = s \<and> length (ss1 @ ss2) = n \<and>
+ − 515
(\<forall>s \<in> set ss1. s \<in> A \<and> s \<noteq> []) \<and> (\<forall>s \<in> set ss2. s \<in> A \<and> s = [])"
+ − 516
using assms
+ − 517
apply(induct n arbitrary: s)
+ − 518
apply(auto)[1]
+ − 519
apply(simp only: Pow_Suc_rev)
+ − 520
apply(simp add: Sequ_def)
+ − 521
apply(erule exE)+
+ − 522
apply(clarify)
+ − 523
apply(drule_tac x="s1" in meta_spec)
+ − 524
apply(simp)
+ − 525
apply(erule exE)+
+ − 526
apply(clarify)
+ − 527
apply(case_tac "s2 = []")
+ − 528
apply(simp)
+ − 529
apply(rule_tac x="ss1" in exI)
+ − 530
apply(rule_tac x="s2#ss2" in exI)
+ − 531
apply(simp)
+ − 532
apply(rule_tac x="ss1 @ [s2]" in exI)
+ − 533
apply(rule_tac x="ss2" in exI)
+ − 534
apply(simp)
+ − 535
apply(subst Aux)
+ − 536
apply(auto)[1]
+ − 537
apply(subst Aux)
+ − 538
apply(auto)[1]
+ − 539
apply(simp)
+ − 540
done
+ − 541
+ − 542
+ − 543
section {* Lexical Values *}
+ − 544
+ − 545
+ − 546
+ − 547
inductive
+ − 548
Prf :: "val \<Rightarrow> rexp \<Rightarrow> bool" ("\<Turnstile> _ : _" [100, 100] 100)
+ − 549
where
+ − 550
"\<lbrakk>\<Turnstile> v1 : r1; \<Turnstile> v2 : r2\<rbrakk> \<Longrightarrow> \<Turnstile> Seq v1 v2 : SEQ r1 r2"
+ − 551
| "\<Turnstile> v1 : r1 \<Longrightarrow> \<Turnstile> Left v1 : ALT r1 r2"
+ − 552
| "\<Turnstile> v2 : r2 \<Longrightarrow> \<Turnstile> Right v2 : ALT r1 r2"
+ − 553
| "\<Turnstile> Void : ONE"
+ − 554
| "\<Turnstile> Char c : CHAR c"
+ − 555
| "\<lbrakk>\<forall>v \<in> set vs. \<Turnstile> v : r \<and> flat v \<noteq> []\<rbrakk> \<Longrightarrow> \<Turnstile> Stars vs : STAR r"
+ − 556
| "\<lbrakk>\<forall>v \<in> set vs. \<Turnstile> v : r \<and> flat v \<noteq> []; length vs \<le> n\<rbrakk> \<Longrightarrow> \<Turnstile> Stars vs : UPNTIMES r n"
+ − 557
| "\<lbrakk>\<forall>v \<in> set vs1. \<Turnstile> v : r \<and> flat v \<noteq> [];
+ − 558
\<forall>v \<in> set vs2. \<Turnstile> v : r \<and> flat v = [];
+ − 559
length (vs1 @ vs2) = n\<rbrakk> \<Longrightarrow> \<Turnstile> Stars (vs1 @ vs2) : NTIMES r n"
+ − 560
| "\<lbrakk>\<forall>v \<in> set vs1. \<Turnstile> v : r \<and> flat v \<noteq> [];
+ − 561
\<forall>v \<in> set vs2. \<Turnstile> v : r \<and> flat v = [];
275
+ − 562
length (vs1 @ vs2) = n\<rbrakk> \<Longrightarrow> \<Turnstile> Stars (vs1 @ vs2) : FROMNTIMES r n"
+ − 563
| "\<lbrakk>\<forall>v \<in> set vs. \<Turnstile> v : r \<and> flat v \<noteq> []; length vs > n\<rbrakk> \<Longrightarrow> \<Turnstile> Stars vs : FROMNTIMES r n"
273
+ − 564
| "\<lbrakk>\<forall>v \<in> set vs1. \<Turnstile> v : r \<and> flat v \<noteq> [];
+ − 565
\<forall>v \<in> set vs2. \<Turnstile> v : r \<and> flat v = [];
275
+ − 566
length (vs1 @ vs2) = n; length (vs1 @ vs2) \<le> m\<rbrakk> \<Longrightarrow> \<Turnstile> Stars (vs1 @ vs2) : NMTIMES r n m"
+ − 567
| "\<lbrakk>\<forall>v \<in> set vs. \<Turnstile> v : r \<and> flat v \<noteq> [];
+ − 568
length vs > n; length vs \<le> m\<rbrakk> \<Longrightarrow> \<Turnstile> Stars vs : NMTIMES r n m"
273
+ − 569
293
+ − 570
+ − 571
+ − 572
+ − 573
273
+ − 574
inductive_cases Prf_elims:
+ − 575
"\<Turnstile> v : ZERO"
+ − 576
"\<Turnstile> v : SEQ r1 r2"
+ − 577
"\<Turnstile> v : ALT r1 r2"
+ − 578
"\<Turnstile> v : ONE"
+ − 579
"\<Turnstile> v : CHAR c"
+ − 580
"\<Turnstile> vs : STAR r"
+ − 581
"\<Turnstile> vs : UPNTIMES r n"
+ − 582
"\<Turnstile> vs : NTIMES r n"
+ − 583
"\<Turnstile> vs : FROMNTIMES r n"
+ − 584
"\<Turnstile> vs : NMTIMES r n m"
+ − 585
+ − 586
lemma Prf_Stars_appendE:
+ − 587
assumes "\<Turnstile> Stars (vs1 @ vs2) : STAR r"
+ − 588
shows "\<Turnstile> Stars vs1 : STAR r \<and> \<Turnstile> Stars vs2 : STAR r"
+ − 589
using assms
+ − 590
by (auto intro: Prf.intros elim!: Prf_elims)
+ − 591
274
+ − 592
+ − 593
273
+ − 594
lemma flats_empty:
+ − 595
assumes "(\<forall>v\<in>set vs. flat v = [])"
+ − 596
shows "flats vs = []"
+ − 597
using assms
+ − 598
by(induct vs) (simp_all)
+ − 599
+ − 600
lemma Star_cval:
+ − 601
assumes "\<forall>s\<in>set ss. \<exists>v. s = flat v \<and> \<Turnstile> v : r"
+ − 602
shows "\<exists>vs. flats vs = concat ss \<and> (\<forall>v\<in>set vs. \<Turnstile> v : r \<and> flat v \<noteq> [])"
+ − 603
using assms
+ − 604
apply(induct ss)
+ − 605
apply(auto)
+ − 606
apply(rule_tac x="[]" in exI)
+ − 607
apply(simp)
+ − 608
apply(case_tac "flat v = []")
+ − 609
apply(rule_tac x="vs" in exI)
+ − 610
apply(simp)
+ − 611
apply(rule_tac x="v#vs" in exI)
+ − 612
apply(simp)
+ − 613
done
+ − 614
+ − 615
+ − 616
lemma flats_cval:
+ − 617
assumes "\<forall>s\<in>set ss. \<exists>v. s = flat v \<and> \<Turnstile> v : r"
+ − 618
shows "\<exists>vs1 vs2. flats (vs1 @ vs2) = concat ss \<and> length (vs1 @ vs2) = length ss \<and>
+ − 619
(\<forall>v\<in>set vs1. \<Turnstile> v : r \<and> flat v \<noteq> []) \<and>
+ − 620
(\<forall>v\<in>set vs2. \<Turnstile> v : r \<and> flat v = [])"
+ − 621
using assms
+ − 622
apply(induct ss rule: rev_induct)
+ − 623
apply(rule_tac x="[]" in exI)+
+ − 624
apply(simp)
+ − 625
apply(simp)
+ − 626
apply(clarify)
+ − 627
apply(case_tac "flat v = []")
+ − 628
apply(rule_tac x="vs1" in exI)
+ − 629
apply(rule_tac x="v#vs2" in exI)
+ − 630
apply(simp)
+ − 631
apply(rule_tac x="vs1 @ [v]" in exI)
+ − 632
apply(rule_tac x="vs2" in exI)
+ − 633
apply(simp)
+ − 634
apply(subst (asm) (2) flats_empty)
+ − 635
apply(simp)
+ − 636
apply(simp)
+ − 637
done
+ − 638
+ − 639
lemma flats_cval_nonempty:
+ − 640
assumes "\<forall>s\<in>set ss. \<exists>v. s = flat v \<and> \<Turnstile> v : r"
+ − 641
shows "\<exists>vs. flats vs = concat ss \<and> length vs \<le> length ss \<and>
+ − 642
(\<forall>v\<in>set vs. \<Turnstile> v : r \<and> flat v \<noteq> [])"
+ − 643
using assms
+ − 644
apply(induct ss)
+ − 645
apply(rule_tac x="[]" in exI)
+ − 646
apply(simp)
+ − 647
apply(simp)
+ − 648
apply(clarify)
+ − 649
apply(case_tac "flat v = []")
+ − 650
apply(rule_tac x="vs" in exI)
+ − 651
apply(simp)
+ − 652
apply(rule_tac x="v # vs" in exI)
+ − 653
apply(simp)
+ − 654
done
+ − 655
+ − 656
lemma Pow_flats:
+ − 657
assumes "\<forall>v \<in> set vs. flat v \<in> A"
+ − 658
shows "flats vs \<in> A \<up> length vs"
+ − 659
using assms
+ − 660
by(induct vs)(auto simp add: Sequ_def)
+ − 661
+ − 662
lemma Pow_flats_appends:
+ − 663
assumes "\<forall>v \<in> set vs1. flat v \<in> A" "\<forall>v \<in> set vs2. flat v \<in> A"
+ − 664
shows "flats vs1 @ flats vs2 \<in> A \<up> (length vs1 + length vs2)"
+ − 665
using assms
+ − 666
apply(induct vs1)
+ − 667
apply(auto simp add: Sequ_def Pow_flats)
+ − 668
done
+ − 669
+ − 670
lemma L_flat_Prf1:
+ − 671
assumes "\<Turnstile> v : r"
+ − 672
shows "flat v \<in> L r"
+ − 673
using assms
+ − 674
apply(induct)
+ − 675
apply(auto simp add: Sequ_def Star_concat Pow_flats)
+ − 676
apply(meson Pow_flats atMost_iff)
+ − 677
using Pow_flats_appends apply blast
275
+ − 678
using Pow_flats_appends apply blast
+ − 679
apply (meson Pow_flats atLeast_iff less_imp_le)
+ − 680
apply(rule_tac x="length vs1 + length vs2" in bexI)
273
+ − 681
apply(meson Pow_flats_appends atLeastAtMost_iff)
275
+ − 682
apply(simp)
+ − 683
apply(meson Pow_flats atLeastAtMost_iff less_or_eq_imp_le)
273
+ − 684
done
+ − 685
+ − 686
lemma L_flat_Prf2:
+ − 687
assumes "s \<in> L r"
+ − 688
shows "\<exists>v. \<Turnstile> v : r \<and> flat v = s"
+ − 689
using assms
+ − 690
proof(induct r arbitrary: s)
+ − 691
case (STAR r s)
+ − 692
have IH: "\<And>s. s \<in> L r \<Longrightarrow> \<exists>v. \<Turnstile> v : r \<and> flat v = s" by fact
+ − 693
have "s \<in> L (STAR r)" by fact
+ − 694
then obtain ss where "concat ss = s" "\<forall>s \<in> set ss. s \<in> L r \<and> s \<noteq> []"
+ − 695
using Star_cstring by auto
+ − 696
then obtain vs where "flats vs = s" "\<forall>v\<in>set vs. \<Turnstile> v : r \<and> flat v \<noteq> []"
+ − 697
using IH Star_cval by metis
+ − 698
then show "\<exists>v. \<Turnstile> v : STAR r \<and> flat v = s"
+ − 699
using Prf.intros(6) flat_Stars by blast
+ − 700
next
+ − 701
case (SEQ r1 r2 s)
+ − 702
then show "\<exists>v. \<Turnstile> v : SEQ r1 r2 \<and> flat v = s"
+ − 703
unfolding Sequ_def L.simps by (fastforce intro: Prf.intros)
+ − 704
next
+ − 705
case (ALT r1 r2 s)
+ − 706
then show "\<exists>v. \<Turnstile> v : ALT r1 r2 \<and> flat v = s"
+ − 707
unfolding L.simps by (fastforce intro: Prf.intros)
+ − 708
next
+ − 709
case (NTIMES r n)
+ − 710
have IH: "\<And>s. s \<in> L r \<Longrightarrow> \<exists>v. \<Turnstile> v : r \<and> flat v = s" by fact
+ − 711
have "s \<in> L (NTIMES r n)" by fact
+ − 712
then obtain ss1 ss2 where "concat (ss1 @ ss2) = s" "length (ss1 @ ss2) = n"
+ − 713
"\<forall>s \<in> set ss1. s \<in> L r \<and> s \<noteq> []" "\<forall>s \<in> set ss2. s \<in> L r \<and> s = []"
+ − 714
using Pow_cstring by force
+ − 715
then obtain vs1 vs2 where "flats (vs1 @ vs2) = s" "length (vs1 @ vs2) = n"
+ − 716
"\<forall>v\<in>set vs1. \<Turnstile> v : r \<and> flat v \<noteq> []" "\<forall>v\<in>set vs2. \<Turnstile> v : r \<and> flat v = []"
+ − 717
using IH flats_cval
+ − 718
apply -
+ − 719
apply(drule_tac x="ss1 @ ss2" in meta_spec)
+ − 720
apply(drule_tac x="r" in meta_spec)
+ − 721
apply(drule meta_mp)
+ − 722
apply(simp)
+ − 723
apply (metis Un_iff)
+ − 724
apply(clarify)
+ − 725
apply(drule_tac x="vs1" in meta_spec)
+ − 726
apply(drule_tac x="vs2" in meta_spec)
+ − 727
apply(simp)
+ − 728
done
+ − 729
then show "\<exists>v. \<Turnstile> v : NTIMES r n \<and> flat v = s"
+ − 730
using Prf.intros(8) flat_Stars by blast
+ − 731
next
+ − 732
case (FROMNTIMES r n)
+ − 733
have IH: "\<And>s. s \<in> L r \<Longrightarrow> \<exists>v. \<Turnstile> v : r \<and> flat v = s" by fact
+ − 734
have "s \<in> L (FROMNTIMES r n)" by fact
276
+ − 735
then obtain ss1 ss2 k where "concat (ss1 @ ss2) = s" "length (ss1 @ ss2) = k" "n \<le> k"
273
+ − 736
"\<forall>s \<in> set ss1. s \<in> L r \<and> s \<noteq> []" "\<forall>s \<in> set ss2. s \<in> L r \<and> s = []"
275
+ − 737
using Pow_cstring by force
276
+ − 738
then obtain vs1 vs2 where "flats (vs1 @ vs2) = s" "length (vs1 @ vs2) = k" "n \<le> k"
273
+ − 739
"\<forall>v\<in>set vs1. \<Turnstile> v : r \<and> flat v \<noteq> []" "\<forall>v\<in>set vs2. \<Turnstile> v : r \<and> flat v = []"
+ − 740
using IH flats_cval
+ − 741
apply -
+ − 742
apply(drule_tac x="ss1 @ ss2" in meta_spec)
+ − 743
apply(drule_tac x="r" in meta_spec)
+ − 744
apply(drule meta_mp)
+ − 745
apply(simp)
+ − 746
apply (metis Un_iff)
+ − 747
apply(clarify)
+ − 748
apply(drule_tac x="vs1" in meta_spec)
+ − 749
apply(drule_tac x="vs2" in meta_spec)
+ − 750
apply(simp)
+ − 751
done
+ − 752
then show "\<exists>v. \<Turnstile> v : FROMNTIMES r n \<and> flat v = s"
275
+ − 753
apply(case_tac "length vs1 \<le> n")
+ − 754
apply(rule_tac x="Stars (vs1 @ take (n - length vs1) vs2)" in exI)
+ − 755
apply(simp)
+ − 756
apply(subgoal_tac "flats (take (n - length vs1) vs2) = []")
+ − 757
prefer 2
+ − 758
apply (meson flats_empty in_set_takeD)
+ − 759
apply(clarify)
+ − 760
apply(rule conjI)
+ − 761
apply(rule Prf.intros)
+ − 762
apply(simp)
+ − 763
apply (meson in_set_takeD)
+ − 764
apply(simp)
+ − 765
apply(simp)
+ − 766
apply (simp add: flats_empty)
+ − 767
apply(rule_tac x="Stars vs1" in exI)
+ − 768
apply(simp)
+ − 769
apply(rule conjI)
+ − 770
apply(rule Prf.intros(10))
+ − 771
apply(auto)
+ − 772
done
273
+ − 773
next
+ − 774
case (NMTIMES r n m)
+ − 775
have IH: "\<And>s. s \<in> L r \<Longrightarrow> \<exists>v. \<Turnstile> v : r \<and> flat v = s" by fact
+ − 776
have "s \<in> L (NMTIMES r n m)" by fact
+ − 777
then obtain ss1 ss2 k where "concat (ss1 @ ss2) = s" "length (ss1 @ ss2) = k" "n \<le> k" "k \<le> m"
+ − 778
"\<forall>s \<in> set ss1. s \<in> L r \<and> s \<noteq> []" "\<forall>s \<in> set ss2. s \<in> L r \<and> s = []"
+ − 779
using Pow_cstring by (auto, blast)
+ − 780
then obtain vs1 vs2 where "flats (vs1 @ vs2) = s" "length (vs1 @ vs2) = k" "n \<le> k" "k \<le> m"
+ − 781
"\<forall>v\<in>set vs1. \<Turnstile> v : r \<and> flat v \<noteq> []" "\<forall>v\<in>set vs2. \<Turnstile> v : r \<and> flat v = []"
+ − 782
using IH flats_cval
+ − 783
apply -
+ − 784
apply(drule_tac x="ss1 @ ss2" in meta_spec)
+ − 785
apply(drule_tac x="r" in meta_spec)
+ − 786
apply(drule meta_mp)
+ − 787
apply(simp)
+ − 788
apply (metis Un_iff)
+ − 789
apply(clarify)
+ − 790
apply(drule_tac x="vs1" in meta_spec)
+ − 791
apply(drule_tac x="vs2" in meta_spec)
+ − 792
apply(simp)
+ − 793
done
+ − 794
then show "\<exists>v. \<Turnstile> v : NMTIMES r n m \<and> flat v = s"
276
+ − 795
apply(case_tac "length vs1 \<le> n")
+ − 796
apply(rule_tac x="Stars (vs1 @ take (n - length vs1) vs2)" in exI)
273
+ − 797
apply(simp)
276
+ − 798
apply(subgoal_tac "flats (take (n - length vs1) vs2) = []")
+ − 799
prefer 2
+ − 800
apply (meson flats_empty in_set_takeD)
+ − 801
apply(clarify)
+ − 802
apply(rule conjI)
+ − 803
apply(rule Prf.intros)
+ − 804
apply(simp)
+ − 805
apply (meson in_set_takeD)
+ − 806
apply(simp)
+ − 807
apply(simp)
+ − 808
apply (simp add: flats_empty)
+ − 809
apply(rule_tac x="Stars vs1" in exI)
+ − 810
apply(simp)
+ − 811
apply(rule conjI)
+ − 812
apply(rule Prf.intros)
+ − 813
apply(auto)
+ − 814
done
273
+ − 815
next
+ − 816
case (UPNTIMES r n s)
+ − 817
have IH: "\<And>s. s \<in> L r \<Longrightarrow> \<exists>v. \<Turnstile> v : r \<and> flat v = s" by fact
+ − 818
have "s \<in> L (UPNTIMES r n)" by fact
+ − 819
then obtain ss where "concat ss = s" "\<forall>s \<in> set ss. s \<in> L r \<and> s \<noteq> []" "length ss \<le> n"
+ − 820
using Pow_cstring_nonempty by force
+ − 821
then obtain vs where "flats vs = s" "\<forall>v\<in>set vs. \<Turnstile> v : r \<and> flat v \<noteq> []" "length vs \<le> n"
+ − 822
using IH flats_cval_nonempty by (smt order.trans)
+ − 823
then show "\<exists>v. \<Turnstile> v : UPNTIMES r n \<and> flat v = s"
+ − 824
using Prf.intros(7) flat_Stars by blast
+ − 825
qed (auto intro: Prf.intros)
+ − 826
+ − 827
+ − 828
lemma L_flat_Prf:
+ − 829
shows "L(r) = {flat v | v. \<Turnstile> v : r}"
+ − 830
using L_flat_Prf1 L_flat_Prf2 by blast
+ − 831
293
+ − 832
thm Prf.intros
+ − 833
thm Prf.cases
273
+ − 834
293
+ − 835
lemma
+ − 836
assumes "\<Turnstile> v : (STAR r)"
+ − 837
shows "\<Turnstile> v : (FROMNTIMES r 0)"
+ − 838
using assms
+ − 839
apply(erule_tac Prf.cases)
+ − 840
apply(simp_all)
+ − 841
apply(case_tac vs)
+ − 842
apply(auto)
+ − 843
apply(subst append_Nil[symmetric])
+ − 844
apply(rule Prf.intros)
+ − 845
apply(auto)
+ − 846
apply(simp add: Prf.intros)
+ − 847
done
+ − 848
+ − 849
lemma
+ − 850
assumes "\<Turnstile> v : (FROMNTIMES r 0)"
+ − 851
shows "\<Turnstile> v : (STAR r)"
+ − 852
using assms
+ − 853
apply(erule_tac Prf.cases)
+ − 854
apply(simp_all)
+ − 855
apply(rule Prf.intros)
+ − 856
apply(simp)
+ − 857
apply(rule Prf.intros)
+ − 858
apply(simp)
+ − 859
done
273
+ − 860
+ − 861
section {* Sets of Lexical Values *}
+ − 862
+ − 863
text {*
+ − 864
Shows that lexical values are finite for a given regex and string.
+ − 865
*}
+ − 866
+ − 867
definition
+ − 868
LV :: "rexp \<Rightarrow> string \<Rightarrow> val set"
+ − 869
where "LV r s \<equiv> {v. \<Turnstile> v : r \<and> flat v = s}"
+ − 870
+ − 871
lemma LV_simps:
+ − 872
shows "LV ZERO s = {}"
+ − 873
and "LV ONE s = (if s = [] then {Void} else {})"
+ − 874
and "LV (CHAR c) s = (if s = [c] then {Char c} else {})"
+ − 875
and "LV (ALT r1 r2) s = Left ` LV r1 s \<union> Right ` LV r2 s"
+ − 876
unfolding LV_def
274
+ − 877
apply(auto intro: Prf.intros elim: Prf.cases)
+ − 878
done
273
+ − 879
+ − 880
abbreviation
275
+ − 881
"Prefixes s \<equiv> {s'. prefix s' s}"
273
+ − 882
+ − 883
abbreviation
275
+ − 884
"Suffixes s \<equiv> {s'. suffix s' s}"
273
+ − 885
+ − 886
abbreviation
275
+ − 887
"SSuffixes s \<equiv> {s'. strict_suffix s' s}"
273
+ − 888
+ − 889
lemma Suffixes_cons [simp]:
+ − 890
shows "Suffixes (c # s) = Suffixes s \<union> {c # s}"
275
+ − 891
by (auto simp add: suffix_def Cons_eq_append_conv)
273
+ − 892
+ − 893
+ − 894
lemma finite_Suffixes:
+ − 895
shows "finite (Suffixes s)"
+ − 896
by (induct s) (simp_all)
+ − 897
+ − 898
lemma finite_SSuffixes:
+ − 899
shows "finite (SSuffixes s)"
+ − 900
proof -
+ − 901
have "SSuffixes s \<subseteq> Suffixes s"
275
+ − 902
unfolding suffix_def strict_suffix_def by auto
273
+ − 903
then show "finite (SSuffixes s)"
+ − 904
using finite_Suffixes finite_subset by blast
+ − 905
qed
+ − 906
+ − 907
lemma finite_Prefixes:
+ − 908
shows "finite (Prefixes s)"
+ − 909
proof -
+ − 910
have "finite (Suffixes (rev s))"
+ − 911
by (rule finite_Suffixes)
+ − 912
then have "finite (rev ` Suffixes (rev s))" by simp
+ − 913
moreover
+ − 914
have "rev ` (Suffixes (rev s)) = Prefixes s"
275
+ − 915
unfolding suffix_def prefix_def image_def
273
+ − 916
by (auto)(metis rev_append rev_rev_ident)+
+ − 917
ultimately show "finite (Prefixes s)" by simp
+ − 918
qed
+ − 919
276
+ − 920
definition
+ − 921
"Stars_Cons V Vs \<equiv> {Stars (v # vs) | v vs. v \<in> V \<and> Stars vs \<in> Vs}"
+ − 922
+ − 923
definition
+ − 924
"Stars_Append Vs1 Vs2 \<equiv> {Stars (vs1 @ vs2) | vs1 vs2. Stars vs1 \<in> Vs1 \<and> Stars vs2 \<in> Vs2}"
+ − 925
+ − 926
fun Stars_Pow :: "val set \<Rightarrow> nat \<Rightarrow> val set"
+ − 927
where
+ − 928
"Stars_Pow Vs 0 = {Stars []}"
+ − 929
| "Stars_Pow Vs (Suc n) = Stars_Cons Vs (Stars_Pow Vs n)"
+ − 930
+ − 931
lemma finite_Stars_Cons:
+ − 932
assumes "finite V" "finite Vs"
+ − 933
shows "finite (Stars_Cons V Vs)"
+ − 934
using assms
+ − 935
proof -
+ − 936
from assms(2) have "finite (Stars -` Vs)"
+ − 937
by(simp add: finite_vimageI inj_on_def)
+ − 938
with assms(1) have "finite (V \<times> (Stars -` Vs))"
+ − 939
by(simp)
+ − 940
then have "finite ((\<lambda>(v, vs). Stars (v # vs)) ` (V \<times> (Stars -` Vs)))"
+ − 941
by simp
+ − 942
moreover have "Stars_Cons V Vs = (\<lambda>(v, vs). Stars (v # vs)) ` (V \<times> (Stars -` Vs))"
+ − 943
unfolding Stars_Cons_def by auto
+ − 944
ultimately show "finite (Stars_Cons V Vs)"
+ − 945
by simp
+ − 946
qed
+ − 947
+ − 948
lemma finite_Stars_Append:
+ − 949
assumes "finite Vs1" "finite Vs2"
+ − 950
shows "finite (Stars_Append Vs1 Vs2)"
+ − 951
using assms
+ − 952
proof -
+ − 953
define UVs1 where "UVs1 \<equiv> Stars -` Vs1"
+ − 954
define UVs2 where "UVs2 \<equiv> Stars -` Vs2"
+ − 955
from assms have "finite UVs1" "finite UVs2"
+ − 956
unfolding UVs1_def UVs2_def
+ − 957
by(simp_all add: finite_vimageI inj_on_def)
+ − 958
then have "finite ((\<lambda>(vs1, vs2). Stars (vs1 @ vs2)) ` (UVs1 \<times> UVs2))"
+ − 959
by simp
+ − 960
moreover
+ − 961
have "Stars_Append Vs1 Vs2 = (\<lambda>(vs1, vs2). Stars (vs1 @ vs2)) ` (UVs1 \<times> UVs2)"
+ − 962
unfolding Stars_Append_def UVs1_def UVs2_def by auto
+ − 963
ultimately show "finite (Stars_Append Vs1 Vs2)"
+ − 964
by simp
+ − 965
qed
+ − 966
+ − 967
lemma finite_Stars_Pow:
+ − 968
assumes "finite Vs"
+ − 969
shows "finite (Stars_Pow Vs n)"
+ − 970
by (induct n) (simp_all add: finite_Stars_Cons assms)
+ − 971
273
+ − 972
lemma LV_STAR_finite:
+ − 973
assumes "\<forall>s. finite (LV r s)"
+ − 974
shows "finite (LV (STAR r) s)"
+ − 975
proof(induct s rule: length_induct)
+ − 976
fix s::"char list"
+ − 977
assume "\<forall>s'. length s' < length s \<longrightarrow> finite (LV (STAR r) s')"
+ − 978
then have IH: "\<forall>s' \<in> SSuffixes s. finite (LV (STAR r) s')"
279
+ − 979
apply(auto simp add: strict_suffix_def suffix_def)
+ − 980
by force
275
+ − 981
define f where "f \<equiv> \<lambda>(v, vs). Stars (v # vs)"
+ − 982
define S1 where "S1 \<equiv> \<Union>s' \<in> Prefixes s. LV r s'"
276
+ − 983
define S2 where "S2 \<equiv> \<Union>s2 \<in> SSuffixes s. LV (STAR r) s2"
273
+ − 984
have "finite S1" using assms
+ − 985
unfolding S1_def by (simp_all add: finite_Prefixes)
+ − 986
moreover
+ − 987
with IH have "finite S2" unfolding S2_def
276
+ − 988
by (auto simp add: finite_SSuffixes)
273
+ − 989
ultimately
276
+ − 990
have "finite ({Stars []} \<union> Stars_Cons S1 S2)"
+ − 991
by (simp add: finite_Stars_Cons)
273
+ − 992
moreover
276
+ − 993
have "LV (STAR r) s \<subseteq> {Stars []} \<union> (Stars_Cons S1 S2)"
+ − 994
unfolding S1_def S2_def f_def LV_def Stars_Cons_def
+ − 995
unfolding prefix_def strict_suffix_def
+ − 996
unfolding image_def
275
+ − 997
apply(auto)
+ − 998
apply(case_tac x)
273
+ − 999
apply(auto elim: Prf_elims)
+ − 1000
apply(erule Prf_elims)
+ − 1001
apply(auto)
+ − 1002
apply(case_tac vs)
275
+ − 1003
apply(auto intro: Prf.intros)
+ − 1004
apply(rule exI)
+ − 1005
apply(rule conjI)
276
+ − 1006
apply(rule_tac x="flats list" in exI)
279
+ − 1007
apply(rule conjI)
+ − 1008
apply(simp add: suffix_def)
275
+ − 1009
apply(blast)
276
+ − 1010
using Prf.intros(6) flat_Stars by blast
273
+ − 1011
ultimately
+ − 1012
show "finite (LV (STAR r) s)" by (simp add: finite_subset)
+ − 1013
qed
+ − 1014
+ − 1015
lemma LV_UPNTIMES_STAR:
+ − 1016
"LV (UPNTIMES r n) s \<subseteq> LV (STAR r) s"
+ − 1017
by(auto simp add: LV_def intro: Prf.intros elim: Prf_elims)
+ − 1018
274
+ − 1019
lemma LV_NTIMES_3:
+ − 1020
shows "LV (NTIMES r (Suc n)) [] = (\<lambda>(v,vs). Stars (v#vs)) ` (LV r [] \<times> (Stars -` (LV (NTIMES r n) [])))"
+ − 1021
unfolding LV_def
+ − 1022
apply(auto elim!: Prf_elims simp add: image_def)
+ − 1023
apply(case_tac vs1)
+ − 1024
apply(auto)
+ − 1025
apply(case_tac vs2)
+ − 1026
apply(auto)
+ − 1027
apply(subst append.simps(1)[symmetric])
+ − 1028
apply(rule Prf.intros)
+ − 1029
apply(auto)
+ − 1030
apply(subst append.simps(1)[symmetric])
+ − 1031
apply(rule Prf.intros)
+ − 1032
apply(auto)
276
+ − 1033
done
275
+ − 1034
276
+ − 1035
lemma LV_FROMNTIMES_3:
+ − 1036
shows "LV (FROMNTIMES r (Suc n)) [] =
+ − 1037
(\<lambda>(v,vs). Stars (v#vs)) ` (LV r [] \<times> (Stars -` (LV (FROMNTIMES r n) [])))"
+ − 1038
unfolding LV_def
+ − 1039
apply(auto elim!: Prf_elims simp add: image_def)
+ − 1040
apply(case_tac vs1)
+ − 1041
apply(auto)
+ − 1042
apply(case_tac vs2)
+ − 1043
apply(auto)
+ − 1044
apply(subst append.simps(1)[symmetric])
+ − 1045
apply(rule Prf.intros)
+ − 1046
apply(auto)
+ − 1047
apply (metis le_imp_less_Suc length_greater_0_conv less_antisym list.exhaust list.set_intros(1) not_less_eq zero_le)
+ − 1048
prefer 2
+ − 1049
using nth_mem apply blast
+ − 1050
apply(case_tac vs1)
+ − 1051
apply (smt Groups.add_ac(2) Prf.intros(9) add.right_neutral add_Suc_right append.simps(1) insert_iff length_append list.set(2) list.size(3) list.size(4))
275
+ − 1052
apply(auto)
276
+ − 1053
done
+ − 1054
+ − 1055
lemma LV_NTIMES_4:
+ − 1056
"LV (NTIMES r n) [] = Stars_Pow (LV r []) n"
+ − 1057
apply(induct n)
+ − 1058
apply(simp add: LV_def)
+ − 1059
apply(auto elim!: Prf_elims simp add: image_def)[1]
+ − 1060
apply(subst append.simps[symmetric])
+ − 1061
apply(rule Prf.intros)
+ − 1062
apply(simp_all)
+ − 1063
apply(simp add: LV_NTIMES_3 image_def Stars_Cons_def)
+ − 1064
apply blast
+ − 1065
done
274
+ − 1066
276
+ − 1067
lemma LV_NTIMES_5:
+ − 1068
"LV (NTIMES r n) s \<subseteq> Stars_Append (LV (STAR r) s) (\<Union>i\<le>n. LV (NTIMES r i) [])"
+ − 1069
apply(auto simp add: LV_def)
+ − 1070
apply(auto elim!: Prf_elims)
+ − 1071
apply(auto simp add: Stars_Append_def)
+ − 1072
apply(rule_tac x="vs1" in exI)
+ − 1073
apply(rule_tac x="vs2" in exI)
+ − 1074
apply(auto)
+ − 1075
using Prf.intros(6) apply(auto)
+ − 1076
apply(rule_tac x="length vs2" in bexI)
+ − 1077
thm Prf.intros
+ − 1078
apply(subst append.simps(1)[symmetric])
+ − 1079
apply(rule Prf.intros)
+ − 1080
apply(auto)[1]
+ − 1081
apply(auto)[1]
+ − 1082
apply(simp)
+ − 1083
apply(simp)
+ − 1084
done
+ − 1085
+ − 1086
lemma ttty:
+ − 1087
"LV (FROMNTIMES r n) [] = Stars_Pow (LV r []) n"
+ − 1088
apply(induct n)
+ − 1089
apply(simp add: LV_def)
+ − 1090
apply(auto elim: Prf_elims simp add: image_def)[1]
+ − 1091
prefer 2
+ − 1092
apply(subst append.simps[symmetric])
+ − 1093
apply(rule Prf.intros)
+ − 1094
apply(simp_all)
+ − 1095
apply(erule Prf_elims)
+ − 1096
apply(case_tac vs1)
+ − 1097
apply(simp)
+ − 1098
apply(simp)
+ − 1099
apply(case_tac x)
+ − 1100
apply(simp_all)
+ − 1101
apply(simp add: LV_FROMNTIMES_3 image_def Stars_Cons_def)
+ − 1102
apply blast
+ − 1103
done
+ − 1104
+ − 1105
lemma LV_FROMNTIMES_5:
+ − 1106
"LV (FROMNTIMES r n) s \<subseteq> Stars_Append (LV (STAR r) s) (\<Union>i\<le>n. LV (FROMNTIMES r i) [])"
+ − 1107
apply(auto simp add: LV_def)
+ − 1108
apply(auto elim!: Prf_elims)
+ − 1109
apply(auto simp add: Stars_Append_def)
+ − 1110
apply(rule_tac x="vs1" in exI)
+ − 1111
apply(rule_tac x="vs2" in exI)
+ − 1112
apply(auto)
+ − 1113
using Prf.intros(6) apply(auto)
+ − 1114
apply(rule_tac x="length vs2" in bexI)
+ − 1115
thm Prf.intros
+ − 1116
apply(subst append.simps(1)[symmetric])
+ − 1117
apply(rule Prf.intros)
+ − 1118
apply(auto)[1]
+ − 1119
apply(auto)[1]
+ − 1120
apply(simp)
+ − 1121
apply(simp)
+ − 1122
apply(rule_tac x="vs" in exI)
+ − 1123
apply(rule_tac x="[]" in exI)
+ − 1124
apply(auto)
+ − 1125
by (metis Prf.intros(9) append_Nil atMost_iff empty_iff le_imp_less_Suc less_antisym list.set(1) nth_mem zero_le)
+ − 1126
+ − 1127
lemma LV_FROMNTIMES_6:
+ − 1128
assumes "\<forall>s. finite (LV r s)"
+ − 1129
shows "finite (LV (FROMNTIMES r n) s)"
275
+ − 1130
apply(rule finite_subset)
276
+ − 1131
apply(rule LV_FROMNTIMES_5)
+ − 1132
apply(rule finite_Stars_Append)
+ − 1133
apply(rule LV_STAR_finite)
+ − 1134
apply(rule assms)
+ − 1135
apply(rule finite_UN_I)
+ − 1136
apply(auto)
+ − 1137
by (simp add: assms finite_Stars_Pow ttty)
275
+ − 1138
276
+ − 1139
lemma LV_NMTIMES_5:
+ − 1140
"LV (NMTIMES r n m) s \<subseteq> Stars_Append (LV (STAR r) s) (\<Union>i\<le>n. LV (FROMNTIMES r i) [])"
+ − 1141
apply(auto simp add: LV_def)
+ − 1142
apply(auto elim!: Prf_elims)
+ − 1143
apply(auto simp add: Stars_Append_def)
+ − 1144
apply(rule_tac x="vs1" in exI)
+ − 1145
apply(rule_tac x="vs2" in exI)
+ − 1146
apply(auto)
+ − 1147
using Prf.intros(6) apply(auto)
+ − 1148
apply(rule_tac x="length vs2" in bexI)
+ − 1149
thm Prf.intros
+ − 1150
apply(subst append.simps(1)[symmetric])
+ − 1151
apply(rule Prf.intros)
+ − 1152
apply(auto)[1]
+ − 1153
apply(auto)[1]
+ − 1154
apply(simp)
+ − 1155
apply(simp)
+ − 1156
apply(rule_tac x="vs" in exI)
+ − 1157
apply(rule_tac x="[]" in exI)
+ − 1158
apply(auto)
+ − 1159
by (metis Prf.intros(9) append_Nil atMost_iff empty_iff le_imp_less_Suc less_antisym list.set(1) nth_mem zero_le)
274
+ − 1160
276
+ − 1161
lemma LV_NMTIMES_6:
+ − 1162
assumes "\<forall>s. finite (LV r s)"
+ − 1163
shows "finite (LV (NMTIMES r n m) s)"
+ − 1164
apply(rule finite_subset)
+ − 1165
apply(rule LV_NMTIMES_5)
+ − 1166
apply(rule finite_Stars_Append)
+ − 1167
apply(rule LV_STAR_finite)
+ − 1168
apply(rule assms)
+ − 1169
apply(rule finite_UN_I)
+ − 1170
apply(auto)
+ − 1171
by (simp add: assms finite_Stars_Pow ttty)
+ − 1172
+ − 1173
273
+ − 1174
lemma LV_finite:
+ − 1175
shows "finite (LV r s)"
+ − 1176
proof(induct r arbitrary: s)
+ − 1177
case (ZERO s)
+ − 1178
show "finite (LV ZERO s)" by (simp add: LV_simps)
+ − 1179
next
+ − 1180
case (ONE s)
+ − 1181
show "finite (LV ONE s)" by (simp add: LV_simps)
+ − 1182
next
+ − 1183
case (CHAR c s)
+ − 1184
show "finite (LV (CHAR c) s)" by (simp add: LV_simps)
+ − 1185
next
+ − 1186
case (ALT r1 r2 s)
+ − 1187
then show "finite (LV (ALT r1 r2) s)" by (simp add: LV_simps)
+ − 1188
next
+ − 1189
case (SEQ r1 r2 s)
275
+ − 1190
define f where "f \<equiv> \<lambda>(v1, v2). Seq v1 v2"
+ − 1191
define S1 where "S1 \<equiv> \<Union>s' \<in> Prefixes s. LV r1 s'"
+ − 1192
define S2 where "S2 \<equiv> \<Union>s' \<in> Suffixes s. LV r2 s'"
273
+ − 1193
have IHs: "\<And>s. finite (LV r1 s)" "\<And>s. finite (LV r2 s)" by fact+
+ − 1194
then have "finite S1" "finite S2" unfolding S1_def S2_def
+ − 1195
by (simp_all add: finite_Prefixes finite_Suffixes)
+ − 1196
moreover
+ − 1197
have "LV (SEQ r1 r2) s \<subseteq> f ` (S1 \<times> S2)"
+ − 1198
unfolding f_def S1_def S2_def
275
+ − 1199
unfolding LV_def image_def prefix_def suffix_def
+ − 1200
apply (auto elim!: Prf_elims)
+ − 1201
by (metis (mono_tags, lifting) mem_Collect_eq)
273
+ − 1202
ultimately
+ − 1203
show "finite (LV (SEQ r1 r2) s)"
+ − 1204
by (simp add: finite_subset)
+ − 1205
next
+ − 1206
case (STAR r s)
+ − 1207
then show "finite (LV (STAR r) s)" by (simp add: LV_STAR_finite)
+ − 1208
next
274
+ − 1209
case (UPNTIMES r n s)
273
+ − 1210
have "\<And>s. finite (LV r s)" by fact
274
+ − 1211
then show "finite (LV (UPNTIMES r n) s)"
+ − 1212
by (meson LV_STAR_finite LV_UPNTIMES_STAR rev_finite_subset)
+ − 1213
next
+ − 1214
case (FROMNTIMES r n s)
+ − 1215
have "\<And>s. finite (LV r s)" by fact
+ − 1216
then show "finite (LV (FROMNTIMES r n) s)"
276
+ − 1217
by (simp add: LV_FROMNTIMES_6)
+ − 1218
next
+ − 1219
case (NTIMES r n s)
+ − 1220
have "\<And>s. finite (LV r s)" by fact
+ − 1221
then show "finite (LV (NTIMES r n) s)"
+ − 1222
by (metis (no_types, lifting) LV_NTIMES_4 LV_NTIMES_5 LV_STAR_finite finite_Stars_Append finite_Stars_Pow finite_UN_I finite_atMost finite_subset)
+ − 1223
next
+ − 1224
case (NMTIMES r n m s)
+ − 1225
have "\<And>s. finite (LV r s)" by fact
+ − 1226
then show "finite (LV (NMTIMES r n m) s)"
+ − 1227
by (simp add: LV_NMTIMES_6)
273
+ − 1228
qed
+ − 1229
+ − 1230
+ − 1231
+ − 1232
section {* Our POSIX Definition *}
+ − 1233
+ − 1234
inductive
+ − 1235
Posix :: "string \<Rightarrow> rexp \<Rightarrow> val \<Rightarrow> bool" ("_ \<in> _ \<rightarrow> _" [100, 100, 100] 100)
+ − 1236
where
+ − 1237
Posix_ONE: "[] \<in> ONE \<rightarrow> Void"
+ − 1238
| Posix_CHAR: "[c] \<in> (CHAR c) \<rightarrow> (Char c)"
+ − 1239
| Posix_ALT1: "s \<in> r1 \<rightarrow> v \<Longrightarrow> s \<in> (ALT r1 r2) \<rightarrow> (Left v)"
+ − 1240
| Posix_ALT2: "\<lbrakk>s \<in> r2 \<rightarrow> v; s \<notin> L(r1)\<rbrakk> \<Longrightarrow> s \<in> (ALT r1 r2) \<rightarrow> (Right v)"
+ − 1241
| Posix_SEQ: "\<lbrakk>s1 \<in> r1 \<rightarrow> v1; s2 \<in> r2 \<rightarrow> v2;
+ − 1242
\<not>(\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (s1 @ s\<^sub>3) \<in> L r1 \<and> s\<^sub>4 \<in> L r2)\<rbrakk> \<Longrightarrow>
+ − 1243
(s1 @ s2) \<in> (SEQ r1 r2) \<rightarrow> (Seq v1 v2)"
+ − 1244
| Posix_STAR1: "\<lbrakk>s1 \<in> r \<rightarrow> v; s2 \<in> STAR r \<rightarrow> Stars vs; flat v \<noteq> [];
+ − 1245
\<not>(\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (s1 @ s\<^sub>3) \<in> L r \<and> s\<^sub>4 \<in> L (STAR r))\<rbrakk>
+ − 1246
\<Longrightarrow> (s1 @ s2) \<in> STAR r \<rightarrow> Stars (v # vs)"
+ − 1247
| Posix_STAR2: "[] \<in> STAR r \<rightarrow> Stars []"
276
+ − 1248
| Posix_NTIMES1: "\<lbrakk>s1 \<in> r \<rightarrow> v; s2 \<in> NTIMES r (n - 1) \<rightarrow> Stars vs; flat v \<noteq> []; 0 < n;
+ − 1249
\<not>(\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (s1 @ s\<^sub>3) \<in> L r \<and> s\<^sub>4 \<in> L (NTIMES r (n - 1)))\<rbrakk>
+ − 1250
\<Longrightarrow> (s1 @ s2) \<in> NTIMES r n \<rightarrow> Stars (v # vs)"
+ − 1251
| Posix_NTIMES2: "\<lbrakk>\<forall>v \<in> set vs. [] \<in> r \<rightarrow> v; length vs = n\<rbrakk>
+ − 1252
\<Longrightarrow> [] \<in> NTIMES r n \<rightarrow> Stars vs"
+ − 1253
| Posix_UPNTIMES1: "\<lbrakk>s1 \<in> r \<rightarrow> v; s2 \<in> UPNTIMES r (n - 1) \<rightarrow> Stars vs; flat v \<noteq> []; 0 < n;
+ − 1254
\<not>(\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (s1 @ s\<^sub>3) \<in> L r \<and> s\<^sub>4 \<in> L (UPNTIMES r (n - 1)))\<rbrakk>
+ − 1255
\<Longrightarrow> (s1 @ s2) \<in> UPNTIMES r n \<rightarrow> Stars (v # vs)"
+ − 1256
| Posix_UPNTIMES2: "[] \<in> UPNTIMES r n \<rightarrow> Stars []"
+ − 1257
| Posix_FROMNTIMES2: "\<lbrakk>\<forall>v \<in> set vs. [] \<in> r \<rightarrow> v; length vs = n\<rbrakk>
+ − 1258
\<Longrightarrow> [] \<in> FROMNTIMES r n \<rightarrow> Stars vs"
+ − 1259
| Posix_FROMNTIMES1: "\<lbrakk>s1 \<in> r \<rightarrow> v; s2 \<in> FROMNTIMES r (n - 1) \<rightarrow> Stars vs; flat v \<noteq> []; 0 < n;
+ − 1260
\<not>(\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (s1 @ s\<^sub>3) \<in> L r \<and> s\<^sub>4 \<in> L (FROMNTIMES r (n - 1)))\<rbrakk>
+ − 1261
\<Longrightarrow> (s1 @ s2) \<in> FROMNTIMES r n \<rightarrow> Stars (v # vs)"
277
+ − 1262
| Posix_FROMNTIMES3: "\<lbrakk>s1 \<in> r \<rightarrow> v; s2 \<in> STAR r \<rightarrow> Stars vs; flat v \<noteq> [];
+ − 1263
\<not>(\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (s1 @ s\<^sub>3) \<in> L r \<and> s\<^sub>4 \<in> L (STAR r))\<rbrakk>
+ − 1264
\<Longrightarrow> (s1 @ s2) \<in> FROMNTIMES r 0 \<rightarrow> Stars (v # vs)"
276
+ − 1265
| Posix_NMTIMES2: "\<lbrakk>\<forall>v \<in> set vs. [] \<in> r \<rightarrow> v; length vs = n; n \<le> m\<rbrakk>
+ − 1266
\<Longrightarrow> [] \<in> NMTIMES r n m \<rightarrow> Stars vs"
278
+ − 1267
| Posix_NMTIMES1: "\<lbrakk>s1 \<in> r \<rightarrow> v; s2 \<in> NMTIMES r (n - 1) (m - 1) \<rightarrow> Stars vs; flat v \<noteq> []; 0 < n; n \<le> m;
+ − 1268
\<not>(\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (s1 @ s\<^sub>3) \<in> L r \<and> s\<^sub>4 \<in> L (NMTIMES r (n - 1) (m - 1)))\<rbrakk>
+ − 1269
\<Longrightarrow> (s1 @ s2) \<in> NMTIMES r n m \<rightarrow> Stars (v # vs)"
+ − 1270
| Posix_NMTIMES3: "\<lbrakk>s1 \<in> r \<rightarrow> v; s2 \<in> UPNTIMES r (m - 1) \<rightarrow> Stars vs; flat v \<noteq> []; 0 < m;
+ − 1271
\<not>(\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (s1 @ s\<^sub>3) \<in> L r \<and> s\<^sub>4 \<in> L (UPNTIMES r (m - 1)))\<rbrakk>
+ − 1272
\<Longrightarrow> (s1 @ s2) \<in> NMTIMES r 0 m \<rightarrow> Stars (v # vs)"
276
+ − 1273
273
+ − 1274
inductive_cases Posix_elims:
+ − 1275
"s \<in> ZERO \<rightarrow> v"
+ − 1276
"s \<in> ONE \<rightarrow> v"
+ − 1277
"s \<in> CHAR c \<rightarrow> v"
+ − 1278
"s \<in> ALT r1 r2 \<rightarrow> v"
+ − 1279
"s \<in> SEQ r1 r2 \<rightarrow> v"
+ − 1280
"s \<in> STAR r \<rightarrow> v"
276
+ − 1281
"s \<in> NTIMES r n \<rightarrow> v"
+ − 1282
"s \<in> UPNTIMES r n \<rightarrow> v"
+ − 1283
"s \<in> FROMNTIMES r n \<rightarrow> v"
+ − 1284
"s \<in> NMTIMES r n m \<rightarrow> v"
+ − 1285
273
+ − 1286
lemma Posix1:
+ − 1287
assumes "s \<in> r \<rightarrow> v"
+ − 1288
shows "s \<in> L r" "flat v = s"
+ − 1289
using assms
276
+ − 1290
apply(induct s r v rule: Posix.induct)
+ − 1291
apply(auto simp add: Sequ_def)[18]
+ − 1292
apply(case_tac n)
+ − 1293
apply(simp)
+ − 1294
apply(simp add: Sequ_def)
+ − 1295
apply(auto)[1]
+ − 1296
apply(simp)
+ − 1297
apply(clarify)
+ − 1298
apply(rule_tac x="Suc x" in bexI)
+ − 1299
apply(simp add: Sequ_def)
+ − 1300
apply(auto)[5]
+ − 1301
using nth_mem nullable.simps(9) nullable_correctness apply auto[1]
+ − 1302
apply simp
+ − 1303
apply(simp)
+ − 1304
apply(clarify)
+ − 1305
apply(rule_tac x="Suc x" in bexI)
+ − 1306
apply(simp add: Sequ_def)
+ − 1307
apply(auto)[3]
277
+ − 1308
defer
276
+ − 1309
apply(simp)
+ − 1310
apply fastforce
+ − 1311
apply(simp)
+ − 1312
apply(simp)
+ − 1313
apply(clarify)
+ − 1314
apply(rule_tac x="Suc x" in bexI)
+ − 1315
apply(auto simp add: Sequ_def)[2]
+ − 1316
apply(simp)
278
+ − 1317
apply(simp)
+ − 1318
apply(clarify)
+ − 1319
apply(rule_tac x="Suc x" in bexI)
+ − 1320
apply(auto simp add: Sequ_def)[2]
+ − 1321
apply(simp)
+ − 1322
apply(simp add: Star.step Star_Pow)
+ − 1323
done
+ − 1324
273
+ − 1325
text {*
+ − 1326
Our Posix definition determines a unique value.
+ − 1327
*}
276
+ − 1328
+ − 1329
lemma List_eq_zipI:
+ − 1330
assumes "\<forall>(v1, v2) \<in> set (zip vs1 vs2). v1 = v2"
+ − 1331
and "length vs1 = length vs2"
+ − 1332
shows "vs1 = vs2"
+ − 1333
using assms
+ − 1334
apply(induct vs1 arbitrary: vs2)
+ − 1335
apply(case_tac vs2)
+ − 1336
apply(simp)
+ − 1337
apply(simp)
+ − 1338
apply(case_tac vs2)
+ − 1339
apply(simp)
+ − 1340
apply(simp)
+ − 1341
done
273
+ − 1342
+ − 1343
lemma Posix_determ:
+ − 1344
assumes "s \<in> r \<rightarrow> v1" "s \<in> r \<rightarrow> v2"
+ − 1345
shows "v1 = v2"
+ − 1346
using assms
+ − 1347
proof (induct s r v1 arbitrary: v2 rule: Posix.induct)
+ − 1348
case (Posix_ONE v2)
+ − 1349
have "[] \<in> ONE \<rightarrow> v2" by fact
+ − 1350
then show "Void = v2" by cases auto
+ − 1351
next
+ − 1352
case (Posix_CHAR c v2)
+ − 1353
have "[c] \<in> CHAR c \<rightarrow> v2" by fact
+ − 1354
then show "Char c = v2" by cases auto
+ − 1355
next
+ − 1356
case (Posix_ALT1 s r1 v r2 v2)
+ − 1357
have "s \<in> ALT r1 r2 \<rightarrow> v2" by fact
+ − 1358
moreover
+ − 1359
have "s \<in> r1 \<rightarrow> v" by fact
+ − 1360
then have "s \<in> L r1" by (simp add: Posix1)
+ − 1361
ultimately obtain v' where eq: "v2 = Left v'" "s \<in> r1 \<rightarrow> v'" by cases auto
+ − 1362
moreover
+ − 1363
have IH: "\<And>v2. s \<in> r1 \<rightarrow> v2 \<Longrightarrow> v = v2" by fact
+ − 1364
ultimately have "v = v'" by simp
+ − 1365
then show "Left v = v2" using eq by simp
+ − 1366
next
+ − 1367
case (Posix_ALT2 s r2 v r1 v2)
+ − 1368
have "s \<in> ALT r1 r2 \<rightarrow> v2" by fact
+ − 1369
moreover
+ − 1370
have "s \<notin> L r1" by fact
+ − 1371
ultimately obtain v' where eq: "v2 = Right v'" "s \<in> r2 \<rightarrow> v'"
+ − 1372
by cases (auto simp add: Posix1)
+ − 1373
moreover
+ − 1374
have IH: "\<And>v2. s \<in> r2 \<rightarrow> v2 \<Longrightarrow> v = v2" by fact
+ − 1375
ultimately have "v = v'" by simp
+ − 1376
then show "Right v = v2" using eq by simp
+ − 1377
next
+ − 1378
case (Posix_SEQ s1 r1 v1 s2 r2 v2 v')
+ − 1379
have "(s1 @ s2) \<in> SEQ r1 r2 \<rightarrow> v'"
+ − 1380
"s1 \<in> r1 \<rightarrow> v1" "s2 \<in> r2 \<rightarrow> v2"
+ − 1381
"\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L r1 \<and> s\<^sub>4 \<in> L r2)" by fact+
+ − 1382
then obtain v1' v2' where "v' = Seq v1' v2'" "s1 \<in> r1 \<rightarrow> v1'" "s2 \<in> r2 \<rightarrow> v2'"
+ − 1383
apply(cases) apply (auto simp add: append_eq_append_conv2)
+ − 1384
using Posix1(1) by fastforce+
+ − 1385
moreover
+ − 1386
have IHs: "\<And>v1'. s1 \<in> r1 \<rightarrow> v1' \<Longrightarrow> v1 = v1'"
+ − 1387
"\<And>v2'. s2 \<in> r2 \<rightarrow> v2' \<Longrightarrow> v2 = v2'" by fact+
+ − 1388
ultimately show "Seq v1 v2 = v'" by simp
+ − 1389
next
+ − 1390
case (Posix_STAR1 s1 r v s2 vs v2)
+ − 1391
have "(s1 @ s2) \<in> STAR r \<rightarrow> v2"
+ − 1392
"s1 \<in> r \<rightarrow> v" "s2 \<in> STAR r \<rightarrow> Stars vs" "flat v \<noteq> []"
+ − 1393
"\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L r \<and> s\<^sub>4 \<in> L (STAR r))" by fact+
+ − 1394
then obtain v' vs' where "v2 = Stars (v' # vs')" "s1 \<in> r \<rightarrow> v'" "s2 \<in> (STAR r) \<rightarrow> (Stars vs')"
+ − 1395
apply(cases) apply (auto simp add: append_eq_append_conv2)
+ − 1396
using Posix1(1) apply fastforce
+ − 1397
apply (metis Posix1(1) Posix_STAR1.hyps(6) append_Nil append_Nil2)
+ − 1398
using Posix1(2) by blast
+ − 1399
moreover
+ − 1400
have IHs: "\<And>v2. s1 \<in> r \<rightarrow> v2 \<Longrightarrow> v = v2"
+ − 1401
"\<And>v2. s2 \<in> STAR r \<rightarrow> v2 \<Longrightarrow> Stars vs = v2" by fact+
+ − 1402
ultimately show "Stars (v # vs) = v2" by auto
+ − 1403
next
+ − 1404
case (Posix_STAR2 r v2)
+ − 1405
have "[] \<in> STAR r \<rightarrow> v2" by fact
+ − 1406
then show "Stars [] = v2" by cases (auto simp add: Posix1)
276
+ − 1407
next
+ − 1408
case (Posix_NTIMES2 vs r n v2)
+ − 1409
then show "Stars vs = v2"
+ − 1410
apply(erule_tac Posix_elims)
+ − 1411
apply(auto)
+ − 1412
apply (simp add: Posix1(2))
+ − 1413
apply(rule List_eq_zipI)
+ − 1414
apply(auto)
+ − 1415
by (meson in_set_zipE)
+ − 1416
next
+ − 1417
case (Posix_NTIMES1 s1 r v s2 n vs v2)
+ − 1418
have "(s1 @ s2) \<in> NTIMES r n \<rightarrow> v2"
+ − 1419
"s1 \<in> r \<rightarrow> v" "s2 \<in> NTIMES r (n - 1) \<rightarrow> Stars vs" "flat v \<noteq> []"
+ − 1420
"\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L r \<and> s\<^sub>4 \<in> L (NTIMES r (n - 1 )))" by fact+
+ − 1421
then obtain v' vs' where "v2 = Stars (v' # vs')" "s1 \<in> r \<rightarrow> v'" "s2 \<in> (NTIMES r (n - 1)) \<rightarrow> (Stars vs')"
+ − 1422
apply(cases) apply (auto simp add: append_eq_append_conv2)
+ − 1423
using Posix1(1) apply fastforce
+ − 1424
apply (metis One_nat_def Posix1(1) Posix_NTIMES1.hyps(7) append.right_neutral append_self_conv2)
+ − 1425
using Posix1(2) by blast
+ − 1426
moreover
+ − 1427
have IHs: "\<And>v2. s1 \<in> r \<rightarrow> v2 \<Longrightarrow> v = v2"
+ − 1428
"\<And>v2. s2 \<in> NTIMES r (n - 1) \<rightarrow> v2 \<Longrightarrow> Stars vs = v2" by fact+
+ − 1429
ultimately show "Stars (v # vs) = v2" by auto
+ − 1430
next
+ − 1431
case (Posix_UPNTIMES1 s1 r v s2 n vs v2)
+ − 1432
have "(s1 @ s2) \<in> UPNTIMES r n \<rightarrow> v2"
+ − 1433
"s1 \<in> r \<rightarrow> v" "s2 \<in> UPNTIMES r (n - 1) \<rightarrow> Stars vs" "flat v \<noteq> []"
+ − 1434
"\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L r \<and> s\<^sub>4 \<in> L (UPNTIMES r (n - 1 )))" by fact+
+ − 1435
then obtain v' vs' where "v2 = Stars (v' # vs')" "s1 \<in> r \<rightarrow> v'" "s2 \<in> (UPNTIMES r (n - 1)) \<rightarrow> (Stars vs')"
+ − 1436
apply(cases) apply (auto simp add: append_eq_append_conv2)
+ − 1437
using Posix1(1) apply fastforce
+ − 1438
apply (metis One_nat_def Posix1(1) Posix_UPNTIMES1.hyps(7) append.right_neutral append_self_conv2)
+ − 1439
using Posix1(2) by blast
+ − 1440
moreover
+ − 1441
have IHs: "\<And>v2. s1 \<in> r \<rightarrow> v2 \<Longrightarrow> v = v2"
+ − 1442
"\<And>v2. s2 \<in> UPNTIMES r (n - 1) \<rightarrow> v2 \<Longrightarrow> Stars vs = v2" by fact+
+ − 1443
ultimately show "Stars (v # vs) = v2" by auto
+ − 1444
next
+ − 1445
case (Posix_UPNTIMES2 r n v2)
+ − 1446
then show "Stars [] = v2"
+ − 1447
apply(erule_tac Posix_elims)
+ − 1448
apply(auto)
+ − 1449
by (simp add: Posix1(2))
+ − 1450
next
+ − 1451
case (Posix_FROMNTIMES1 s1 r v s2 n vs v2)
+ − 1452
have "(s1 @ s2) \<in> FROMNTIMES r n \<rightarrow> v2"
277
+ − 1453
"s1 \<in> r \<rightarrow> v" "s2 \<in> FROMNTIMES r (n - 1) \<rightarrow> Stars vs" "flat v \<noteq> []" "0 < n"
276
+ − 1454
"\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L r \<and> s\<^sub>4 \<in> L (FROMNTIMES r (n - 1 )))" by fact+
+ − 1455
then obtain v' vs' where "v2 = Stars (v' # vs')" "s1 \<in> r \<rightarrow> v'" "s2 \<in> (FROMNTIMES r (n - 1)) \<rightarrow> (Stars vs')"
+ − 1456
apply(cases) apply (auto simp add: append_eq_append_conv2)
+ − 1457
using Posix1(1) Posix1(2) apply blast
+ − 1458
apply(case_tac n)
+ − 1459
apply(simp)
277
+ − 1460
apply(simp)
+ − 1461
apply(drule_tac x="va" in meta_spec)
+ − 1462
apply(drule_tac x="vs" in meta_spec)
+ − 1463
apply(simp)
+ − 1464
apply(drule meta_mp)
+ − 1465
apply (metis L.simps(9) Posix1(1) UN_E append.right_neutral append_Nil diff_Suc_1 local.Posix_FROMNTIMES1(4) val.inject(5))
+ − 1466
apply (metis L.simps(9) Posix1(1) UN_E append.right_neutral append_Nil)
+ − 1467
by (metis One_nat_def Posix1(1) Posix_FROMNTIMES1.hyps(7) self_append_conv self_append_conv2)
276
+ − 1468
moreover
+ − 1469
have IHs: "\<And>v2. s1 \<in> r \<rightarrow> v2 \<Longrightarrow> v = v2"
+ − 1470
"\<And>v2. s2 \<in> FROMNTIMES r (n - 1) \<rightarrow> v2 \<Longrightarrow> Stars vs = v2" by fact+
+ − 1471
ultimately show "Stars (v # vs) = v2" by auto
+ − 1472
next
+ − 1473
case (Posix_FROMNTIMES2 vs r n v2)
+ − 1474
then show "Stars vs = v2"
+ − 1475
apply(erule_tac Posix_elims)
+ − 1476
apply(auto)
+ − 1477
apply(rule List_eq_zipI)
+ − 1478
apply(auto)
277
+ − 1479
apply(meson in_set_zipE)
+ − 1480
apply (simp add: Posix1(2))
+ − 1481
using Posix1(2) by blast
276
+ − 1482
next
277
+ − 1483
case (Posix_FROMNTIMES3 s1 r v s2 vs v2)
+ − 1484
have "(s1 @ s2) \<in> FROMNTIMES r 0 \<rightarrow> v2"
+ − 1485
"s1 \<in> r \<rightarrow> v" "s2 \<in> STAR r \<rightarrow> Stars vs" "flat v \<noteq> []"
+ − 1486
"\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L r \<and> s\<^sub>4 \<in> L (STAR r))" by fact+
+ − 1487
then obtain v' vs' where "v2 = Stars (v' # vs')" "s1 \<in> r \<rightarrow> v'" "s2 \<in> (STAR r) \<rightarrow> (Stars vs')"
+ − 1488
apply(cases) apply (auto simp add: append_eq_append_conv2)
+ − 1489
using Posix1(2) apply fastforce
+ − 1490
using Posix1(1) apply fastforce
+ − 1491
by (metis Posix1(1) Posix_FROMNTIMES3.hyps(6) append.right_neutral append_Nil)
+ − 1492
moreover
+ − 1493
have IHs: "\<And>v2. s1 \<in> r \<rightarrow> v2 \<Longrightarrow> v = v2"
+ − 1494
"\<And>v2. s2 \<in> STAR r \<rightarrow> v2 \<Longrightarrow> Stars vs = v2" by fact+
+ − 1495
ultimately show "Stars (v # vs) = v2" by auto
+ − 1496
next
276
+ − 1497
case (Posix_NMTIMES1 s1 r v s2 n m vs v2)
278
+ − 1498
have "(s1 @ s2) \<in> NMTIMES r n m \<rightarrow> v2"
+ − 1499
"s1 \<in> r \<rightarrow> v" "s2 \<in> NMTIMES r (n - 1) (m - 1) \<rightarrow> Stars vs" "flat v \<noteq> []"
+ − 1500
"0 < n" "n \<le> m"
+ − 1501
"\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L r \<and> s\<^sub>4 \<in> L (NMTIMES r (n - 1) (m - 1)))" by fact+
+ − 1502
then obtain v' vs' where "v2 = Stars (v' # vs')" "s1 \<in> r \<rightarrow> v'"
+ − 1503
"s2 \<in> (NMTIMES r (n - 1) (m - 1)) \<rightarrow> (Stars vs')"
+ − 1504
apply(cases) apply (auto simp add: append_eq_append_conv2)
+ − 1505
using Posix1(1) Posix1(2) apply blast
+ − 1506
apply(case_tac n)
+ − 1507
apply(simp)
+ − 1508
apply(simp)
+ − 1509
apply(case_tac m)
+ − 1510
apply(simp)
+ − 1511
apply(simp)
+ − 1512
apply(drule_tac x="va" in meta_spec)
+ − 1513
apply(drule_tac x="vs" in meta_spec)
+ − 1514
apply(simp)
+ − 1515
apply(drule meta_mp)
280
+ − 1516
apply(drule Posix1(1))
+ − 1517
apply(drule Posix1(1))
+ − 1518
apply(drule Posix1(1))
+ − 1519
apply(frule Posix1(1))
+ − 1520
apply(simp)
+ − 1521
using Posix_NMTIMES1.hyps(4) apply force
278
+ − 1522
apply (metis L.simps(10) Posix1(1) UN_E append_Nil2 append_self_conv2)
+ − 1523
by (metis One_nat_def Posix1(1) Posix_NMTIMES1.hyps(8) append.right_neutral append_Nil)
+ − 1524
moreover
+ − 1525
have IHs: "\<And>v2. s1 \<in> r \<rightarrow> v2 \<Longrightarrow> v = v2"
+ − 1526
"\<And>v2. s2 \<in> NMTIMES r (n - 1) (m - 1) \<rightarrow> v2 \<Longrightarrow> Stars vs = v2" by fact+
+ − 1527
ultimately show "Stars (v # vs) = v2" by auto
276
+ − 1528
next
+ − 1529
case (Posix_NMTIMES2 vs r n m v2)
+ − 1530
then show "Stars vs = v2"
278
+ − 1531
apply(erule_tac Posix_elims)
+ − 1532
apply(simp)
+ − 1533
apply(rule List_eq_zipI)
+ − 1534
apply(auto)
+ − 1535
apply (meson in_set_zipE)
+ − 1536
apply (simp add: Posix1(2))
+ − 1537
apply(erule_tac Posix_elims)
+ − 1538
apply(auto)
+ − 1539
apply (simp add: Posix1(2))+
+ − 1540
done
+ − 1541
next
+ − 1542
case (Posix_NMTIMES3 s1 r v s2 m vs v2)
+ − 1543
have "(s1 @ s2) \<in> NMTIMES r 0 m \<rightarrow> v2"
+ − 1544
"s1 \<in> r \<rightarrow> v" "s2 \<in> UPNTIMES r (m - 1) \<rightarrow> Stars vs" "flat v \<noteq> []" "0 < m"
+ − 1545
"\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L r \<and> s\<^sub>4 \<in> L (UPNTIMES r (m - 1 )))" by fact+
+ − 1546
then obtain v' vs' where "v2 = Stars (v' # vs')" "s1 \<in> r \<rightarrow> v'" "s2 \<in> (UPNTIMES r (m - 1)) \<rightarrow> (Stars vs')"
+ − 1547
apply(cases) apply (auto simp add: append_eq_append_conv2)
+ − 1548
using Posix1(2) apply blast
+ − 1549
apply (smt L.simps(7) Posix1(1) UN_E append_eq_append_conv2)
+ − 1550
by (metis One_nat_def Posix1(1) Posix_NMTIMES3.hyps(7) append.right_neutral append_Nil)
+ − 1551
moreover
+ − 1552
have IHs: "\<And>v2. s1 \<in> r \<rightarrow> v2 \<Longrightarrow> v = v2"
+ − 1553
"\<And>v2. s2 \<in> UPNTIMES r (m - 1) \<rightarrow> v2 \<Longrightarrow> Stars vs = v2" by fact+
+ − 1554
ultimately show "Stars (v # vs) = v2" by auto
273
+ − 1555
qed
+ − 1556
+ − 1557
+ − 1558
text {*
+ − 1559
Our POSIX value is a lexical value.
+ − 1560
*}
+ − 1561
+ − 1562
lemma Posix_LV:
+ − 1563
assumes "s \<in> r \<rightarrow> v"
+ − 1564
shows "v \<in> LV r s"
+ − 1565
using assms unfolding LV_def
+ − 1566
apply(induct rule: Posix.induct)
276
+ − 1567
apply(auto simp add: intro!: Prf.intros elim!: Prf_elims)[7]
+ − 1568
defer
+ − 1569
defer
+ − 1570
apply(auto simp add: intro!: Prf.intros elim!: Prf_elims)[2]
+ − 1571
apply (metis (mono_tags, lifting) Prf.intros(9) append_Nil empty_iff flat_Stars flats_empty list.set(1) mem_Collect_eq)
277
+ − 1572
apply(simp)
+ − 1573
apply(clarify)
+ − 1574
apply(case_tac n)
+ − 1575
apply(simp)
+ − 1576
apply(simp)
+ − 1577
apply(erule Prf_elims)
+ − 1578
apply(simp)
276
+ − 1579
apply(subst append.simps(2)[symmetric])
277
+ − 1580
apply(rule Prf.intros)
+ − 1581
apply(simp)
+ − 1582
apply(simp)
+ − 1583
apply(simp)
+ − 1584
apply(simp)
+ − 1585
apply(rule Prf.intros)
+ − 1586
apply(simp)
+ − 1587
apply(simp)
+ − 1588
apply(simp)
+ − 1589
apply(clarify)
+ − 1590
apply(erule Prf_elims)
+ − 1591
apply(simp)
+ − 1592
apply(rule Prf.intros)
+ − 1593
apply(simp)
278
+ − 1594
apply(simp)
+ − 1595
(* NTIMES *)
+ − 1596
prefer 4
+ − 1597
apply(simp)
+ − 1598
apply(case_tac n)
277
+ − 1599
apply(simp)
278
+ − 1600
apply(simp)
+ − 1601
apply(clarify)
+ − 1602
apply(rotate_tac 5)
+ − 1603
apply(erule Prf_elims)
+ − 1604
apply(simp)
+ − 1605
apply(subst append.simps(2)[symmetric])
+ − 1606
apply(rule Prf.intros)
+ − 1607
apply(simp)
+ − 1608
apply(simp)
+ − 1609
apply(simp)
+ − 1610
prefer 4
+ − 1611
apply(simp)
+ − 1612
apply (metis Prf.intros(8) length_removeAll_less less_irrefl_nat removeAll.simps(1) self_append_conv2)
277
+ − 1613
(* NMTIMES *)
278
+ − 1614
apply(simp)
+ − 1615
apply (metis Prf.intros(11) append_Nil empty_iff list.set(1))
+ − 1616
apply(simp)
+ − 1617
apply(clarify)
+ − 1618
apply(rotate_tac 6)
+ − 1619
apply(erule Prf_elims)
+ − 1620
apply(simp)
+ − 1621
apply(subst append.simps(2)[symmetric])
+ − 1622
apply(rule Prf.intros)
+ − 1623
apply(simp)
+ − 1624
apply(simp)
+ − 1625
apply(simp)
+ − 1626
apply(simp)
+ − 1627
apply(rule Prf.intros)
+ − 1628
apply(simp)
+ − 1629
apply(simp)
+ − 1630
apply(simp)
+ − 1631
apply(simp)
+ − 1632
apply(clarify)
+ − 1633
apply(rotate_tac 6)
+ − 1634
apply(erule Prf_elims)
+ − 1635
apply(simp)
+ − 1636
apply(rule Prf.intros)
+ − 1637
apply(simp)
+ − 1638
apply(simp)
+ − 1639
apply(simp)
+ − 1640
done
276
+ − 1641
273
+ − 1642
end