author | Christian Urban <christian dot urban at kcl dot ac dot uk> |
Sun, 22 Dec 2013 07:37:26 +0000 | |
changeset 393 | 058f29ab515c |
parent 372 | 2c56b20032a7 |
permissions | -rw-r--r-- |
182
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
1 |
theory Prefix_subtract |
372
2c56b20032a7
made changes and updates to the journal paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
182
diff
changeset
|
2 |
imports Main "../List_Prefix" |
182
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
3 |
begin |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
4 |
|
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
5 |
|
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
6 |
section {* A small theory of prefix subtraction *} |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
7 |
|
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
8 |
text {* |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
9 |
The notion of @{text "prefix_subtract"} makes |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
10 |
the second direction of the Myhill-Nerode theorem |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
11 |
more readable. |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
12 |
*} |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
13 |
|
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
14 |
instantiation list :: (type) minus |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
15 |
begin |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
16 |
|
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
17 |
fun minus_list :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
18 |
where |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
19 |
"minus_list [] xs = []" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
20 |
| "minus_list (x#xs) [] = x#xs" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
21 |
| "minus_list (x#xs) (y#ys) = (if x = y then minus_list xs ys else (x#xs))" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
22 |
|
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
23 |
instance by default |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
24 |
|
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
25 |
end |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
26 |
|
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
27 |
lemma [simp]: "x - [] = x" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
28 |
by (induct x) (auto) |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
29 |
|
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
30 |
lemma [simp]: "(x @ y) - x = y" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
31 |
by (induct x) (auto) |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
32 |
|
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
33 |
lemma [simp]: "x - x = []" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
34 |
by (induct x) (auto) |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
35 |
|
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
36 |
lemma [simp]: "x = z @ y \<Longrightarrow> x - z = y " |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
37 |
by (induct x) (auto) |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
38 |
|
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
39 |
lemma diff_prefix: |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
40 |
"\<lbrakk>c \<le> a - b; b \<le> a\<rbrakk> \<Longrightarrow> b @ c \<le> a" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
41 |
by (auto elim: prefixE) |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
42 |
|
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
43 |
lemma diff_diff_append: |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
44 |
"\<lbrakk>c < a - b; b < a\<rbrakk> \<Longrightarrow> (a - b) - c = a - (b @ c)" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
45 |
apply (clarsimp simp:strict_prefix_def) |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
46 |
by (drule diff_prefix, auto elim:prefixE) |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
47 |
|
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
48 |
lemma append_eq_cases: |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
49 |
assumes a: "x @ y = m @ n" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
50 |
shows "x \<le> m \<or> m \<le> x" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
51 |
unfolding prefix_def using a |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
52 |
by (auto simp add: append_eq_append_conv2) |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
53 |
|
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
54 |
lemma append_eq_dest: |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
55 |
assumes a: "x @ y = m @ n" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
56 |
shows "(x \<le> m \<and> (m - x) @ n = y) \<or> (m \<le> x \<and> (x - m) @ y = n)" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
57 |
using append_eq_cases[OF a] a |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
58 |
by (auto elim: prefixE) |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
59 |
|
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
diff
changeset
|
60 |
end |