Module Fsa


module Fsa: sig .. end
This is documentation for the command line executable "fsa".

author: Jeff Heinz

last updated: July 30, 2006



This page explains how to use the fsa command line executable. Usage of this function allows one to apply a variety of operations and functions to finite state acceptors (FSAs). With this command it is straightforward to take unions and intersections of FSAs, to determinize, minimize, reverse FSAs, to rename the states of an FSA and to query certain properties of FSAs. It is also straightforward to generate words from a FSA, build prefix trees from a finite set of words etc.

Usage



Invocation



Like other OCaML executables, the program is run by typing ./fsa or ocamlrun fsa at the command prompt. If you compiled using ocamlopt then you can just type fsa. Generally it is invoked as follows.

fsa command flags file

Input and Output



The output of the fsa command is always written to standard output. Therefore it is possible to pipe it | to other commands or direct it > to a file. The finite state acceptor that the fsa command operates on is typically identified by a filename. However, if no filename is given, the fsa can be entered from standard input. Use ^D to send the input to the command.

Commands



By itself fsa will not do anything-- the argument command is mandatory. The command arguments recognized by fsa are shown in the list below. The command is illustrated without any flag arguments assuming that file contains an FSA. A brief description is also given.

Equivalence relations for merge



The equivalence relations that are implemented are:

Flags



Finally, in the event you want to appy more than one function to an FSA there are flags available that allow you can use. Of course you can always pipe the command to another fsa command, but a flag requires less typing. These are discussed below.

Following the first argument (the main command) you can optionally list as many of the following flags as you like (separated by spaces): When these are stacked they are applied in left to right order. For example, the command fsa union -rv -m -rn fsa1 fsa1 does the following:

rename(minimize(reverse(union fsa1 fsa2)))

Reading and Writing FSAs



You can secify how you want to write the FSAs by customizing the "fsa_specs" file. When you run fsa it reads the finite state acceptor from the input according to the specifications in this file in the current directory. (If no file is in the directory, it uses default values.)

A FSA consists of three components:

These must be seperated by the FSA delimiter (default "!"). The start states should also be delimited by something (default ","). Similarly, the transitions should be delimited by something (default "\n"; i.e a newline).a The final states are delimited in the same way as the start states.

A transition also consists of three components:

These components should also be separated by a delimiter (default ","). If desired, it is also possible to specify left brace and right brace strings for the various components mentioned above.

As an example, the following is a well-formed acceptor.

    A!

    A,B,2
    B,C,0
    C,E,1
    E,C,0
    C,D,0
    
    !B,C,D   

See the file "examples/Pintupi.fsa" for more info.

Writing DOT files and Drawing



When using the command "to_dot", fsa reads the "dot_specs" file in the current directory to see how you want to the machine to appear. If there is no file named "dot_specs" in the current directory, fsa uses default values. There are only a few customizable options. They are: Note that the Graphviz drawing program allows further customization. For the most part the options above provide enough flexibility for readable graphs. If you want further customization just produce and then edit the dot file directly.