src/HOL/Lex/RegExp2NAe.ML
author paulson
Thu Sep 10 17:27:50 1998 +0200 (1998-09-10)
changeset 5457 367878234bb2
parent 5337 2f7d09a927c4
child 5608 a82a038a3e7a
permissions -rw-r--r--
tidied, fixing PROOF FAILED
nipkow@4907
     1
(*  Title:      HOL/Lex/RegExp2NAe.ML
nipkow@4907
     2
    ID:         $Id$
nipkow@4907
     3
    Author:     Tobias Nipkow
nipkow@4907
     4
    Copyright   1998 TUM
nipkow@4907
     5
*)
nipkow@4907
     6
nipkow@4907
     7
(******************************************************)
nipkow@4907
     8
(*                       atom                         *)
nipkow@4907
     9
(******************************************************)
nipkow@4907
    10
wenzelm@5069
    11
Goalw [atom_def] "(fin (atom a) q) = (q = [False])";
wenzelm@5132
    12
by (Simp_tac 1);
nipkow@4907
    13
qed "fin_atom";
nipkow@4907
    14
wenzelm@5069
    15
Goalw [atom_def] "start (atom a) = [True]";
wenzelm@5132
    16
by (Simp_tac 1);
nipkow@4907
    17
qed "start_atom";
nipkow@4907
    18
nipkow@4907
    19
(* Use {x. False} = {}? *)
nipkow@4907
    20
wenzelm@5069
    21
Goalw [atom_def,step_def]
nipkow@4907
    22
 "eps(atom a) = {}";
wenzelm@5132
    23
by (Simp_tac 1);
nipkow@4907
    24
by (Blast_tac 1);
nipkow@4907
    25
qed "eps_atom";
nipkow@4907
    26
Addsimps [eps_atom];
nipkow@4907
    27
wenzelm@5069
    28
Goalw [atom_def,step_def]
nipkow@4907
    29
 "(p,q) : step (atom a) (Some b) = (p=[True] & q=[False] & b=a)";
wenzelm@5132
    30
by (Simp_tac 1);
nipkow@4907
    31
qed "in_step_atom_Some";
nipkow@4907
    32
Addsimps [in_step_atom_Some];
nipkow@4907
    33
nipkow@5118
    34
Goal "([False],[False]) : steps (atom a) w = (w = [])";
nipkow@4907
    35
by (induct_tac "w" 1);
wenzelm@5132
    36
 by (Simp_tac 1);
wenzelm@5132
    37
by (asm_simp_tac (simpset() addsimps [comp_def]) 1);
nipkow@4907
    38
qed "False_False_in_steps_atom";
nipkow@4907
    39
nipkow@5118
    40
Goal "(start (atom a), [False]) : steps (atom a) w = (w = [a])";
nipkow@4907
    41
by (induct_tac "w" 1);
wenzelm@5132
    42
 by (asm_simp_tac (simpset() addsimps [start_atom,rtrancl_empty]) 1);
wenzelm@5132
    43
by (asm_full_simp_tac (simpset()
nipkow@4907
    44
     addsimps [False_False_in_steps_atom,comp_def,start_atom]) 1);
nipkow@4907
    45
qed "start_fin_in_steps_atom";
nipkow@4907
    46
nipkow@5118
    47
Goal "accepts (atom a) w = (w = [a])";
wenzelm@5132
    48
by (simp_tac(simpset() addsimps
nipkow@4907
    49
       [accepts_def,start_fin_in_steps_atom,fin_atom]) 1);
nipkow@4907
    50
qed "accepts_atom";
nipkow@4907
    51
nipkow@4907
    52
nipkow@4907
    53
(******************************************************)
nipkow@4907
    54
(*                      union                         *)
nipkow@4907
    55
(******************************************************)
nipkow@4907
    56
nipkow@4907
    57
(***** True/False ueber fin anheben *****)
nipkow@4907
    58
wenzelm@5069
    59
Goalw [union_def] 
nipkow@4907
    60
 "!L R. fin (union L R) (True#p) = fin L p";
nipkow@4907
    61
by (Simp_tac 1);
nipkow@4907
    62
qed_spec_mp "fin_union_True";
nipkow@4907
    63
wenzelm@5069
    64
Goalw [union_def] 
nipkow@4907
    65
 "!L R. fin (union L R) (False#p) = fin R p";
nipkow@4907
    66
by (Simp_tac 1);
nipkow@4907
    67
qed_spec_mp "fin_union_False";
nipkow@4907
    68
nipkow@4907
    69
AddIffs [fin_union_True,fin_union_False];
nipkow@4907
    70
nipkow@4907
    71
(***** True/False ueber step anheben *****)
nipkow@4907
    72
wenzelm@5069
    73
Goalw [union_def,step_def]
nipkow@4907
    74
"!L R. (True#p,q) : step (union L R) a = (? r. q = True#r & (p,r) : step L a)";
nipkow@4907
    75
by (Simp_tac 1);
wenzelm@5132
    76
by (Blast_tac 1);
nipkow@4907
    77
qed_spec_mp "True_in_step_union";
nipkow@4907
    78
wenzelm@5069
    79
Goalw [union_def,step_def]
nipkow@4907
    80
"!L R. (False#p,q) : step (union L R) a = (? r. q = False#r & (p,r) : step R a)";
nipkow@4907
    81
by (Simp_tac 1);
wenzelm@5132
    82
by (Blast_tac 1);
nipkow@4907
    83
qed_spec_mp "False_in_step_union";
nipkow@4907
    84
nipkow@4907
    85
AddIffs [True_in_step_union,False_in_step_union];
nipkow@4907
    86
nipkow@4907
    87
(***** True/False ueber epsclosure anheben *****)
nipkow@4907
    88
wenzelm@5069
    89
Goal
nipkow@5118
    90
 "(tp,tq) : (eps(union L R))^* ==> \
nipkow@4907
    91
\ !p. tp = True#p --> (? q. (p,q) : (eps L)^* & tq = True#q)";
wenzelm@5132
    92
by (etac rtrancl_induct 1);
wenzelm@5132
    93
 by (Blast_tac 1);
wenzelm@5132
    94
by (Clarify_tac 1);
wenzelm@5132
    95
by (Asm_full_simp_tac 1);
wenzelm@5132
    96
by (blast_tac (claset() addIs [rtrancl_into_rtrancl]) 1);
nipkow@4907
    97
val lemma1a = result();
nipkow@4907
    98
wenzelm@5069
    99
Goal
nipkow@5118
   100
 "(tp,tq) : (eps(union L R))^* ==> \
nipkow@4907
   101
\ !p. tp = False#p --> (? q. (p,q) : (eps R)^* & tq = False#q)";
wenzelm@5132
   102
by (etac rtrancl_induct 1);
wenzelm@5132
   103
 by (Blast_tac 1);
wenzelm@5132
   104
by (Clarify_tac 1);
wenzelm@5132
   105
by (Asm_full_simp_tac 1);
wenzelm@5132
   106
by (blast_tac (claset() addIs [rtrancl_into_rtrancl]) 1);
nipkow@4907
   107
val lemma1b = result();
nipkow@4907
   108
wenzelm@5069
   109
Goal
nipkow@5118
   110
 "(p,q) : (eps L)^*  ==> (True#p, True#q) : (eps(union L R))^*";
wenzelm@5132
   111
by (etac rtrancl_induct 1);
wenzelm@5132
   112
 by (Blast_tac 1);
wenzelm@5132
   113
by (blast_tac (claset() addIs [rtrancl_into_rtrancl]) 1);
nipkow@4907
   114
val lemma2a = result();
nipkow@4907
   115
wenzelm@5069
   116
Goal
nipkow@5118
   117
 "(p,q) : (eps R)^*  ==> (False#p, False#q) : (eps(union L R))^*";
wenzelm@5132
   118
by (etac rtrancl_induct 1);
wenzelm@5132
   119
 by (Blast_tac 1);
wenzelm@5132
   120
by (blast_tac (claset() addIs [rtrancl_into_rtrancl]) 1);
nipkow@4907
   121
val lemma2b = result();
nipkow@4907
   122
wenzelm@5069
   123
Goal
nipkow@4907
   124
 "(True#p,q) : (eps(union L R))^* = (? r. q = True#r & (p,r) : (eps L)^*)";
wenzelm@5132
   125
by (blast_tac (claset() addDs [lemma1a,lemma2a]) 1);
nipkow@4907
   126
qed "True_epsclosure_union";
nipkow@4907
   127
wenzelm@5069
   128
Goal
nipkow@4907
   129
 "(False#p,q) : (eps(union L R))^* = (? r. q = False#r & (p,r) : (eps R)^*)";
wenzelm@5132
   130
by (blast_tac (claset() addDs [lemma1b,lemma2b]) 1);
nipkow@4907
   131
qed "False_epsclosure_union";
nipkow@4907
   132
nipkow@4907
   133
AddIffs [True_epsclosure_union,False_epsclosure_union];
nipkow@4907
   134
nipkow@4907
   135
(***** True/False ueber steps anheben *****)
nipkow@4907
   136
wenzelm@5069
   137
Goal
nipkow@4907
   138
 "!p. (True#p,q):steps (union L R) w = (? r. q = True # r & (p,r):steps L w)";
nipkow@4907
   139
by (induct_tac "w" 1);
paulson@5457
   140
by Auto_tac;
nipkow@4907
   141
qed_spec_mp "lift_True_over_steps_union";
nipkow@4907
   142
wenzelm@5069
   143
Goal 
nipkow@4907
   144
 "!p. (False#p,q):steps (union L R) w = (? r. q = False#r & (p,r):steps R w)";
nipkow@4907
   145
by (induct_tac "w" 1);
paulson@5457
   146
by Auto_tac;
nipkow@4907
   147
qed_spec_mp "lift_False_over_steps_union";
nipkow@4907
   148
nipkow@4907
   149
AddIffs [lift_True_over_steps_union,lift_False_over_steps_union];
nipkow@4907
   150
nipkow@4907
   151
nipkow@4907
   152
(***** Epsilonhuelle des Startzustands  *****)
nipkow@4907
   153
wenzelm@5069
   154
Goal
nipkow@4907
   155
 "R^* = id Un (R^* O R)";
wenzelm@5132
   156
by (rtac set_ext 1);
wenzelm@5132
   157
by (split_all_tac 1);
wenzelm@5132
   158
by (rtac iffI 1);
wenzelm@5132
   159
 by (etac rtrancl_induct 1);
wenzelm@5132
   160
  by (Blast_tac 1);
wenzelm@5132
   161
 by (blast_tac (claset() addIs [rtrancl_into_rtrancl]) 1);
wenzelm@5132
   162
by (blast_tac (claset() addIs [rtrancl_into_rtrancl2]) 1);
nipkow@4907
   163
qed "unfold_rtrancl2";
nipkow@4907
   164
wenzelm@5069
   165
Goal
nipkow@4907
   166
 "(p,q) : R^* = (q = p | (? r. (p,r) : R & (r,q) : R^*))";
wenzelm@5132
   167
by (rtac (unfold_rtrancl2 RS equalityE) 1);
wenzelm@5132
   168
by (Blast_tac 1);
nipkow@4907
   169
qed "in_unfold_rtrancl2";
nipkow@4907
   170
nipkow@4907
   171
val epsclosure_start_step_union =
nipkow@4907
   172
  read_instantiate [("p","start(union L R)")] in_unfold_rtrancl2;
nipkow@4907
   173
AddIffs [epsclosure_start_step_union];
nipkow@4907
   174
wenzelm@5069
   175
Goalw [union_def,step_def]
nipkow@4907
   176
 "!L R. (start(union L R),q) : eps(union L R) = \
nipkow@4907
   177
\       (q = True#start L | q = False#start R)";
wenzelm@5132
   178
by (Simp_tac 1);
nipkow@4907
   179
qed_spec_mp "start_eps_union";
nipkow@4907
   180
AddIffs [start_eps_union];
nipkow@4907
   181
wenzelm@5069
   182
Goalw [union_def,step_def]
nipkow@4907
   183
 "!L R. (start(union L R),q) ~: step (union L R) (Some a)";
wenzelm@5132
   184
by (Simp_tac 1);
nipkow@4907
   185
qed_spec_mp "not_start_step_union_Some";
nipkow@4907
   186
AddIffs [not_start_step_union_Some];
nipkow@4907
   187
wenzelm@5069
   188
Goal
nipkow@4907
   189
 "(start(union L R), q) : steps (union L R) w = \
nipkow@4907
   190
\ ( (w = [] & q = start(union L R)) | \
nipkow@4907
   191
\   (? p.  q = True  # p & (start L,p) : steps L w | \
nipkow@4907
   192
\          q = False # p & (start R,p) : steps R w) )";
nipkow@4907
   193
by (exhaust_tac "w" 1);
nipkow@4907
   194
 by (Asm_simp_tac 1);
paulson@5457
   195
 by (Blast_tac 1);
nipkow@4907
   196
by (Asm_simp_tac 1);
paulson@5457
   197
by (Blast_tac 1);
nipkow@4907
   198
qed "steps_union";
nipkow@4907
   199
wenzelm@5069
   200
Goalw [union_def]
nipkow@4907
   201
 "!L R. ~ fin (union L R) (start(union L R))";
wenzelm@5132
   202
by (Simp_tac 1);
nipkow@4907
   203
qed_spec_mp "start_union_not_final";
nipkow@4907
   204
AddIffs [start_union_not_final];
nipkow@4907
   205
wenzelm@5069
   206
Goalw [accepts_def]
nipkow@4907
   207
 "accepts (union L R) w = (accepts L w | accepts R w)";
nipkow@4907
   208
by (simp_tac (simpset() addsimps [steps_union]) 1);
wenzelm@5132
   209
by Auto_tac;
nipkow@4907
   210
qed "accepts_union";
nipkow@4907
   211
nipkow@4907
   212
nipkow@4907
   213
(******************************************************)
nipkow@4907
   214
(*                      conc                        *)
nipkow@4907
   215
(******************************************************)
nipkow@4907
   216
nipkow@4907
   217
(** True/False in fin **)
nipkow@4907
   218
wenzelm@5069
   219
Goalw [conc_def]
nipkow@4907
   220
 "!L R. fin (conc L R) (True#p) = False";
nipkow@4907
   221
by (Simp_tac 1);
nipkow@4907
   222
qed_spec_mp "fin_conc_True";
nipkow@4907
   223
wenzelm@5069
   224
Goalw [conc_def] 
nipkow@4907
   225
 "!L R. fin (conc L R) (False#p) = fin R p";
nipkow@4907
   226
by (Simp_tac 1);
nipkow@4907
   227
qed "fin_conc_False";
nipkow@4907
   228
nipkow@4907
   229
AddIffs [fin_conc_True,fin_conc_False];
nipkow@4907
   230
nipkow@4907
   231
(** True/False in step **)
nipkow@4907
   232
wenzelm@5069
   233
Goalw [conc_def,step_def]
nipkow@4907
   234
 "!L R. (True#p,q) : step (conc L R) a = \
nipkow@4907
   235
\       ((? r. q=True#r & (p,r): step L a) | \
nipkow@4907
   236
\        (fin L p & a=None & q=False#start R))";
nipkow@4907
   237
by (Simp_tac 1);
wenzelm@5132
   238
by (Blast_tac 1);
nipkow@4907
   239
qed_spec_mp "True_step_conc";
nipkow@4907
   240
wenzelm@5069
   241
Goalw [conc_def,step_def]
nipkow@4907
   242
 "!L R. (False#p,q) : step (conc L R) a = \
nipkow@4907
   243
\       (? r. q = False#r & (p,r) : step R a)";
nipkow@4907
   244
by (Simp_tac 1);
wenzelm@5132
   245
by (Blast_tac 1);
nipkow@4907
   246
qed_spec_mp "False_step_conc";
nipkow@4907
   247
nipkow@4907
   248
AddIffs [True_step_conc, False_step_conc];
nipkow@4907
   249
nipkow@4907
   250
(** False in epsclosure **)
nipkow@4907
   251
wenzelm@5069
   252
Goal
nipkow@5118
   253
 "(tp,tq) : (eps(conc L R))^* ==> \
nipkow@4907
   254
\ !p. tp = False#p --> (? q. (p,q) : (eps R)^* & tq = False#q)";
wenzelm@5132
   255
by (etac rtrancl_induct 1);
wenzelm@5132
   256
 by (Blast_tac 1);
wenzelm@5132
   257
by (blast_tac (claset() addIs [rtrancl_into_rtrancl]) 1);
nipkow@4907
   258
qed "lemma1b";
nipkow@4907
   259
wenzelm@5069
   260
Goal
nipkow@5118
   261
 "(p,q) : (eps R)^* ==> (False#p, False#q) : (eps(conc L R))^*";
wenzelm@5132
   262
by (etac rtrancl_induct 1);
wenzelm@5132
   263
 by (Blast_tac 1);
wenzelm@5132
   264
by (blast_tac (claset() addIs [rtrancl_into_rtrancl]) 1);
nipkow@4907
   265
val lemma2b = result();
nipkow@4907
   266
wenzelm@5069
   267
Goal
nipkow@4907
   268
 "((False # p, q) : (eps (conc L R))^*) = \
nipkow@4907
   269
\ (? r. q = False # r & (p, r) : (eps R)^*)";
nipkow@4907
   270
by (rtac iffI 1);
wenzelm@5132
   271
 by (blast_tac (claset() addDs [lemma1b]) 1);
wenzelm@5132
   272
by (blast_tac (claset() addDs [lemma2b]) 1);
nipkow@4907
   273
qed "False_epsclosure_conc";
nipkow@4907
   274
AddIffs [False_epsclosure_conc];
nipkow@4907
   275
nipkow@4907
   276
(** False in steps **)
nipkow@4907
   277
wenzelm@5069
   278
Goal
nipkow@4907
   279
 "!p. (False#p,q): steps (conc L R) w = (? r. q=False#r & (p,r): steps R w)";
nipkow@4907
   280
by (induct_tac "w" 1);
nipkow@4907
   281
 by (Simp_tac 1);
nipkow@4907
   282
by (Simp_tac 1);
paulson@5457
   283
by (Fast_tac 1);  (*MUCH faster than Blast_tac*)
nipkow@4907
   284
qed_spec_mp "False_steps_conc";
nipkow@4907
   285
AddIffs [False_steps_conc];
nipkow@4907
   286
nipkow@4907
   287
(** True in epsclosure **)
nipkow@4907
   288
wenzelm@5069
   289
Goal
nipkow@5118
   290
 "(p,q): (eps L)^* ==> (True#p,True#q) : (eps(conc L R))^*";
wenzelm@5132
   291
by (etac rtrancl_induct 1);
wenzelm@5132
   292
 by (Blast_tac 1);
wenzelm@5132
   293
by (blast_tac (claset() addIs [rtrancl_into_rtrancl]) 1);
nipkow@4907
   294
qed "True_True_eps_concI";
nipkow@4907
   295
wenzelm@5069
   296
Goal
nipkow@5118
   297
 "!p. (p,q) : steps L w --> (True#p,True#q) : steps (conc L R) w";
wenzelm@5132
   298
by (induct_tac "w" 1);
nipkow@4907
   299
 by (simp_tac (simpset() addsimps [True_True_eps_concI]) 1);
nipkow@4907
   300
by (Simp_tac 1);
wenzelm@5132
   301
by (blast_tac (claset() addIs [True_True_eps_concI]) 1);
nipkow@4907
   302
qed_spec_mp "True_True_steps_concI";
nipkow@4907
   303
wenzelm@5069
   304
Goal
nipkow@5118
   305
 "(tp,tq) : (eps(conc L R))^* ==> \
nipkow@4907
   306
\ !p. tp = True#p --> \
nipkow@4907
   307
\ (? q. tq = True#q & (p,q) : (eps L)^*) | \
nipkow@4907
   308
\ (? q r. tq = False#q & (p,r):(eps L)^* & fin L r & (start R,q) : (eps R)^*)";
wenzelm@5132
   309
by (etac rtrancl_induct 1);
wenzelm@5132
   310
 by (Blast_tac 1);
wenzelm@5132
   311
by (blast_tac (claset() addIs [rtrancl_into_rtrancl]) 1);
nipkow@4907
   312
val lemma1a = result();
nipkow@4907
   313
wenzelm@5069
   314
Goal
nipkow@5118
   315
 "(p, q) : (eps L)^* ==> (True#p, True#q) : (eps(conc L R))^*";
wenzelm@5132
   316
by (etac rtrancl_induct 1);
wenzelm@5132
   317
 by (Blast_tac 1);
wenzelm@5132
   318
by (blast_tac (claset() addIs [rtrancl_into_rtrancl]) 1);
nipkow@4907
   319
val lemma2a = result();
nipkow@4907
   320
wenzelm@5069
   321
Goalw [conc_def,step_def]
nipkow@4907
   322
 "!!L R. (p,q) : step R None ==> (False#p, False#q) : step (conc L R) None";
wenzelm@5132
   323
by (split_all_tac 1);
nipkow@4907
   324
by (Asm_full_simp_tac 1);
nipkow@4907
   325
val lemma = result();
nipkow@4907
   326
wenzelm@5069
   327
Goal
nipkow@5118
   328
 "(p,q) : (eps R)^* ==> (False#p, False#q) : (eps(conc L R))^*";
wenzelm@5132
   329
by (etac rtrancl_induct 1);
wenzelm@5132
   330
 by (Blast_tac 1);
nipkow@4907
   331
by (dtac lemma 1);
wenzelm@5132
   332
by (blast_tac (claset() addIs [rtrancl_into_rtrancl]) 1);
nipkow@4907
   333
val lemma2b = result();
nipkow@4907
   334
wenzelm@5069
   335
Goalw [conc_def,step_def]
nipkow@4907
   336
 "!!L R. fin L p ==> (True#p, False#start R) : eps(conc L R)";
wenzelm@5132
   337
by (split_all_tac 1);
wenzelm@5132
   338
by (Asm_full_simp_tac 1);
nipkow@4907
   339
qed "True_False_eps_concI";
nipkow@4907
   340
wenzelm@5069
   341
Goal
nipkow@4907
   342
 "((True#p,q) : (eps(conc L R))^*) = \
nipkow@4907
   343
\ ((? r. (p,r) : (eps L)^* & q = True#r) | \
nipkow@4907
   344
\  (? r. (p,r) : (eps L)^* & fin L r & \
nipkow@4907
   345
\        (? s. (start R, s) : (eps R)^* & q = False#s)))";
wenzelm@5132
   346
by (rtac iffI 1);
wenzelm@5132
   347
 by (blast_tac (claset() addDs [lemma1a]) 1);
wenzelm@5132
   348
by (etac disjE 1);
wenzelm@5132
   349
 by (blast_tac (claset() addIs [lemma2a]) 1);
wenzelm@5132
   350
by (Clarify_tac 1);
wenzelm@5132
   351
by (rtac (rtrancl_trans) 1);
wenzelm@5132
   352
by (etac lemma2a 1);
wenzelm@5132
   353
by (rtac (rtrancl_into_rtrancl2) 1);
wenzelm@5132
   354
by (etac True_False_eps_concI 1);
wenzelm@5132
   355
by (etac lemma2b 1);
nipkow@4907
   356
qed "True_epsclosure_conc";
nipkow@4907
   357
AddIffs [True_epsclosure_conc];
nipkow@4907
   358
nipkow@4907
   359
(** True in steps **)
nipkow@4907
   360
wenzelm@5069
   361
Goal
nipkow@4907
   362
 "!p. (True#p,q) : steps (conc L R) w --> \
nipkow@4907
   363
\     ((? r. (p,r) : steps L w & q = True#r)  | \
nipkow@4907
   364
\      (? u v. w = u@v & (? r. (p,r) : steps L u & fin L r & \
nipkow@4907
   365
\              (? s. (start R,s) : steps R v & q = False#s))))";
wenzelm@5132
   366
by (induct_tac "w" 1);
wenzelm@5132
   367
 by (Simp_tac 1);
wenzelm@5132
   368
by (Simp_tac 1);
wenzelm@5132
   369
by (clarify_tac (claset() delrules [disjCI]) 1);
wenzelm@5132
   370
 by (etac disjE 1);
wenzelm@5132
   371
 by (clarify_tac (claset() delrules [disjCI]) 1);
wenzelm@5132
   372
 by (etac disjE 1);
wenzelm@5132
   373
  by (clarify_tac (claset() delrules [disjCI]) 1);
wenzelm@5132
   374
  by (etac allE 1 THEN mp_tac 1);
wenzelm@5132
   375
  by (etac disjE 1);
nipkow@4907
   376
   by (Blast_tac 1);
wenzelm@5132
   377
  by (rtac disjI2 1);
nipkow@4907
   378
  by (Clarify_tac 1);
wenzelm@5132
   379
  by (Simp_tac 1);
wenzelm@5132
   380
  by (res_inst_tac[("x","a#u")] exI 1);
wenzelm@5132
   381
  by (Simp_tac 1);
nipkow@4907
   382
  by (Blast_tac 1);
nipkow@4907
   383
 by (Blast_tac 1);
wenzelm@5132
   384
by (rtac disjI2 1);
nipkow@4907
   385
by (Clarify_tac 1);
wenzelm@5132
   386
by (Simp_tac 1);
wenzelm@5132
   387
by (res_inst_tac[("x","[]")] exI 1);
wenzelm@5132
   388
by (Simp_tac 1);
nipkow@4907
   389
by (Blast_tac 1);
nipkow@4907
   390
qed_spec_mp "True_steps_concD";
nipkow@4907
   391
wenzelm@5069
   392
Goal
nipkow@4907
   393
 "(True#p,q) : steps (conc L R) w = \
nipkow@4907
   394
\ ((? r. (p,r) : steps L w & q = True#r)  | \
nipkow@4907
   395
\  (? u v. w = u@v & (? r. (p,r) : steps L u & fin L r & \
nipkow@4907
   396
\          (? s. (start R,s) : steps R v & q = False#s))))";
wenzelm@5132
   397
by (blast_tac (claset() addDs [True_steps_concD]
nipkow@4907
   398
     addIs [True_True_steps_concI,in_steps_epsclosure,r_into_rtrancl]) 1);
nipkow@4907
   399
qed "True_steps_conc";
nipkow@4907
   400
nipkow@4907
   401
(** starting from the start **)
nipkow@4907
   402
wenzelm@5069
   403
Goalw [conc_def]
nipkow@4907
   404
  "!L R. start(conc L R) = True#start L";
wenzelm@5132
   405
by (Simp_tac 1);
nipkow@4907
   406
qed_spec_mp "start_conc";
nipkow@4907
   407
wenzelm@5069
   408
Goalw [conc_def]
nipkow@4907
   409
 "!L R. fin(conc L R) p = (? s. p = False#s & fin R s)";
berghofe@5184
   410
by (simp_tac (simpset() addsplits [list.split]) 1);
nipkow@4907
   411
qed_spec_mp "final_conc";
nipkow@4907
   412
wenzelm@5069
   413
Goal
nipkow@4907
   414
 "accepts (conc L R) w = (? u v. w = u@v & accepts L u & accepts R v)";
nipkow@4907
   415
by (simp_tac (simpset() addsimps
nipkow@4907
   416
     [accepts_def,True_steps_conc,final_conc,start_conc]) 1);
wenzelm@5132
   417
by (Blast_tac 1);
nipkow@4907
   418
qed "accepts_conc";
nipkow@4907
   419
nipkow@4907
   420
(******************************************************)
nipkow@4907
   421
(*                       star                         *)
nipkow@4907
   422
(******************************************************)
nipkow@4907
   423
wenzelm@5069
   424
Goalw [star_def,step_def]
nipkow@4907
   425
 "!A. (True#p,q) : eps(star A) = \
nipkow@4907
   426
\     ( (? r. q = True#r & (p,r) : eps A) | (fin A p & q = True#start A) )";
wenzelm@5132
   427
by (Simp_tac 1);
wenzelm@5132
   428
by (Blast_tac 1);
nipkow@4907
   429
qed_spec_mp "True_in_eps_star";
nipkow@4907
   430
AddIffs [True_in_eps_star];
nipkow@4907
   431
wenzelm@5069
   432
Goalw [star_def,step_def]
nipkow@4907
   433
  "!A. (p,q) : step A a --> (True#p, True#q) : step (star A) a";
wenzelm@5132
   434
by (Simp_tac 1);
nipkow@4907
   435
qed_spec_mp "True_True_step_starI";
nipkow@4907
   436
wenzelm@5069
   437
Goal
nipkow@5118
   438
  "(p,r) : (eps A)^* ==> (True#p, True#r) : (eps(star A))^*";
wenzelm@5132
   439
by (etac rtrancl_induct 1);
wenzelm@5132
   440
 by (Blast_tac 1);
wenzelm@5132
   441
by (blast_tac (claset() addIs [True_True_step_starI,rtrancl_into_rtrancl]) 1);
nipkow@4907
   442
qed_spec_mp "True_True_eps_starI";
nipkow@4907
   443
wenzelm@5069
   444
Goalw [star_def,step_def]
nipkow@4907
   445
 "!A. fin A p --> (True#p,True#start A) : eps(star A)";
wenzelm@5132
   446
by (Simp_tac 1);
nipkow@4907
   447
qed_spec_mp "True_start_eps_starI";
nipkow@4907
   448
wenzelm@5069
   449
Goal
nipkow@5118
   450
 "(tp,s) : (eps(star A))^* ==> (! p. tp = True#p --> \
nipkow@4907
   451
\ (? r. ((p,r) : (eps A)^* | \
nipkow@4907
   452
\        (? q. (p,q) : (eps A)^* & fin A q & (start A,r) : (eps A)^*)) & \
nipkow@4907
   453
\       s = True#r))";
wenzelm@5132
   454
by (etac rtrancl_induct 1);
wenzelm@5132
   455
 by (Simp_tac 1);
nipkow@4907
   456
by (Clarify_tac 1);
nipkow@4907
   457
by (Asm_full_simp_tac 1);
wenzelm@5132
   458
by (blast_tac (claset() addIs [rtrancl_into_rtrancl]) 1);
nipkow@4907
   459
val lemma = result();
nipkow@4907
   460
wenzelm@5069
   461
Goal
nipkow@4907
   462
 "((True#p,s) : (eps(star A))^*) = \
nipkow@4907
   463
\ (? r. ((p,r) : (eps A)^* | \
nipkow@4907
   464
\        (? q. (p,q) : (eps A)^* & fin A q & (start A,r) : (eps A)^*)) & \
nipkow@4907
   465
\       s = True#r)";
wenzelm@5132
   466
by (rtac iffI 1);
wenzelm@5132
   467
 by (dtac lemma 1);
wenzelm@5132
   468
 by (Blast_tac 1);
nipkow@4907
   469
(* Why can't blast_tac do the rest? *)
nipkow@4907
   470
by (Clarify_tac 1);
wenzelm@5132
   471
by (etac disjE 1);
wenzelm@5132
   472
by (etac True_True_eps_starI 1);
nipkow@4907
   473
by (Clarify_tac 1);
wenzelm@5132
   474
by (rtac rtrancl_trans 1);
wenzelm@5132
   475
by (etac True_True_eps_starI 1);
wenzelm@5132
   476
by (rtac rtrancl_trans 1);
wenzelm@5132
   477
by (rtac r_into_rtrancl 1);
wenzelm@5132
   478
by (etac True_start_eps_starI 1);
wenzelm@5132
   479
by (etac True_True_eps_starI 1);
nipkow@4907
   480
qed "True_eps_star";
nipkow@4907
   481
AddIffs [True_eps_star];
nipkow@4907
   482
nipkow@4907
   483
(** True in step Some **)
nipkow@4907
   484
wenzelm@5069
   485
Goalw [star_def,step_def]
nipkow@4907
   486
 "!A. (True#p,r): step (star A) (Some a) = \
nipkow@4907
   487
\     (? q. (p,q): step A (Some a) & r=True#q)";
wenzelm@5132
   488
by (Simp_tac 1);
wenzelm@5132
   489
by (Blast_tac 1);
nipkow@4907
   490
qed_spec_mp "True_step_star";
nipkow@4907
   491
AddIffs [True_step_star];
nipkow@4907
   492
nipkow@4907
   493
nipkow@4907
   494
(** True in steps **)
nipkow@4907
   495
nipkow@4907
   496
(* reverse list induction! Complicates matters for conc? *)
wenzelm@5069
   497
Goal
nipkow@4907
   498
 "!rr. (True#start A,rr) : steps (star A) w --> \
nipkow@4907
   499
\ (? us v. w = concat us @ v & \
nipkow@4907
   500
\             (!u:set us. accepts A u) & \
nipkow@4907
   501
\             (? r. (start A,r) : steps A v & rr = True#r))";
wenzelm@5132
   502
by (res_inst_tac [("xs","w")] rev_induct 1);
nipkow@4907
   503
 by (Asm_full_simp_tac 1);
nipkow@4907
   504
 by (Clarify_tac 1);
wenzelm@5132
   505
 by (res_inst_tac [("x","[]")] exI 1);
wenzelm@5132
   506
 by (etac disjE 1);
nipkow@4907
   507
  by (Asm_simp_tac 1);
nipkow@4907
   508
 by (Clarify_tac 1);
nipkow@4907
   509
 by (Asm_simp_tac 1);
wenzelm@5132
   510
by (simp_tac (simpset() addsimps [O_assoc,epsclosure_steps]) 1);
nipkow@4907
   511
by (Clarify_tac 1);
wenzelm@5132
   512
by (etac allE 1 THEN mp_tac 1);
nipkow@4907
   513
by (Clarify_tac 1);
wenzelm@5132
   514
by (etac disjE 1);
wenzelm@5132
   515
 by (res_inst_tac [("x","us")] exI 1);
wenzelm@5132
   516
 by (res_inst_tac [("x","v@[x]")] exI 1);
wenzelm@5132
   517
 by (asm_simp_tac (simpset() addsimps [O_assoc,epsclosure_steps]) 1);
wenzelm@5132
   518
 by (Blast_tac 1);
nipkow@4907
   519
by (Clarify_tac 1);
wenzelm@5132
   520
by (res_inst_tac [("x","us@[v@[x]]")] exI 1);
wenzelm@5132
   521
by (res_inst_tac [("x","[]")] exI 1);
wenzelm@5132
   522
by (asm_full_simp_tac (simpset() addsimps [accepts_def]) 1);
wenzelm@5132
   523
by (Blast_tac 1);
nipkow@4907
   524
qed_spec_mp "True_start_steps_starD";
nipkow@4907
   525
wenzelm@5069
   526
Goal "!p. (p,q) : steps A w --> (True#p,True#q) : steps (star A) w";
wenzelm@5132
   527
by (induct_tac "w" 1);
wenzelm@5132
   528
 by (Simp_tac 1);
wenzelm@5132
   529
by (Simp_tac 1);
wenzelm@5132
   530
by (blast_tac (claset() addIs [True_True_eps_starI,True_True_step_starI]) 1);
nipkow@4907
   531
qed_spec_mp "True_True_steps_starI";
nipkow@4907
   532
wenzelm@5069
   533
Goalw [accepts_def]
nipkow@4907
   534
 "(!u : set us. accepts A u) --> \
nipkow@4907
   535
\ (True#start A,True#start A) : steps (star A) (concat us)";
wenzelm@5132
   536
by (induct_tac "us" 1);
wenzelm@5132
   537
 by (Simp_tac 1);
wenzelm@5132
   538
by (Simp_tac 1);
wenzelm@5132
   539
by (blast_tac (claset() addIs [True_True_steps_starI,True_start_eps_starI,r_into_rtrancl,in_epsclosure_steps]) 1);
nipkow@4907
   540
qed_spec_mp "steps_star_cycle";
nipkow@4907
   541
nipkow@4907
   542
(* Better stated directly with start(star A)? Loop in star A back to start(star A)?*)
wenzelm@5069
   543
Goal
nipkow@4907
   544
 "(True#start A,rr) : steps (star A) w = \
nipkow@4907
   545
\ (? us v. w = concat us @ v & \
nipkow@4907
   546
\             (!u:set us. accepts A u) & \
nipkow@4907
   547
\             (? r. (start A,r) : steps A v & rr = True#r))";
wenzelm@5132
   548
by (rtac iffI 1);
wenzelm@5132
   549
 by (etac True_start_steps_starD 1);
nipkow@4907
   550
by (Clarify_tac 1);
wenzelm@5132
   551
by (Asm_simp_tac 1);
wenzelm@5132
   552
by (blast_tac (claset() addIs [True_True_steps_starI,steps_star_cycle]) 1);
nipkow@4907
   553
qed "True_start_steps_star";
nipkow@4907
   554
nipkow@4907
   555
(** the start state **)
nipkow@4907
   556
wenzelm@5069
   557
Goalw [star_def,step_def]
nipkow@4907
   558
  "!A. (start(star A),r) : step (star A) a = (a=None & r = True#start A)";
wenzelm@5132
   559
by (Simp_tac 1);
nipkow@4907
   560
qed_spec_mp "start_step_star";
nipkow@4907
   561
AddIffs [start_step_star];
nipkow@4907
   562
nipkow@4907
   563
val epsclosure_start_step_star =
nipkow@4907
   564
  read_instantiate [("p","start(star A)")] in_unfold_rtrancl2;
nipkow@4907
   565
wenzelm@5069
   566
Goal
nipkow@4907
   567
 "(start(star A),r) : steps (star A) w = \
nipkow@4907
   568
\ ((w=[] & r= start(star A)) | (True#start A,r) : steps (star A) w)";
wenzelm@5132
   569
by (rtac iffI 1);
wenzelm@5132
   570
 by (exhaust_tac "w" 1);
wenzelm@5132
   571
  by (asm_full_simp_tac (simpset() addsimps
nipkow@4907
   572
    [epsclosure_start_step_star]) 1);
wenzelm@5132
   573
 by (Asm_full_simp_tac 1);
nipkow@4907
   574
 by (Clarify_tac 1);
wenzelm@5132
   575
 by (asm_full_simp_tac (simpset() addsimps
nipkow@4907
   576
    [epsclosure_start_step_star]) 1);
wenzelm@5132
   577
 by (Blast_tac 1);
wenzelm@5132
   578
by (etac disjE 1);
wenzelm@5132
   579
 by (Asm_simp_tac 1);
wenzelm@5132
   580
by (blast_tac (claset() addIs [in_steps_epsclosure,r_into_rtrancl]) 1);
nipkow@4907
   581
qed "start_steps_star";
nipkow@4907
   582
wenzelm@5069
   583
Goalw [star_def] "!A. fin (star A) (True#p) = fin A p";
wenzelm@5132
   584
by (Simp_tac 1);
nipkow@4907
   585
qed_spec_mp "fin_star_True";
nipkow@4907
   586
AddIffs [fin_star_True];
nipkow@4907
   587
wenzelm@5069
   588
Goalw [star_def] "!A. fin (star A) (start(star A))";
wenzelm@5132
   589
by (Simp_tac 1);
nipkow@4907
   590
qed_spec_mp "fin_star_start";
nipkow@4907
   591
AddIffs [fin_star_start];
nipkow@4907
   592
nipkow@4907
   593
(* too complex! Simpler if loop back to start(star A)? *)
wenzelm@5069
   594
Goalw [accepts_def]
nipkow@4907
   595
 "accepts (star A) w = \
nipkow@4907
   596
\ (? us. (!u : set(us). accepts A u) & (w = concat us) )";
wenzelm@5132
   597
by (simp_tac (simpset() addsimps [start_steps_star,True_start_steps_star]) 1);
wenzelm@5132
   598
by (rtac iffI 1);
nipkow@4907
   599
 by (Clarify_tac 1);
wenzelm@5132
   600
 by (etac disjE 1);
nipkow@4907
   601
  by (Clarify_tac 1);
wenzelm@5132
   602
  by (Simp_tac 1);
wenzelm@5132
   603
  by (res_inst_tac [("x","[]")] exI 1);
wenzelm@5132
   604
  by (Simp_tac 1);
nipkow@4907
   605
 by (Clarify_tac 1);
wenzelm@5132
   606
 by (res_inst_tac [("x","us@[v]")] exI 1);
wenzelm@5132
   607
 by (asm_full_simp_tac (simpset() addsimps [accepts_def]) 1);
wenzelm@5132
   608
 by (Blast_tac 1);
nipkow@4907
   609
by (Clarify_tac 1);
wenzelm@5132
   610
by (res_inst_tac [("xs","us")] rev_exhaust 1);
wenzelm@5132
   611
 by (Asm_simp_tac 1);
wenzelm@5132
   612
 by (Blast_tac 1);
nipkow@4907
   613
by (Clarify_tac 1);
wenzelm@5132
   614
by (asm_full_simp_tac (simpset() addsimps [accepts_def]) 1);
wenzelm@5132
   615
by (Blast_tac 1);
nipkow@4907
   616
qed "accepts_star";
nipkow@4907
   617
nipkow@4907
   618
nipkow@4907
   619
(***** Correctness of r2n *****)
nipkow@4907
   620
wenzelm@5069
   621
Goal
nipkow@4907
   622
 "!w. accepts (rexp2nae r) w = (w : lang r)";
wenzelm@5132
   623
by (induct_tac "r" 1);
wenzelm@5132
   624
    by (simp_tac (simpset() addsimps [accepts_def]) 1);
wenzelm@5132
   625
   by (simp_tac(simpset() addsimps [accepts_atom]) 1);
wenzelm@5132
   626
  by (asm_simp_tac (simpset() addsimps [accepts_union]) 1);
wenzelm@5132
   627
 by (asm_simp_tac (simpset() addsimps [accepts_conc,RegSet.conc_def]) 1);
wenzelm@5132
   628
by (asm_simp_tac (simpset() addsimps [accepts_star,in_star]) 1);
nipkow@4907
   629
qed "accepts_rexp2nae";