laser.regularlanguage.fsa
Interface MutableFSAInterface<L extends LabelInterface>

Type Parameters:
L - The type of Label associated with this FSA.
All Superinterfaces:
Annotatable, ArtifactInterface, java.lang.Cloneable, FSAInterface<L>, Persistent, java.io.Serializable, Visualizable
All Known Subinterfaces:
MutableDFAInterface<L>
All Known Implementing Classes:
AbstractMutableFSA, MutableDFA, MutableFSA

public interface MutableFSAInterface<L extends LabelInterface>
extends FSAInterface<L>

This class represents FSAs that are mutable: i.e. their structure can be changed but no computation can be performed on them.

More formally, a mutable FSA is defined as a 9-tuple:

(Q, Σ, P, q0, A, T, source, target, label)

where Σ, A, T, source, and target remain the same as in FSAInterface and the following have been modified:

If the FSA supports label pattern transitions then label is defined to include P otherwise it is defined to exclude P. See supportsLabelPatterns().

A mutable FSA is considered well-formed when Q is non-empty and q0 is defined. A well-formed mutable FSA can generate its corresponding runnable FSA.

Author:
Nathan Jokel (laser-software@cs.umass.edu)
See Also:
FSAInterface, RunnableFSAInterface, laser.alphabetinterface.labelpatterninterface.LabelPatternInterface, FSALabelPatternTransitionInterface

Field Summary
 
Fields inherited from interface laser.util.Persistent
PER_EXTENSION, READ_PERSISTENT_METHOD_NAME
 
Method Summary
 FSAEpsilonTransitionInterface<L> addEpsilonTransition(FSAStateInterface<L> source, FSAStateInterface<L> target, java.lang.Object... args)
          Adds an epsilon (ε) transition to this FSA from the specified source state to the specified target state, and returns a reference to the newly created transition (optional operation).
 boolean addLabel(L label)
          Adds a copy of the specified Label to the Alphabet of this FSA if it was not already present and returns true, otherwise the alphabet remains unchanged and false is returned.
 boolean addLabels(java.util.Set<? extends L> labels)
          Adds a copy of any of the Labels in the specified Set to the Alphabet of this FSA if they were not already present and returns true, otherwise the alphabet remains unchanged and false is returned.
 FSAStateInterface<L> addState(java.lang.Object... args)
          Creates a new state and adds it to this FSA, returning a reference to the new state.
 FSALabelPatternTransitionInterface<L> addTransition(FSAStateInterface<L> source, LabelPatternInterface<L> labelPattern, FSAStateInterface<L> target, java.lang.Object... args)
          Adds a transition to this FSA from the specified source state to the specified target state on the given LabelPattern and returns a reference to the newly created transition (optional operation).
 FSALabelTransitionInterface<L> addTransition(FSAStateInterface<L> source, L label, FSAStateInterface<L> target, java.lang.Object... args)
          Adds a transition to this FSA from the specified source state to the specified target state on the given Label, and returns a reference to the newly created transition.
 java.util.SortedSet<? extends FSALabelTransitionInterface<L>> addTransitions(FSAStateInterface<L> source, java.util.Set<? extends L> labels, FSAStateInterface<L> target, java.lang.Object... args)
          Adds transitions to this FSA from the specified source state to the specified target state on each of the given Labels and returns a Set containing references to the newly created transitions.
 java.util.Map<? extends FSAStateInterface<L>,? extends FSAStateInterface<L>> copy(FSAInterface<L> fsa, boolean setAttributes, boolean setStart, boolean setAccept)
          Copies the given FSA into this FSA.
 void copyFSAAttributes(FSAInterface<L> fsa)
          Copies the attributes of the given FSA into this FSA excluding the alphabet, states, and transitions.
 FSAStateInterface<L> copyState(FSAStateInterface<L> state, boolean setStart, boolean setAccept)
          Copies the given FSA state into this FSA.
 FSATransitionInterface<L> copyTransition(FSATransitionInterface<L> transition, FSAStateInterface<L> sourceState, FSAStateInterface<L> targetState)
          Copies the given FSA transition into this FSA.
 boolean deleteDeadStates()
          Removes any state except the start state from this FSA that is not accepting and can not reach an accepting state by any sequence of transitions, returning true is any states were so removed.
 boolean deleteUnreachableStates()
          Removes any state from this FSA that is not the start state and is not reachable from the start state by any sequence of transitions, returning true if any states were so removed, false otherwise.
 java.util.Set<LabelPatternInterface<L>> getLabelPatterns()
          Returns the set P, the LabelPatterns on transitions in this FSA (optional operation).
 RunnableFSAInterface<L> getRunnableFSA()
          Returns the runnable FSA corresponding to this mutable FSA.
 FSALabelPatternTransitionInterface<L> getTransition(FSAStateInterface<L> source, LabelPatternInterface<L> labelPattern, FSAStateInterface<L> target)
          Returns the transition from the specified source state to the specified target state on a LabelPattern equal to the given LabelPattern if one exists in the FSA, otherwise null is returned (optional operation).
 boolean hasTransitionsOnLabelPatterns()
          Returns true if this FSA has any transitions on LabelPatterns, false otherwise (optional operation).
 FSAStateInterface<L> makeTotal()
          Makes this FSA total if it is not already.
 boolean removeLabel(L label)
          Removes the Label equal to the specified Label from the Alphabet of this FSA.
 boolean removeLabels(java.util.Set<? extends L> labels)
          Removes from the Alphabet of this FSA all of its Labels equal to the Labels that are contained in the specified Set.
 void removeState(FSAStateInterface<L> state)
          Removes the specified state from this FSA.
 void removeTransition(FSATransitionInterface<L> transition)
          Removes the specified transition from this FSA.
 void removeTransitions(java.util.Set<? extends FSATransitionInterface<L>> transitions)
          Removes the specified transitions from this FSA.
 boolean replaceLabelPatternTransitionsWithLabelTransitions()
          Replaces each transition on a LabelPattern in this FSA with the corresponding set of transitions on Labels in this FSA (optional operation).
 void setAlphabet(AlphabetInterface<? extends L> alphabet)
          Sets the Alphabet of this FSA to a copy of the specified Alphabet.
 void setStartState(FSAStateInterface<L> state)
          Sets the start state, q0 of this FSA to the specified state.
 boolean supportsLabelPatterns()
          Returns true if this FSA supports label patterns and false otherwise.
 
Methods inherited from interface laser.regularlanguage.fsa.FSAInterface
checkWellFormed, clone, getAcceptStates, getAlphabet, getDescription, getEpsilonTransition, getFactory, getName, getNonAcceptStates, getStartState, getStates, getStateWithID, getTransition, getTransitions, getTransitions, getTransitionWithID, hasTransitionsOnEpsilon, isDeterministic, isTotal, setDescription, setName, supportsEpsilonTransitions, supportsNondeterminism
 
Methods inherited from interface laser.util.Annotatable
addAnnotation, addAnnotations, copyAnnotations, getAnnotationClasses, getAnnotationClasses, getAnnotationFilters, getAnnotations, getAnnotations, removeAnnotation, removeAnnotations, removeAnnotations, removeAnnotations, setAnnotationFilters
 
Methods inherited from interface laser.util.Persistent
writePersistent, writePersistent
 
Methods inherited from interface laser.util.Visualizable
getVisExtension, visualize, visualize
 

Method Detail

addEpsilonTransition

FSAEpsilonTransitionInterface<L> addEpsilonTransition(FSAStateInterface<L> source,
                                                      FSAStateInterface<L> target,
                                                      java.lang.Object... args)
Adds an epsilon (ε) transition to this FSA from the specified source state to the specified target state, and returns a reference to the newly created transition (optional operation).

More formally, adds a transition t to T such that source(t) = sourcetarget(t) = targetlabel(t) = ε.

NOTES:

If the same source and target state are specified as that of an epsilon (ε) transition that already exists in the FSA, a reference to that transition is returned and the FSA remains unchanged.

If this FSA does not support epsilon (ε) transitions, this method should not be supported. Depending on the implementation, calling this method may cause an UnsupportedOperationException to be thrown.

PRECONDITIONS:

Parameters:
source - The source state of the transition to be added.
target - The target state of the transition to be added.
args - Implementation specific arguments used to create the transition (optional).
Returns:
A reference to the epsilon (ε) transition.
Throws:
java.lang.IllegalArgumentException - if source/target is null or is not a state in this FSA else if invalid arguments are specified by args.
java.lang.UnsupportedOperationException - if this FSA does not support epsilon (ε) transitions.

addLabel

boolean addLabel(L label)
Adds a copy of the specified Label to the Alphabet of this FSA if it was not already present and returns true, otherwise the alphabet remains unchanged and false is returned.

NOTE: No references are maintained between the specified Label and the Label in the Alphabet, thus changing the specified Label has no effect on the Label in the Alphabet and vice versa.

PRECONDITION: The label must be non-null.

Parameters:
label - Label to be added to the Alphabet of this FSA.
Returns:
true if the Alphabet did not already contain the specified Label, false otherwise.
Throws:
java.lang.IllegalArgumentException - the specified Label is null.
See Also:
Set.add(E)

addLabels

boolean addLabels(java.util.Set<? extends L> labels)
Adds a copy of any of the Labels in the specified Set to the Alphabet of this FSA if they were not already present and returns true, otherwise the alphabet remains unchanged and false is returned.

NOTE: No references are maintained between the specified Labels and the Labels in the Alphabet, thus changing any of the specified Labels has no effect on the Labels in the Alphabet and vice versa.

PRECONDITIONS:

Parameters:
labels - Set containing Labels to be added
Returns:
true if any Labels were actually added to the Alphabet, false otherwise.
Throws:
java.lang.IllegalArgumentException - if labels is null or any of its elements is null
See Also:
Set.addAll(java.util.Collection)

addState

FSAStateInterface<L> addState(java.lang.Object... args)
Creates a new state and adds it to this FSA, returning a reference to the new state.

PRECONDITION: The args must be valid.

Parameters:
args - Implementation specific arguments used to create the state (optional).
Returns:
A reference to the newly created state.
Throws:
java.lang.IllegalArgumentException - invalid arguments are specified by args.

addTransition

FSALabelTransitionInterface<L> addTransition(FSAStateInterface<L> source,
                                             L label,
                                             FSAStateInterface<L> target,
                                             java.lang.Object... args)
Adds a transition to this FSA from the specified source state to the specified target state on the given Label, and returns a reference to the newly created transition. More formally, adds a transition t to T such that source(t) = sourcetarget(t) = targetlabel(t) = label. The behavior of this method differs depending on whether the FSA supports nondeterminism or not.

If the FSA does not support nondeterminism, there can only be exactly one transition with a certain source state and Label. In this case, attempting to add a transition with the same source state and Label but a different target state as an existing transition will result in an FSAInterfaceException being thrown. This condition is formally specified as (∃ t'T : source(t') = sourcetarget(t') ≠ targetlabel(t') = label. Instead, the existing transition should first be removed using the removeTransition(laser.regularlanguage.fsa.FSATransitionInterface) method.

By contrast, if the FSA supports nondeterminism, there can be multiple transitions with the same source state and Label but differing target states. In this case, adding such a transition with a different target state is allowed, and the existing transition(s) remain unchanged.

NOTES:

A copy of the Label is used, thus no references are maintained between the specified Label and the Label on the transition, thus modifying the specified Label has no effect on the Label on the transition and vice versa.

If the same source state, Label, and target state are specified as a transition that already exists in the FSA, a reference to that transition is returned and the FSA remains unchanged.

PRECONDITIONS:

Parameters:
source - The source state of the transition to be added.
label - The Label of the transition to be added.
target - The target state of the transition to be added.
args - Implementation specific arguments used to create the transition (optional).
Returns:
A reference to the transition.
Throws:
java.lang.IllegalArgumentException - if source/target is null or is not a state in this FSA, if label is null or is not contained in the alphabet of this FSA, or if invalid arguments are specified by args
java.lang.UnsupportedOperationException - if adding the transition would violate the label function of the FSA
See Also:
FSAInterface.checkWellFormed(), removeTransition(laser.regularlanguage.fsa.FSATransitionInterface)

addTransition

FSALabelPatternTransitionInterface<L> addTransition(FSAStateInterface<L> source,
                                                    LabelPatternInterface<L> labelPattern,
                                                    FSAStateInterface<L> target,
                                                    java.lang.Object... args)
Adds a transition to this FSA from the specified source state to the specified target state on the given LabelPattern and returns a reference to the newly created transition (optional operation). For details see FSALabelPatternTransitionInterface and replaceLabelPatternTransitionsWithLabelTransitions().

This may introduce nondeterminism if a transition exists or is later added to the FSA with the same source state and a different target state on a Label that is matched by the LabelPattern or another LabelPattern that matches a common Label with the specified LabelPattern. Nondeterminism may also be introduced if the Alphabet of the FSA is subsequently changed, thus changing the set of Labels matched by the LabelPattern. If the FSA does not support nondeterminism, this may cause the FSA to be not well-formed.

If the FSA does not support nondeterminism, attempting to add a transition with the same source state and an equal LabelPattern but a different target state as an existing transition will definitely result in nondeterminism, thus an FSAInterfaceException will be thrown. Instead, the existing transition should first be removed using the removeTransition(laser.regularlanguage.fsa.FSATransitionInterface) method.

By contrast, if the FSA supports nondeterminism, there can be multiple transitions with the same source state and an equal LabelPattern but differing target states. In this case, adding such a transition with a different target state is allowed, and the existing transition(s) remain unchanged.

NOTES:

A copy of the LabelPattern is used, thus no references are maintained between the specified LabelPattern and the LabelPattern on the transition, thus modifying the specified LabelPattern has no effect on the LabelPattern on the transition and vice versa.

If the same source state, LabelPattern, and target state are specified as a transition that already exists in the FSA, a reference to that transition is returned and the FSA remains unchanged.

If this FSA does not support transitions on LabelPatterns, calling this method may cause an UnsupportedOperationException to be thrown, depending on the implementation.

PRECONDITIONS:

Parameters:
source - The source state of the transition to be added.
labelPattern - The LabelPattern of the transition to be added.
target - The target state of the transition to be added.
args - Implementation specific arguments used to create the transition (optional).
Returns:
A refernce to the transition.
Throws:
java.lang.IllegalArgumentException - if source/target is null or is not a state in this FSA, if labelPattern is null, or if invalid arguments are specified by args
FSAInterfaceException - if adding the transition would violate some well-formedness condition of this FSA.
java.lang.UnsupportedOperationException - this FSA does not support transitions on LabelPatterns or if adding the transition would violate the label function of the FSA
See Also:
laser.alphabetinterface.labelpatterninterface.LabelPatternInterface, FSAInterface.checkWellFormed(), removeTransition(laser.regularlanguage.fsa.FSATransitionInterface)

addTransitions

java.util.SortedSet<? extends FSALabelTransitionInterface<L>> addTransitions(FSAStateInterface<L> source,
                                                                             java.util.Set<? extends L> labels,
                                                                             FSAStateInterface<L> target,
                                                                             java.lang.Object... args)
Adds transitions to this FSA from the specified source state to the specified target state on each of the given Labels and returns a Set containing references to the newly created transitions. More formally, for each l in labels adds a transition t to T such that source(t) = sourcetarget(t) = targetlabel(t) = l. The behavior of this method differs depending on whether the FSA supports nondeterminism or not.

If the FSA does not support nondeterminism, there can only be exactly one transition with a certain source state and Label. In this case, attempting to add a transition with the same source state and Label but different target state as an existing transition will result in an FSAInterfaceException being thrown. This condition is formally specified as (∃ t'T : source(t') = sourcetarget(t') ≠ targetlabel(t') = l. Instead, the existing transition should first be removed using the removeTransition(laser.regularlanguage.fsa.FSATransitionInterface) method.

By contrast, if the FSA supports nondeterminism, there can be multiple transitions with the same source state and Label but differing target states. In this case, adding such a transition with a different target state is allowed, and the existing transition(s) remain unchanged.

NOTES:

A copy of each Label is used, thus no references are maintained between the specified Labels and the Labels on the transitions, thus modifying any of the specified Labels has no effect on the Labels on the transition and vice versa.

If the same source state, Label, and target state are specified as a transition that already exists in the FSA, a reference to that transition is returned and no new transition on that Label is added.

PRECONDITIONS:

Parameters:
source - The source state of the transitions to be added.
labels - The Labels on the transitions to be added.
target - The target state of the transitions to be added.
args - Implementation specific arguments used to create the transition (optional).
Returns:
A Set containing references to the newly created transitions.
Throws:
java.lang.IllegalArgumentException - if source/target is null or is not a state in this FSA, if labels is null or any element is null or is not contained in the alphabet of this FSA, or if invalid arguments are specified by args
java.lang.UnsupportedOperationException - if adding the transitions would violate the label function of this FSA
See Also:
addTransition(FSAStateInterface, LabelInterface, FSAStateInterface, Object[]), removeTransition(laser.regularlanguage.fsa.FSATransitionInterface)

copy

java.util.Map<? extends FSAStateInterface<L>,? extends FSAStateInterface<L>> copy(FSAInterface<L> fsa,
                                                                                  boolean setAttributes,
                                                                                  boolean setStart,
                                                                                  boolean setAccept)
Copies the given FSA into this FSA.

PRECONDITION:

Parameters:
fsa - The given FSA to be copied from
setAttributes - If the attributes of the given FSA should be copied
setStart - If the given FSA has a start state, then it will become the this FSA's start state
setAccept - If there are any accept states in the given FSA, then they will become accept states in this FSA
Returns:
A Map from each state in the given FSA to its corresponding state in this FSA
Throws:
java.lang.IllegalArgumentException - if the given FSA is null or is not well-formed
java.lang.UnsupportedOperationException - if copying the given FSA requires features that this FSA does not support

copyFSAAttributes

void copyFSAAttributes(FSAInterface<L> fsa)
Copies the attributes of the given FSA into this FSA excluding the alphabet, states, and transitions.

PRECONDITION: The fsa must be non-null.

Parameters:
fsa - The given FSA to be copied from
Throws:
java.lang.IllegalArgumentException - if the given FSA is null

copyState

FSAStateInterface<L> copyState(FSAStateInterface<L> state,
                               boolean setStart,
                               boolean setAccept)
Copies the given FSA state into this FSA.

PRECONDITION: The state must be non-null.

Parameters:
state - The given FSA state to be copied
setStart - If true and the state is the start state of the given FSA then the corresponding state is the start state of this FSA
setAccept - If true and the state is an accept state of the given FSA then the corresponding state is an accept state of this FSA
Returns:
The corresponding FSA state in this FSA
Throws:
java.lang.IllegalArgumentException - if the given state is null

copyTransition

FSATransitionInterface<L> copyTransition(FSATransitionInterface<L> transition,
                                         FSAStateInterface<L> sourceState,
                                         FSAStateInterface<L> targetState)
Copies the given FSA transition into this FSA.

PRECONDITIONS:

Parameters:
transition - The given FSA transition to be copied from
sourceState - The state in this FSA that will be the source
targetState - the state in this FSA that will be the target
Returns:
The corresponding transition in this FSA
Throws:
java.lang.IllegalArgumentException - if the given transition is null or if the source/target state is null or is not in this FSA
FSAInterfaceException - if copying the given transition into this FSA causes well-formedness violations
java.lang.UnsupportedOperationException - if the given transition type is not supported in this FSA or if copying the given transition would violate the label function of this FSA

deleteDeadStates

boolean deleteDeadStates()
Removes any state except the start state from this FSA that is not accepting and can not reach an accepting state by any sequence of transitions, returning true is any states were so removed.

More formally, removes all states qQ such that q ∉ ({q0} ∪ F) ∧ (∄ t1, t2, …, tn : (∀ 1 ≤ in : tiTsource(t1) = qtarget(tn) ∈ F ∧ (∀ 1 ≤ j < n : target(tj) = source(tj + 1)))). This takes into account any transitions in T specified by transitions on LabelPatterns.

NOTE: This does not change the set of input strings that is accepted by this FSA.

Returns:
true if any states were removed by this method, false otherwise.

deleteUnreachableStates

boolean deleteUnreachableStates()
                                throws FSAInterfaceException
Removes any state from this FSA that is not the start state and is not reachable from the start state by any sequence of transitions, returning true if any states were so removed, false otherwise. This does not change the set of input strings that is accepted by this FSA.

More formally, removes all states qQ such that qq0 ∧ (∄ t1, t2, …, tn : (∀ 1 ≤ in : tiTsource(t1) = q0target(tn) = q ∧ (∀ 1 ≤ j < n : target(tj) = source(tj + 1)))). This takes into account any transitions in T specified by transitions on LabelPatterns.

NOTE: This does not change the set of input strings that is accepted by this FSA.

PRECONDITION: This FSA must have a start state.

Returns:
true if any states were removed by this method, false otherwise.
Throws:
FSAInterfaceException - if this FSA does not have a start state

getLabelPatterns

java.util.Set<LabelPatternInterface<L>> getLabelPatterns()
Returns the set P, the LabelPatterns on transitions in this FSA (optional operation).

NOTES:

Modifying the returned set will not affect this FSA.

If this FSA does not support transitions on LabelPatterns, calling this method may cause an UnsupportedOperationException to be thrown, depending on the implementation.

Returns:
The set P, the LabelPatterns on transitions in this FSA.
Throws:
java.lang.UnsupportedOperationException - this FSA does not support transitions on LabelPatterns.

getRunnableFSA

RunnableFSAInterface<L> getRunnableFSA()
                                                              throws FSAInterfaceException
Returns the runnable FSA corresponding to this mutable FSA. This FSA must be well-formed. Any transitions on LabelPatterns are replaced with the corresponding transitions on Labels in the runnable FSA since a runnable FSA can not have transitions on LabelPatterns, but the mutable FSA remains unchanged. The states and transitions in the runnable FSA are reindexed, therefore the ID of a state or transition in the mutable FSA might not equal the ID of its corresponding state or transition in the runnable FSA.

NOTE: No references are maintained between the FSAs, thus modifying the mutable FSA has no effect on the runnable FSA.

PRECONDITION: This fsa must be well-formed.

Returns:
The runnable FSA corresponding to this mutable FSA.
Throws:
FSAInterfaceException - if this FSA is not well-formed.
See Also:
RunnableFSAInterface, FSAInterface.checkWellFormed(), replaceLabelPatternTransitionsWithLabelTransitions()

getTransition

FSALabelPatternTransitionInterface<L> getTransition(FSAStateInterface<L> source,
                                                    LabelPatternInterface<L> labelPattern,
                                                    FSAStateInterface<L> target)
Returns the transition from the specified source state to the specified target state on a LabelPattern equal to the given LabelPattern if one exists in the FSA, otherwise null is returned (optional operation).

If this FSA does not support transitions on LabelPatterns, calling this method may cause an UnsupportedOperationException to be thrown, depending on the implementation.

PRECONDITIONS:

Parameters:
source - The source state.
labelPattern - The LabelPattern of the transition.
target - The target state.
Returns:
The transition if it exists, null otherwise.
Throws:
java.lang.IllegalArgumentException - if source/target is null or is not a part of this FSA, if labelPattern is null or is not valid
java.lang.UnsupportedOperationException - this FSA does not support transitions on LabelPatterns.

hasTransitionsOnLabelPatterns

boolean hasTransitionsOnLabelPatterns()
Returns true if this FSA has any transitions on LabelPatterns, false otherwise (optional operation). More formally, returns true iff (∃ t ∈ T : label(t) ∈ P).

NOTE: This FSA may support transitions on LabelPatterns but not actually contain any transition on a LabelPattern.

If this FSA does not support transitions on LabelPatterns, calling this method may cause an UnsupportedOperationException to be thrown, depending on the implementation.

Returns:
true if this FSA has any transitions on LabelPatterns, false otherwise.
Throws:
java.lang.UnsupportedOperationException - this FSA does not support transitions on LabelPatterns.

makeTotal

FSAStateInterface<L> makeTotal()
Makes this FSA total if it is not already. Making an FSA total does not change the set of input strings that it accepts.

A non-accepting state is added to the FSA and a reference to it is returned. Transitions on Labels are added as necessary from every state in the FSA to target this new state to make the FSA total. Call the added state qtrap. (∀ l ∈ Σ, qQ : (∄ tT : source(t) = qlabel(t) = l) → add a transition t' to T such that source(t') = qlabel(t') = ltarget(t') = qtrap). This takes into account any transitions in T specified by transitions on LabelPatterns.

If this FSA was already total, no state is added, and instead null is returned.

Returns:
A reference to the non-accepting state that was added, or null if no state was added.
See Also:
FSAInterface.isTotal()

removeLabel

boolean removeLabel(L label)
Removes the Label equal to the specified Label from the Alphabet of this FSA. If the Label was present, it is removed and true is returned. If it was not present, the Alphabet remains unchanged and false is returned.

When a Label is removed from the Alphabet of the FSA with this method, all transitions on that Label are likewise removed.

PRECONDITION: The label must be non-null.

Parameters:
label - Label to be removed from the Alphabet of this FSA.
Returns:
true if the Alphabet contained the specified label, false otherwise.
Throws:
java.lang.IllegalArgumentException - the specified label is null.
See Also:
Set.remove(java.lang.Object), removeTransition(laser.regularlanguage.fsa.FSATransitionInterface)

removeLabels

boolean removeLabels(java.util.Set<? extends L> labels)
Removes from the Alphabet of this FSA all of its Labels equal to the Labels that are contained in the specified Set. If any Labels are so removed, true is returned, otherwise false is returned and the Alphabet remains unchanged.

When a Label is removed from the Alphabet of the FSA with this method, all transitions on that Label are likewise removed.

PRECONDITIONS:

Parameters:
labels - Set containing Labels to be removed from the Alphabet of this FSA.
Returns:
true if Labels were actually removed from the Alphabet of this FSA, false otherwise.
Throws:
java.lang.IllegalArgumentException - if labels or any of its elements is null.
See Also:
Set.removeAll(java.util.Collection), removeTransition(laser.regularlanguage.fsa.FSATransitionInterface)

removeState

void removeState(FSAStateInterface<L> state)
Removes the specified state from this FSA. The specified state must be a part of this FSA. If the specified state is the start state, the FSA will not be well formed until another start state has been set. When a state is removed, all transitions whose source or target is that state are also removed.

PRECONDITION: The state must be non-null and a part of this FSA.

Parameters:
state - The state to be removed from this FSA.
Throws:
java.lang.IllegalArgumentException - if state is null or is not part of this FSA.
See Also:
setStartState(laser.regularlanguage.fsa.FSAStateInterface), removeTransition(laser.regularlanguage.fsa.FSATransitionInterface)

removeTransition

void removeTransition(FSATransitionInterface<L> transition)
Removes the specified transition from this FSA.

PRECONDITION: The transition must be non-null and a part of this FSA.

Parameters:
transition - The transition to be removed.
Throws:
java.lang.IllegalArgumentException - if transition is null or is not part of this FSA.

removeTransitions

void removeTransitions(java.util.Set<? extends FSATransitionInterface<L>> transitions)
Removes the specified transitions from this FSA.

PRECONDITIONS:

Parameters:
transitions - The transitions to be removed.
Throws:
java.lang.IllegalArgumentException - if transitions or any of its elements is null or if any of its elements is not a part of this FSA.
See Also:
removeTransition(laser.regularlanguage.fsa.FSATransitionInterface)

replaceLabelPatternTransitionsWithLabelTransitions

boolean replaceLabelPatternTransitionsWithLabelTransitions()
Replaces each transition on a LabelPattern in this FSA with the corresponding set of transitions on Labels in this FSA (optional operation). If any such transitions were so replaced true is returned, otherwise false is returned.

More formally, call the set of all transitions on LabelPatterns in this FSA TP then:

TP' = { t' | ∃ tpTP : (source(t') = source(tp) ∧ target(t') = target(tp) ∧ label(t') ∈ t.getLabelPattern().getMatchingLabels(Σ)) }

Then after this method is called, the set of transitions in this FSA T' will be (T \ TP) ∪ TP'.

If this FSA does not support transitions on LabelPatterns, calling this method may cause an UnsupportedOperationException to be thrown, depending on the implementation.

Returns:
true if any transitions were replaced, false otherwise.
Throws:
java.lang.UnsupportedOperationException - this FSA does not support transitions on LabelPatterns.
See Also:
FSALabelPatternTransitionInterface, removeTransition(laser.regularlanguage.fsa.FSATransitionInterface), addTransitions(FSAStateInterface, Set, FSAStateInterface, Object[])

setAlphabet

void setAlphabet(AlphabetInterface<? extends L> alphabet)
Sets the Alphabet of this FSA to a copy of the specified Alphabet.

NOTES:

No references are maintained between the new Alphabet of the FSA and the specified Alphabet, thus modifying the specified Alphabet does not affect the FSA's Alphabet and vice versa.

If there are any Labels in the current Alphabet that are not equal to Labels contained in the specified Alphabet, all transitions on Labels equal to those labels are removed.

Any transitions on Labels equal to Labels contained in both the current and specified alphabets remain unchanged.

PRECONDITIONS:

Parameters:
alphabet - The specified Alphabet, a copy of which will become the new Alphabet of this FSA.
Throws:
java.lang.IllegalArgumentException - if alphabet or any of its elements is null.

setStartState

void setStartState(FSAStateInterface<L> state)
Sets the start state, q0 of this FSA to the specified state.

NOTE: Since an FSA has exactly one start state, if another state was previously the start state, it is no longer the start state.

PRECONDITION: The state is null or else it is non-null and a part of this FSA.

Parameters:
state - The state that is to be the new start state.
Throws:
java.lang.IllegalArgumentException - if state is non-null and is not part of this FSA.

supportsLabelPatterns

boolean supportsLabelPatterns()
Returns true if this FSA supports label patterns and false otherwise.

Returns:
True if label patterns are supported and false otherwise