# HG changeset patch # User nipkow # Date 878717315 -3600 # Node ID 2ce2e659c2b1e770b56a4a796ffa9d2fffd9a55a # Parent ba267836dd7a1a500eb75ddcdba6145b7f472332 Added an alternativ version of AutoChopper and a theory for the conversion of automata into regular sets. diff -r ba267836dd7a -r 2ce2e659c2b1 src/HOL/Lex/AutoChopper.thy --- a/src/HOL/Lex/AutoChopper.thy Tue Nov 04 20:52:20 1997 +0100 +++ b/src/HOL/Lex/AutoChopper.thy Wed Nov 05 09:08:35 1997 +0100 @@ -12,6 +12,8 @@ WARNING: auto_chopper is exponential(?) if the recursive calls in the penultimate argument are evaluated eagerly. + +A more efficient version is defined in AutoChopper1. *) AutoChopper = Auto + Chopper + @@ -39,32 +41,3 @@ else acc xs (nxt st x) ys (zs@[x]) chopsr A)" end - -(* The following definition of acc should also work: -consts - acc1 :: [('a,'b)auto, 'a list, 'b, 'a list list, 'a list, 'a list] - => 'a list list * 'a list - -acc1 A [] s xss zs xs = - (if xs=[] then (xss, zs) - else acc1 A zs (start A) (xss @ [xs]) [] []) -acc1 A (y#ys) s xss zs rec = - let s' = next A s; - zs' = (if fin A s' then [] else zs@[y]) - xs' = (if fin A s' then xs@zs@[y] else xs) - in acc1 A ys s' xss zs' xs' - -Advantage: does not need lazy evaluation for reasonable (quadratic) -performance. - -Disadavantage: not primrec. - -Termination measure: - size(A,ys,s,xss,zs,rec) = (|xs| + |ys| + |zs|, |ys|) - -Termination proof: the first clause reduces the first component by |xs|, -the second clause leaves the first component alone but reduces the second by 1. - -Claim: acc1 A xs s [] [] [] = acc xs s [] [] ([],xs) A -Generalization? -*) diff -r ba267836dd7a -r 2ce2e659c2b1 src/HOL/Lex/AutoChopper1.thy --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/HOL/Lex/AutoChopper1.thy Wed Nov 05 09:08:35 1997 +0100 @@ -0,0 +1,37 @@ +(* Title: HOL/Lex/AutoChopper1.thy + ID: $Id$ + Author: Tobias Nipkow + Copyright 1997 TUM + +This is a version of theory AutoChopper base on a non-primrec definition of +`acc'. Advantage: does not need lazy evaluation for reasonable (quadratic?) +performance. + +Verification: +1. Via AutoChopper.acc using + Claim: acc A xs s [] [] [] = AutoChopper.acc xs s [] [] ([],xs) A + Generalization? +2. Directly. + Hope: acc is easier to verify than AutoChopper.acc because simpler. + +No proofs yet. +*) + +AutoChopper1 = Auto + Chopper + WF_Rel + + +consts + acc :: "(('a,'b)auto * 'a list * 'b * 'a list list * 'a list * 'a list) + => 'a list list * 'a list" +recdef acc "inv_image (less_than ** less_than) + (%(A,ys,s,xss,zs,xs). (length xs + length ys + length zs, + length ys))" +simpset "simpset() addsimps (less_add_Suc2::add_ac) addsplits [expand_if]" +"acc(A,[],s,xss,zs,[]) = (xss, zs)" +"acc(A,[],s,xss,zs,x#xs) = acc(A,zs,start A, xss @ [x#xs],[],[])" +"acc(A,y#ys,s,xss,zs,xs) = + (let s' = next A s y; + zs' = (if fin A s' then [] else zs@[y]); + xs' = (if fin A s' then xs@zs@[y] else xs) + in acc(A,ys,s',xss,zs',xs'))" + +end diff -r ba267836dd7a -r 2ce2e659c2b1 src/HOL/Lex/README.html --- a/src/HOL/Lex/README.html Tue Nov 04 20:52:20 1997 +0100 +++ b/src/HOL/Lex/README.html Wed Nov 05 09:08:35 1997 +0100 @@ -30,9 +30,16 @@ [ab,ab] and the suffix aab.
-The auto_chopper is implemented in theory AutoChopper. The top part of the -diagram, i.e. the translation of regular expressions into deterministic -finite automata is still missing.
+The auto_chopper is implemented in theory AutoChopper. An alternative (more +efficient) version is defined in AutoChopper1. However, no properties have +been proved for it yet. +The top part of the diagram, i.e. the translation of regular expressions into +deterministic finite automata is still missing (although we have some bits +and pieces). +
+ +The directory also contains Regset_of_auto, a theory describing the +translation of deterministic automata into regular sets.