caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Alain Frisch <Alain.Frisch@ens.fr>
To: Yann Regis-Gianas <Yann.Regis-Gianas@inria.fr>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] automata -> regular expression
Date: Tue, 3 Aug 2004 11:25:18 +0200 (MET DST)	[thread overview]
Message-ID: <Pine.SOL.4.44.0408031110150.19989-100000@clipper.ens.fr> (raw)
In-Reply-To: <200408031025.30412.Yann.Regis-Gianas@inria.fr>

On Tue, 3 Aug 2004, Yann Regis-Gianas wrote:

> Le lundi 2 Août 2004 14:58, debarbie@lazarus.lifl.fr a écrit :
> > Hello,
> > [...]
> > Can you help me?
>
> 	Well, there are two popular methods to convert an automaton into a rational
> expression : the Yamada/McNaughton method and the state elimination method.
> The former can be found in every good book about FSMs. The latter is a bit
> more simple : it works on a generalized finite state machine (a fsm whose
> labels are rational expressions), removes the automaton states one by one and
> for each state removal, builds the transitions that denote the sub-language
> of the removed state. A piece of code might be more expressive :-) :

Here is another implementation, with some (naive) heuristics to produce
compact regexps:

http://www.cduce.org/c-bin/viewcvs.cgi/misc/pretty.ml?rev=1.3

The interface is:


(* Decompilation of regular expressions *)

type 'a regexp =
  | Empty
  | Epsilon
  | Seq of 'a regexp * 'a regexp
  | Alt of 'a regexp * 'a regexp
  | Star of 'a regexp
  | Plus of 'a regexp
  | Trans of 'a

module Decompile(H : Hashtbl.S)(S : Set.OrderedType) : sig
  val decompile: (H.key -> (S.t * H.key) list * bool) -> H.key -> S.t regexp
end



H.key: type of nodes
S.t: type of transitions

The first argument is the transition relation (maps a node to the list
of its outgoing transitions + final flag), the second is the initial
state.


-- Alain

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


      reply	other threads:[~2004-08-03  9:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-02 12:58 debarbie
2004-08-03  8:25 ` Yann Regis-Gianas
2004-08-03  9:25   ` Alain Frisch [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.SOL.4.44.0408031110150.19989-100000@clipper.ens.fr \
    --to=alain.frisch@ens.fr \
    --cc=Yann.Regis-Gianas@inria.fr \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).