src/HOL/Lex/RegExp2NAe.ML
author oheimb
Fri Oct 23 20:44:34 1998 +0200 (1998-10-23)
changeset 5758 27a2b36efd95
parent 5608 a82a038a3e7a
child 7958 f531589c9fc1
permissions -rw-r--r--
corrected auto_tac (applications of unsafe wrappers)
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);
oheimb@5758
   140
 by Auto_tac;
oheimb@5758
   141
by (Force_tac 1);
nipkow@4907
   142
qed_spec_mp "lift_True_over_steps_union";
nipkow@4907
   143
wenzelm@5069
   144
Goal 
nipkow@4907
   145
 "!p. (False#p,q):steps (union L R) w = (? r. q = False#r & (p,r):steps R w)";
nipkow@4907
   146
by (induct_tac "w" 1);
oheimb@5758
   147
 by Auto_tac;
oheimb@5758
   148
by (Force_tac 1);
nipkow@4907
   149
qed_spec_mp "lift_False_over_steps_union";
nipkow@4907
   150
nipkow@4907
   151
AddIffs [lift_True_over_steps_union,lift_False_over_steps_union];
nipkow@4907
   152
nipkow@4907
   153
nipkow@4907
   154
(***** Epsilonhuelle des Startzustands  *****)
nipkow@4907
   155
wenzelm@5069
   156
Goal
nipkow@5608
   157
 "R^* = Id Un (R^* O R)";
wenzelm@5132
   158
by (rtac set_ext 1);
wenzelm@5132
   159
by (split_all_tac 1);
wenzelm@5132
   160
by (rtac iffI 1);
wenzelm@5132
   161
 by (etac rtrancl_induct 1);
wenzelm@5132
   162
  by (Blast_tac 1);
wenzelm@5132
   163
 by (blast_tac (claset() addIs [rtrancl_into_rtrancl]) 1);
wenzelm@5132
   164
by (blast_tac (claset() addIs [rtrancl_into_rtrancl2]) 1);
nipkow@4907
   165
qed "unfold_rtrancl2";
nipkow@4907
   166
wenzelm@5069
   167
Goal
nipkow@4907
   168
 "(p,q) : R^* = (q = p | (? r. (p,r) : R & (r,q) : R^*))";
wenzelm@5132
   169
by (rtac (unfold_rtrancl2 RS equalityE) 1);
wenzelm@5132
   170
by (Blast_tac 1);
nipkow@4907
   171
qed "in_unfold_rtrancl2";
nipkow@4907
   172
nipkow@4907
   173
val epsclosure_start_step_union =
nipkow@4907
   174
  read_instantiate [("p","start(union L R)")] in_unfold_rtrancl2;
nipkow@4907
   175
AddIffs [epsclosure_start_step_union];
nipkow@4907
   176
wenzelm@5069
   177
Goalw [union_def,step_def]
nipkow@4907
   178
 "!L R. (start(union L R),q) : eps(union L R) = \
nipkow@4907
   179
\       (q = True#start L | q = False#start R)";
wenzelm@5132
   180
by (Simp_tac 1);
nipkow@4907
   181
qed_spec_mp "start_eps_union";
nipkow@4907
   182
AddIffs [start_eps_union];
nipkow@4907
   183
wenzelm@5069
   184
Goalw [union_def,step_def]
nipkow@4907
   185
 "!L R. (start(union L R),q) ~: step (union L R) (Some a)";
wenzelm@5132
   186
by (Simp_tac 1);
nipkow@4907
   187
qed_spec_mp "not_start_step_union_Some";
nipkow@4907
   188
AddIffs [not_start_step_union_Some];
nipkow@4907
   189
wenzelm@5069
   190
Goal
nipkow@4907
   191
 "(start(union L R), q) : steps (union L R) w = \
nipkow@4907
   192
\ ( (w = [] & q = start(union L R)) | \
nipkow@4907
   193
\   (? p.  q = True  # p & (start L,p) : steps L w | \
nipkow@4907
   194
\          q = False # p & (start R,p) : steps R w) )";
nipkow@4907
   195
by (exhaust_tac "w" 1);
nipkow@4907
   196
 by (Asm_simp_tac 1);
paulson@5457
   197
 by (Blast_tac 1);
nipkow@4907
   198
by (Asm_simp_tac 1);
paulson@5457
   199
by (Blast_tac 1);
nipkow@4907
   200
qed "steps_union";
nipkow@4907
   201
wenzelm@5069
   202
Goalw [union_def]
nipkow@4907
   203
 "!L R. ~ fin (union L R) (start(union L R))";
wenzelm@5132
   204
by (Simp_tac 1);
nipkow@4907
   205
qed_spec_mp "start_union_not_final";
nipkow@4907
   206
AddIffs [start_union_not_final];
nipkow@4907
   207
wenzelm@5069
   208
Goalw [accepts_def]
nipkow@4907
   209
 "accepts (union L R) w = (accepts L w | accepts R w)";
nipkow@4907
   210
by (simp_tac (simpset() addsimps [steps_union]) 1);
wenzelm@5132
   211
by Auto_tac;
nipkow@4907
   212
qed "accepts_union";
nipkow@4907
   213
nipkow@4907
   214
nipkow@4907
   215
(******************************************************)
nipkow@4907
   216
(*                      conc                        *)
nipkow@4907
   217
(******************************************************)
nipkow@4907
   218
nipkow@4907
   219
(** True/False in fin **)
nipkow@4907
   220
wenzelm@5069
   221
Goalw [conc_def]
nipkow@4907
   222
 "!L R. fin (conc L R) (True#p) = False";
nipkow@4907
   223
by (Simp_tac 1);
nipkow@4907
   224
qed_spec_mp "fin_conc_True";
nipkow@4907
   225
wenzelm@5069
   226
Goalw [conc_def] 
nipkow@4907
   227
 "!L R. fin (conc L R) (False#p) = fin R p";
nipkow@4907
   228
by (Simp_tac 1);
nipkow@4907
   229
qed "fin_conc_False";
nipkow@4907
   230
nipkow@4907
   231
AddIffs [fin_conc_True,fin_conc_False];
nipkow@4907
   232
nipkow@4907
   233
(** True/False in step **)
nipkow@4907
   234
wenzelm@5069
   235
Goalw [conc_def,step_def]
nipkow@4907
   236
 "!L R. (True#p,q) : step (conc L R) a = \
nipkow@4907
   237
\       ((? r. q=True#r & (p,r): step L a) | \
nipkow@4907
   238
\        (fin L p & a=None & q=False#start R))";
nipkow@4907
   239
by (Simp_tac 1);
wenzelm@5132
   240
by (Blast_tac 1);
nipkow@4907
   241
qed_spec_mp "True_step_conc";
nipkow@4907
   242
wenzelm@5069
   243
Goalw [conc_def,step_def]
nipkow@4907
   244
 "!L R. (False#p,q) : step (conc L R) a = \
nipkow@4907
   245
\       (? r. q = False#r & (p,r) : step R a)";
nipkow@4907
   246
by (Simp_tac 1);
wenzelm@5132
   247
by (Blast_tac 1);
nipkow@4907
   248
qed_spec_mp "False_step_conc";
nipkow@4907
   249
nipkow@4907
   250
AddIffs [True_step_conc, False_step_conc];
nipkow@4907
   251
nipkow@4907
   252
(** False in epsclosure **)
nipkow@4907
   253
wenzelm@5069
   254
Goal
nipkow@5118
   255
 "(tp,tq) : (eps(conc L R))^* ==> \
nipkow@4907
   256
\ !p. tp = False#p --> (? q. (p,q) : (eps R)^* & tq = False#q)";
wenzelm@5132
   257
by (etac rtrancl_induct 1);
wenzelm@5132
   258
 by (Blast_tac 1);
wenzelm@5132
   259
by (blast_tac (claset() addIs [rtrancl_into_rtrancl]) 1);
nipkow@4907
   260
qed "lemma1b";
nipkow@4907
   261
wenzelm@5069
   262
Goal
nipkow@5118
   263
 "(p,q) : (eps R)^* ==> (False#p, False#q) : (eps(conc L R))^*";
wenzelm@5132
   264
by (etac rtrancl_induct 1);
wenzelm@5132
   265
 by (Blast_tac 1);
wenzelm@5132
   266
by (blast_tac (claset() addIs [rtrancl_into_rtrancl]) 1);
nipkow@4907
   267
val lemma2b = result();
nipkow@4907
   268
wenzelm@5069
   269
Goal
nipkow@4907
   270
 "((False # p, q) : (eps (conc L R))^*) = \
nipkow@4907
   271
\ (? r. q = False # r & (p, r) : (eps R)^*)";
nipkow@4907
   272
by (rtac iffI 1);
wenzelm@5132
   273
 by (blast_tac (claset() addDs [lemma1b]) 1);
wenzelm@5132
   274
by (blast_tac (claset() addDs [lemma2b]) 1);
nipkow@4907
   275
qed "False_epsclosure_conc";
nipkow@4907
   276
AddIffs [False_epsclosure_conc];
nipkow@4907
   277
nipkow@4907
   278
(** False in steps **)
nipkow@4907
   279
wenzelm@5069
   280
Goal
nipkow@4907
   281
 "!p. (False#p,q): steps (conc L R) w = (? r. q=False#r & (p,r): steps R w)";
nipkow@4907
   282
by (induct_tac "w" 1);
nipkow@4907
   283
 by (Simp_tac 1);
nipkow@4907
   284
by (Simp_tac 1);
paulson@5457
   285
by (Fast_tac 1);  (*MUCH faster than Blast_tac*)
nipkow@4907
   286
qed_spec_mp "False_steps_conc";
nipkow@4907
   287
AddIffs [False_steps_conc];
nipkow@4907
   288
nipkow@4907
   289
(** True in epsclosure **)
nipkow@4907
   290
wenzelm@5069
   291
Goal
nipkow@5118
   292
 "(p,q): (eps L)^* ==> (True#p,True#q) : (eps(conc L R))^*";
wenzelm@5132
   293
by (etac rtrancl_induct 1);
wenzelm@5132
   294
 by (Blast_tac 1);
wenzelm@5132
   295
by (blast_tac (claset() addIs [rtrancl_into_rtrancl]) 1);
nipkow@4907
   296
qed "True_True_eps_concI";
nipkow@4907
   297
wenzelm@5069
   298
Goal
nipkow@5118
   299
 "!p. (p,q) : steps L w --> (True#p,True#q) : steps (conc L R) w";
wenzelm@5132
   300
by (induct_tac "w" 1);
nipkow@4907
   301
 by (simp_tac (simpset() addsimps [True_True_eps_concI]) 1);
nipkow@4907
   302
by (Simp_tac 1);
wenzelm@5132
   303
by (blast_tac (claset() addIs [True_True_eps_concI]) 1);
nipkow@4907
   304
qed_spec_mp "True_True_steps_concI";
nipkow@4907
   305
wenzelm@5069
   306
Goal
nipkow@5118
   307
 "(tp,tq) : (eps(conc L R))^* ==> \
nipkow@4907
   308
\ !p. tp = True#p --> \
nipkow@4907
   309
\ (? q. tq = True#q & (p,q) : (eps L)^*) | \
nipkow@4907
   310
\ (? q r. tq = False#q & (p,r):(eps L)^* & fin L r & (start R,q) : (eps R)^*)";
wenzelm@5132
   311
by (etac rtrancl_induct 1);
wenzelm@5132
   312
 by (Blast_tac 1);
wenzelm@5132
   313
by (blast_tac (claset() addIs [rtrancl_into_rtrancl]) 1);
nipkow@4907
   314
val lemma1a = result();
nipkow@4907
   315
wenzelm@5069
   316
Goal
nipkow@5118
   317
 "(p, q) : (eps L)^* ==> (True#p, True#q) : (eps(conc L R))^*";
wenzelm@5132
   318
by (etac rtrancl_induct 1);
wenzelm@5132
   319
 by (Blast_tac 1);
wenzelm@5132
   320
by (blast_tac (claset() addIs [rtrancl_into_rtrancl]) 1);
nipkow@4907
   321
val lemma2a = result();
nipkow@4907
   322
wenzelm@5069
   323
Goalw [conc_def,step_def]
nipkow@4907
   324
 "!!L R. (p,q) : step R None ==> (False#p, False#q) : step (conc L R) None";
wenzelm@5132
   325
by (split_all_tac 1);
nipkow@4907
   326
by (Asm_full_simp_tac 1);
nipkow@4907
   327
val lemma = result();
nipkow@4907
   328
wenzelm@5069
   329
Goal
nipkow@5118
   330
 "(p,q) : (eps R)^* ==> (False#p, False#q) : (eps(conc L R))^*";
wenzelm@5132
   331
by (etac rtrancl_induct 1);
wenzelm@5132
   332
 by (Blast_tac 1);
nipkow@4907
   333
by (dtac lemma 1);
wenzelm@5132
   334
by (blast_tac (claset() addIs [rtrancl_into_rtrancl]) 1);
nipkow@4907
   335
val lemma2b = result();
nipkow@4907
   336
wenzelm@5069
   337
Goalw [conc_def,step_def]
nipkow@4907
   338
 "!!L R. fin L p ==> (True#p, False#start R) : eps(conc L R)";
wenzelm@5132
   339
by (split_all_tac 1);
wenzelm@5132
   340
by (Asm_full_simp_tac 1);
nipkow@4907
   341
qed "True_False_eps_concI";
nipkow@4907
   342
wenzelm@5069
   343
Goal
nipkow@4907
   344
 "((True#p,q) : (eps(conc L R))^*) = \
nipkow@4907
   345
\ ((? r. (p,r) : (eps L)^* & q = True#r) | \
nipkow@4907
   346
\  (? r. (p,r) : (eps L)^* & fin L r & \
nipkow@4907
   347
\        (? s. (start R, s) : (eps R)^* & q = False#s)))";
wenzelm@5132
   348
by (rtac iffI 1);
wenzelm@5132
   349
 by (blast_tac (claset() addDs [lemma1a]) 1);
wenzelm@5132
   350
by (etac disjE 1);
wenzelm@5132
   351
 by (blast_tac (claset() addIs [lemma2a]) 1);
wenzelm@5132
   352
by (Clarify_tac 1);
wenzelm@5132
   353
by (rtac (rtrancl_trans) 1);
wenzelm@5132
   354
by (etac lemma2a 1);
wenzelm@5132
   355
by (rtac (rtrancl_into_rtrancl2) 1);
wenzelm@5132
   356
by (etac True_False_eps_concI 1);
wenzelm@5132
   357
by (etac lemma2b 1);
nipkow@4907
   358
qed "True_epsclosure_conc";
nipkow@4907
   359
AddIffs [True_epsclosure_conc];
nipkow@4907
   360
nipkow@4907
   361
(** True in steps **)
nipkow@4907
   362
wenzelm@5069
   363
Goal
nipkow@4907
   364
 "!p. (True#p,q) : steps (conc L R) w --> \
nipkow@4907
   365
\     ((? r. (p,r) : steps L w & q = True#r)  | \
nipkow@4907
   366
\      (? u v. w = u@v & (? r. (p,r) : steps L u & fin L r & \
nipkow@4907
   367
\              (? s. (start R,s) : steps R v & q = False#s))))";
wenzelm@5132
   368
by (induct_tac "w" 1);
wenzelm@5132
   369
 by (Simp_tac 1);
wenzelm@5132
   370
by (Simp_tac 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 disjE 1);
wenzelm@5132
   375
  by (clarify_tac (claset() delrules [disjCI]) 1);
wenzelm@5132
   376
  by (etac allE 1 THEN mp_tac 1);
wenzelm@5132
   377
  by (etac disjE 1);
nipkow@4907
   378
   by (Blast_tac 1);
wenzelm@5132
   379
  by (rtac disjI2 1);
nipkow@4907
   380
  by (Clarify_tac 1);
wenzelm@5132
   381
  by (Simp_tac 1);
wenzelm@5132
   382
  by (res_inst_tac[("x","a#u")] exI 1);
wenzelm@5132
   383
  by (Simp_tac 1);
nipkow@4907
   384
  by (Blast_tac 1);
nipkow@4907
   385
 by (Blast_tac 1);
wenzelm@5132
   386
by (rtac disjI2 1);
nipkow@4907
   387
by (Clarify_tac 1);
wenzelm@5132
   388
by (Simp_tac 1);
wenzelm@5132
   389
by (res_inst_tac[("x","[]")] exI 1);
wenzelm@5132
   390
by (Simp_tac 1);
nipkow@4907
   391
by (Blast_tac 1);
nipkow@4907
   392
qed_spec_mp "True_steps_concD";
nipkow@4907
   393
wenzelm@5069
   394
Goal
nipkow@4907
   395
 "(True#p,q) : steps (conc L R) w = \
nipkow@4907
   396
\ ((? r. (p,r) : steps L w & q = True#r)  | \
nipkow@4907
   397
\  (? u v. w = u@v & (? r. (p,r) : steps L u & fin L r & \
nipkow@4907
   398
\          (? s. (start R,s) : steps R v & q = False#s))))";
wenzelm@5132
   399
by (blast_tac (claset() addDs [True_steps_concD]
nipkow@4907
   400
     addIs [True_True_steps_concI,in_steps_epsclosure,r_into_rtrancl]) 1);
nipkow@4907
   401
qed "True_steps_conc";
nipkow@4907
   402
nipkow@4907
   403
(** starting from the start **)
nipkow@4907
   404
wenzelm@5069
   405
Goalw [conc_def]
nipkow@4907
   406
  "!L R. start(conc L R) = True#start L";
wenzelm@5132
   407
by (Simp_tac 1);
nipkow@4907
   408
qed_spec_mp "start_conc";
nipkow@4907
   409
wenzelm@5069
   410
Goalw [conc_def]
nipkow@4907
   411
 "!L R. fin(conc L R) p = (? s. p = False#s & fin R s)";
berghofe@5184
   412
by (simp_tac (simpset() addsplits [list.split]) 1);
nipkow@4907
   413
qed_spec_mp "final_conc";
nipkow@4907
   414
wenzelm@5069
   415
Goal
nipkow@4907
   416
 "accepts (conc L R) w = (? u v. w = u@v & accepts L u & accepts R v)";
nipkow@4907
   417
by (simp_tac (simpset() addsimps
nipkow@4907
   418
     [accepts_def,True_steps_conc,final_conc,start_conc]) 1);
wenzelm@5132
   419
by (Blast_tac 1);
nipkow@4907
   420
qed "accepts_conc";
nipkow@4907
   421
nipkow@4907
   422
(******************************************************)
nipkow@4907
   423
(*                       star                         *)
nipkow@4907
   424
(******************************************************)
nipkow@4907
   425
wenzelm@5069
   426
Goalw [star_def,step_def]
nipkow@4907
   427
 "!A. (True#p,q) : eps(star A) = \
nipkow@4907
   428
\     ( (? r. q = True#r & (p,r) : eps A) | (fin A p & q = True#start A) )";
wenzelm@5132
   429
by (Simp_tac 1);
wenzelm@5132
   430
by (Blast_tac 1);
nipkow@4907
   431
qed_spec_mp "True_in_eps_star";
nipkow@4907
   432
AddIffs [True_in_eps_star];
nipkow@4907
   433
wenzelm@5069
   434
Goalw [star_def,step_def]
nipkow@4907
   435
  "!A. (p,q) : step A a --> (True#p, True#q) : step (star A) a";
wenzelm@5132
   436
by (Simp_tac 1);
nipkow@4907
   437
qed_spec_mp "True_True_step_starI";
nipkow@4907
   438
wenzelm@5069
   439
Goal
nipkow@5118
   440
  "(p,r) : (eps A)^* ==> (True#p, True#r) : (eps(star A))^*";
wenzelm@5132
   441
by (etac rtrancl_induct 1);
wenzelm@5132
   442
 by (Blast_tac 1);
wenzelm@5132
   443
by (blast_tac (claset() addIs [True_True_step_starI,rtrancl_into_rtrancl]) 1);
nipkow@4907
   444
qed_spec_mp "True_True_eps_starI";
nipkow@4907
   445
wenzelm@5069
   446
Goalw [star_def,step_def]
nipkow@4907
   447
 "!A. fin A p --> (True#p,True#start A) : eps(star A)";
wenzelm@5132
   448
by (Simp_tac 1);
nipkow@4907
   449
qed_spec_mp "True_start_eps_starI";
nipkow@4907
   450
wenzelm@5069
   451
Goal
nipkow@5118
   452
 "(tp,s) : (eps(star A))^* ==> (! p. tp = True#p --> \
nipkow@4907
   453
\ (? r. ((p,r) : (eps A)^* | \
nipkow@4907
   454
\        (? q. (p,q) : (eps A)^* & fin A q & (start A,r) : (eps A)^*)) & \
nipkow@4907
   455
\       s = True#r))";
wenzelm@5132
   456
by (etac rtrancl_induct 1);
wenzelm@5132
   457
 by (Simp_tac 1);
nipkow@4907
   458
by (Clarify_tac 1);
nipkow@4907
   459
by (Asm_full_simp_tac 1);
wenzelm@5132
   460
by (blast_tac (claset() addIs [rtrancl_into_rtrancl]) 1);
nipkow@4907
   461
val lemma = result();
nipkow@4907
   462
wenzelm@5069
   463
Goal
nipkow@4907
   464
 "((True#p,s) : (eps(star A))^*) = \
nipkow@4907
   465
\ (? r. ((p,r) : (eps A)^* | \
nipkow@4907
   466
\        (? q. (p,q) : (eps A)^* & fin A q & (start A,r) : (eps A)^*)) & \
nipkow@4907
   467
\       s = True#r)";
wenzelm@5132
   468
by (rtac iffI 1);
wenzelm@5132
   469
 by (dtac lemma 1);
wenzelm@5132
   470
 by (Blast_tac 1);
nipkow@4907
   471
(* Why can't blast_tac do the rest? *)
nipkow@4907
   472
by (Clarify_tac 1);
wenzelm@5132
   473
by (etac disjE 1);
wenzelm@5132
   474
by (etac True_True_eps_starI 1);
nipkow@4907
   475
by (Clarify_tac 1);
wenzelm@5132
   476
by (rtac rtrancl_trans 1);
wenzelm@5132
   477
by (etac True_True_eps_starI 1);
wenzelm@5132
   478
by (rtac rtrancl_trans 1);
wenzelm@5132
   479
by (rtac r_into_rtrancl 1);
wenzelm@5132
   480
by (etac True_start_eps_starI 1);
wenzelm@5132
   481
by (etac True_True_eps_starI 1);
nipkow@4907
   482
qed "True_eps_star";
nipkow@4907
   483
AddIffs [True_eps_star];
nipkow@4907
   484
nipkow@4907
   485
(** True in step Some **)
nipkow@4907
   486
wenzelm@5069
   487
Goalw [star_def,step_def]
nipkow@4907
   488
 "!A. (True#p,r): step (star A) (Some a) = \
nipkow@4907
   489
\     (? q. (p,q): step A (Some a) & r=True#q)";
wenzelm@5132
   490
by (Simp_tac 1);
wenzelm@5132
   491
by (Blast_tac 1);
nipkow@4907
   492
qed_spec_mp "True_step_star";
nipkow@4907
   493
AddIffs [True_step_star];
nipkow@4907
   494
nipkow@4907
   495
nipkow@4907
   496
(** True in steps **)
nipkow@4907
   497
nipkow@4907
   498
(* reverse list induction! Complicates matters for conc? *)
wenzelm@5069
   499
Goal
nipkow@4907
   500
 "!rr. (True#start A,rr) : steps (star A) w --> \
nipkow@4907
   501
\ (? us v. w = concat us @ v & \
nipkow@4907
   502
\             (!u:set us. accepts A u) & \
nipkow@4907
   503
\             (? r. (start A,r) : steps A v & rr = True#r))";
wenzelm@5132
   504
by (res_inst_tac [("xs","w")] rev_induct 1);
nipkow@4907
   505
 by (Asm_full_simp_tac 1);
nipkow@4907
   506
 by (Clarify_tac 1);
wenzelm@5132
   507
 by (res_inst_tac [("x","[]")] exI 1);
wenzelm@5132
   508
 by (etac disjE 1);
nipkow@4907
   509
  by (Asm_simp_tac 1);
nipkow@4907
   510
 by (Clarify_tac 1);
nipkow@4907
   511
 by (Asm_simp_tac 1);
wenzelm@5132
   512
by (simp_tac (simpset() addsimps [O_assoc,epsclosure_steps]) 1);
nipkow@4907
   513
by (Clarify_tac 1);
wenzelm@5132
   514
by (etac allE 1 THEN mp_tac 1);
nipkow@4907
   515
by (Clarify_tac 1);
wenzelm@5132
   516
by (etac disjE 1);
wenzelm@5132
   517
 by (res_inst_tac [("x","us")] exI 1);
wenzelm@5132
   518
 by (res_inst_tac [("x","v@[x]")] exI 1);
wenzelm@5132
   519
 by (asm_simp_tac (simpset() addsimps [O_assoc,epsclosure_steps]) 1);
wenzelm@5132
   520
 by (Blast_tac 1);
nipkow@4907
   521
by (Clarify_tac 1);
wenzelm@5132
   522
by (res_inst_tac [("x","us@[v@[x]]")] exI 1);
wenzelm@5132
   523
by (res_inst_tac [("x","[]")] exI 1);
wenzelm@5132
   524
by (asm_full_simp_tac (simpset() addsimps [accepts_def]) 1);
wenzelm@5132
   525
by (Blast_tac 1);
nipkow@4907
   526
qed_spec_mp "True_start_steps_starD";
nipkow@4907
   527
wenzelm@5069
   528
Goal "!p. (p,q) : steps A w --> (True#p,True#q) : steps (star A) w";
wenzelm@5132
   529
by (induct_tac "w" 1);
wenzelm@5132
   530
 by (Simp_tac 1);
wenzelm@5132
   531
by (Simp_tac 1);
wenzelm@5132
   532
by (blast_tac (claset() addIs [True_True_eps_starI,True_True_step_starI]) 1);
nipkow@4907
   533
qed_spec_mp "True_True_steps_starI";
nipkow@4907
   534
wenzelm@5069
   535
Goalw [accepts_def]
nipkow@4907
   536
 "(!u : set us. accepts A u) --> \
nipkow@4907
   537
\ (True#start A,True#start A) : steps (star A) (concat us)";
wenzelm@5132
   538
by (induct_tac "us" 1);
wenzelm@5132
   539
 by (Simp_tac 1);
wenzelm@5132
   540
by (Simp_tac 1);
wenzelm@5132
   541
by (blast_tac (claset() addIs [True_True_steps_starI,True_start_eps_starI,r_into_rtrancl,in_epsclosure_steps]) 1);
nipkow@4907
   542
qed_spec_mp "steps_star_cycle";
nipkow@4907
   543
nipkow@4907
   544
(* Better stated directly with start(star A)? Loop in star A back to start(star A)?*)
wenzelm@5069
   545
Goal
nipkow@4907
   546
 "(True#start A,rr) : steps (star A) w = \
nipkow@4907
   547
\ (? us v. w = concat us @ v & \
nipkow@4907
   548
\             (!u:set us. accepts A u) & \
nipkow@4907
   549
\             (? r. (start A,r) : steps A v & rr = True#r))";
wenzelm@5132
   550
by (rtac iffI 1);
wenzelm@5132
   551
 by (etac True_start_steps_starD 1);
nipkow@4907
   552
by (Clarify_tac 1);
wenzelm@5132
   553
by (Asm_simp_tac 1);
wenzelm@5132
   554
by (blast_tac (claset() addIs [True_True_steps_starI,steps_star_cycle]) 1);
nipkow@4907
   555
qed "True_start_steps_star";
nipkow@4907
   556
nipkow@4907
   557
(** the start state **)
nipkow@4907
   558
wenzelm@5069
   559
Goalw [star_def,step_def]
nipkow@4907
   560
  "!A. (start(star A),r) : step (star A) a = (a=None & r = True#start A)";
wenzelm@5132
   561
by (Simp_tac 1);
nipkow@4907
   562
qed_spec_mp "start_step_star";
nipkow@4907
   563
AddIffs [start_step_star];
nipkow@4907
   564
nipkow@4907
   565
val epsclosure_start_step_star =
nipkow@4907
   566
  read_instantiate [("p","start(star A)")] in_unfold_rtrancl2;
nipkow@4907
   567
wenzelm@5069
   568
Goal
nipkow@4907
   569
 "(start(star A),r) : steps (star A) w = \
nipkow@4907
   570
\ ((w=[] & r= start(star A)) | (True#start A,r) : steps (star A) w)";
wenzelm@5132
   571
by (rtac iffI 1);
wenzelm@5132
   572
 by (exhaust_tac "w" 1);
wenzelm@5132
   573
  by (asm_full_simp_tac (simpset() addsimps
nipkow@4907
   574
    [epsclosure_start_step_star]) 1);
wenzelm@5132
   575
 by (Asm_full_simp_tac 1);
nipkow@4907
   576
 by (Clarify_tac 1);
wenzelm@5132
   577
 by (asm_full_simp_tac (simpset() addsimps
nipkow@4907
   578
    [epsclosure_start_step_star]) 1);
wenzelm@5132
   579
 by (Blast_tac 1);
wenzelm@5132
   580
by (etac disjE 1);
wenzelm@5132
   581
 by (Asm_simp_tac 1);
wenzelm@5132
   582
by (blast_tac (claset() addIs [in_steps_epsclosure,r_into_rtrancl]) 1);
nipkow@4907
   583
qed "start_steps_star";
nipkow@4907
   584
wenzelm@5069
   585
Goalw [star_def] "!A. fin (star A) (True#p) = fin A p";
wenzelm@5132
   586
by (Simp_tac 1);
nipkow@4907
   587
qed_spec_mp "fin_star_True";
nipkow@4907
   588
AddIffs [fin_star_True];
nipkow@4907
   589
wenzelm@5069
   590
Goalw [star_def] "!A. fin (star A) (start(star A))";
wenzelm@5132
   591
by (Simp_tac 1);
nipkow@4907
   592
qed_spec_mp "fin_star_start";
nipkow@4907
   593
AddIffs [fin_star_start];
nipkow@4907
   594
nipkow@4907
   595
(* too complex! Simpler if loop back to start(star A)? *)
wenzelm@5069
   596
Goalw [accepts_def]
nipkow@4907
   597
 "accepts (star A) w = \
nipkow@4907
   598
\ (? us. (!u : set(us). accepts A u) & (w = concat us) )";
wenzelm@5132
   599
by (simp_tac (simpset() addsimps [start_steps_star,True_start_steps_star]) 1);
wenzelm@5132
   600
by (rtac iffI 1);
nipkow@4907
   601
 by (Clarify_tac 1);
wenzelm@5132
   602
 by (etac disjE 1);
nipkow@4907
   603
  by (Clarify_tac 1);
wenzelm@5132
   604
  by (Simp_tac 1);
wenzelm@5132
   605
  by (res_inst_tac [("x","[]")] exI 1);
wenzelm@5132
   606
  by (Simp_tac 1);
nipkow@4907
   607
 by (Clarify_tac 1);
wenzelm@5132
   608
 by (res_inst_tac [("x","us@[v]")] exI 1);
wenzelm@5132
   609
 by (asm_full_simp_tac (simpset() addsimps [accepts_def]) 1);
wenzelm@5132
   610
 by (Blast_tac 1);
nipkow@4907
   611
by (Clarify_tac 1);
wenzelm@5132
   612
by (res_inst_tac [("xs","us")] rev_exhaust 1);
wenzelm@5132
   613
 by (Asm_simp_tac 1);
wenzelm@5132
   614
 by (Blast_tac 1);
nipkow@4907
   615
by (Clarify_tac 1);
wenzelm@5132
   616
by (asm_full_simp_tac (simpset() addsimps [accepts_def]) 1);
wenzelm@5132
   617
by (Blast_tac 1);
nipkow@4907
   618
qed "accepts_star";
nipkow@4907
   619
nipkow@4907
   620
nipkow@4907
   621
(***** Correctness of r2n *****)
nipkow@4907
   622
wenzelm@5069
   623
Goal
nipkow@4907
   624
 "!w. accepts (rexp2nae r) w = (w : lang r)";
wenzelm@5132
   625
by (induct_tac "r" 1);
wenzelm@5132
   626
    by (simp_tac (simpset() addsimps [accepts_def]) 1);
wenzelm@5132
   627
   by (simp_tac(simpset() addsimps [accepts_atom]) 1);
wenzelm@5132
   628
  by (asm_simp_tac (simpset() addsimps [accepts_union]) 1);
wenzelm@5132
   629
 by (asm_simp_tac (simpset() addsimps [accepts_conc,RegSet.conc_def]) 1);
wenzelm@5132
   630
by (asm_simp_tac (simpset() addsimps [accepts_star,in_star]) 1);
nipkow@4907
   631
qed "accepts_rexp2nae";