Class BasicOperations
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addEpsilons
(Automaton a, Collection<StatePair> pairs) Adds epsilon transitions to the given automaton.static Automaton
Returns a (deterministic) automaton that accepts the complement of the language of the given automaton.static Automaton
concatenate
(List<Automaton> l) Returns an automaton that accepts the concatenation of the languages of the given automata.static Automaton
concatenate
(Automaton a1, Automaton a2) Returns an automaton that accepts the concatenation of the languages of the given automata.static void
Determinizes the given automaton.static Automaton
intersection
(Automaton a1, Automaton a2) Returns an automaton that accepts the intersection of the languages of the given automata.static boolean
Returns true if the given automaton accepts no strings.static boolean
Returns true if the given automaton accepts the empty string and nothing else.static boolean
Returns true if the given automaton accepts all strings.static Automaton
Returns a (deterministic) automaton that accepts the intersection of the language ofa1
and the complement of the language ofa2
.static Automaton
Returns an automaton that accepts the union of the empty string and the language of the given automaton.static Automaton
Returns an automaton that accepts the Kleene star (zero or more concatenated repetitions) of the language of the given automaton.static Automaton
Returns an automaton that acceptsmin
or more concatenated repetitions of the language of the given automaton.static Automaton
Returns an automaton that accepts betweenmin
andmax
(including both) concatenated repetitions of the language of the given automaton.static boolean
Returns true if the given string is accepted by the automaton.static boolean
sameLanguage
(Automaton a1, Automaton a2) Returns true if these two automata accept exactly the same language.static boolean
Returns true if the language ofa1
is a subset of the language ofa2
.static Automaton
union
(Collection<Automaton> l) Returns an automaton that accepts the union of the languages of the given automata.static Automaton
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 acceptsmin
or 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 betweenmin
andmax
(including both) concatenated repetitions of the language of the given automaton.Complexity: linear in number of states and in
min
andmax
. -
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 ofa1
and 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.
-
sameLanguage
Returns true if these two automata accept exactly the same language. This is a costly computation! Note also that a1 and a2 will be determinized as a side effect. -
subsetOf
Returns true if the language ofa1
is a subset of the language ofa2
. As a side-effect,a2
is 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.Worst case 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 ofStatePair
objects 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. -
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
RunAutomaton
class.
-