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>
- All Known Implementing Classes:
AbstractVPAlphabet
,DefaultProceduralInputAlphabet
,DefaultVPAlphabet
,GrowingVPAlphabet
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 class
VPAlphabet.SymbolType
Classifies 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 int
callReturnBalance(Word<I> word)
Returns the call-return balance of the given word relative to this alphabet.Alphabet<I>
getCallAlphabet()
Returns the call symbols ofthis
alphabet as a (sub-) alphabet.I
getCallSymbol(int index)
TheAlphabet.getSymbol(int)
variant for the call alphabet.int
getCallSymbolIndex(I symbol)
TheAlphabet.getSymbolIndex(Object)
variant for the call alphabet.Alphabet<I>
getInternalAlphabet()
Returns the internal symbols ofthis
alphabet as a (sub-) alphabet.I
getInternalSymbol(int index)
TheAlphabet.getSymbol(int)
variant for the internal alphabet.int
getInternalSymbolIndex(I symbol)
TheAlphabet.getSymbolIndex(Object)
variant for the internal alphabet.int
getNumCalls()
TheArrayWritable.size()
variant for the call alphabet.int
getNumInternals()
TheArrayWritable.size()
variant for the internal alphabet.int
getNumReturns()
TheArrayWritable.size()
variant for the return alphabet.Alphabet<I>
getReturnAlphabet()
Returns the return symbols ofthis
alphabet as a (sub-) alphabet.I
getReturnSymbol(int index)
TheAlphabet.getSymbol(int)
variant for the return alphabet.int
getReturnSymbolIndex(I symbol)
TheAlphabet.getSymbolIndex(Object)
variant for the return alphabet.VPAlphabet.SymbolType
getSymbolType(I symbol)
Returns thesymbol type
of the given alphabet symbol.default boolean
isCallMatched(Word<I> word)
Returns whether the given word is call-matched relative tothis
alphabet.default boolean
isCallSymbol(I symbol)
Returns whether the given symbol is a call symbol ofthis
alphabet.default boolean
isInternalSymbol(I symbol)
Returns whether the given symbol is an internal symbol ofthis
alphabet.default boolean
isReturnMatched(Word<I> word)
Returns whether the given word is return-matched relative tothis
alphabet.default boolean
isReturnSymbol(I symbol)
Returns whether the given symbol is a return symbol ofthis
alphabet.default boolean
isWellMatched(Word<I> word)
Returns whether the given word is well-matched relative tothis
alphabet.default Word<I>
longestWellMatchedPrefix(Word<I> word)
Return the longestwell-matched
(relative tothis
alphabet) prefix of the given word.default Word<I>
longestWellMatchedSuffix(Word<I> word)
Return the longestwell-matched
(relative tothis
alphabet) 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 ofthis
alphabet as a (sub-) alphabet.- Returns:
- the call symbols of
this
alphabet
-
getCallSymbol
I getCallSymbol(int index)
TheAlphabet.getSymbol(int)
variant for the call alphabet. Note that the index must be relative to thecall alphabet
and not tothis
alphabet.- 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 alphabet
and not tothis
alphabet.- 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 ofthis
alphabet as a (sub-) alphabet.- Returns:
- the internal symbols of
this
alphabet
-
getInternalSymbol
I getInternalSymbol(int index)
TheAlphabet.getSymbol(int)
variant for the internal alphabet. Note that the index must be relative to theinternal alphabet
and not tothis
alphabet.- 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 alphabet
and not tothis
alphabet.- 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 ofthis
alphabet as a (sub-) alphabet.- Returns:
- the return symbols of
this
alphabet
-
getReturnSymbol
I getReturnSymbol(int index)
TheAlphabet.getSymbol(int)
variant for the return alphabet. Note that the index must be relative to thereturn alphabet
and not tothis
alphabet.- 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 alphabet
and not tothis
alphabet.- 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 type
of the given alphabet symbol.- Parameters:
symbol
- the symbol whose type should be returned- Returns:
- the
symbol type
of 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 ofthis
alphabet.- Parameters:
symbol
- the symbol to analyze- Returns:
true
if the given symbol is a call symbol of this alphabet,false
otherwise- 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 ofthis
alphabet.- Parameters:
symbol
- the symbol to analyze- Returns:
true
if the given symbol is an internal symbol of this alphabet,false
otherwise- 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 ofthis
alphabet.- Parameters:
symbol
- the symbol to analyze- Returns:
true
if the given symbol is a return symbol of this alphabet,false
otherwise- 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 tothis
alphabet. 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:
true
if the given word is call-matched,false
otherwise
-
isReturnMatched
default boolean isReturnMatched(Word<I> word)
Returns whether the given word is return-matched relative tothis
alphabet. 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:
true
if the given word is return-matched,false
otherwise
-
isWellMatched
default boolean isWellMatched(Word<I> word)
Returns whether the given word is well-matched relative tothis
alphabet. 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:
true
if the given word is well-matched,false
otherwise
-
longestWellMatchedPrefix
default Word<I> longestWellMatchedPrefix(Word<I> word)
Return the longestwell-matched
(relative tothis
alphabet) 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 tothis
alphabet) suffix of the given word.- Parameters:
word
- the word to analyze- Returns:
- the longest well-matched suffix of the given word
-
-