Package dk.brics.automaton
Class BasicOperations
java.lang.Object
dk.brics.automaton.BasicOperations
Basic automata operations.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddEpsilons(Automaton a, Collection<StatePair> pairs) Adds epsilon transitions to the given automaton.static AutomatonReturns a (deterministic) automaton that accepts the complement of the language of the given automaton.static Automatonconcatenate(Automaton a1, Automaton a2) Returns an automaton that accepts the concatenation of the languages of the given automata.static Automatonconcatenate(List<Automaton> l) Returns an automaton that accepts the concatenation of the languages of the given automata.static voidDeterminizes the given automaton.static StringgetShortestExample(Automaton a, boolean accepted) Returns a shortest accepted/rejected string.static Automatonintersection(Automaton a1, Automaton a2) Returns an automaton that accepts the intersection of the languages of the given automata.static booleanReturns true if the given automaton accepts no strings.static booleanReturns true if the given automaton accepts the empty string and nothing else.static booleanReturns true if the given automaton accepts all strings.static AutomatonReturns a (deterministic) automaton that accepts the intersection of the language ofa1and the complement of the language ofa2.static AutomatonReturns an automaton that accepts the union of the empty string and the language of the given automaton.static AutomatonReturns an automaton that accepts the Kleene star (zero or more concatenated repetitions) of the language of the given automaton.static AutomatonReturns an automaton that acceptsminor more concatenated repetitions of the language of the given automaton.static AutomatonReturns an automaton that accepts betweenminandmax(including both) concatenated repetitions of the language of the given automaton.static booleanReturns true if the given string is accepted by the automaton.static booleanReturns true if the language ofa1is a subset of the language ofa2.static AutomatonReturns an automaton that accepts the union of the languages of the given automata.static Automatonunion(Collection<Automaton> l) Returns an automaton that accepts the union of the languages of the given automata.
-
Method Details
-
concatenate
Returns an automaton that accepts the concatenation of the languages of the given automata.Complexity: linear in number of states.
-
concatenate
Returns an automaton that accepts the concatenation of the languages of the given automata.Complexity: linear in total number of states.
-
optional
Returns an automaton that accepts the union of the empty string and the language of the given automaton.Complexity: linear in number of states.
-
repeat
Returns an automaton that accepts the Kleene star (zero or more concatenated repetitions) of the language of the given automaton. Never modifies the input automaton language.Complexity: linear in number of states.
-
repeat
Returns an automaton that acceptsminor more concatenated repetitions of the language of the given automaton.Complexity: linear in number of states and in
min. -
repeat
Returns an automaton that accepts betweenminandmax(including both) concatenated repetitions of the language of the given automaton.Complexity: linear in number of states and in
minandmax. -
complement
Returns a (deterministic) automaton that accepts the complement of the language of the given automaton.Complexity: linear in number of states (if already deterministic).
-
minus
Returns a (deterministic) automaton that accepts the intersection of the language ofa1and the complement of the language ofa2. As a side-effect, the automata may be determinized, if not already deterministic.Complexity: quadratic in number of states (if already deterministic).
-
intersection
Returns an automaton that accepts the intersection of the languages of the given automata. Never modifies the input automata languages.Complexity: quadratic in number of states.
-
subsetOf
Returns true if the language ofa1is a subset of the language ofa2. As a side-effect,a2is determinized if not already marked as deterministic.Complexity: quadratic in number of states.
-
union
Returns an automaton that accepts the union of the languages of the given automata.Complexity: linear in number of states.
-
union
Returns an automaton that accepts the union of the languages of the given automata.Complexity: linear in number of states.
-
determinize
Determinizes the given automaton.Complexity: exponential in number of states.
-
addEpsilons
Adds epsilon transitions to the given automaton. This method adds extra character interval transitions that are equivalent to the given set of epsilon transitions.- Parameters:
pairs- collection ofStatePairobjects representing pairs of source/destination states where epsilon transitions should be added
-
isEmptyString
Returns true if the given automaton accepts the empty string and nothing else. -
isEmpty
Returns true if the given automaton accepts no strings. -
isTotal
Returns true if the given automaton accepts all strings. -
getShortestExample
Returns a shortest accepted/rejected string. If more than one shortest string is found, the lexicographically first of the shortest strings is returned.- Parameters:
accepted- if true, look for accepted strings; otherwise, look for rejected strings- Returns:
- the string, null if none found
-
run
Returns true if the given string is accepted by the automaton.Complexity: linear in the length of the string.
Note: for full performance, use the
RunAutomatonclass.
-