// // libsemigroups - C++ library for semigroups and monoids // Copyright (C) 2019 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. //
#include"libsemigroups/knuth-bendix.hpp"// for KnuthBendix, KnuthBe...
#include <cstddef> // for size_t #include <string> // for string
#include"libsemigroups/cong-intf.hpp"// for CongruenceInterface #include"libsemigroups/debug.hpp"// for LIBSEMIGROUPS_ASSERT #include"libsemigroups/digraph.hpp"// for ActionDigraph #include"libsemigroups/exception.hpp"// for LIBSEMIGROUPS_EXCEPTION #include"libsemigroups/fpsemi-intf.hpp"// for FpSemigroupInterface #include"libsemigroups/froidure-pin-base.hpp"// for FroidurePinBase #include"libsemigroups/froidure-pin.hpp"// for FroidurePin #include"libsemigroups/kbe.hpp"// for detail::KBE #include"libsemigroups/knuth-bendix.hpp"// for KnuthBendix, KnuthBe... #include"libsemigroups/obvinf.hpp"// for IsObviouslyInfinitePairs #include"libsemigroups/types.hpp"// for word_type
#include"knuth-bendix-impl.hpp"
// Include kbe-impl.hpp after knuth-bendix-impl.hpp since detail::KBE depends on // KnuthBendixImpl. #include"kbe-impl.hpp"
namespace libsemigroups { using froidure_pin_type
= FroidurePin<detail::KBE,
FroidurePinTraits<detail::KBE, fpsemigroup::KnuthBendix>>;
////////////////////////////////////////////////////////////////////////// // KnuthBendix - setters for Settings - public //////////////////////////////////////////////////////////////////////////
KnuthBendix& KnuthBendix::overlap_policy(options::overlap p) {
_impl->set_overlap_policy(p); // the next line must be after _impl->set_overlap_policy
_settings._overlap_policy = p; return *this;
}
////////////////////////////////////////////////////////////////////////// // KnuthBendix - constructors and destructor - public //////////////////////////////////////////////////////////////////////////
void KnuthBendix::init_from(FroidurePinBase& S) { if (S.number_of_generators() != 0) { if (alphabet().empty()) {
set_alphabet(S.number_of_generators());
} // throws if rules contain letters that are not in the alphabet.
add_rules(S);
} // Do not set froidure_pin so we are guaranteed that it // returns a FroidurePin of detail::KBE's.
}
void KnuthBendix::init_from(KnuthBendix const& kb, bool add) { // TODO(later) set confluence if known? Other things? if (!kb.alphabet().empty()) { if (alphabet().empty()) {
set_alphabet(kb.alphabet());
} // throws if rules contain letters that are not in the alphabet. if (add) {
add_rules(kb.active_rules());
}
} // TODO(later) copy other settings
_settings._overlap_policy = kb._settings._overlap_policy;
}
////////////////////////////////////////////////////////////////////////// // FpSemigroupInterface - non-pure virtual methods - public //////////////////////////////////////////////////////////////////////////
KnuthBendix::const_normal_form_iterator
KnuthBendix::cbegin_normal_forms(std::string const& lphbt,
size_t const min,
size_t const max) { using state_type = NormalFormsIteratorTraits::state_type; auto it = const_normal_form_iterator(
state_type(lphbt, ""), gilman_digraph().cbegin_pislo(0, min, max)); if (min == 0 && !contains_empty_string()) {
++it;
} return it;
}
////////////////////////////////////////////////////////////////////////// // KnuthBendix public methods for rules and rewriting //////////////////////////////////////////////////////////////////////////
using const_iterator = FpSemigroupInterface::const_iterator;
////////////////////////////////////////////////////////////////////////// // KnuthBendix - main methods - public //////////////////////////////////////////////////////////////////////////
bool KnuthBendix::validate_identity_impl(std::string const& id) const { if (id.length() > 1) {
LIBSEMIGROUPS_EXCEPTION( "invalid identity, found %d letters, should be 0 or 1 letters",
id.length());
} if (id.length() == 1) {
validate_letter(id[0]); returntrue; // Add rules for the identity
} else { returnfalse; // Don't add rules for the identity
}
}
////////////////////////////////////////////////////////////////////////// // KnuthBendix - main member functions - public //////////////////////////////////////////////////////////////////////////
} // namespace fpsemigroup
namespace congruence { using class_index_type = CongruenceInterface::class_index_type;
//////////////////////////////////////////////////////////////////////////// // KnuthBendix - constructors - public ////////////////////////////////////////////////////////////////////////////
KnuthBendix::KnuthBendix(fpsemigroup::KnuthBendix const& kb)
: KnuthBendix() {
_kb->init_from(kb, false); // false = don't add rules if (!_kb->alphabet().empty()) {
set_number_of_generators(_kb->alphabet().size());
} // TODO(later): // The following lines don't do anything because _kb does not get the // FroidurePin from kb. Could be kb->has_froidure_pin()? // if (_kb->has_froidure_pin()) { // set_parent_froidure_pin(_kb->froidure_pin()); // } for (autoconst& r : kb.active_rules()) {
add_pair(kb.string_to_word(r.first), kb.string_to_word(r.second));
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.