4832
|
1 |
(* Title: HOL/Lex/RegSet_of_nat_DA.thy
|
|
2 |
ID: $Id$
|
|
3 |
Author: Tobias Nipkow
|
|
4 |
Copyright 1998 TUM
|
|
5 |
|
|
6 |
Conversion of deterministic automata into regular sets.
|
|
7 |
|
|
8 |
To generate a regual expression, the alphabet must be finite.
|
|
9 |
regexp needs to be supplied with an 'a list for a unique order
|
|
10 |
|
|
11 |
add_Atom d i j r a = (if d a i = j then Union r (Atom a) else r)
|
|
12 |
atoms d i j as = foldl (add_Atom d i j) Empty as
|
|
13 |
|
|
14 |
regexp as d i j 0 = (if i=j then Union (Star Empty) (atoms d i j as)
|
|
15 |
else atoms d i j as
|
|
16 |
*)
|
|
17 |
|
|
18 |
RegSet_of_nat_DA = RegSet + DA +
|
|
19 |
|
|
20 |
types 'a nat_next = "'a => nat => nat"
|
|
21 |
|
|
22 |
syntax deltas :: 'a nat_next => 'a list => nat => nat
|
|
23 |
translations "deltas" == "foldl2"
|
|
24 |
|
|
25 |
consts trace :: 'a nat_next => nat => 'a list => nat list
|
5184
|
26 |
primrec
|
4832
|
27 |
"trace d i [] = []"
|
|
28 |
"trace d i (x#xs) = d x i # trace d (d x i) xs"
|
|
29 |
|
|
30 |
(* conversion a la Warshall *)
|
|
31 |
|
|
32 |
consts regset :: 'a nat_next => nat => nat => nat => 'a list set
|
5184
|
33 |
primrec
|
4832
|
34 |
"regset d i j 0 = (if i=j then insert [] {[a] | a. d a i = j}
|
|
35 |
else {[a] | a. d a i = j})"
|
|
36 |
"regset d i j (Suc k) = regset d i j k Un
|
|
37 |
conc (regset d i k k)
|
|
38 |
(conc (star(regset d k k k))
|
|
39 |
(regset d k j k))"
|
|
40 |
|
|
41 |
constdefs
|
|
42 |
regset_of_DA :: ('a,nat)da => nat => 'a list set
|
|
43 |
"regset_of_DA A k == UN j:{j. j<k & fin A j}. regset (next A) (start A) j k"
|
|
44 |
|
|
45 |
bounded :: "'a => nat => bool"
|
|
46 |
"bounded d k == !n. n < k --> (!x. d x n < k)"
|
|
47 |
|
|
48 |
end
|