Class RegexAutomaton
- java.lang.Object
-
- it.unive.lisa.util.datastructures.automaton.Automaton<RegexAutomaton,it.unive.lisa.util.datastructures.regex.RegularExpression>
-
- it.unive.lisa.analysis.string.tarsis.RegexAutomaton
-
- All Implemented Interfaces:
it.unive.lisa.util.datastructures.automaton.AutomataFactory<RegexAutomaton,it.unive.lisa.util.datastructures.regex.RegularExpression>
public class RegexAutomaton extends it.unive.lisa.util.datastructures.automaton.Automaton<RegexAutomaton,it.unive.lisa.util.datastructures.regex.RegularExpression>
A class that describes an generic automaton(dfa, nfa, epsilon nfa) using an alphabet of strings, extended with a special symbol for statically unknown ones. Transition symbols areRegularExpressions.
-
-
Constructor Summary
Constructors Constructor Description RegexAutomaton(java.util.SortedSet<it.unive.lisa.util.datastructures.automaton.State> states, java.util.SortedSet<it.unive.lisa.util.datastructures.automaton.Transition<it.unive.lisa.util.datastructures.regex.RegularExpression>> transitions)Builds a new automaton with givenstatesandtransitions.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanacceptsTopEventually()Yieldstrueif and only if there is at least one transition in this automaton that recognizes a top string.RegexAutomatoncollapse()Yields a new automaton that is built by collapsingthis, that is, by merging together subsequent states that are never the root of a branch, the destination of a loop, or that have at least one outgoing transition recognizing the top string.
thisis never modified by this method.it.unive.lisa.util.datastructures.regex.RegularExpressionconcat(it.unive.lisa.util.datastructures.regex.RegularExpression first, it.unive.lisa.util.datastructures.regex.RegularExpression second)static RegexAutomatonemptyLang()Builds aRegexAutomatonrecognizing the empty language.RegexAutomatonemptyLanguage()static RegexAutomatonemptyStr()Builds aRegexAutomatonrecognizing the empty string.RegexAutomatonemptyString()it.unive.lisa.util.datastructures.regex.RegularExpressionepsilon()RegexAutomatonexplode()Yields a new automaton that is built by exploding this one, that is, by ensuring that each transition recognizes regular expressions of at most one character (excluding the ones recognizing the top string).RegexAutomatonfrom(java.util.SortedSet<it.unive.lisa.util.datastructures.automaton.State> states, java.util.SortedSet<it.unive.lisa.util.datastructures.automaton.Transition<it.unive.lisa.util.datastructures.regex.RegularExpression>> transitions)RegexAutomatonintersection(RegexAutomaton other)RegexAutomatonreplace(RegexAutomaton toReplace, RegexAutomaton 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).RegexAutomatonsingleString(java.lang.String string)static RegexAutomatonstring(it.unive.lisa.util.datastructures.regex.symbolic.SymbolicString s)Builds aRegexAutomatonrecognizing the given string.static RegexAutomatonstring(java.lang.String string)Builds aRegexAutomatonrecognizing the given string.static RegexAutomatonstrings(java.lang.String... strings)Builds aRegexAutomatonrecognizing the given strings.it.unive.lisa.util.datastructures.regex.RegularExpressionsymbolToRegex(it.unive.lisa.util.datastructures.regex.RegularExpression symbol)static RegexAutomatontopString()Builds aRegexAutomatonrecognizing the top string, that is, with a single transition recognizingTopAtom.RegexAutomatonunknownString()-
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, 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
-
RegexAutomaton
public RegexAutomaton(java.util.SortedSet<it.unive.lisa.util.datastructures.automaton.State> states, java.util.SortedSet<it.unive.lisa.util.datastructures.automaton.Transition<it.unive.lisa.util.datastructures.regex.RegularExpression>> 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
-
-
Method Detail
-
topString
public static RegexAutomaton topString()
Builds aRegexAutomatonrecognizing the top string, that is, with a single transition recognizingTopAtom.- Returns:
- the automaton
-
emptyLang
public static RegexAutomaton emptyLang()
Builds aRegexAutomatonrecognizing the empty language.- Returns:
- the automaton
-
string
public static RegexAutomaton string(java.lang.String string)
Builds aRegexAutomatonrecognizing the given string.- Parameters:
string- the string to recognize- Returns:
- the automaton
-
string
public static RegexAutomaton string(it.unive.lisa.util.datastructures.regex.symbolic.SymbolicString s)
Builds aRegexAutomatonrecognizing the given string.- Parameters:
s- the string to recognize- Returns:
- the automaton
-
emptyStr
public static RegexAutomaton emptyStr()
Builds aRegexAutomatonrecognizing the empty string.- Returns:
- the automaton
-
strings
public static RegexAutomaton strings(java.lang.String... strings)
Builds aRegexAutomatonrecognizing the given strings.- Parameters:
strings- the strings to recognize- Returns:
- the automaton
-
singleString
public RegexAutomaton singleString(java.lang.String string)
-
unknownString
public RegexAutomaton unknownString()
-
emptyLanguage
public RegexAutomaton emptyLanguage()
-
emptyString
public RegexAutomaton emptyString()
-
from
public RegexAutomaton from(java.util.SortedSet<it.unive.lisa.util.datastructures.automaton.State> states, java.util.SortedSet<it.unive.lisa.util.datastructures.automaton.Transition<it.unive.lisa.util.datastructures.regex.RegularExpression>> transitions)
-
epsilon
public it.unive.lisa.util.datastructures.regex.RegularExpression epsilon()
- Specified by:
epsilonin classit.unive.lisa.util.datastructures.automaton.Automaton<RegexAutomaton,it.unive.lisa.util.datastructures.regex.RegularExpression>
-
concat
public it.unive.lisa.util.datastructures.regex.RegularExpression concat(it.unive.lisa.util.datastructures.regex.RegularExpression first, it.unive.lisa.util.datastructures.regex.RegularExpression second)- Specified by:
concatin classit.unive.lisa.util.datastructures.automaton.Automaton<RegexAutomaton,it.unive.lisa.util.datastructures.regex.RegularExpression>
-
symbolToRegex
public it.unive.lisa.util.datastructures.regex.RegularExpression symbolToRegex(it.unive.lisa.util.datastructures.regex.RegularExpression symbol)
- Specified by:
symbolToRegexin classit.unive.lisa.util.datastructures.automaton.Automaton<RegexAutomaton,it.unive.lisa.util.datastructures.regex.RegularExpression>
-
acceptsTopEventually
public boolean acceptsTopEventually()
Yieldstrueif and only if there is at least one transition in this automaton that recognizes a top string.- Returns:
trueif that condition holds
-
explode
public RegexAutomaton explode()
Yields a new automaton that is built by exploding this one, that is, by ensuring that each transition recognizes regular expressions of at most one character (excluding the ones recognizing the top string).
This automaton is never modified by this method.- Returns:
- the exploded automaton
-
intersection
public RegexAutomaton intersection(RegexAutomaton other)
- Overrides:
intersectionin classit.unive.lisa.util.datastructures.automaton.Automaton<RegexAutomaton,it.unive.lisa.util.datastructures.regex.RegularExpression>
-
collapse
public RegexAutomaton collapse()
Yields a new automaton that is built by collapsingthis, that is, by merging together subsequent states that are never the root of a branch, the destination of a loop, or that have at least one outgoing transition recognizing the top string.
thisis never modified by this method.- Returns:
- the collapsed automaton
-
replace
public RegexAutomaton replace(RegexAutomaton toReplace, RegexAutomaton 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.
IftoReplacerecognizes a single string, than this method performs a must-replacement, meaning that the string recognized bytoReplacewill effectively be replaced. Otherwise, occurrences of strings oftoReplaceare not replaced in the resulting automaton: instead, a branching will be introduced to model an or between the original string oftoReplaceand the wholestr.
thisis never modified by this method.- 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
-
-