progs/Matcher2.thy
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Wed, 25 Nov 2015 15:59:32 +0000
changeset 385 7f8516ff408d
parent 363 0d6deecdb2eb
child 397 cf3ca219c727
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
385
7f8516ff408d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 363
diff changeset
     1
ytheory Matcher2
191
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     2
  imports "Main" 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     3
begin
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     4
355
a259eec25156 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 272
diff changeset
     5
lemma Suc_Union:
a259eec25156 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 272
diff changeset
     6
  "(\<Union> x\<le>Suc m. B x) = (B (Suc m) \<union> (\<Union> x\<le>m. B x))"
a259eec25156 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 272
diff changeset
     7
by (metis UN_insert atMost_Suc)
a259eec25156 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 272
diff changeset
     8
a259eec25156 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 272
diff changeset
     9
lemma Suc_reduce_Union:
a259eec25156 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 272
diff changeset
    10
  "(\<Union>x\<in>{Suc n..Suc m}. B x) = (\<Union>x\<in>{n..m}. B (Suc x))"
a259eec25156 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 272
diff changeset
    11
by (metis UN_extend_simps(10) image_Suc_atLeastAtMost)
a259eec25156 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 272
diff changeset
    12
a259eec25156 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 272
diff changeset
    13
191
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    14
section {* Regular Expressions *}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    15
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    16
datatype rexp =
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    17
  NULL
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    18
| EMPTY
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    19
| CHAR char
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    20
| SEQ rexp rexp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    21
| ALT rexp rexp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    22
| STAR rexp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    23
| NOT rexp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    24
| PLUS rexp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    25
| OPT rexp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    26
| NTIMES rexp nat
362
57ea439feaff updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 361
diff changeset
    27
| NMTIMES rexp nat nat
57ea439feaff updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 361
diff changeset
    28
191
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    29
fun M :: "rexp \<Rightarrow> nat"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    30
where
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    31
  "M (NULL) = 0"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    32
| "M (EMPTY) = 0"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    33
| "M (CHAR char) = 0"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    34
| "M (SEQ r1 r2) = Suc ((M r1) + (M r2))"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    35
| "M (ALT r1 r2) = Suc ((M r1) + (M r2))"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    36
| "M (STAR r) = Suc (M r)"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    37
| "M (NOT r) = Suc (M r)"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    38
| "M (PLUS r) = Suc (M r)"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    39
| "M (OPT r) = Suc (M r)"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    40
| "M (NTIMES r n) = Suc (M r) * 2 * (Suc n)"
362
57ea439feaff updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 361
diff changeset
    41
| "M (NMTIMES r n m) = Suc (M r) * 2 * (Suc m - Suc n)"
57ea439feaff updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 361
diff changeset
    42
191
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    43
section {* Sequential Composition of Sets *}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    44
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    45
definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    46
  Seq :: "string set \<Rightarrow> string set \<Rightarrow> string set" ("_ ;; _" [100,100] 100)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    47
where 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    48
  "A ;; B = {s1 @ s2 | s1 s2. s1 \<in> A \<and> s2 \<in> B}"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    49
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    50
text {* Two Simple Properties about Sequential Composition *}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    51
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    52
lemma seq_empty [simp]:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    53
  shows "A ;; {[]} = A"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    54
  and   "{[]} ;; A = A"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    55
by (simp_all add: Seq_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    56
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    57
lemma seq_null [simp]:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    58
  shows "A ;; {} = {}"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    59
  and   "{} ;; A = {}"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    60
by (simp_all add: Seq_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    61
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    62
lemma seq_union:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    63
  shows "A ;; (B \<union> C) = A ;; B \<union> A ;; C"
194
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
    64
  and   "(B \<union> C) ;; A = B ;; A \<union> C ;; A"
191
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    65
by (auto simp add: Seq_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    66
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    67
lemma seq_Union:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    68
  shows "A ;; (\<Union>x\<in>B. C x) = (\<Union>x\<in>B. A ;; C x)"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    69
by (auto simp add: Seq_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    70
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    71
lemma seq_empty_in [simp]:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    72
  "[] \<in> A ;; B \<longleftrightarrow> ([] \<in> A \<and> [] \<in> B)"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    73
by (simp add: Seq_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    74
194
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
    75
lemma seq_assoc: 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
    76
  shows "A ;; (B ;; C) = (A ;; B) ;; C" 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
    77
apply(auto simp add: Seq_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
    78
apply(metis append_assoc)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
    79
apply(metis)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
    80
done
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
    81
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
    82
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
    83
section {* Power for Sets *}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
    84
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
    85
fun 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
    86
  pow :: "string set \<Rightarrow> nat \<Rightarrow> string set" ("_ \<up> _" [101, 102] 101)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
    87
where
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
    88
   "A \<up> 0 = {[]}"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
    89
|  "A \<up> (Suc n) = A ;; (A \<up> n)"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
    90
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
    91
lemma pow_empty [simp]:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
    92
  shows "[] \<in> A \<up> n \<longleftrightarrow> (n = 0 \<or> [] \<in> A)"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
    93
by (induct n) (auto)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
    94
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
    95
lemma pow_plus:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
    96
  "A \<up> (n + m) = A \<up> n ;; A \<up> m"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
    97
by (induct n) (simp_all add: seq_assoc)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
    98
191
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    99
section {* Kleene Star for Sets *}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   100
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   101
inductive_set
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   102
  Star :: "string set \<Rightarrow> string set" ("_\<star>" [101] 102)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   103
  for A :: "string set"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   104
where
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   105
  start[intro]: "[] \<in> A\<star>"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   106
| step[intro]:  "\<lbrakk>s1 \<in> A; s2 \<in> A\<star>\<rbrakk> \<Longrightarrow> s1 @ s2 \<in> A\<star>"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   107
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   108
text {* A Standard Property of Star *}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   109
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   110
lemma star_decomp: 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   111
  assumes a: "c # x \<in> A\<star>" 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   112
  shows "\<exists>a b. x = a @ b \<and> c # a \<in> A \<and> b \<in> A\<star>"
194
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   113
using a 
191
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   114
using a
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   115
by (induct x\<equiv>"c # x" rule: Star.induct) 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   116
   (auto simp add: append_eq_Cons_conv)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   117
194
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   118
lemma star_cases:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   119
  shows "A\<star> = {[]} \<union> A ;; A\<star>"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   120
unfolding Seq_def 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   121
by (auto) (metis Star.simps)
191
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   122
194
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   123
lemma Star_in_Pow:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   124
  assumes a: "s \<in> A\<star>"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   125
  shows "\<exists>n. s \<in> A \<up> n"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   126
using a
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   127
apply(induct)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   128
apply(auto)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   129
apply(rule_tac x="Suc n" in exI)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   130
apply(auto simp add: Seq_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   131
done
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   132
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   133
lemma Pow_in_Star:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   134
  assumes a: "s \<in> A \<up> n"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   135
  shows "s \<in> A\<star>"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   136
using a
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   137
by (induct n arbitrary: s) (auto simp add: Seq_def)
191
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   138
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   139
194
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   140
lemma Star_def2: 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   141
  shows "A\<star> = (\<Union>n. A \<up> n)"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   142
using Star_in_Pow Pow_in_Star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   143
by (auto)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 193
diff changeset
   144
191
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   145
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   146
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   147
section {* Semantics of Regular Expressions *}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   148
 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   149
fun
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   150
  L :: "rexp \<Rightarrow> string set"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   151
where
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   152
  "L (NULL) = {}"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   153
| "L (EMPTY) = {[]}"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   154
| "L (CHAR c) = {[c]}"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   155
| "L (SEQ r1 r2) = (L r1) ;; (L r2)"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   156
| "L (ALT r1 r2) = (L r1) \<union> (L r2)"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   157
| "L (STAR r) = (L r)\<star>"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   158
| "L (NOT r) = UNIV - (L r)"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   159
| "L (PLUS r) = (L r) ;; ((L r)\<star>)"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   160
| "L (OPT r) = (L r) \<union> {[]}"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   161
| "L (NTIMES r n) = (L r) \<up> n"
362
57ea439feaff updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 361
diff changeset
   162
| "L (NMTIMES r n m) = (\<Union>i\<in> {n..m} . ((L r) \<up> i))" 
355
a259eec25156 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 272
diff changeset
   163
191
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   164
227
93bd75031ced added handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 198
diff changeset
   165
lemma "L (NOT NULL) = UNIV"
93bd75031ced added handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 198
diff changeset
   166
apply(simp)
93bd75031ced added handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 198
diff changeset
   167
done
93bd75031ced added handout
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 198
diff changeset
   168
191
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   169
section {* The Matcher *}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   170
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   171
fun
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   172
 nullable :: "rexp \<Rightarrow> bool"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   173
where
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   174
  "nullable (NULL) = False"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   175
| "nullable (EMPTY) = True"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   176
| "nullable (CHAR c) = False"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   177
| "nullable (ALT r1 r2) = (nullable r1 \<or> nullable r2)"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   178
| "nullable (SEQ r1 r2) = (nullable r1 \<and> nullable r2)"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   179
| "nullable (STAR r) = True"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   180
| "nullable (NOT r) = (\<not>(nullable r))"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   181
| "nullable (PLUS r) = (nullable r)"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   182
| "nullable (OPT r) = True"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   183
| "nullable (NTIMES r n) = (if n = 0 then True else nullable r)"
362
57ea439feaff updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 361
diff changeset
   184
| "nullable (NMTIMES r n m) = (if m < n then False else (if n = 0 then True else nullable r))"
361
9c7eb266594c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 355
diff changeset
   185
9c7eb266594c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 355
diff changeset
   186
function der :: "char \<Rightarrow> rexp \<Rightarrow> rexp"
191
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   187
where
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   188
  "der c (NULL) = NULL"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   189
| "der c (EMPTY) = NULL"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   190
| "der c (CHAR d) = (if c = d then EMPTY else NULL)"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   191
| "der c (ALT r1 r2) = ALT (der c r1) (der c r2)"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   192
| "der c (SEQ r1 r2) = ALT (SEQ (der c r1) r2) (if nullable r1 then der c r2 else NULL)"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   193
| "der c (STAR r) = SEQ (der c r) (STAR r)"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   194
| "der c (NOT r) = NOT(der c r)"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   195
| "der c (PLUS r) = SEQ (der c r) (STAR r)"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   196
| "der c (OPT r) = der c r"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   197
| "der c (NTIMES r 0) = NULL"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   198
| "der c (NTIMES r (Suc n)) = der c (SEQ r (NTIMES r n))"
363
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   199
| "der c (NMTIMES r n m) = 
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   200
     (if m < n then NULL else 
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   201
     (if m = 0 then NULL else
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   202
     (der c (SEQ r (NMTIMES r (n - 1) (m - 1))))))"
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   203
(*
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   204
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   205
  (if m < n then NULL else 
355
a259eec25156 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 272
diff changeset
   206
                              (if n = m then der c (NTIMES r n) else
362
57ea439feaff updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 361
diff changeset
   207
                                ALT (der c (NTIMES r n)) (der c (NMTIMES r (Suc n) m))))"
363
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   208
*)
191
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   209
by pat_completeness auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   210
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   211
termination der 
361
9c7eb266594c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 355
diff changeset
   212
apply(relation "measure (\<lambda>(c, r). M r)") 
9c7eb266594c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 355
diff changeset
   213
apply(simp_all)
355
a259eec25156 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 272
diff changeset
   214
sorry
361
9c7eb266594c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 355
diff changeset
   215
193
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 191
diff changeset
   216
191
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   217
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   218
fun 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   219
 ders :: "string \<Rightarrow> rexp \<Rightarrow> rexp"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   220
where
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   221
  "ders [] r = r"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   222
| "ders (c # s) r = ders s (der c r)"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   223
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   224
fun
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   225
  matcher :: "rexp \<Rightarrow> string \<Rightarrow> bool"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   226
where
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   227
  "matcher r s = nullable (ders s r)"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   228
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   229
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   230
section {* Correctness Proof of the Matcher *}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   231
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   232
lemma nullable_correctness:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   233
  shows "nullable r  \<longleftrightarrow> [] \<in> (L r)"
355
a259eec25156 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 272
diff changeset
   234
apply(induct r) 
a259eec25156 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 272
diff changeset
   235
apply(auto simp add: Seq_def) 
a259eec25156 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 272
diff changeset
   236
done
191
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   237
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   238
section {* Left-Quotient of a Set *}
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   239
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   240
definition
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   241
  Der :: "char \<Rightarrow> string set \<Rightarrow> string set"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   242
where
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   243
  "Der c A \<equiv> {s. [c] @ s \<in> A}"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   244
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   245
lemma Der_null [simp]:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   246
  shows "Der c {} = {}"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   247
unfolding Der_def
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   248
by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   249
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   250
lemma Der_empty [simp]:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   251
  shows "Der c {[]} = {}"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   252
unfolding Der_def
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   253
by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   254
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   255
lemma Der_char [simp]:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   256
  shows "Der c {[d]} = (if c = d then {[]} else {})"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   257
unfolding Der_def
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   258
by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   259
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   260
lemma Der_union [simp]:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   261
  shows "Der c (A \<union> B) = Der c A \<union> Der c B"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   262
unfolding Der_def
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   263
by auto
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   264
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   265
lemma Der_insert_nil [simp]:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   266
  shows "Der c (insert [] A) = Der c A"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   267
unfolding Der_def 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   268
by auto 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   269
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   270
lemma Der_seq [simp]:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   271
  shows "Der c (A ;; B) = (Der c A) ;; B \<union> (if [] \<in> A then Der c B else {})"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   272
unfolding Der_def Seq_def
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   273
by (auto simp add: Cons_eq_append_conv)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   274
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   275
lemma Der_star [simp]:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   276
  shows "Der c (A\<star>) = (Der c A) ;; A\<star>"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   277
proof -    
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   278
  have "Der c (A\<star>) = Der c ({[]} \<union> A ;; A\<star>)"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   279
    by (simp only: star_cases[symmetric])
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   280
  also have "... = Der c (A ;; A\<star>)"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   281
    by (simp only: Der_union Der_empty) (simp)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   282
  also have "... = (Der c A) ;; A\<star> \<union> (if [] \<in> A then Der c (A\<star>) else {})"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   283
    by simp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   284
  also have "... =  (Der c A) ;; A\<star>"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   285
    unfolding Seq_def Der_def
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   286
    by (auto dest: star_decomp)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   287
  finally show "Der c (A\<star>) = (Der c A) ;; A\<star>" .
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   288
qed
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   289
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   290
lemma Der_UNIV [simp]:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   291
  "Der c (UNIV - A) = UNIV - Der c A"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   292
unfolding Der_def
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   293
by (auto)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   294
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   295
lemma Der_pow [simp]:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   296
  shows "Der c (A \<up> (Suc n)) = (Der c A) ;; (A \<up> n) \<union> (if [] \<in> A then Der c (A \<up> n) else {})"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   297
unfolding Der_def 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   298
by(auto simp add: Cons_eq_append_conv Seq_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   299
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   300
lemma Der_UNION [simp]: 
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   301
  shows "Der c (\<Union>x\<in>A. B x) = (\<Union>x\<in>A. Der c (B x))"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   302
by (auto simp add: Der_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   303
363
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   304
lemma der_correctness:
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   305
  shows "L (der c r) = Der c (L r)"
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   306
apply(induct rule: der.induct) 
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   307
apply(simp_all add: nullable_correctness 
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   308
    Suc_Union Suc_reduce_Union seq_Union atLeast0AtMost)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   309
apply(case_tac "[] \<in> L r")
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   310
apply(simp)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   311
apply(case_tac n)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   312
apply(auto)[1]
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   313
apply(case_tac m)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   314
apply(simp)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   315
apply(auto simp add: )[1]
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   316
apply (metis (full_types, hide_lams) Der_pow Der_seq Suc_le_mono UnCI atLeast0AtMost atMost_iff not_less_eq_eq)
191
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   317
363
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   318
apply (metis (poly_guards_query) atLeastAtMost_iff not_le order_refl)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   319
apply (metis Suc_leD atLeastAtMost_iff)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   320
by (metis atLeastAtMost_iff le_antisym not_less_eq_eq)
191
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   321
363
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   322
(*
191
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   323
lemma der_correctness:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   324
  shows "L (der c r) = Der c (L r)"
355
a259eec25156 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 272
diff changeset
   325
apply(induct rule: der.induct) 
a259eec25156 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 272
diff changeset
   326
apply(simp_all add: nullable_correctness 
193
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 191
diff changeset
   327
    Suc_Union Suc_reduce_Union seq_Union atLeast0AtMost)
355
a259eec25156 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 272
diff changeset
   328
apply(case_tac m)
a259eec25156 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 272
diff changeset
   329
apply(simp)
a259eec25156 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 272
diff changeset
   330
apply(simp)
a259eec25156 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 272
diff changeset
   331
apply(auto)
a259eec25156 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 272
diff changeset
   332
apply (metis (poly_guards_query) atLeastAtMost_iff not_le order_refl)
a259eec25156 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 272
diff changeset
   333
apply (metis Suc_leD atLeastAtMost_iff)
a259eec25156 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 272
diff changeset
   334
by (metis atLeastAtMost_iff le_antisym not_less_eq_eq)
363
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   335
*)
191
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   336
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   337
lemma matcher_correctness:
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   338
  shows "matcher r s \<longleftrightarrow> s \<in> L r"
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   339
by (induct s arbitrary: r)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   340
   (simp_all add: nullable_correctness der_correctness Der_def)
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   341
272
1446bc47a294 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 227
diff changeset
   342
363
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   343
lemma "L (der c (NMTIMES r n m)) = 
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   344
  L ((if m < n then NULL else 
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   345
     (if m = 0 then NULL else
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   346
     (der c (SEQ r (NMTIMES r (n - 1) (m - 1)))))))"
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   347
apply(subst der.simps(12))
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   348
apply(auto simp del: der.simps)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   349
apply(simp)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   350
apply(auto)[1]
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   351
apply(case_tac m)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   352
apply(simp)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   353
apply(simp)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   354
apply(case_tac m)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   355
apply(simp)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   356
apply(simp)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   357
apply(simp)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   358
apply(subst (asm) der.simps(12))
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   359
apply(auto)[1]
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   360
apply(case_tac m)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   361
apply(simp)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   362
apply(simp)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   363
apply(case_tac m)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   364
apply(simp)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   365
apply(simp)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   366
apply(auto)[1]
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   367
apply(auto simp del: der.simps(12))[1]
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   368
apply(subst (asm) der.simps(12))
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   369
apply(case_tac n)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   370
apply(simp)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   371
apply(simp)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   372
apply(case_tac m)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   373
apply(simp)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   374
apply(simp)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   375
apply(case_tac "Suc nat = nata")
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   376
apply(simp)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   377
apply(auto simp del: der.simps(12))[1]
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   378
apply(auto)[1]
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   379
apply(case_tac n)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   380
apply(simp)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   381
apply(simp)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   382
apply(case_tac m)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   383
apply(simp)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   384
apply(simp)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   385
apply(simp add: Seq_def)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   386
apply(auto)[1]
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   387
apply (metis atLeastAtMost_iff le_eq_less_or_eq linorder_neqE_nat)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   388
apply(simp (no_asm) del: der.simps(12))
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   389
apply(auto simp del: der.simps(12))[1]
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   390
apply(case_tac "m = Suc n")
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   391
apply(simp)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   392
apply(case_tac n)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   393
apply(simp)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   394
apply(simp)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   395
apply(auto simp add: Seq_def del: der.simps(12))[1]
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   396
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   397
apply(case_tac n)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   398
apply(simp)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   399
apply(case_tac m)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   400
apply(simp)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   401
apply(simp)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   402
apply(simp add: Seq_def)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   403
apply(auto)[1]
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   404
apply(case_tac "nat = 0")
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   405
apply(simp)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   406
apply(simp)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   407
apply(auto)[1]
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   408
apply(case_tac "Suc 0 = nat")
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   409
apply(simp)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   410
apply(auto simp del: der.simps(12))[1]
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   411
apply(simp)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   412
apply(case_tac "Suc 0 = nat")
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   413
apply(simp)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   414
apply(auto simp add: Seq_def del: der.simps(12))[1]
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   415
apply(rule_tac x="s1" in exI)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   416
apply(rule_tac x="s2" in exI)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   417
apply(simp)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   418
apply(rule_tac x="1" in bexI)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   419
apply(simp)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   420
apply(simp)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   421
apply(simp)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   422
apply(auto simp add: Seq_def)[1]
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   423
apply(case_tac m)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   424
apply(simp)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   425
apply(simp)
0d6deecdb2eb updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 362
diff changeset
   426
191
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   427
end