NAME

Set::FA - Set class for finite automata

SYNOPSIS

use Set::FA;
my $set = Set::FA->new(@evenlist);

DESCRIPTION

This module provides an interface by which sets of different finite automata can be constructed. Normal FA execution, stepwise execution, and acceptance tests can be performed for each FA on a single input. The sets can also be manipulated with standard set operations or manipulated by state or arbitrary identifier.

CONSTRUCTOR

new LIST

Constructs a new Set::FA object. LIST is an optional list of Set::FA::Element object references.

See Set::FA::Element.

SET METHODS

insert [ LIST ]

Adds elements to the set. Adding the same object multiple times will result in a single addition. The actual number of elements inserted is returned.

includes [ LIST ]

Return true if all the objects in list are members of the set. LIST may be empty, in which case true is returned.

members

Return a list of object references for the members of the set.

id SCALAR

Returns a subset of the members of the set that have SCALAR as an id.

size

Return the number of elements in the set.

remove [ LIST ]

Remove objects from the set. Removing the same object more than once, or removing an object absent from the set is not an error. Returns the number of elements that were actually removed.

clear

Empty the set.

clone

Return a clone of the set. All references (except for code references) in the new set point to newly created objects.

as_string

Return a textual Smalltalk-ish representation of the set.

Also available as overloaded operator "".

intersection [ LIST ]

Return a new set containing the intersection of the sets passed as arguments.

Also available as overloaded operator *.

union [ LIST ]

Return a new set containing the union of the sets passed as arguments.

Also available as overloaded operator +.

subset SET

Return true if this set is a subset of SET.

Also available as operator <=.

proper_subset SET

Return true if this set is a proper subset of SET.

Also available as operator <.

superset SET

Return true if this set is a superset of SET.

Also available as operator >=.

proper_superset SET

Return true if this set is a proper superset of SET.

Also available as operator >.

FA METHODS

accept INPUT

Returns a subset containing the member elements that move to an accepting state on the given INPUT. All members of the superset are advanced using INPUT, regardless of whether they accept INPUT.

advance INPUT

Executes all members of the set on INPUT.

final

Returns a subset containing all memebers of the set that are in an accepting state.

in_state STATE

Returns a subset containing all members of the set that are currently in state STATE.

reset

Initializes all members to the start state.

step INPUT

Executes a single step on INPUT, unconsumed output is lost.

EXPORT

None by default.

NOTES

At this time, only Set::FA::Element objects are supported as members. In the future, I plan to add support for FA::Simple objects, as well as nondeterministic FA.

AUTHOR

Mark Rogaski, <mrogaski@cpan.org>

Many thanks to Philip Gwyn for first suggesting the ideas that led to this module, even though I don't think I quite answered his original question ... Leolo++.

SEE ALSO

Set::FA::Element.

For a thorough discussion of finite automata and related topics, I recommend:

Cohen, Daniel I.A., "Introduction to Computer Theory",
John Wiley & Sons, Inc.  1991.  ISBN 0-471-51010-6.