Backtrack searches
Proving finiteness of the language of the automaton.
KnuthBendix.Automata.BacktrackOracle
— Typeabstract type BacktrackOracle end
Each Oracle<:BacktrackOracle
should implement the following methods:
(bto::Oracle)(bts::BacktrackSearch)::Tuple{Bool, Bool}
which may access (read-only!) the internal fields of bts::BacktrackSearch
:
bts.automaton::Automaton
is the explored automaton,bts.history
containsd+1
states (including the initial one) describing the currently explored branch,bts.path
contains the tracing word ofbts.history
(of lengthd
).
return_value(::Oracle, bts::BacktrackSearch)
what should be returned from
the backtrack search
Base.eltype(::Type{<:Oracle}, ::Type{<:BacktrackSearch})
the type of
objects returned by return_value
.
The returned tuple (bcktrk, rtrn)
indicate if the search should switch to the backtrack phase and if the currently visited node should be returned. Note: oracle will not be queried while backtracking so returning is not possible then.
If needed MyOracle<:BacktrackOracle
may provide __reset!(bo::Oracle)
function to reset (e.g. the performance counters) itself to the initial state.
KnuthBendix.Automata.BacktrackSearch
— TypeBacktrackSearch{S, A<:Automaton{S}, O<:BacktrackOracle}
BacktrackSearch(at::Automaton, oracle::Oracle[, initial_st=initial(at)])
Struct for backtrack searches inside automatons.
The backtrack oracle must be provided as oracle<:BacktrackOracle
. For more information see BacktrackOracle
Backtrack search starts from initial_st
and uses oracle
to prune branches.
Given bts::BacktrackSearch
and a word w
one may call
(bts::BacktrackSearch)(w::AbstractWord)
to trace w
through bts.automaton
and start bts
at the resulting state.
Examples
julia> rws = RWS_Example_237_abaB(4)
rewriting system with 8 active rules.
[...]
julia> R = knuthbendix(rws)
reduced, confluent rewriting system with 40 active rules.
[...]
julia> bts = BacktrackSearch(IndexAutomaton(R), IrreducibleWordsOracle());
julia> w = Word([1,2,1])
julia> for u in bts(w)
println(w*u)
end
1·2·1
1·2·1·2
1·2·1·2·1
1·2·1·2·1·2
1·2·1·2·1·2·1
[...]
KnuthBendix.Automata.ConfluenceOracle
— TypeConfluenceOracle <: BacktrackOracle
Oracle for backtrack search to determine the confluence of a rewriting system.
ConfluenceOracle
backtracks on too long paths (or shortcuts). the rules leading to critical pairs are returned.
KnuthBendix.Automata.LoopSearchOracle
— TypeLoopSearchOracle <: BacktrackOracle
Oracle for backtrack search to determine the finiteness of the language of irreducible words w.r.t. a rewriting system.
LoopSearchOracle
backtracks on terminal states only and returns the a state σ
which is contained in a loop witnessing the infiniteness of the language, see infiniteness_certificate
.
As the oracle passes through all irreducible words (in order defined by the depth first search on the corresponding IndexAutomaton
) it can be used to cheaply count those words and their maximal length (i.e. if finite).
After backtrack search those numbers can be read of the internal fields of the oracle (n_visited
and max_depth
).
KnuthBendix.Automata.IrreducibleWordsOracle
— TypeIrreducibleWordsOracle <: BacktrackOracle
Oracle for backtrack search returning the irreducible words w.r.t. a rewriting system.
It is necessary to pass min_length
and max_length
to the constructor to control the length of the returned words.
The oracle backtracks on terminal states and returns the irreducible words.