Class SimpleAutomaton
- java.lang.Object
-
- it.unive.lisa.util.datastructures.automaton.Automaton<SimpleAutomaton,StringSymbol>
-
- it.unive.lisa.analysis.string.fsa.SimpleAutomaton
-
- All Implemented Interfaces:
it.unive.lisa.util.datastructures.automaton.AutomataFactory<SimpleAutomaton,StringSymbol>
public final class SimpleAutomaton extends it.unive.lisa.util.datastructures.automaton.Automaton<SimpleAutomaton,StringSymbol>
A class that describes an generic automaton(dfa, nfa, epsilon nfa) using a standard alphabet of single characters.
-
-
Constructor Summary
Constructors Constructor Description SimpleAutomaton(java.lang.String s)Builds a new automaton that accepts a given string.SimpleAutomaton(java.util.SortedSet<it.unive.lisa.util.datastructures.automaton.State> states, java.util.SortedSet<it.unive.lisa.util.datastructures.automaton.Transition<StringSymbol>> transitions)Builds a new automaton with givenstatesandtransitions.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringSymbolconcat(StringSymbol first, StringSymbol second)SimpleAutomatonemptyLanguage()SimpleAutomatonemptyString()StringSymbolepsilon()SimpleAutomatonfrom(java.util.SortedSet<it.unive.lisa.util.datastructures.automaton.State> states, java.util.SortedSet<it.unive.lisa.util.datastructures.automaton.Transition<StringSymbol>> transitions)SimpleAutomatonreplace(SimpleAutomaton toReplace, SimpleAutomaton str)Yields a new automaton where all occurrences of strings recognized bytoReplaceare replaced with the automatonstr, assuming thattoReplaceis finite (i.e., no loops nor top-transitions).SimpleAutomatonsingleString(java.lang.String string)it.unive.lisa.util.datastructures.regex.RegularExpressionsymbolToRegex(StringSymbol symbol)SimpleAutomatonunknownString()booleanvalidateString(java.lang.String str)Computes all the automaton transitions to validate a given stringstr.-
Methods inherited from class it.unive.lisa.util.datastructures.automaton.Automaton
acceptsEmptyLanguage, addState, addTransition, addTransition, areMutuallyReachable, commonAlphabet, complement, concat, copy, determinize, epsilonClosure, epsilonClosure, equals, extractLongestString, factors, factorsChangingInitialState, getAllPaths, getAllTransitionsConnecting, getAlphabet, getFinalStates, getIngoingTransitionsFrom, getInitialState, getInitialStates, getLanguage, getNextStates, getNextSymbols, getOutgoingTransitionsFrom, getReadableSymbolsFromState, getReadableSymbolsFromStates, getStateFromPair, getStates, getTransitions, hasCycle, hashCode, hasOnlyOnePath, intersection, isContained, isDeterministic, isEqualTo, lenghtOfLongestString, makeAcyclic, maximumPath, minimize, minimumPath, nextStatesNFA, prefix, prettyPrint, recognizesExactlyOneString, removeStates, removeTransitions, removeUnreachableStates, reverse, star, suffix, toRegex, toSingleInitalState, toString, totalize, union, widening
-
-
-
-
Constructor Detail
-
SimpleAutomaton
public SimpleAutomaton(java.util.SortedSet<it.unive.lisa.util.datastructures.automaton.State> states, java.util.SortedSet<it.unive.lisa.util.datastructures.automaton.Transition<StringSymbol>> transitions)Builds a new automaton with givenstatesandtransitions.- Parameters:
states- the set of states of the new automatontransitions- the set of the transitions of the new automaton
-
SimpleAutomaton
public SimpleAutomaton(java.lang.String s)
Builds a new automaton that accepts a given string.- Parameters:
s- the only string accepted by the automaton.
-
-
Method Detail
-
singleString
public SimpleAutomaton singleString(java.lang.String string)
-
unknownString
public SimpleAutomaton unknownString()
-
emptyLanguage
public SimpleAutomaton emptyLanguage()
-
emptyString
public SimpleAutomaton emptyString()
-
from
public SimpleAutomaton from(java.util.SortedSet<it.unive.lisa.util.datastructures.automaton.State> states, java.util.SortedSet<it.unive.lisa.util.datastructures.automaton.Transition<StringSymbol>> transitions)
-
epsilon
public StringSymbol epsilon()
- Specified by:
epsilonin classit.unive.lisa.util.datastructures.automaton.Automaton<SimpleAutomaton,StringSymbol>
-
concat
public StringSymbol concat(StringSymbol first, StringSymbol second)
- Specified by:
concatin classit.unive.lisa.util.datastructures.automaton.Automaton<SimpleAutomaton,StringSymbol>
-
symbolToRegex
public it.unive.lisa.util.datastructures.regex.RegularExpression symbolToRegex(StringSymbol symbol)
- Specified by:
symbolToRegexin classit.unive.lisa.util.datastructures.automaton.Automaton<SimpleAutomaton,StringSymbol>
-
validateString
public boolean validateString(java.lang.String str)
Computes all the automaton transitions to validate a given stringstr.- Parameters:
str- String that has to be checked.- Returns:
- a boolean value that indicates either if
strhas been accepted or not.
-
replace
public SimpleAutomaton replace(SimpleAutomaton toReplace, SimpleAutomaton str) throws it.unive.lisa.util.datastructures.automaton.CyclicAutomatonException
Yields a new automaton where all occurrences of strings recognized bytoReplaceare replaced with the automatonstr, assuming thattoReplaceis finite (i.e., no loops nor top-transitions). The resulting automaton is then collapsed.
- Parameters:
toReplace- the automaton recognizing the strings to replacestr- the automaton that must be used as replacement- Returns:
- the replaced automaton
- Throws:
it.unive.lisa.util.datastructures.automaton.CyclicAutomatonException- iftoReplacecontains loops
-
-