Package net.automatalib.alphabet
Interface VPAlphabet<I>
-
- Type Parameters:
I- input alphabet type
- All Superinterfaces:
Alphabet<I>,ArrayWritable<I>,Collection<I>,Comparator<I>,IntFunction<I>,Iterable<I>,ToIntFunction<I>
- All Known Subinterfaces:
ProceduralInputAlphabet<I>
public interface VPAlphabet<I> extends Alphabet<I>
Alphabet definition for visible push-down automata. Partitions the overall input alphabet into call-, internal-, and return symbols.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classVPAlphabet.SymbolTypeClassifies an input symbol either as a call symbol, an internal symbol, or a return symbol.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default intcallReturnBalance(Word<I> word)Returns the call-return balance of the given word relative to this alphabet.Alphabet<I>getCallAlphabet()Returns the call symbols ofthisalphabet as a (sub-) alphabet.IgetCallSymbol(int index)TheAlphabet.getSymbol(int)variant for the call alphabet.intgetCallSymbolIndex(I symbol)TheAlphabet.getSymbolIndex(Object)variant for the call alphabet.Alphabet<I>getInternalAlphabet()Returns the internal symbols ofthisalphabet as a (sub-) alphabet.IgetInternalSymbol(int index)TheAlphabet.getSymbol(int)variant for the internal alphabet.intgetInternalSymbolIndex(I symbol)TheAlphabet.getSymbolIndex(Object)variant for the internal alphabet.intgetNumCalls()TheArrayWritable.size()variant for the call alphabet.intgetNumInternals()TheArrayWritable.size()variant for the internal alphabet.intgetNumReturns()TheArrayWritable.size()variant for the return alphabet.Alphabet<I>getReturnAlphabet()Returns the return symbols ofthisalphabet as a (sub-) alphabet.IgetReturnSymbol(int index)TheAlphabet.getSymbol(int)variant for the return alphabet.intgetReturnSymbolIndex(I symbol)TheAlphabet.getSymbolIndex(Object)variant for the return alphabet.VPAlphabet.SymbolTypegetSymbolType(I symbol)Returns thesymbol typeof the given alphabet symbol.default booleanisCallMatched(Word<I> word)Returns whether the given word is call-matched relative tothisalphabet.default booleanisCallSymbol(I symbol)Returns whether the given symbol is a call symbol ofthisalphabet.default booleanisInternalSymbol(I symbol)Returns whether the given symbol is an internal symbol ofthisalphabet.default booleanisReturnMatched(Word<I> word)Returns whether the given word is return-matched relative tothisalphabet.default booleanisReturnSymbol(I symbol)Returns whether the given symbol is a return symbol ofthisalphabet.default booleanisWellMatched(Word<I> word)Returns whether the given word is well-matched relative tothisalphabet.default Word<I>longestWellMatchedPrefix(Word<I> word)Return the longestwell-matched(relative tothisalphabet) prefix of the given word.default Word<I>longestWellMatchedSuffix(Word<I> word)Return the longestwell-matched(relative tothisalphabet) suffix of the given word.-
Methods inherited from interface net.automatalib.alphabet.Alphabet
apply, applyAsInt, compare, containsSymbol, getSymbol, getSymbolIndex, translateFrom, writeToArray
-
Methods inherited from interface net.automatalib.common.smartcollection.ArrayWritable
size
-
Methods inherited from interface java.util.Collection
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, parallelStream, remove, removeAll, removeIf, retainAll, size, spliterator, stream, toArray, toArray
-
Methods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
-
-
-
Method Detail
-
getCallAlphabet
Alphabet<I> getCallAlphabet()
Returns the call symbols ofthisalphabet as a (sub-) alphabet.- Returns:
- the call symbols of
thisalphabet
-
getCallSymbol
I getCallSymbol(int index)
TheAlphabet.getSymbol(int)variant for the call alphabet. Note that the index must be relative to thecall alphabetand not tothisalphabet.- Parameters:
index- the index of the symbol- Returns:
- the call symbol at the given index
- Throws:
IllegalArgumentException- if there is no symbol with this index
-
getCallSymbolIndex
int getCallSymbolIndex(I symbol)
TheAlphabet.getSymbolIndex(Object)variant for the call alphabet. Note that the index is relative to thecall alphabetand not tothisalphabet.- Parameters:
symbol- the symbol whose index should be determined- Returns:
- the index of the given call symbol
- Throws:
IllegalArgumentException- if the provided symbol does not belong to the call alphabet.
-
getNumCalls
int getNumCalls()
TheArrayWritable.size()variant for the call alphabet.- Returns:
- the number of call symbols
-
getInternalAlphabet
Alphabet<I> getInternalAlphabet()
Returns the internal symbols ofthisalphabet as a (sub-) alphabet.- Returns:
- the internal symbols of
thisalphabet
-
getInternalSymbol
I getInternalSymbol(int index)
TheAlphabet.getSymbol(int)variant for the internal alphabet. Note that the index must be relative to theinternal alphabetand not tothisalphabet.- Parameters:
index- the index of the symbol- Returns:
- the internal symbol at the given index
- Throws:
IllegalArgumentException- if there is no symbol with this index
-
getInternalSymbolIndex
int getInternalSymbolIndex(I symbol)
TheAlphabet.getSymbolIndex(Object)variant for the internal alphabet. Note that the index is relative to theinternal alphabetand not tothisalphabet.- Parameters:
symbol- the symbol whose index should be determined- Returns:
- the index of the given internal symbol
- Throws:
IllegalArgumentException- if the provided symbol does not belong to the internal alphabet.
-
getNumInternals
int getNumInternals()
TheArrayWritable.size()variant for the internal alphabet.- Returns:
- the number of internal symbols
-
getReturnAlphabet
Alphabet<I> getReturnAlphabet()
Returns the return symbols ofthisalphabet as a (sub-) alphabet.- Returns:
- the return symbols of
thisalphabet
-
getReturnSymbol
I getReturnSymbol(int index)
TheAlphabet.getSymbol(int)variant for the return alphabet. Note that the index must be relative to thereturn alphabetand not tothisalphabet.- Parameters:
index- the index of the symbol- Returns:
- the return symbol at the given index
- Throws:
IllegalArgumentException- if there is no symbol with this index
-
getReturnSymbolIndex
int getReturnSymbolIndex(I symbol)
TheAlphabet.getSymbolIndex(Object)variant for the return alphabet. Note that the index is relative to thereturn alphabetand not tothisalphabet.- Parameters:
symbol- the symbol whose index should be determined- Returns:
- the index of the given return symbol
- Throws:
IllegalArgumentException- if the provided symbol does not belong to the return alphabet.
-
getNumReturns
int getNumReturns()
TheArrayWritable.size()variant for the return alphabet.- Returns:
- the number of return symbols
-
getSymbolType
VPAlphabet.SymbolType getSymbolType(I symbol)
Returns thesymbol typeof the given alphabet symbol.- Parameters:
symbol- the symbol whose type should be returned- Returns:
- the
symbol typeof the given alphabet symbol. - Throws:
IllegalArgumentException- if the provided symbol does not belong to the alphabet.
-
isCallSymbol
default boolean isCallSymbol(I symbol)
Returns whether the given symbol is a call symbol ofthisalphabet.- Parameters:
symbol- the symbol to analyze- Returns:
trueif the given symbol is a call symbol of this alphabet,falseotherwise- Throws:
IllegalArgumentException- if the provided symbol does not belong to the alphabet.
-
isInternalSymbol
default boolean isInternalSymbol(I symbol)
Returns whether the given symbol is an internal symbol ofthisalphabet.- Parameters:
symbol- the symbol to analyze- Returns:
trueif the given symbol is an internal symbol of this alphabet,falseotherwise- Throws:
IllegalArgumentException- if the provided symbol does not belong to the alphabet.
-
isReturnSymbol
default boolean isReturnSymbol(I symbol)
Returns whether the given symbol is a return symbol ofthisalphabet.- Parameters:
symbol- the symbol to analyze- Returns:
trueif the given symbol is a return symbol of this alphabet,falseotherwise- Throws:
IllegalArgumentException- if the provided symbol does not belong to the alphabet.
-
callReturnBalance
default int callReturnBalance(Word<I> word)
Returns the call-return balance of the given word relative to this alphabet. The call-return balance is positive, if the given word contains more call symbols than return symbols, negative if the given word contains more return symbols than call symbols, and 0 if it contains an equal number of call symbols and return symbols.- Parameters:
word- the word to analyze- Returns:
- the call-return balance
-
isCallMatched
default boolean isCallMatched(Word<I> word)
Returns whether the given word is call-matched relative tothisalphabet. A word is call-matched if every call symbol is at one point succeeded by a matching return symbol and there exist no un-matched call symbols. Note that a call-matched word may still contain un-matched return symbols.- Parameters:
word- the word to analyze- Returns:
trueif the given word is call-matched,falseotherwise
-
isReturnMatched
default boolean isReturnMatched(Word<I> word)
Returns whether the given word is return-matched relative tothisalphabet. A word is return-matched if every return symbol is at one point preceded by a matching call symbol and there exist no un-matched return symbols. Note that a return-matched word may still contain un-matched call symbols.- Parameters:
word- the word to analyze- Returns:
trueif the given word is return-matched,falseotherwise
-
isWellMatched
default boolean isWellMatched(Word<I> word)
Returns whether the given word is well-matched relative tothisalphabet. A word is well-matched if every call symbol is at one point succeeded by a matching return symbol and there exist no un-matched call symbols or return symbols.- Parameters:
word- the word to analyze- Returns:
trueif the given word is well-matched,falseotherwise
-
longestWellMatchedPrefix
default Word<I> longestWellMatchedPrefix(Word<I> word)
Return the longestwell-matched(relative tothisalphabet) prefix of the given word.- Parameters:
word- the word to analyze- Returns:
- the longest well-matched prefix of the given word
-
longestWellMatchedSuffix
default Word<I> longestWellMatchedSuffix(Word<I> word)
Return the longestwell-matched(relative tothisalphabet) suffix of the given word.- Parameters:
word- the word to analyze- Returns:
- the longest well-matched suffix of the given word
-
-