Alphabets
KnuthBendix.Alphabet — TypeAlphabet(letters::AbstractVector[, inversions])An alphabet consists of the symbols of a common type T.
An Alphabet defines a bijection between consecutive integers and its letters, i.e. it can be queried for the index of a letter, or the letter corresponding to a given index.
Example
julia> al = Alphabet([:a, :b, :c])
Alphabet of Symbol
1. a
2. b
3. c
julia> al[2]
:b
julia> al[:c]
3
julia> Alphabet([:a, :A, :b], [2, 1, 0])
Alphabet of Symbol
1. a (inverse of: A)
2. A (inverse of: a)
3. bKnuthBendix.setinverse! — Functionsetinverse!(A::Alphabet{T}, x::T, X::T) where TSet the inversion of x to X (and vice versa).
Example
julia> al = Alphabet([:a, :b, :c])
Alphabet of Symbol
1. a
2. b
3. c
julia> KnuthBendix.setinverse!(al, :a, :c)
Alphabet of Symbol
1. a (inverse of: c)
2. b
3. c (inverse of: a)
julia> KnuthBendix.setinverse!(al, :a, :b)
┌ Warning: a already has an inverse: c; overriding
└ @ KnuthBendix ~/.julia/dev/KnuthBendix/src/alphabets.jl:161
Alphabet of Symbol
1. a (inverse of: b)
2. b (inverse of: a)
3. cKnuthBendix.hasinverse — Functionhasinverse(idx::Integer, A::Alphabet)
hasinverse(letter, A::Alphabet)Check if alphabet A defines the inverse of letter.
Base.inv — Methodinv(idx::Integer, A::Alphabet)
inv(letter::T, A::Alphabet{T}) where TReturn the inverse of a letter letter in the context of alphabet A.
If hasinverse(letter, A) == false a DomainError is thrown.
Base.inv — Methodinv(w::AbstractWord, A::Alphabet)Return the inverse of a word w in the context of alphabet A.