From 62071264c8982fa882db55b1f002056236471f1c Mon Sep 17 00:00:00 2001 From: James Mitchell Date: Mon, 13 Jul 2026 14:15:09 +0100 Subject: [PATCH 1/3] knuth-bendix: update for upstream changes --- src/cong-common.cpp | 243 +++++++++++---------- src/froidure-pin.cpp | 28 +-- src/kbe.cpp | 27 +-- src/knuth-bendix-impl.cpp | 15 +- src/knuth-bendix.cpp | 41 ++-- src/libsemigroups_pybind11/froidure_pin.py | 24 +- src/libsemigroups_pybind11/knuth_bendix.py | 16 +- src/libsemigroups_pybind11/to.py | 24 +- src/to-froidure-pin.cpp | 16 +- src/to-knuth-bendix.cpp | 29 +-- src/to-presentation.cpp | 35 +-- src/to-todd-coxeter.cpp | 16 +- tests/test_to.py | 16 +- 13 files changed, 278 insertions(+), 252 deletions(-) diff --git a/src/cong-common.cpp b/src/cong-common.cpp index 7420166c..590c2206 100644 --- a/src/cong-common.cpp +++ b/src/cong-common.cpp @@ -40,10 +40,10 @@ namespace libsemigroups { namespace py = pybind11; - using LenLexTrie = detail::RewritingSystemTrie; - using LenLexSet = detail::RewritingSystemSet; - using RPOTrie = detail::RewritingSystemTrie; - using RPOSet = detail::RewritingSystemSet; + using LenLexTrie = detail::RewritingSystemTrie; + using LenLexSet = detail::RewritingSystemSet; + using RevRPOTrie = detail::RewritingSystemTrie; + using RevRPOSet = detail::RewritingSystemSet; template using MultiView = detail::MultiView; @@ -54,10 +54,10 @@ namespace libsemigroups { using KnuthBendixWordLenLexTrie = KnuthBendix; using KnuthBendixWordLenLexSet = KnuthBendix; - using KnuthBendixStringRPOTrie = KnuthBendix; - using KnuthBendixStringRPOSet = KnuthBendix; - using KnuthBendixWordRPOTrie = KnuthBendix; - using KnuthBendixWordRPOSet = KnuthBendix; + using KnuthBendixStringRevRPOTrie = KnuthBendix; + using KnuthBendixStringRevRPOSet = KnuthBendix; + using KnuthBendixWordRevRPOTrie = KnuthBendix; + using KnuthBendixWordRevRPOSet = KnuthBendix; //////////////////////////////////////////////////////////////////////// // Implementation helpers @@ -138,9 +138,9 @@ This function default constructs an uninitialised :any:`{name}` instance. DEF_CONSTRUCT_DEFAULT(detail::KnuthBendixImpl, detail::CongruenceCommon); - DEF_CONSTRUCT_DEFAULT(detail::KnuthBendixImpl, + DEF_CONSTRUCT_DEFAULT(detail::KnuthBendixImpl, detail::CongruenceCommon); - DEF_CONSTRUCT_DEFAULT(detail::KnuthBendixImpl, + DEF_CONSTRUCT_DEFAULT(detail::KnuthBendixImpl, detail::CongruenceCommon); DEF_CONSTRUCT_DEFAULT(KnuthBendixStringLenLexTrie, @@ -152,13 +152,14 @@ This function default constructs an uninitialised :any:`{name}` instance. DEF_CONSTRUCT_DEFAULT(KnuthBendixWordLenLexSet, detail::KnuthBendixImpl); - DEF_CONSTRUCT_DEFAULT(KnuthBendixStringRPOTrie, - detail::KnuthBendixImpl); - DEF_CONSTRUCT_DEFAULT(KnuthBendixStringRPOSet, - detail::KnuthBendixImpl); - DEF_CONSTRUCT_DEFAULT(KnuthBendixWordRPOTrie, - detail::KnuthBendixImpl); - DEF_CONSTRUCT_DEFAULT(KnuthBendixWordRPOSet, detail::KnuthBendixImpl); + DEF_CONSTRUCT_DEFAULT(KnuthBendixStringRevRPOTrie, + detail::KnuthBendixImpl); + DEF_CONSTRUCT_DEFAULT(KnuthBendixStringRevRPOSet, + detail::KnuthBendixImpl); + DEF_CONSTRUCT_DEFAULT(KnuthBendixWordRevRPOTrie, + detail::KnuthBendixImpl); + DEF_CONSTRUCT_DEFAULT(KnuthBendixWordRevRPOSet, + detail::KnuthBendixImpl); DEF_CONSTRUCT_DEFAULT(Congruence, detail::CongruenceCommon); DEF_CONSTRUCT_DEFAULT(Congruence, detail::CongruenceCommon); @@ -211,8 +212,10 @@ have been in if it had just been newly default constructed. DEF_INIT_DEFAULT(detail::KnuthBendixImpl, detail::CongruenceCommon); - DEF_INIT_DEFAULT(detail::KnuthBendixImpl, detail::CongruenceCommon); - DEF_INIT_DEFAULT(detail::KnuthBendixImpl, detail::CongruenceCommon); + DEF_INIT_DEFAULT(detail::KnuthBendixImpl, + detail::CongruenceCommon); + DEF_INIT_DEFAULT(detail::KnuthBendixImpl, + detail::CongruenceCommon); DEF_INIT_DEFAULT(KnuthBendixStringLenLexTrie, detail::KnuthBendixImpl); @@ -223,10 +226,14 @@ have been in if it had just been newly default constructed. DEF_INIT_DEFAULT(KnuthBendixWordLenLexSet, detail::KnuthBendixImpl); - DEF_INIT_DEFAULT(KnuthBendixStringRPOTrie, detail::KnuthBendixImpl); - DEF_INIT_DEFAULT(KnuthBendixStringRPOSet, detail::KnuthBendixImpl); - DEF_INIT_DEFAULT(KnuthBendixWordRPOTrie, detail::KnuthBendixImpl); - DEF_INIT_DEFAULT(KnuthBendixWordRPOSet, detail::KnuthBendixImpl); + DEF_INIT_DEFAULT(KnuthBendixStringRevRPOTrie, + detail::KnuthBendixImpl); + DEF_INIT_DEFAULT(KnuthBendixStringRevRPOSet, + detail::KnuthBendixImpl); + DEF_INIT_DEFAULT(KnuthBendixWordRevRPOTrie, + detail::KnuthBendixImpl); + DEF_INIT_DEFAULT(KnuthBendixWordRevRPOSet, + detail::KnuthBendixImpl); DEF_INIT_DEFAULT(Congruence, detail::CongruenceCommon); DEF_INIT_DEFAULT(Congruence, detail::CongruenceCommon); @@ -302,19 +309,19 @@ of kind *knd* over the semigroup or monoid defined by the presentation *p*. DEF_CONSTRUCT_KIND_PRESENTATION(KnuthBendixWordLenLexSet, detail::KnuthBendixImpl); - DEF_CONSTRUCT_KIND_PRESENTATION(detail::KnuthBendixImpl, + DEF_CONSTRUCT_KIND_PRESENTATION(detail::KnuthBendixImpl, detail::CongruenceCommon); - DEF_CONSTRUCT_KIND_PRESENTATION(detail::KnuthBendixImpl, + DEF_CONSTRUCT_KIND_PRESENTATION(detail::KnuthBendixImpl, detail::CongruenceCommon); - DEF_CONSTRUCT_KIND_PRESENTATION(KnuthBendixStringRPOTrie, - detail::KnuthBendixImpl); - DEF_CONSTRUCT_KIND_PRESENTATION(KnuthBendixStringRPOSet, - detail::KnuthBendixImpl); - DEF_CONSTRUCT_KIND_PRESENTATION(KnuthBendixWordRPOTrie, - detail::KnuthBendixImpl); - DEF_CONSTRUCT_KIND_PRESENTATION(KnuthBendixWordRPOSet, - detail::KnuthBendixImpl); + DEF_CONSTRUCT_KIND_PRESENTATION(KnuthBendixStringRevRPOTrie, + detail::KnuthBendixImpl); + DEF_CONSTRUCT_KIND_PRESENTATION(KnuthBendixStringRevRPOSet, + detail::KnuthBendixImpl); + DEF_CONSTRUCT_KIND_PRESENTATION(KnuthBendixWordRevRPOTrie, + detail::KnuthBendixImpl); + DEF_CONSTRUCT_KIND_PRESENTATION(KnuthBendixWordRevRPOSet, + detail::KnuthBendixImpl); DEF_CONSTRUCT_KIND_PRESENTATION(Congruence, detail::CongruenceCommon); @@ -393,19 +400,19 @@ had been newly constructed from *knd* and *p*. DEF_INIT_KIND_PRESENTATION(KnuthBendixWordLenLexSet, detail::KnuthBendixImpl); - DEF_INIT_KIND_PRESENTATION(detail::KnuthBendixImpl, + DEF_INIT_KIND_PRESENTATION(detail::KnuthBendixImpl, detail::CongruenceCommon); - DEF_INIT_KIND_PRESENTATION(detail::KnuthBendixImpl, + DEF_INIT_KIND_PRESENTATION(detail::KnuthBendixImpl, detail::CongruenceCommon); - DEF_INIT_KIND_PRESENTATION(KnuthBendixStringRPOTrie, - detail::KnuthBendixImpl); - DEF_INIT_KIND_PRESENTATION(KnuthBendixStringRPOSet, - detail::KnuthBendixImpl); - DEF_INIT_KIND_PRESENTATION(KnuthBendixWordRPOTrie, - detail::KnuthBendixImpl); - DEF_INIT_KIND_PRESENTATION(KnuthBendixWordRPOSet, - detail::KnuthBendixImpl); + DEF_INIT_KIND_PRESENTATION(KnuthBendixStringRevRPOTrie, + detail::KnuthBendixImpl); + DEF_INIT_KIND_PRESENTATION(KnuthBendixStringRevRPOSet, + detail::KnuthBendixImpl); + DEF_INIT_KIND_PRESENTATION(KnuthBendixWordRevRPOTrie, + detail::KnuthBendixImpl); + DEF_INIT_KIND_PRESENTATION(KnuthBendixWordRevRPOSet, + detail::KnuthBendixImpl); DEF_INIT_KIND_PRESENTATION(Congruence, detail::CongruenceCommon); DEF_INIT_KIND_PRESENTATION(Congruence, detail::CongruenceCommon); @@ -458,13 +465,13 @@ Copy a :any:`{name}` object. DEF_COPY(KnuthBendixWordLenLexTrie, detail::KnuthBendixImpl); DEF_COPY(KnuthBendixWordLenLexSet, detail::KnuthBendixImpl); - DEF_COPY(detail::KnuthBendixImpl, detail::CongruenceCommon); - DEF_COPY(detail::KnuthBendixImpl, detail::CongruenceCommon); + DEF_COPY(detail::KnuthBendixImpl, detail::CongruenceCommon); + DEF_COPY(detail::KnuthBendixImpl, detail::CongruenceCommon); - DEF_COPY(KnuthBendixStringRPOTrie, detail::KnuthBendixImpl); - DEF_COPY(KnuthBendixStringRPOSet, detail::KnuthBendixImpl); - DEF_COPY(KnuthBendixWordRPOTrie, detail::KnuthBendixImpl); - DEF_COPY(KnuthBendixWordRPOSet, detail::KnuthBendixImpl); + DEF_COPY(KnuthBendixStringRevRPOTrie, detail::KnuthBendixImpl); + DEF_COPY(KnuthBendixStringRevRPOSet, detail::KnuthBendixImpl); + DEF_COPY(KnuthBendixWordRevRPOTrie, detail::KnuthBendixImpl); + DEF_COPY(KnuthBendixWordRevRPOSet, detail::KnuthBendixImpl); DEF_COPY(Congruence, detail::CongruenceCommon); DEF_COPY(Congruence, detail::CongruenceCommon); @@ -522,9 +529,9 @@ number of classes in the congruence represented by a :any:`{name}` instance. DEF_NUMBER_OF_CLASSES(detail::KnuthBendixImpl, detail::CongruenceCommon); - DEF_NUMBER_OF_CLASSES(detail::KnuthBendixImpl, + DEF_NUMBER_OF_CLASSES(detail::KnuthBendixImpl, detail::CongruenceCommon); - DEF_NUMBER_OF_CLASSES(detail::KnuthBendixImpl, + DEF_NUMBER_OF_CLASSES(detail::KnuthBendixImpl, detail::CongruenceCommon); DEF_NUMBER_OF_CLASSES(Congruence, detail::CongruenceCommon); @@ -610,19 +617,19 @@ This function adds a generating pair to the congruence represented by a DEF_ADD_GENERATING_PAIR(KnuthBendixWordLenLexSet, detail::KnuthBendixImpl); - DEF_ADD_GENERATING_PAIR(detail::KnuthBendixImpl, + DEF_ADD_GENERATING_PAIR(detail::KnuthBendixImpl, detail::CongruenceCommon); - DEF_ADD_GENERATING_PAIR(detail::KnuthBendixImpl, + DEF_ADD_GENERATING_PAIR(detail::KnuthBendixImpl, detail::CongruenceCommon); - DEF_ADD_GENERATING_PAIR(KnuthBendixStringRPOTrie, - detail::KnuthBendixImpl); - DEF_ADD_GENERATING_PAIR(KnuthBendixStringRPOSet, - detail::KnuthBendixImpl); - DEF_ADD_GENERATING_PAIR(KnuthBendixWordRPOTrie, - detail::KnuthBendixImpl); - DEF_ADD_GENERATING_PAIR(KnuthBendixWordRPOSet, - detail::KnuthBendixImpl); + DEF_ADD_GENERATING_PAIR(KnuthBendixStringRevRPOTrie, + detail::KnuthBendixImpl); + DEF_ADD_GENERATING_PAIR(KnuthBendixStringRevRPOSet, + detail::KnuthBendixImpl); + DEF_ADD_GENERATING_PAIR(KnuthBendixWordRevRPOTrie, + detail::KnuthBendixImpl); + DEF_ADD_GENERATING_PAIR(KnuthBendixWordRevRPOSet, + detail::KnuthBendixImpl); DEF_ADD_GENERATING_PAIR(Congruence, detail::CongruenceCommon); DEF_ADD_GENERATING_PAIR(Congruence, detail::CongruenceCommon); @@ -707,19 +714,19 @@ contained in the congruence, but that this is not currently known. DEF_CURRENTLY_CONTAINS(KnuthBendixWordLenLexSet, detail::KnuthBendixImpl); - DEF_CURRENTLY_CONTAINS(detail::KnuthBendixImpl, + DEF_CURRENTLY_CONTAINS(detail::KnuthBendixImpl, detail::CongruenceCommon); - DEF_CURRENTLY_CONTAINS(detail::KnuthBendixImpl, + DEF_CURRENTLY_CONTAINS(detail::KnuthBendixImpl, detail::CongruenceCommon); - DEF_CURRENTLY_CONTAINS(KnuthBendixStringRPOTrie, - detail::KnuthBendixImpl); - DEF_CURRENTLY_CONTAINS(KnuthBendixStringRPOSet, - detail::KnuthBendixImpl); - DEF_CURRENTLY_CONTAINS(KnuthBendixWordRPOTrie, - detail::KnuthBendixImpl); - DEF_CURRENTLY_CONTAINS(KnuthBendixWordRPOSet, - detail::KnuthBendixImpl); + DEF_CURRENTLY_CONTAINS(KnuthBendixStringRevRPOTrie, + detail::KnuthBendixImpl); + DEF_CURRENTLY_CONTAINS(KnuthBendixStringRevRPOSet, + detail::KnuthBendixImpl); + DEF_CURRENTLY_CONTAINS(KnuthBendixWordRevRPOTrie, + detail::KnuthBendixImpl); + DEF_CURRENTLY_CONTAINS(KnuthBendixWordRevRPOSet, + detail::KnuthBendixImpl); DEF_CURRENTLY_CONTAINS(Congruence, detail::CongruenceCommon); DEF_CURRENTLY_CONTAINS(Congruence, detail::CongruenceCommon); @@ -792,13 +799,14 @@ congruence represented by a :py:class:`{name}` instance. DEF_CONTAINS(KnuthBendixWordLenLexTrie, detail::KnuthBendixImpl); DEF_CONTAINS(KnuthBendixWordLenLexSet, detail::KnuthBendixImpl); - DEF_CONTAINS(detail::KnuthBendixImpl, detail::CongruenceCommon); - DEF_CONTAINS(detail::KnuthBendixImpl, detail::CongruenceCommon); + DEF_CONTAINS(detail::KnuthBendixImpl, detail::CongruenceCommon); + DEF_CONTAINS(detail::KnuthBendixImpl, detail::CongruenceCommon); - DEF_CONTAINS(KnuthBendixStringRPOTrie, detail::KnuthBendixImpl); - DEF_CONTAINS(KnuthBendixStringRPOSet, detail::KnuthBendixImpl); - DEF_CONTAINS(KnuthBendixWordRPOTrie, detail::KnuthBendixImpl); - DEF_CONTAINS(KnuthBendixWordRPOSet, detail::KnuthBendixImpl); + DEF_CONTAINS(KnuthBendixStringRevRPOTrie, + detail::KnuthBendixImpl); + DEF_CONTAINS(KnuthBendixStringRevRPOSet, detail::KnuthBendixImpl); + DEF_CONTAINS(KnuthBendixWordRevRPOTrie, detail::KnuthBendixImpl); + DEF_CONTAINS(KnuthBendixWordRevRPOSet, detail::KnuthBendixImpl); DEF_CONTAINS(Congruence, detail::CongruenceCommon); DEF_CONTAINS(Congruence, detail::CongruenceCommon); @@ -873,13 +881,19 @@ normal form for the input word *w*. DEF_REDUCE_NO_RUN(KnuthBendixWordLenLexSet, detail::KnuthBendixImpl); - DEF_REDUCE_NO_RUN(detail::KnuthBendixImpl, detail::CongruenceCommon); - DEF_REDUCE_NO_RUN(detail::KnuthBendixImpl, detail::CongruenceCommon); + DEF_REDUCE_NO_RUN(detail::KnuthBendixImpl, + detail::CongruenceCommon); + DEF_REDUCE_NO_RUN(detail::KnuthBendixImpl, + detail::CongruenceCommon); - DEF_REDUCE_NO_RUN(KnuthBendixStringRPOTrie, detail::KnuthBendixImpl); - DEF_REDUCE_NO_RUN(KnuthBendixStringRPOSet, detail::KnuthBendixImpl); - DEF_REDUCE_NO_RUN(KnuthBendixWordRPOTrie, detail::KnuthBendixImpl); - DEF_REDUCE_NO_RUN(KnuthBendixWordRPOSet, detail::KnuthBendixImpl); + DEF_REDUCE_NO_RUN(KnuthBendixStringRevRPOTrie, + detail::KnuthBendixImpl); + DEF_REDUCE_NO_RUN(KnuthBendixStringRevRPOSet, + detail::KnuthBendixImpl); + DEF_REDUCE_NO_RUN(KnuthBendixWordRevRPOTrie, + detail::KnuthBendixImpl); + DEF_REDUCE_NO_RUN(KnuthBendixWordRevRPOSet, + detail::KnuthBendixImpl); DEF_REDUCE_NO_RUN(Congruence, detail::CongruenceCommon); DEF_REDUCE_NO_RUN(Congruence, detail::CongruenceCommon); @@ -949,13 +963,13 @@ input word. DEF_REDUCE(KnuthBendixWordLenLexTrie, detail::KnuthBendixImpl); DEF_REDUCE(KnuthBendixWordLenLexSet, detail::KnuthBendixImpl); - DEF_REDUCE(detail::KnuthBendixImpl, detail::CongruenceCommon); - DEF_REDUCE(detail::KnuthBendixImpl, detail::CongruenceCommon); + DEF_REDUCE(detail::KnuthBendixImpl, detail::CongruenceCommon); + DEF_REDUCE(detail::KnuthBendixImpl, detail::CongruenceCommon); - DEF_REDUCE(KnuthBendixStringRPOTrie, detail::KnuthBendixImpl); - DEF_REDUCE(KnuthBendixStringRPOSet, detail::KnuthBendixImpl); - DEF_REDUCE(KnuthBendixWordRPOTrie, detail::KnuthBendixImpl); - DEF_REDUCE(KnuthBendixWordRPOSet, detail::KnuthBendixImpl); + DEF_REDUCE(KnuthBendixStringRevRPOTrie, detail::KnuthBendixImpl); + DEF_REDUCE(KnuthBendixStringRevRPOSet, detail::KnuthBendixImpl); + DEF_REDUCE(KnuthBendixWordRevRPOTrie, detail::KnuthBendixImpl); + DEF_REDUCE(KnuthBendixWordRevRPOSet, detail::KnuthBendixImpl); DEF_REDUCE(Congruence, detail::CongruenceCommon); DEF_REDUCE(Congruence, detail::CongruenceCommon); @@ -1015,13 +1029,14 @@ This function returns the generating pairs of the congruence as added via DEF_GENERATING_PAIRS(KnuthBendixWordLenLexSet, detail::KnuthBendixImpl); - DEF_GENERATING_PAIRS(KnuthBendixStringRPOTrie, - detail::KnuthBendixImpl); - DEF_GENERATING_PAIRS(KnuthBendixStringRPOSet, - detail::KnuthBendixImpl); - DEF_GENERATING_PAIRS(KnuthBendixWordRPOTrie, - detail::KnuthBendixImpl); - DEF_GENERATING_PAIRS(KnuthBendixWordRPOSet, detail::KnuthBendixImpl); + DEF_GENERATING_PAIRS(KnuthBendixStringRevRPOTrie, + detail::KnuthBendixImpl); + DEF_GENERATING_PAIRS(KnuthBendixStringRevRPOSet, + detail::KnuthBendixImpl); + DEF_GENERATING_PAIRS(KnuthBendixWordRevRPOTrie, + detail::KnuthBendixImpl); + DEF_GENERATING_PAIRS(KnuthBendixWordRevRPOSet, + detail::KnuthBendixImpl); DEF_GENERATING_PAIRS(Congruence, detail::CongruenceCommon); DEF_GENERATING_PAIRS(Congruence, detail::CongruenceCommon); @@ -1082,10 +1097,14 @@ presentation, then this presentation is returned by this function. DEF_PRESENTATION(KnuthBendixWordLenLexSet, detail::KnuthBendixImpl); - DEF_PRESENTATION(KnuthBendixStringRPOTrie, detail::KnuthBendixImpl); - DEF_PRESENTATION(KnuthBendixStringRPOSet, detail::KnuthBendixImpl); - DEF_PRESENTATION(KnuthBendixWordRPOTrie, detail::KnuthBendixImpl); - DEF_PRESENTATION(KnuthBendixWordRPOSet, detail::KnuthBendixImpl); + DEF_PRESENTATION(KnuthBendixStringRevRPOTrie, + detail::KnuthBendixImpl); + DEF_PRESENTATION(KnuthBendixStringRevRPOSet, + detail::KnuthBendixImpl); + DEF_PRESENTATION(KnuthBendixWordRevRPOTrie, + detail::KnuthBendixImpl); + DEF_PRESENTATION(KnuthBendixWordRevRPOSet, + detail::KnuthBendixImpl); DEF_PRESENTATION(Congruence, detail::CongruenceCommon); DEF_PRESENTATION(Congruence, detail::CongruenceCommon); @@ -1155,10 +1174,10 @@ triggers a full enumeration of *{var}*. DEF_PARTITION(KnuthBendixWordLenLexTrie); DEF_PARTITION(KnuthBendixWordLenLexSet); - DEF_PARTITION(KnuthBendixStringRPOTrie); - DEF_PARTITION(KnuthBendixStringRPOSet); - DEF_PARTITION(KnuthBendixWordRPOTrie); - DEF_PARTITION(KnuthBendixWordRPOSet); + DEF_PARTITION(KnuthBendixStringRevRPOTrie); + DEF_PARTITION(KnuthBendixStringRevRPOSet); + DEF_PARTITION(KnuthBendixWordRevRPOTrie); + DEF_PARTITION(KnuthBendixWordRevRPOSet); DEF_PARTITION(Congruence); DEF_PARTITION(Congruence); @@ -1227,10 +1246,10 @@ instance *{var}*. DEF_NON_TRIVIAL_CLASSES(KnuthBendixWordLenLexTrie); DEF_NON_TRIVIAL_CLASSES(KnuthBendixWordLenLexSet); - DEF_NON_TRIVIAL_CLASSES(KnuthBendixStringRPOTrie); - DEF_NON_TRIVIAL_CLASSES(KnuthBendixStringRPOSet); - DEF_NON_TRIVIAL_CLASSES(KnuthBendixWordRPOTrie); - DEF_NON_TRIVIAL_CLASSES(KnuthBendixWordRPOSet); + DEF_NON_TRIVIAL_CLASSES(KnuthBendixStringRevRPOTrie); + DEF_NON_TRIVIAL_CLASSES(KnuthBendixStringRevRPOSet); + DEF_NON_TRIVIAL_CLASSES(KnuthBendixWordRevRPOTrie); + DEF_NON_TRIVIAL_CLASSES(KnuthBendixWordRevRPOSet); DEF_NON_TRIVIAL_CLASSES(Congruence); DEF_NON_TRIVIAL_CLASSES(Congruence); @@ -1295,10 +1314,10 @@ the congruence represented by an instance of :any:`{name}`. DEF_NORMAL_FORMS(KnuthBendixWordLenLexTrie); DEF_NORMAL_FORMS(KnuthBendixWordLenLexSet); - DEF_NORMAL_FORMS(KnuthBendixStringRPOTrie); - DEF_NORMAL_FORMS(KnuthBendixStringRPOSet); - DEF_NORMAL_FORMS(KnuthBendixWordRPOTrie); - DEF_NORMAL_FORMS(KnuthBendixWordRPOSet); + DEF_NORMAL_FORMS(KnuthBendixStringRevRPOTrie); + DEF_NORMAL_FORMS(KnuthBendixStringRevRPOSet); + DEF_NORMAL_FORMS(KnuthBendixWordRevRPOTrie); + DEF_NORMAL_FORMS(KnuthBendixWordRevRPOSet); // TODO(1) uncomment when implemented in libsemigroups // DEF_NORMAL_FORMS(Congruence); diff --git a/src/froidure-pin.cpp b/src/froidure-pin.cpp index 47122eb3..c521eb5c 100644 --- a/src/froidure-pin.cpp +++ b/src/froidure-pin.cpp @@ -1269,13 +1269,13 @@ This function returns the element of *fp* obtained by evaluating *w*. }); } } // bind_froidure_pin_stateful - } // namespace + } // namespace void init_froidure_pin(py::module& m) { - using LenLexTrie = detail::RewritingSystemTrie; - using LenLexSet = detail::RewritingSystemSet; - using RPOTrie = detail::RewritingSystemTrie; - using RPOSet = detail::RewritingSystemSet; + using LenLexTrie = detail::RewritingSystemTrie; + using LenLexSet = detail::RewritingSystemSet; + using RevRPOTrie = detail::RewritingSystemTrie; + using RevRPOSet = detail::RewritingSystemSet; bind_froidure_pin_stateless>(m, "Transf1"); bind_froidure_pin_stateless>(m, "Transf2"); @@ -1316,14 +1316,16 @@ This function returns the element of *fp* obtained by evaluating *w*. bind_froidure_pin_stateful>>( m, "KBEWordLenLexTrie"); - bind_froidure_pin_stateful>>( - m, "KBEStringRPOSet"); - bind_froidure_pin_stateful>>( - m, "KBEStringRPOTrie"); - bind_froidure_pin_stateful>>( - m, "KBEWordRPOSet"); - bind_froidure_pin_stateful>>( - m, "KBEWordRPOTrie"); + bind_froidure_pin_stateful< + detail::KBE>>(m, + "KBEStringRevRPOSet"); + bind_froidure_pin_stateful< + detail::KBE>>( + m, "KBEStringRevRPOTrie"); + bind_froidure_pin_stateful>>( + m, "KBEWordRevRPOSet"); + bind_froidure_pin_stateful>>( + m, "KBEWordRevRPOTrie"); bind_froidure_pin_stateful>(m, "KEString"); bind_froidure_pin_stateful>>( diff --git a/src/kbe.cpp b/src/kbe.cpp index 96db52e6..19065bbb 100644 --- a/src/kbe.cpp +++ b/src/kbe.cpp @@ -73,10 +73,10 @@ namespace libsemigroups { } void init_kbe(py::module& m) { - using LenLexTrie = detail::RewritingSystemTrie; - using LenLexSet = detail::RewritingSystemSet; - using RPOTrie = detail::RewritingSystemTrie; - using RPOSet = detail::RewritingSystemSet; + using LenLexTrie = detail::RewritingSystemTrie; + using LenLexSet = detail::RewritingSystemSet; + using RevRPOTrie = detail::RewritingSystemTrie; + using RevRPOSet = detail::RewritingSystemSet; // LenLex using KBEStringLenLexTrie @@ -91,14 +91,15 @@ namespace libsemigroups { bind_kbe(m, "KBEWordLenLexSet"); // RPO - using KBEStringRPOTrie = detail::KBE>; - using KBEWordRPOTrie = detail::KBE>; - using KBEStringRPOSet = detail::KBE>; - using KBEWordRPOSet = detail::KBE>; - - bind_kbe(m, "KBEStringRPOTrie"); - bind_kbe(m, "KBEWordRPOTrie"); - bind_kbe(m, "KBEStringRPOSet"); - bind_kbe(m, "KBEWordRPOSet"); + using KBEStringRevRPOTrie + = detail::KBE>; + using KBEWordRevRPOTrie = detail::KBE>; + using KBEStringRevRPOSet = detail::KBE>; + using KBEWordRevRPOSet = detail::KBE>; + + bind_kbe(m, "KBEStringRevRPOTrie"); + bind_kbe(m, "KBEWordRevRPOTrie"); + bind_kbe(m, "KBEStringRevRPOSet"); + bind_kbe(m, "KBEWordRevRPOSet"); } } // namespace libsemigroups diff --git a/src/knuth-bendix-impl.cpp b/src/knuth-bendix-impl.cpp index f93bcf04..c4a04b8a 100644 --- a/src/knuth-bendix-impl.cpp +++ b/src/knuth-bendix-impl.cpp @@ -16,7 +16,6 @@ // // TODO(1) this file is not organised like any other: -// * kb should be called thing // * we don't chain the "def"s in the other files (easier to wrangle) // C std headers.... @@ -507,17 +506,19 @@ infinite; ``False`` is returned if it is not. } // namespace detail void init_detail_knuth_bendix_impl(py::module& m) { - using LenLexTrie = detail::RewritingSystemTrie; - using LenLexSet = detail::RewritingSystemSet; - using RPOTrie = detail::RewritingSystemTrie; - using RPOSet = detail::RewritingSystemSet; + using LenLexTrie = detail::RewritingSystemTrie; + using LenLexSet = detail::RewritingSystemSet; + using RevRPOTrie = detail::RewritingSystemTrie; + using RevRPOSet = detail::RewritingSystemSet; detail::bind_detail_knuth_bendix_impl( m, "KnuthBendixImplLenLexSet"); detail::bind_detail_knuth_bendix_impl( m, "KnuthBendixImplLenLexTrie"); - detail::bind_detail_knuth_bendix_impl(m, "KnuthBendixImplRPOSet"); - detail::bind_detail_knuth_bendix_impl(m, "KnuthBendixImplRPOTrie"); + detail::bind_detail_knuth_bendix_impl( + m, "KnuthBendixImplRevRPOSet"); + detail::bind_detail_knuth_bendix_impl( + m, "KnuthBendixImplRevRPOTrie"); } } // namespace libsemigroups diff --git a/src/knuth-bendix.cpp b/src/knuth-bendix.cpp index b4921330..57b4eb38 100644 --- a/src/knuth-bendix.cpp +++ b/src/knuth-bendix.cpp @@ -331,10 +331,8 @@ Check if all rules are reduced with respect to each other. template void bind_normal_form_range(py::module& m, char const* name) { - using NormalFormRange = detail::KnuthBendixNormalFormRange< - Word, - Rewriter, - typename Rewriter::reduction_order>; + using NormalFormRange + = detail::KnuthBendixNormalFormRange; py::class_ thing(m, name); thing.def("__repr__", [](NormalFormRange const& nfr) { @@ -390,7 +388,7 @@ Copy a :any:`NormalFormRange` object. }); thing.def("next", [](NormalFormRange& nfr) { nfr.next(); }); } // bind_normal_form_range - } // namespace + } // namespace template void bind_redundant_rule(py::module& m) { @@ -451,10 +449,10 @@ redundant in this way, then ``None`` is returned. } void init_knuth_bendix(py::module& m) { - using LenLexTrie = detail::RewritingSystemTrie; - using LenLexSet = detail::RewritingSystemSet; - using RPOTrie = detail::RewritingSystemTrie; - using RPOSet = detail::RewritingSystemSet; + using LenLexTrie = detail::RewritingSystemTrie; + using LenLexSet = detail::RewritingSystemSet; + using RevRPOTrie = detail::RewritingSystemTrie; + using RevRPOSet = detail::RewritingSystemSet; bind_knuth_bendix(m, "KnuthBendixWordLenLexTrie"); bind_knuth_bendix(m, "KnuthBendixWordLenLexSet"); @@ -462,10 +460,11 @@ redundant in this way, then ``None`` is returned. "KnuthBendixStringLenLexTrie"); bind_knuth_bendix(m, "KnuthBendixStringLenLexSet"); - bind_knuth_bendix(m, "KnuthBendixWordRPOTrie"); - bind_knuth_bendix(m, "KnuthBendixWordRPOSet"); - bind_knuth_bendix(m, "KnuthBendixStringRPOTrie"); - bind_knuth_bendix(m, "KnuthBendixStringRPOSet"); + bind_knuth_bendix(m, "KnuthBendixWordRevRPOTrie"); + bind_knuth_bendix(m, "KnuthBendixWordRevRPOSet"); + bind_knuth_bendix(m, + "KnuthBendixStringRevRPOTrie"); + bind_knuth_bendix(m, "KnuthBendixStringRevRPOSet"); bind_normal_form_range( m, "KnuthBendixNormalFormRangeWordLenLexTrie"); @@ -476,14 +475,14 @@ redundant in this way, then ``None`` is returned. bind_normal_form_range( m, "KnuthBendixNormalFormRangeStringLenLexSet"); - bind_normal_form_range( - m, "KnuthBendixNormalFormRangeWordRPOTrie"); - bind_normal_form_range( - m, "KnuthBendixNormalFormRangeWordRPOSet"); - bind_normal_form_range( - m, "KnuthBendixNormalFormRangeStringRPOTrie"); - bind_normal_form_range( - m, "KnuthBendixNormalFormRangeStringRPOSet"); + bind_normal_form_range( + m, "KnuthBendixNormalFormRangeWordRevRPOTrie"); + bind_normal_form_range( + m, "KnuthBendixNormalFormRangeWordRevRPOSet"); + bind_normal_form_range( + m, "KnuthBendixNormalFormRangeStringRevRPOTrie"); + bind_normal_form_range( + m, "KnuthBendixNormalFormRangeStringRevRPOSet"); bind_redundant_rule(m); bind_redundant_rule(m); diff --git a/src/libsemigroups_pybind11/froidure_pin.py b/src/libsemigroups_pybind11/froidure_pin.py index d892be0f..baa206e5 100644 --- a/src/libsemigroups_pybind11/froidure_pin.py +++ b/src/libsemigroups_pybind11/froidure_pin.py @@ -28,12 +28,12 @@ FroidurePinIntMat as _FroidurePinIntMat, FroidurePinKBEStringLenLexSet as _FroidurePinKBEStringLenLexSet, FroidurePinKBEStringLenLexTrie as _FroidurePinKBEStringLenLexTrie, - FroidurePinKBEStringRPOSet as _FroidurePinKBEStringRPOSet, - FroidurePinKBEStringRPOTrie as _FroidurePinKBEStringRPOTrie, + FroidurePinKBEStringRevRPOSet as _FroidurePinKBEStringRevRPOSet, + FroidurePinKBEStringRevRPOTrie as _FroidurePinKBEStringRevRPOTrie, FroidurePinKBEWordLenLexSet as _FroidurePinKBEWordLenLexSet, FroidurePinKBEWordLenLexTrie as _FroidurePinKBEWordLenLexTrie, - FroidurePinKBEWordRPOSet as _FroidurePinKBEWordRPOSet, - FroidurePinKBEWordRPOTrie as _FroidurePinKBEWordRPOTrie, + FroidurePinKBEWordRevRPOSet as _FroidurePinKBEWordRevRPOSet, + FroidurePinKBEWordRevRPOTrie as _FroidurePinKBEWordRevRPOTrie, FroidurePinKEMultiViewString as _FroidurePinKEMultiViewString, FroidurePinKEString as _FroidurePinKEString, FroidurePinKEWord as _FroidurePinKEWord, @@ -57,12 +57,12 @@ IntMat as _IntMat, KBEStringLenLexSet as _KBEStringLenLexSet, KBEStringLenLexTrie as _KBEStringLenLexTrie, - KBEStringRPOSet as _KBEStringRPOSet, - KBEStringRPOTrie as _KBEStringRPOTrie, + KBEStringRevRPOSet as _KBEStringRevRPOSet, + KBEStringRevRPOTrie as _KBEStringRevRPOTrie, KBEWordLenLexSet as _KBEWordLenLexSet, KBEWordLenLexTrie as _KBEWordLenLexTrie, - KBEWordRPOSet as _KBEWordRPOSet, - KBEWordRPOTrie as _KBEWordRPOTrie, + KBEWordRevRPOSet as _KBEWordRevRPOSet, + KBEWordRevRPOTrie as _KBEWordRevRPOTrie, MaxPlusMat as _MaxPlusMat, MaxPlusTruncMat as _MaxPlusTruncMat, MinPlusMat as _MinPlusMat, @@ -157,10 +157,10 @@ class FroidurePin(_CxxWrapper): (_KBEStringLenLexSet,): _FroidurePinKBEStringLenLexSet, (_KBEWordLenLexTrie,): _FroidurePinKBEWordLenLexTrie, (_KBEWordLenLexSet,): _FroidurePinKBEWordLenLexSet, - (_KBEStringRPOTrie,): _FroidurePinKBEStringRPOTrie, - (_KBEStringRPOSet,): _FroidurePinKBEStringRPOSet, - (_KBEWordRPOTrie,): _FroidurePinKBEWordRPOTrie, - (_KBEWordRPOSet,): _FroidurePinKBEWordRPOSet, + (_KBEStringRevRPOTrie,): _FroidurePinKBEStringRevRPOTrie, + (_KBEStringRevRPOSet,): _FroidurePinKBEStringRevRPOSet, + (_KBEWordRevRPOTrie,): _FroidurePinKBEWordRevRPOTrie, + (_KBEWordRevRPOSet,): _FroidurePinKBEWordRevRPOSet, } | ( { (_HPCombiPTransf16,): _FroidurePinHPCombiPTransf16, diff --git a/src/libsemigroups_pybind11/knuth_bendix.py b/src/libsemigroups_pybind11/knuth_bendix.py index 856835dc..b187bbba 100644 --- a/src/libsemigroups_pybind11/knuth_bendix.py +++ b/src/libsemigroups_pybind11/knuth_bendix.py @@ -14,12 +14,12 @@ from _libsemigroups_pybind11 import ( KnuthBendixStringLenLexSet as _KnuthBendixStringLenLexSet, KnuthBendixStringLenLexTrie as _KnuthBendixStringLenLexTrie, - KnuthBendixStringRPOSet as _KnuthBendixStringRPOSet, - KnuthBendixStringRPOTrie as _KnuthBendixStringRPOTrie, + KnuthBendixStringRevRPOSet as _KnuthBendixStringRevRPOSet, + KnuthBendixStringRevRPOTrie as _KnuthBendixStringRevRPOTrie, KnuthBendixWordLenLexSet as _KnuthBendixWordLenLexSet, KnuthBendixWordLenLexTrie as _KnuthBendixWordLenLexTrie, - KnuthBendixWordRPOSet as _KnuthBendixWordRPOSet, - KnuthBendixWordRPOTrie as _KnuthBendixWordRPOTrie, + KnuthBendixWordRevRPOSet as _KnuthBendixWordRevRPOSet, + KnuthBendixWordRevRPOTrie as _KnuthBendixWordRevRPOTrie, Order as _Order, knuth_bendix_by_overlap_length as _knuth_bendix_by_overlap_length, knuth_bendix_is_reduced as _knuth_bendix_is_reduced, @@ -54,10 +54,10 @@ class KnuthBendix(_CongruenceCommon): (str, "Trie", _Order.shortlex): _KnuthBendixStringLenLexTrie, (list[int], "Set", _Order.shortlex): _KnuthBendixWordLenLexSet, (str, "Set", _Order.shortlex): _KnuthBendixStringLenLexSet, - (list[int], "Trie", _Order.recursive): _KnuthBendixWordRPOTrie, - (str, "Trie", _Order.recursive): _KnuthBendixStringRPOTrie, - (list[int], "Set", _Order.recursive): _KnuthBendixWordRPOSet, - (str, "Set", _Order.recursive): _KnuthBendixStringRPOSet, + (list[int], "Trie", _Order.recursive): _KnuthBendixWordRevRPOTrie, + (str, "Trie", _Order.recursive): _KnuthBendixStringRevRPOTrie, + (list[int], "Set", _Order.recursive): _KnuthBendixWordRevRPOSet, + (str, "Set", _Order.recursive): _KnuthBendixStringRevRPOSet, } _cxx_type_to_py_template_params = dict( diff --git a/src/libsemigroups_pybind11/to.py b/src/libsemigroups_pybind11/to.py index f195a4c7..82944b28 100644 --- a/src/libsemigroups_pybind11/to.py +++ b/src/libsemigroups_pybind11/to.py @@ -23,16 +23,16 @@ to_knuth_bendix as _to_knuth_bendix, to_knuth_bendix_LenLexSet as _to_knuth_bendix_LenLexSet, to_knuth_bendix_LenLexTrie as _to_knuth_bendix_LenLexTrie, - to_knuth_bendix_RPOSet as _to_knuth_bendix_RPOSet, - to_knuth_bendix_RPOTrie as _to_knuth_bendix_RPOTrie, + to_knuth_bendix_RevRPOSet as _to_knuth_bendix_RevRPOSet, + to_knuth_bendix_RevRPOTrie as _to_knuth_bendix_RevRPOTrie, to_knuth_bendix_string_LenLexSet as _to_knuth_bendix_string_LenLexSet, to_knuth_bendix_string_LenLexTrie as _to_knuth_bendix_string_LenLexTrie, - to_knuth_bendix_string_RPOSet as _to_knuth_bendix_string_RPOSet, - to_knuth_bendix_string_RPOTrie as _to_knuth_bendix_string_RPOTrie, + to_knuth_bendix_string_RevRPOSet as _to_knuth_bendix_string_RevRPOSet, + to_knuth_bendix_string_RevRPOTrie as _to_knuth_bendix_string_RevRPOTrie, to_knuth_bendix_word_LenLexSet as _to_knuth_bendix_word_LenLexSet, to_knuth_bendix_word_LenLexTrie as _to_knuth_bendix_word_LenLexTrie, - to_knuth_bendix_word_RPOSet as _to_knuth_bendix_word_RPOSet, - to_knuth_bendix_word_RPOTrie as _to_knuth_bendix_word_RPOTrie, + to_knuth_bendix_word_RevRPOSet as _to_knuth_bendix_word_RevRPOSet, + to_knuth_bendix_word_RevRPOTrie as _to_knuth_bendix_word_RevRPOTrie, to_presentation as _to_presentation, to_presentation_string as _to_presentation_string, to_presentation_word as _to_presentation_word, @@ -88,12 +88,12 @@ def _nice_name(type_list): (_KnuthBendix, list[int], "Trie", _Order.shortlex): _to_knuth_bendix_word_LenLexTrie, (_KnuthBendix, str, "Set", _Order.shortlex): _to_knuth_bendix_string_LenLexSet, (_KnuthBendix, str, "Trie", _Order.shortlex): _to_knuth_bendix_string_LenLexTrie, - (_KnuthBendix, "Set", _Order.recursive): _to_knuth_bendix_RPOSet, - (_KnuthBendix, "Trie", _Order.recursive): _to_knuth_bendix_RPOTrie, - (_KnuthBendix, list[int], "Set", _Order.recursive): _to_knuth_bendix_word_RPOSet, - (_KnuthBendix, list[int], "Trie", _Order.recursive): _to_knuth_bendix_word_RPOTrie, - (_KnuthBendix, str, "Set", _Order.recursive): _to_knuth_bendix_string_RPOSet, - (_KnuthBendix, str, "Trie", _Order.recursive): _to_knuth_bendix_string_RPOTrie, + (_KnuthBendix, "Set", _Order.recursive): _to_knuth_bendix_RevRPOSet, + (_KnuthBendix, "Trie", _Order.recursive): _to_knuth_bendix_RevRPOTrie, + (_KnuthBendix, list[int], "Set", _Order.recursive): _to_knuth_bendix_word_RevRPOSet, + (_KnuthBendix, list[int], "Trie", _Order.recursive): _to_knuth_bendix_word_RevRPOTrie, + (_KnuthBendix, str, "Set", _Order.recursive): _to_knuth_bendix_string_RevRPOSet, + (_KnuthBendix, str, "Trie", _Order.recursive): _to_knuth_bendix_string_RevRPOTrie, (_Presentation,): _to_presentation, (_Presentation, str): _to_presentation_string, (_Presentation, list[int]): _to_presentation_word, diff --git a/src/to-froidure-pin.cpp b/src/to-froidure-pin.cpp index 4c7f557f..fc5886fb 100644 --- a/src/to-froidure-pin.cpp +++ b/src/to-froidure-pin.cpp @@ -52,10 +52,10 @@ namespace libsemigroups { } // namespace void init_to_froidure_pin(py::module& m) { - using LenLexTrie = detail::RewritingSystemTrie; - using LenLexSet = detail::RewritingSystemSet; - using RPOTrie = detail::RewritingSystemTrie; - using RPOSet = detail::RewritingSystemSet; + using LenLexTrie = detail::RewritingSystemTrie; + using LenLexSet = detail::RewritingSystemSet; + using RevRPOTrie = detail::RewritingSystemTrie; + using RevRPOSet = detail::RewritingSystemSet; // Congruence bind_to_froidure_pin>(m); @@ -72,10 +72,10 @@ namespace libsemigroups { bind_to_froidure_pin>(m); bind_to_froidure_pin>(m); - bind_to_froidure_pin>(m); - bind_to_froidure_pin>(m); - bind_to_froidure_pin>(m); - bind_to_froidure_pin>(m); + bind_to_froidure_pin>(m); + bind_to_froidure_pin>(m); + bind_to_froidure_pin>(m); + bind_to_froidure_pin>(m); // ToddCoxeter bind_to_froidure_pin>(m); diff --git a/src/to-knuth-bendix.cpp b/src/to-knuth-bendix.cpp index 8c420a94..c3ffa79d 100644 --- a/src/to-knuth-bendix.cpp +++ b/src/to-knuth-bendix.cpp @@ -65,10 +65,10 @@ namespace libsemigroups { } // namespace void init_to_knuth_bendix(py::module& m) { - using LenLexTrie = detail::RewritingSystemTrie; - using LenLexSet = detail::RewritingSystemSet; - using RPOTrie = detail::RewritingSystemTrie; - using RPOSet = detail::RewritingSystemSet; + using LenLexTrie = detail::RewritingSystemTrie; + using LenLexSet = detail::RewritingSystemSet; + using RevRPOTrie = detail::RewritingSystemTrie; + using RevRPOSet = detail::RewritingSystemSet; // FroidurePin bind_froidure_pin_to_knuth_bendix( @@ -79,21 +79,24 @@ namespace libsemigroups { "word_LenLexSet"); bind_froidure_pin_to_knuth_bendix(m, "word_LenLexTrie"); - bind_froidure_pin_to_knuth_bendix(m, "string_RPOSet"); - bind_froidure_pin_to_knuth_bendix(m, - "string_RPOTrie"); - bind_froidure_pin_to_knuth_bendix(m, "word_RPOSet"); - bind_froidure_pin_to_knuth_bendix(m, "word_RPOTrie"); + bind_froidure_pin_to_knuth_bendix( + m, "string_RevRPOSet"); + bind_froidure_pin_to_knuth_bendix( + m, "string_RevRPOTrie"); + bind_froidure_pin_to_knuth_bendix(m, + "word_RevRPOSet"); + bind_froidure_pin_to_knuth_bendix(m, + "word_RevRPOTrie"); // ToddCoxeter + rewriter bind_todd_coxeter_to_knuth_bendix(m, "LenLexSet"); bind_todd_coxeter_to_knuth_bendix(m, "LenLexSet"); bind_todd_coxeter_to_knuth_bendix(m, "LenLexTrie"); bind_todd_coxeter_to_knuth_bendix(m, "LenLexTrie"); - bind_todd_coxeter_to_knuth_bendix(m, "RPOSet"); - bind_todd_coxeter_to_knuth_bendix(m, "RPOSet"); - bind_todd_coxeter_to_knuth_bendix(m, "RPOTrie"); - bind_todd_coxeter_to_knuth_bendix(m, "RPOTrie"); + bind_todd_coxeter_to_knuth_bendix(m, "RevRPOSet"); + bind_todd_coxeter_to_knuth_bendix(m, "RevRPOSet"); + bind_todd_coxeter_to_knuth_bendix(m, "RevRPOTrie"); + bind_todd_coxeter_to_knuth_bendix(m, "RevRPOTrie"); // ToddCoxeter bind_todd_coxeter_to_knuth_bendix_default(m); diff --git a/src/to-presentation.cpp b/src/to-presentation.cpp index 3103d439..f7e12189 100644 --- a/src/to-presentation.cpp +++ b/src/to-presentation.cpp @@ -190,10 +190,10 @@ namespace libsemigroups { } // namespace void init_to_present(py::module& m) { - using LenLexTrie = detail::RewritingSystemTrie; - using LenLexSet = detail::RewritingSystemSet; - using RPOTrie = detail::RewritingSystemTrie; - using RPOSet = detail::RewritingSystemSet; + using LenLexTrie = detail::RewritingSystemTrie; + using LenLexSet = detail::RewritingSystemSet; + using RevRPOTrie = detail::RewritingSystemTrie; + using RevRPOSet = detail::RewritingSystemSet; //////////////////////////////////////////////////////////////////////////// // to @@ -227,19 +227,20 @@ namespace libsemigroups { bind_kb_to_pres_with_word(m, "word"); bind_kb_to_pres_with_word(m, "word"); - bind_kb_to_pres(m); - bind_kb_to_pres(m); - bind_kb_to_pres(m); - bind_kb_to_pres(m); - - bind_kb_to_pres_with_word(m, "string"); - bind_kb_to_pres_with_word(m, "string"); - bind_kb_to_pres_with_word(m, "string"); - bind_kb_to_pres_with_word(m, "string"); - bind_kb_to_pres_with_word(m, "word"); - bind_kb_to_pres_with_word(m, "word"); - bind_kb_to_pres_with_word(m, "word"); - bind_kb_to_pres_with_word(m, "word"); + bind_kb_to_pres(m); + bind_kb_to_pres(m); + bind_kb_to_pres(m); + bind_kb_to_pres(m); + + bind_kb_to_pres_with_word(m, "string"); + bind_kb_to_pres_with_word(m, + "string"); + bind_kb_to_pres_with_word(m, "string"); + bind_kb_to_pres_with_word(m, "string"); + bind_kb_to_pres_with_word(m, "word"); + bind_kb_to_pres_with_word(m, "word"); + bind_kb_to_pres_with_word(m, "word"); + bind_kb_to_pres_with_word(m, "word"); // From FroidurePin bind_fp_to_pres(m, "string"); diff --git a/src/to-todd-coxeter.cpp b/src/to-todd-coxeter.cpp index 9ee2a46e..450f3e1e 100644 --- a/src/to-todd-coxeter.cpp +++ b/src/to-todd-coxeter.cpp @@ -51,10 +51,10 @@ namespace libsemigroups { } // namespace void init_to_todd_coxeter(py::module& m) { - using LenLexTrie = detail::RewritingSystemTrie; - using LenLexSet = detail::RewritingSystemSet; - using RPOTrie = detail::RewritingSystemTrie; - using RPOSet = detail::RewritingSystemSet; + using LenLexTrie = detail::RewritingSystemTrie; + using LenLexSet = detail::RewritingSystemSet; + using RevRPOTrie = detail::RewritingSystemTrie; + using RevRPOSet = detail::RewritingSystemSet; // KnuthBendix bind_to_todd_coxeter_kb(m); @@ -62,10 +62,10 @@ namespace libsemigroups { bind_to_todd_coxeter_kb(m); bind_to_todd_coxeter_kb(m); - bind_to_todd_coxeter_kb(m); - bind_to_todd_coxeter_kb(m); - bind_to_todd_coxeter_kb(m); - bind_to_todd_coxeter_kb(m); + bind_to_todd_coxeter_kb(m); + bind_to_todd_coxeter_kb(m); + bind_to_todd_coxeter_kb(m); + bind_to_todd_coxeter_kb(m); // WordGraph m.def("to_todd_coxeter_word", diff --git a/tests/test_to.py b/tests/test_to.py index ba9f1ad1..682020c1 100644 --- a/tests/test_to.py +++ b/tests/test_to.py @@ -15,12 +15,12 @@ from _libsemigroups_pybind11 import ( FroidurePinKBEStringLenLexSet, FroidurePinKBEStringLenLexTrie, - FroidurePinKBEStringRPOSet, - FroidurePinKBEStringRPOTrie, + FroidurePinKBEStringRevRPOSet, + FroidurePinKBEStringRevRPOTrie, FroidurePinKBEWordLenLexSet, FroidurePinKBEWordLenLexTrie, - FroidurePinKBEWordRPOSet, - FroidurePinKBEWordRPOTrie, + FroidurePinKBEWordRevRPOSet, + FroidurePinKBEWordRevRPOTrie, FroidurePinKEMultiViewString, FroidurePinKEString, FroidurePinKEWord, @@ -236,7 +236,7 @@ def test_to_FroidurePin_000(): assert isinstance(to_cxx(fp), FroidurePinKBEStringLenLexSet) fp = check_cong_to_froidure_pin(KnuthBendix, str, rewriting_system="Set", order=Order.recursive) - assert isinstance(to_cxx(fp), FroidurePinKBEStringRPOSet) + assert isinstance(to_cxx(fp), FroidurePinKBEStringRevRPOSet) def test_to_FroidurePin_001(): @@ -246,7 +246,7 @@ def test_to_FroidurePin_001(): fp = check_cong_to_froidure_pin( KnuthBendix, str, rewriting_system="Trie", order=Order.recursive ) - assert isinstance(to_cxx(fp), FroidurePinKBEStringRPOTrie) + assert isinstance(to_cxx(fp), FroidurePinKBEStringRevRPOTrie) def test_to_FroidurePin_002(): @@ -254,7 +254,7 @@ def test_to_FroidurePin_002(): assert isinstance(to_cxx(fp), FroidurePinKBEWordLenLexSet) fp = check_cong_to_froidure_pin(KnuthBendix, int, rewriting_system="Set", order=Order.recursive) - assert isinstance(to_cxx(fp), FroidurePinKBEWordRPOSet) + assert isinstance(to_cxx(fp), FroidurePinKBEWordRevRPOSet) def test_to_FroidurePin_003(): @@ -264,7 +264,7 @@ def test_to_FroidurePin_003(): fp = check_cong_to_froidure_pin( KnuthBendix, int, rewriting_system="Trie", order=Order.recursive ) - assert isinstance(to_cxx(fp), FroidurePinKBEWordRPOTrie) + assert isinstance(to_cxx(fp), FroidurePinKBEWordRevRPOTrie) # From ToddCoxeter From 45f78f597b148255c4d3dbe56acac7e5315f4c05 Mon Sep 17 00:00:00 2001 From: Codex OpenAI Date: Mon, 13 Jul 2026 14:37:18 +0100 Subject: [PATCH 2/3] order: add support for Alphabet --- src/froidure-pin.cpp | 2 +- src/knuth-bendix.cpp | 2 +- src/libsemigroups_pybind11/__init__.py | 15 ++ src/main.cpp | 4 +- src/order.cpp | 343 +++++++++++++++---------- src/word-range.cpp | 13 +- tests/test_order.py | 75 ++++++ tests/test_stephen.py | 20 +- 8 files changed, 312 insertions(+), 162 deletions(-) create mode 100644 tests/test_order.py diff --git a/src/froidure-pin.cpp b/src/froidure-pin.cpp index c521eb5c..eaf8cccf 100644 --- a/src/froidure-pin.cpp +++ b/src/froidure-pin.cpp @@ -1269,7 +1269,7 @@ This function returns the element of *fp* obtained by evaluating *w*. }); } } // bind_froidure_pin_stateful - } // namespace + } // namespace void init_froidure_pin(py::module& m) { using LenLexTrie = detail::RewritingSystemTrie; diff --git a/src/knuth-bendix.cpp b/src/knuth-bendix.cpp index 57b4eb38..d5cce759 100644 --- a/src/knuth-bendix.cpp +++ b/src/knuth-bendix.cpp @@ -388,7 +388,7 @@ Copy a :any:`NormalFormRange` object. }); thing.def("next", [](NormalFormRange& nfr) { nfr.next(); }); } // bind_normal_form_range - } // namespace + } // namespace template void bind_redundant_rule(py::module& m) { diff --git a/src/libsemigroups_pybind11/__init__.py b/src/libsemigroups_pybind11/__init__.py index d75c4998..4d15bbd4 100644 --- a/src/libsemigroups_pybind11/__init__.py +++ b/src/libsemigroups_pybind11/__init__.py @@ -41,6 +41,7 @@ from .bipartition import Bipartition from .blocks import Blocks from .congruence import Congruence +from .detail.cxx_wrapper import wrap_cxx_free_fn as _wrap_cxx_free_fn from .detail.dot import Dot from .forest import PathsFromRoots, PathsToRoots from .froidure_pin import FroidurePin @@ -103,12 +104,16 @@ delta, error_message_with_prefix, freeband_equal_to, + lenlex_cmp as _lenlex_cmp, + lex_cmp as _lex_cmp, lexicographical_compare, number_of_words, random_string, random_strings, random_word, recursive_path_compare, + rev_rpo_cmp as _rev_rpo_cmp, + rpo_cmp as _rpo_cmp, shortlex_compare, side, tril, @@ -120,6 +125,12 @@ ) from e +lenlex_cmp = _wrap_cxx_free_fn(_lenlex_cmp) +lex_cmp = _wrap_cxx_free_fn(_lex_cmp) +rev_rpo_cmp = _wrap_cxx_free_fn(_rev_rpo_cmp) +rpo_cmp = _wrap_cxx_free_fn(_rpo_cmp) + + __all__ = [ "__version__", # Constants from _libsemigruops_pybind11 @@ -158,12 +169,16 @@ "delta", "error_message_with_prefix", "freeband_equal_to", + "lenlex_cmp", + "lex_cmp", "lexicographical_compare", "number_of_words", "random_string", "random_strings", "random_word", "recursive_path_compare", + "rev_rpo_cmp", + "rpo_cmp", "shortlex_compare", "side", "tril", diff --git a/src/main.cpp b/src/main.cpp index c67bbdcf..fd5c9afb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -68,6 +68,9 @@ namespace libsemigroups { // Must be before most things init_constants(m); + // The alphabet-aware order comparison overloads require the Alphabet + // classes to be registered before their signatures are created. + init_alphabet(m); init_order(m); init_types(m); @@ -76,7 +79,6 @@ namespace libsemigroups { init_runner(m); // Must be before cong classes - init_alphabet(m); init_present(m); init_inverse_present(m); diff --git a/src/order.cpp b/src/order.cpp index 94d10852..7e9e0c53 100644 --- a/src/order.cpp +++ b/src/order.cpp @@ -1,6 +1,6 @@ // // libsemigroups_pybind11 -// Copyright (C) 2023-2024 Murray T. Whyte +// Copyright (C) 2023-2026 Murray T. Whyte // // 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 @@ -16,195 +16,256 @@ // along with this program. If not, see . // -// C std headers.... - // C++ stl headers.... +#include // for string // libsemigroups.... -#include // for order -#include // for order +#include // for *_cmp, Order +#include // for word_type // pybind11.... -#include // for class_, make_iterator, init, enum_ -#include +#include // for arg, enum_, module, options +#include // for automatic conversions // libsemigroups_pybind11.... -#include "main.hpp" // for init_paths +#include "main.hpp" // for init_order namespace libsemigroups { namespace py = pybind11; - void init_order(py::module& m) { - py::options options; - options.disable_enum_members_docstring(); - - py::enum_(m, "Order", R"pbdoc( -An enum class for the possible orderings of words and strings. - -The values in this enum can be used as the arguments for functions such as -:any:`ToddCoxeter.standardize` or :any:`WordRange.order` to specify which -ordering should be used. The normal forms for congruence classes are given with -respect to one of the orders specified by the values in this enum. - -The valid values are: - -.. py:attribute:: Order.none - :value: - - No ordering + namespace { + void warn_deprecated(char const* old_name, char const* new_name) { + std::string message = old_name; + message += " is deprecated, and will be removed from " + "libsemigroups_pybind11 in v2. Instead, use "; + message += new_name; + message += "."; + if (PyErr_WarnEx(PyExc_DeprecationWarning, message.c_str(), 2) < 0) { + throw py::error_already_set(); + } + } + + template + void bind_compare(py::module& m, + char const* name, + Compare compare, + AlphabetCompare alphabet_compare, + char const* doc) { + m.def( + name, + [compare](Word const& x, Word const& y) { return compare(x, y); }, + py::arg("x"), + py::arg("y"), + doc); + m.def( + name, + [alphabet_compare]( + Alphabet const& alphabet, Word const& x, Word const& y) { + return alphabet_compare(alphabet, x, y); + }, + py::arg("alphabet"), + py::arg("x"), + py::arg("y"), + doc); + } + + template + void bind_deprecated_compare(py::module& m, + char const* old_name, + char const* new_name, + Compare compare, + char const* doc) { + m.def( + old_name, + [old_name, new_name, compare](Word const& x, Word const& y) { + warn_deprecated(old_name, new_name); + return compare(x, y); + }, + py::arg("x"), + py::arg("y"), + doc); + } + + template + void bind_order_comparisons(py::module& m) { + bind_compare( + m, + "lex_cmp", + [](Word const& x, Word const& y) { return lex_cmp(x, y); }, + [](Alphabet const& alphabet, Word const& x, Word const& y) { + return lex_cmp(alphabet, x, y); + }, + R"pbdoc( +:sig=(x: str | list[int], y: str | list[int]) -> bool: +:only-document-once: +Compare two words lexicographically. -.. py:attribute:: Order.shortlex - :value: +The three-argument overload ``lex_cmp(alphabet, x, y)`` compares letters by +their positions in *alphabet*. It raises :any:`LibsemigroupsError` if either +word contains a letter that does not belong to *alphabet*. - The short-lex ordering. Words are first ordered by length, and then - lexicographically. +:param x: the first word. +:type x: str | list[int] +:param y: the second word. +:type y: str | list[int] +:returns: Whether *x* is less than *y*. +:rtype: bool +)pbdoc"); -.. py:attribute:: Order.lex - :value: + bind_compare( + m, + "lenlex_cmp", + [](Word const& x, Word const& y) { return lenlex_cmp(x, y); }, + [](Alphabet const& alphabet, Word const& x, Word const& y) { + return lenlex_cmp(alphabet, x, y); + }, + R"pbdoc( +:sig=(x: str | list[int], y: str | list[int]) -> bool: +:only-document-once: +Compare two words using len-lex ordering. - The lexicographic ordering. Note that this is not a well-order, so there may - not be a lexicographically least word in a given congruence class of words. +Words are first ordered by length and then lexicographically. The +three-argument overload ``lenlex_cmp(alphabet, x, y)`` compares letters by +their positions in *alphabet*. It raises :any:`LibsemigroupsError` if either +word contains a letter that does not belong to *alphabet*. -.. py:attribute:: Order.recursive - :value: +:param x: the first word. +:type x: str | list[int] +:param y: the second word. +:type y: str | list[int] +:returns: Whether *x* is less than *y*. +:rtype: bool +)pbdoc"); - The recursive-path ordering, as described in :cite:`Jantzen2012aa` (Definition - 1.2.14, page 24). -)pbdoc") - .value("none", Order::none) - .value("shortlex", Order::shortlex) - .value("lex", Order::lex) - .value("recursive", Order::recursive); - - // No prefix because not in subpackage - m.def( - "lexicographical_compare", - [](std::string const& x, std::string const& y) { - return lexicographical_compare(x, y); - }, - py::arg("x"), - py::arg("y"), - R"pbdoc( + bind_compare( + m, + "rpo_cmp", + [](Word const& x, Word const& y) { return rpo_cmp(x, y); }, + [](Alphabet const& alphabet, Word const& x, Word const& y) { + return rpo_cmp(alphabet, x, y); + }, + R"pbdoc( :sig=(x: str | list[int], y: str | list[int]) -> bool: :only-document-once: -Compare two values of type :any:`str` or ``list[int]`` using lexicographical ordering. +Compare two words using recursive-path ordering. -:param x: the first object for comparison. -:type x: str | list[int] +The three-argument overload ``rpo_cmp(alphabet, x, y)`` compares letters by +their positions in *alphabet*. It raises :any:`LibsemigroupsError` if either +word contains a letter that does not belong to *alphabet*. -:param y: the second object for comparison. +:param x: the first word. +:type x: str | list[int] +:param y: the second word. :type y: str | list[int] - -:returns: The boolean value ``True`` if *x* is lexicographically less than *y*, and ``False`` otherwise. +:returns: Whether *x* is less than *y*. :rtype: bool -:complexity: At most :math:`O(n)` where :math:`n` is the minimum of the length of *x* and the length of *y*. +.. warning:: + This function has significantly worse performance than :any:`lenlex_cmp` + and :any:`lex_cmp`. )pbdoc"); - // No prefix because not in subpackage - m.def( - "lexicographical_compare", - [](word_type const& x, word_type const& y) { - return lexicographical_compare(x, y); - }, - py::arg("x"), - py::arg("y"), - R"pbdoc( + bind_compare( + m, + "rev_rpo_cmp", + [](Word const& x, Word const& y) { return rev_rpo_cmp(x, y); }, + [](Alphabet const& alphabet, Word const& x, Word const& y) { + return rev_rpo_cmp(alphabet, x, y); + }, + R"pbdoc( :sig=(x: str | list[int], y: str | list[int]) -> bool: :only-document-once: -)pbdoc"); +Compare two words using reversed recursive-path ordering. - // No prefix because not in subpackage - m.def( - "shortlex_compare", - [](std::string const& x, std::string const& y) { - return shortlex_compare(x, y); - }, - py::arg("x"), - py::arg("y"), - R"pbdoc( -:sig=(x: str | list[int], y: str | list[int]) -> bool: -:only-document-once: -Compare two values of type :any:`str` or ``list[int]`` using shortlex ordering. +This is recursive-path ordering applied after reading both words from right to +left. The three-argument overload ``rev_rpo_cmp(alphabet, x, y)`` compares +letters by their positions in *alphabet*. It raises +:any:`LibsemigroupsError` if either word contains a letter that does not belong +to *alphabet*. -:param x: the first object for comparison. +:param x: the first word. :type x: str | list[int] - -:param y: the second object for comparison. +:param y: the second word. :type y: str | list[int] - -:returns: The boolean value ``True`` if *x* is short-lex less than *y*, and ``False`` otherwise. +:returns: Whether *x* is less than *y*. :rtype: bool -:complexity: At most :math:`O(n)` where :math:`n` is the minimum of the length of *x* and the length of *y*. +.. warning:: + This function has significantly worse performance than :any:`lenlex_cmp` + and :any:`lex_cmp`. )pbdoc"); - // No prefix because not in subpackage - m.def( - "shortlex_compare", - [](word_type const& x, word_type const& y) { - return shortlex_compare(x, y); - }, - py::arg("x"), - py::arg("y"), - R"pbdoc( + bind_deprecated_compare( + m, + "lexicographical_compare", + "lex_cmp", + [](Word const& x, Word const& y) { return lex_cmp(x, y); }, + R"pbdoc( :sig=(x: str | list[int], y: str | list[int]) -> bool: :only-document-once: +Compare two words lexicographically. + +.. deprecated:: 1.5 + This will be removed from ``libsemigroups_pybind11`` in v2. Instead, use + :any:`lex_cmp`. )pbdoc"); - // No prefix because not in subpackage - m.def( - "recursive_path_compare", - [](std::string const& x, std::string const& y) { - return recursive_path_compare(x, y); - }, - py::arg("x"), - py::arg("y"), - R"pbdoc( + bind_deprecated_compare( + m, + "shortlex_compare", + "lenlex_cmp", + [](Word const& x, Word const& y) { return lenlex_cmp(x, y); }, + R"pbdoc( :sig=(x: str | list[int], y: str | list[int]) -> bool: :only-document-once: -Compare two values of type :any:`str` or ``list[int]`` using recursive-path ordering. +Compare two words using len-lex ordering. -This function compares two values of type :any:`str` or ``list[int]`` using the -recursive-path ordering described in :cite:`Jantzen2012aa` (Definition 1.2.14, -page 24). - -If :math:`u, v\in X ^ {*}`, :math:`u \neq v`, and :math:`u = a'u`, -:math:`v = bv'` for some :math:`a,b \in X`, :math:`u',v'\in X ^ {*}`, then -:math:`u > v` if one of the following conditions holds: +.. deprecated:: 1.5 + This will be removed from ``libsemigroups_pybind11`` in v2. Instead, use + :any:`lenlex_cmp`. +)pbdoc"); -#. :math:`a = b` and :math:`u' \geq v'`; -#. :math:`a > b` and :math:`u > v'`; -#. :math:`b > a` and :math:`u' > v`. + bind_deprecated_compare( + m, + "recursive_path_compare", + "rev_rpo_cmp", + [](Word const& x, Word const& y) { return rev_rpo_cmp(x, y); }, + R"pbdoc( +:sig=(x: str | list[int], y: str | list[int]) -> bool: +:only-document-once: +Compare two words using reversed recursive-path ordering. -This documentation and the implementation of :any:`recursive_path_compare` -is based on the source code of :cite:`Holt2018aa`. +.. deprecated:: 1.5 + This will be removed from ``libsemigroups_pybind11`` in v2. Instead, use + :any:`rev_rpo_cmp`. +)pbdoc"); + } + } // namespace -:param x: the first object for comparison. -:type x: str | list[int] + void init_order(py::module& m) { + py::options options; + options.disable_enum_members_docstring(); -:param y: the second object for comparison. -:type y: str | list[int] + py::enum_(m, "Order", R"pbdoc( +An enum class for the possible orderings of words and strings. -:returns: The boolean value ``True`` if *x* is less than *y* with respect to the recursive path ordering, and ``False`` otherwise. -:rtype: bool +The values in this enum can be used as the arguments for functions such as +:any:`ToddCoxeter.standardize` or :any:`WordRange.order` to specify which +ordering should be used. -.. warning:: - This function has significantly worse performance than - :any:`shortlex_compare` and :any:`lexicographical_compare`. -)pbdoc"); +The values :any:`Order.shortlex` and :any:`Order.recursive` are retained for +backwards compatibility; use :any:`Order.lenlex` and :any:`Order.rev_rpo`, +respectively, in new code. +)pbdoc") + .value("none", Order::none) + .value("lenlex", Order::lenlex) + .value("shortlex", Order::lenlex) + .value("lex", Order::lex) + .value("rpo", Order::rpo) + .value("rev_rpo", Order::rev_rpo) + .value("recursive", Order::rev_rpo); - // No prefix because not in subpackage - m.def( - "recursive_path_compare", - [](word_type const& x, word_type const& y) { - return recursive_path_compare(x, y); - }, - py::arg("x"), - py::arg("y"), - R"pbdoc( -:sig=(x: str | list[int], y: str | list[int]) -> bool: -:only-document-once: -)pbdoc"); + bind_order_comparisons(m); + bind_order_comparisons(m); } } // namespace libsemigroups diff --git a/src/word-range.cpp b/src/word-range.cpp index b84a1fe7..4c1b3bc6 100644 --- a/src/word-range.cpp +++ b/src/word-range.cpp @@ -84,7 +84,7 @@ Example ... .max(5) >>> words.order() - + >>> from libsemigroups_pybind11 import ToString >>> words.alphabet_size(1).min(0).max(10) @@ -166,10 +166,11 @@ Returns ``True`` if a :any:`WordRange` object is exhausted, and ``False`` if not R"pbdoc( The actual size of the range. -Returns the number of words in a :any:`WordRange` object. If :any:`WordRange.order()` is -:any:`Order.shortlex`, then :any:`WordRange.size_hint()` is used. If :any:`WordRange.order()` is -not :any:`Order.shortlex`, then a copy of the range may have to be looped over -in order to find the return value of this function. +Returns the number of words in a :any:`WordRange` object. If +:any:`WordRange.order()` is :any:`Order.shortlex`, then +:any:`WordRange.size_hint()` is used. If :any:`WordRange.order()` is not +:any:`Order.shortlex`, then a copy of the range may have to be looped over in +order to find the return value of this function. :returns: The size of the range. :rtype: int @@ -484,7 +485,7 @@ Example ... .max(5) >>> strings.order() - + >>> from libsemigroups_pybind11 import ToWord >>> strings.alphabet("a").min(0).max(10) diff --git a/tests/test_order.py b/tests/test_order.py new file mode 100644 index 00000000..5805036f --- /dev/null +++ b/tests/test_order.py @@ -0,0 +1,75 @@ +# Copyright (c) 2026 J. D. Mitchell +# +# Distributed under the terms of the GPL license version 3. +# +# The full license is in the file LICENSE, distributed with this software. + +"""Tests for order.cpp.""" + +import pytest + +from libsemigroups_pybind11 import ( + Alphabet, + LibsemigroupsError, + Order, + lenlex_cmp, + lex_cmp, + lexicographical_compare, + recursive_path_compare, + rev_rpo_cmp, + rpo_cmp, + shortlex_compare, +) + + +@pytest.mark.parametrize( + ("compare", "x", "y"), + [ + (lex_cmp, "ab", "ba"), + (lex_cmp, [0, 1], [1, 0]), + (lenlex_cmp, "ba", "aaa"), + (lenlex_cmp, [1, 0], [0, 0, 0]), + (rpo_cmp, "ab", "ba"), + (rpo_cmp, [0, 1], [1, 0]), + (rev_rpo_cmp, "ab", "ba"), + (rev_rpo_cmp, [0, 1], [1, 0]), + ], +) +def test_compare_without_alphabet(compare, x, y): + """Check that each comparison function works without an alphabet.""" + assert isinstance(compare(x, y), bool) + + +@pytest.mark.parametrize("compare", [lex_cmp, lenlex_cmp, rpo_cmp, rev_rpo_cmp]) +@pytest.mark.parametrize( + ("alphabet", "x", "y", "missing"), + [(Alphabet("ba"), "ba", "ab", "c"), (Alphabet([1, 0]), [1, 0], [0, 1], [2])], +) +def test_compare_with_alphabet(compare, alphabet, x, y, missing): + """Check alphabet-aware comparisons and reject unknown letters.""" + assert isinstance(compare(alphabet, x, y), bool) + + with pytest.raises(LibsemigroupsError): + compare(alphabet, x, x + missing) + + +def test_order_values_and_backwards_compatible_aliases(): + """Check the new order values and their backwards-compatible aliases.""" + assert Order.shortlex == Order.lenlex + assert Order.recursive == Order.rev_rpo + assert Order.rpo != Order.rev_rpo + + +@pytest.mark.parametrize( + ("old_compare", "new_compare"), + [ + (lexicographical_compare, lex_cmp), + (shortlex_compare, lenlex_cmp), + (recursive_path_compare, rev_rpo_cmp), + ], +) +def test_deprecated_comparisons(old_compare, new_compare): + """Check that legacy comparisons warn and delegate to their replacements.""" + with pytest.deprecated_call(): + result = old_compare("ab", "ba") + assert result == new_compare("ab", "ba") diff --git a/tests/test_stephen.py b/tests/test_stephen.py index ae6d4cba..01f6b0f2 100644 --- a/tests/test_stephen.py +++ b/tests/test_stephen.py @@ -26,7 +26,7 @@ ToWord, WordGraph, congruence_kind, - lexicographical_compare, + lex_cmp, presentation, stephen, todd_coxeter, @@ -69,22 +69,22 @@ def check_000(s): # The following is needed so that we can sort lists with a custom order. # Why does Python not support a comparator directly? Who knows. # Why does it not automatically convert a boolean comparator to a key function? WHO KNOWS! -def lexicographic_compare_comparator(x, y) -> int: +def lex_cmp_comparator(x, y) -> int: if x == y: return 0 - if lexicographical_compare(x, y): + if lex_cmp(x, y): return -1 return 1 -lexicographic_compare_key_func = cmp_to_key(lexicographic_compare_comparator) +lex_cmp_key_func = cmp_to_key(lex_cmp_comparator) def verify_c4_normal_form(p, word, nf): S = Stephen(p) S.set_word(word).run() - assert sorted(list(stephen.words_accepted(S)), key=lexicographic_compare_key_func)[0] == nf + assert sorted(list(stephen.words_accepted(S)), key=lex_cmp_key_func)[0] == nf assert all(stephen.accepts(S, w) for w in stephen.words_accepted(S)) assert stephen.number_of_words_accepted(S) == sum(1 for _ in stephen.words_accepted(S)) @@ -574,9 +574,7 @@ def test_stephen_008(): to_word("dgabcdg"), ] - assert sorted(list(stephen.words_accepted(S)), key=lexicographic_compare_key_func)[ - 0 - ] == to_word("dfabcdf") + assert sorted(list(stephen.words_accepted(S)), key=lex_cmp_key_func)[0] == to_word("dfabcdf") assert all(stephen.accepts(S, w) for w in stephen.words_accepted(S)) assert stephen.number_of_words_accepted(S) == sum(1 for _ in stephen.words_accepted(S)) @@ -584,7 +582,7 @@ def test_stephen_008(): S.set_word(to_word("abcdfceg")).run() assert stephen.number_of_words_accepted(S) == 16 - assert sorted(list(stephen.words_accepted(S)), key=lexicographic_compare_key_func) == [ + assert sorted(list(stephen.words_accepted(S)), key=lex_cmp_key_func) == [ to_word("abcdfabcdf"), to_word("abcdfabcdg"), to_word("abcdfcef"), @@ -603,9 +601,7 @@ def test_stephen_008(): to_word("cegceg"), ] - assert sorted(list(stephen.words_accepted(S)), key=lexicographic_compare_key_func)[ - 0 - ] == to_word("abcdfabcdf") + assert sorted(list(stephen.words_accepted(S)), key=lex_cmp_key_func)[0] == to_word("abcdfabcdf") assert stephen.accepts(S, to_word("abcdfabcdf")) From ec1a2316aa117b9a3b459bfc9943cbefe30a0683 Mon Sep 17 00:00:00 2001 From: Joseph Edwards Date: Mon, 20 Jul 2026 14:54:04 +0100 Subject: [PATCH 3/3] order: remove deprecated functions from doc --- docs/source/data-structures/order/index.rst | 12 ++ .../knuth-bendix/to-knuth-bendix.rst | 32 ++--- src/knuth-bendix.cpp | 2 +- src/libsemigroups_pybind11/knuth_bendix.py | 22 ++-- src/libsemigroups_pybind11/to.py | 24 ++-- src/order.cpp | 68 +++++++++++ src/paths.cpp | 6 +- src/present.cpp | 14 +-- src/todd-coxeter-impl.cpp | 12 +- src/todd-coxeter.cpp | 6 +- src/word-graph.cpp | 6 +- src/word-range.cpp | 28 ++--- tests/test_knuth_bendix.py | 6 +- tests/test_paths.py | 2 +- tests/test_sims.py | 4 +- tests/test_to.py | 114 ++++++++---------- tests/test_todd_coxeter.py | 6 +- tests/test_word_graph.py | 2 +- tests/test_word_range.py | 6 +- 19 files changed, 222 insertions(+), 150 deletions(-) diff --git a/docs/source/data-structures/order/index.rst b/docs/source/data-structures/order/index.rst index 2cd7ff38..6f371ce9 100644 --- a/docs/source/data-structures/order/index.rst +++ b/docs/source/data-structures/order/index.rst @@ -23,15 +23,27 @@ Contents .. autosummary:: :signatures: short + lenlex_cmp + lex_cmp lexicographical_compare recursive_path_compare + rev_rpo_cmp + rpo_cmp shortlex_compare Full API -------- +.. autofunction:: lenlex_cmp + +.. autofunction:: lex_cmp + .. autofunction:: lexicographical_compare .. autofunction:: recursive_path_compare +.. autofunction:: rev_rpo_cmp + +.. autofunction:: rpo_cmp + .. autofunction:: shortlex_compare diff --git a/docs/source/main-algorithms/knuth-bendix/to-knuth-bendix.rst b/docs/source/main-algorithms/knuth-bendix/to-knuth-bendix.rst index 31218659..4e623bc1 100644 --- a/docs/source/main-algorithms/knuth-bendix/to-knuth-bendix.rst +++ b/docs/source/main-algorithms/knuth-bendix/to-knuth-bendix.rst @@ -106,10 +106,10 @@ Additionally, specify *rtype* to be a tuple with first item :any:`KnuthBendix`, and the third item one of: - - :any:`Order.shortlex` for constructing a :any:`KnuthBendix` + - :any:`Order.lenlex` for constructing a :any:`KnuthBendix` with short-lex reduction ordering. - - :any:`Order.recursive` for constructing a :any:`KnuthBendix` - with recursive path reduction ordering. + - :any:`Order.rpo` for constructing a :any:`KnuthBendix` + with recursive-path reduction ordering. This function converts a :any:`ToddCoxeter` object *tc* to a :any:`KnuthBendix` object with the rewriter as specified above, using @@ -140,7 +140,7 @@ the semigroup defined by *tc*. >>> kb = to( ... congruence_kind.twosided, # knd ... tc, # tc - ... rtype=(KnuthBendix, 'Set', Order.shortlex) + ... rtype=(KnuthBendix, 'Set', Order.lenlex) ... ) >>> kb.run() @@ -162,28 +162,28 @@ following values for *args*: Additionally, specify one of the following for *rtype*: - - ``(KnuthBendix, str, 'Trie', Order.shortlex)`` for constructing a + - ``(KnuthBendix, str, 'Trie', Order.lenlex)`` for constructing a :any:`KnuthBendix` on words with type ``str`` using the trie based rewriting system and short-lex reduction ordering. - - ``(KnuthBendix, list[int], 'Trie', Order.shortlex)`` for constructing a + - ``(KnuthBendix, list[int], 'Trie', Order.lenlex)`` for constructing a :any:`KnuthBendix` on words with type ``list[int]`` using the trie based rewriting system and short-lex reduction ordering. - - ``(KnuthBendix, str, 'Set', Order.shortlex)`` for constructing a + - ``(KnuthBendix, str, 'Set', Order.lenlex)`` for constructing a :any:`KnuthBendix` on words with type ``str`` using a set based rewriting system and short-lex reduction ordering. - - ``(KnuthBendix, list[int], 'Set', Order.shortlex)`` for constructing a + - ``(KnuthBendix, list[int], 'Set', Order.lenlex)`` for constructing a :any:`KnuthBendix` on words with type ``list[int]`` using a set based rewriting system and short-lex reduction ordering. - - ``(KnuthBendix, str, 'Trie', Order.recursive)`` for constructing a + - ``(KnuthBendix, str, 'Trie', Order.rpo)`` for constructing a :any:`KnuthBendix` on words with type ``str`` using the - trie based rewriting system and recursive path reduction ordering. - - ``(KnuthBendix, list[int], 'Trie', Order.recursive)`` for constructing a + trie based rewriting system and recursive-path reduction ordering. + - ``(KnuthBendix, list[int], 'Trie', Order.rpo)`` for constructing a :any:`KnuthBendix` on words with type ``list[int]`` using the - trie based rewriting system and recursive path reduction ordering. - - ``(KnuthBendix, str, 'Set', Order.recursive)`` for constructing a + trie based rewriting system and recursive-path reduction ordering. + - ``(KnuthBendix, str, 'Set', Order.rpo)`` for constructing a :any:`KnuthBendix` on words with type ``str`` using a set based rewriting - system and recursive path reduction ordering. - - ``(KnuthBendix, list[int], 'Set', Order.recursive)`` for constructing a + system and recursive-path reduction ordering. + - ``(KnuthBendix, list[int], 'Set', Order.rpo)`` for constructing a :any:`KnuthBendix` on words with type ``list[int]`` using a set based rewriting system and short-lex reduction ordering. @@ -216,7 +216,7 @@ the semigroup defined by *fpb*. >>> kb = to( ... congruence_kind.twosided, # knd ... S, # tc - ... rtype=(KnuthBendix, list[int], 'Set', Order.recursive) + ... rtype=(KnuthBendix, list[int], 'Set', Order.rpo) ... ) >>> kb.run() diff --git a/src/knuth-bendix.cpp b/src/knuth-bendix.cpp index d5cce759..294a6b6b 100644 --- a/src/knuth-bendix.cpp +++ b/src/knuth-bendix.cpp @@ -90,7 +90,7 @@ nested class :any:`KnuthBendix.options`. doc{.extra_kwargs = ", rewriting_system: str, order: Order", .extra_kwargs_doc = R"pbdoc( * **rewriting_system** (*str*) -- the type of rewriting system to use, must be either ``"Trie"`` or ``"Set"``. - * **order** (*Order*) -- the reduction ordering to use, must be either :any:`Order.shortlex` or :any:`Order.recursive`.)pbdoc"sv}); + * **order** (*Order*) -- the reduction ordering to use, must be either :any:`Order.lenlex` or :any:`Order.rpo`.)pbdoc"sv}); def_init_default(thing, "KnuthBendix"); def_construct_kind_presentation(thing, "KnuthBendix"); diff --git a/src/libsemigroups_pybind11/knuth_bendix.py b/src/libsemigroups_pybind11/knuth_bendix.py index b187bbba..3fdb14e6 100644 --- a/src/libsemigroups_pybind11/knuth_bendix.py +++ b/src/libsemigroups_pybind11/knuth_bendix.py @@ -50,14 +50,14 @@ class KnuthBendix(_CongruenceCommon): _py_template_params_to_cxx_type = { (list[int],): _KnuthBendixWordLenLexTrie, (str,): _KnuthBendixStringLenLexTrie, - (list[int], "Trie", _Order.shortlex): _KnuthBendixWordLenLexTrie, - (str, "Trie", _Order.shortlex): _KnuthBendixStringLenLexTrie, - (list[int], "Set", _Order.shortlex): _KnuthBendixWordLenLexSet, - (str, "Set", _Order.shortlex): _KnuthBendixStringLenLexSet, - (list[int], "Trie", _Order.recursive): _KnuthBendixWordRevRPOTrie, - (str, "Trie", _Order.recursive): _KnuthBendixStringRevRPOTrie, - (list[int], "Set", _Order.recursive): _KnuthBendixWordRevRPOSet, - (str, "Set", _Order.recursive): _KnuthBendixStringRevRPOSet, + (list[int], "Trie", _Order.lenlex): _KnuthBendixWordLenLexTrie, + (str, "Trie", _Order.lenlex): _KnuthBendixStringLenLexTrie, + (list[int], "Set", _Order.lenlex): _KnuthBendixWordLenLexSet, + (str, "Set", _Order.lenlex): _KnuthBendixStringLenLexSet, + (list[int], "Trie", _Order.rpo): _KnuthBendixWordRevRPOTrie, + (str, "Trie", _Order.rpo): _KnuthBendixStringRevRPOTrie, + (list[int], "Set", _Order.rpo): _KnuthBendixWordRevRPOSet, + (str, "Set", _Order.rpo): _KnuthBendixStringRevRPOSet, } _cxx_type_to_py_template_params = dict( @@ -73,7 +73,7 @@ class KnuthBendix(_CongruenceCommon): options = _KnuthBendixStringLenLexTrie.options @_copydoc(_KnuthBendixStringLenLexTrie.__init__) - def __init__(self, *args, rewriting_system="Trie", order=_Order.shortlex, **kwargs) -> None: + def __init__(self, *args, rewriting_system="Trie", order=_Order.lenlex, **kwargs) -> None: if "rewriter" in kwargs: # TODO(v2) remove this entire if-statement warn( @@ -92,10 +92,10 @@ def __init__(self, *args, rewriting_system="Trie", order=_Order.shortlex, **kwar ) if kwargs["rewriter"] == "RewriteFromLeft": rewriting_system = "Set" - order = _Order.shortlex + order = _Order.lenlex else: rewriting_system = "Trie" - order = _Order.shortlex + order = _Order.lenlex msg = f"""expected either: 1) 2 positional arguments of types congruence_kind and Presentation; or diff --git a/src/libsemigroups_pybind11/to.py b/src/libsemigroups_pybind11/to.py index 82944b28..aa21ccd1 100644 --- a/src/libsemigroups_pybind11/to.py +++ b/src/libsemigroups_pybind11/to.py @@ -82,18 +82,18 @@ def _nice_name(type_list): (_InversePresentation, list[int]): _to_inverse_presentation_word, (_InversePresentation, str): _to_inverse_presentation_string, (_KnuthBendix,): _to_knuth_bendix, - (_KnuthBendix, "Set", _Order.shortlex): _to_knuth_bendix_LenLexSet, - (_KnuthBendix, "Trie", _Order.shortlex): _to_knuth_bendix_LenLexTrie, - (_KnuthBendix, list[int], "Set", _Order.shortlex): _to_knuth_bendix_word_LenLexSet, - (_KnuthBendix, list[int], "Trie", _Order.shortlex): _to_knuth_bendix_word_LenLexTrie, - (_KnuthBendix, str, "Set", _Order.shortlex): _to_knuth_bendix_string_LenLexSet, - (_KnuthBendix, str, "Trie", _Order.shortlex): _to_knuth_bendix_string_LenLexTrie, - (_KnuthBendix, "Set", _Order.recursive): _to_knuth_bendix_RevRPOSet, - (_KnuthBendix, "Trie", _Order.recursive): _to_knuth_bendix_RevRPOTrie, - (_KnuthBendix, list[int], "Set", _Order.recursive): _to_knuth_bendix_word_RevRPOSet, - (_KnuthBendix, list[int], "Trie", _Order.recursive): _to_knuth_bendix_word_RevRPOTrie, - (_KnuthBendix, str, "Set", _Order.recursive): _to_knuth_bendix_string_RevRPOSet, - (_KnuthBendix, str, "Trie", _Order.recursive): _to_knuth_bendix_string_RevRPOTrie, + (_KnuthBendix, "Set", _Order.lenlex): _to_knuth_bendix_LenLexSet, + (_KnuthBendix, "Trie", _Order.lenlex): _to_knuth_bendix_LenLexTrie, + (_KnuthBendix, list[int], "Set", _Order.lenlex): _to_knuth_bendix_word_LenLexSet, + (_KnuthBendix, list[int], "Trie", _Order.lenlex): _to_knuth_bendix_word_LenLexTrie, + (_KnuthBendix, str, "Set", _Order.lenlex): _to_knuth_bendix_string_LenLexSet, + (_KnuthBendix, str, "Trie", _Order.lenlex): _to_knuth_bendix_string_LenLexTrie, + (_KnuthBendix, "Set", _Order.rpo): _to_knuth_bendix_RevRPOSet, + (_KnuthBendix, "Trie", _Order.rpo): _to_knuth_bendix_RevRPOTrie, + (_KnuthBendix, list[int], "Set", _Order.rpo): _to_knuth_bendix_word_RevRPOSet, + (_KnuthBendix, list[int], "Trie", _Order.rpo): _to_knuth_bendix_word_RevRPOTrie, + (_KnuthBendix, str, "Set", _Order.rpo): _to_knuth_bendix_string_RevRPOSet, + (_KnuthBendix, str, "Trie", _Order.rpo): _to_knuth_bendix_string_RevRPOTrie, (_Presentation,): _to_presentation, (_Presentation, str): _to_presentation_string, (_Presentation, list[int]): _to_presentation_word, diff --git a/src/order.cpp b/src/order.cpp index 7e9e0c53..8e05b195 100644 --- a/src/order.cpp +++ b/src/order.cpp @@ -205,6 +205,13 @@ to *alphabet*. :only-document-once: Compare two words lexicographically. +:param x: the first word. +:type x: str | list[int] +:param y: the second word. +:type y: str | list[int] +:returns: Whether *x* is less than *y*. +:rtype: bool + .. deprecated:: 1.5 This will be removed from ``libsemigroups_pybind11`` in v2. Instead, use :any:`lex_cmp`. @@ -220,6 +227,13 @@ Compare two words lexicographically. :only-document-once: Compare two words using len-lex ordering. +:param x: the first word. +:type x: str | list[int] +:param y: the second word. +:type y: str | list[int] +:returns: Whether *x* is less than *y*. +:rtype: bool + .. deprecated:: 1.5 This will be removed from ``libsemigroups_pybind11`` in v2. Instead, use :any:`lenlex_cmp`. @@ -235,6 +249,13 @@ Compare two words using len-lex ordering. :only-document-once: Compare two words using reversed recursive-path ordering. +:param x: the first word. +:type x: str | list[int] +:param y: the second word. +:type y: str | list[int] +:returns: Whether *x* is less than *y*. +:rtype: bool + .. deprecated:: 1.5 This will be removed from ``libsemigroups_pybind11`` in v2. Instead, use :any:`rev_rpo_cmp`. @@ -256,6 +277,53 @@ ordering should be used. The values :any:`Order.shortlex` and :any:`Order.recursive` are retained for backwards compatibility; use :any:`Order.lenlex` and :any:`Order.rev_rpo`, respectively, in new code. + +.. py:attribute:: Order.none + :value: + + No ordering + +.. py:attribute:: Order.lenlex + :value: + + The len-lex ordering. Words are first ordered by length, and then + lexicographically. + +.. py:attribute:: Order.shortlex + :value: + + The short-lex ordering. Words are first ordered by length, and then + lexicographically. + + This is deprecated; use :any:`Order.lenlex` instead. + +.. py:attribute:: Order.lex + :value: + + The lexicographic ordering. Note that this is not a well-order, so there + may not be a lexicographically least word in a given congruence class of + words. + +.. py:attribute:: Order.rpo + :value: + + The recursive-path ordering, as described in :cite:`Jantzen2012aa` + (Definition 1.2.14, page 24). + +.. py:attribute:: Order.rev_rpo + :value: + + The reversed recursive-path ordering, based on the description in + :cite:`Jantzen2012aa` (Definition 1.2.14, page 24), where words are read + right-to-left before ordering. + +.. py:attribute:: Order.recursive + :value: + + The recursive-path ordering, as described in :cite:`Jantzen2012aa` + (Definition 1.2.14, page 24). + + This is deprecated; use :any:`Order.rpo` instead. )pbdoc") .value("none", Order::none) .value("lenlex", Order::lenlex) diff --git a/src/paths.cpp b/src/paths.cpp index d5758768..bc97f44a 100644 --- a/src/paths.cpp +++ b/src/paths.cpp @@ -291,7 +291,7 @@ then this function does nothing. R"pbdoc( Get the order of the paths in the range. This function returns the current order of the paths in the range defined by a :any:`Paths` -object. The initial value is :any:`Order.shortlex`. +object. The initial value is :any:`Order.lenlex`. :returns: The order of the paths in the range. @@ -307,7 +307,7 @@ object. The initial value is :any:`Order.shortlex`. Set the order of the paths in the range. This function can be used to set the order of the paths in the range defined by -a :any:`Paths` object. The initial value is :any:`Order.shortlex`. +a :any:`Paths` object. The initial value is :any:`Order.lenlex`. :param val: the order of the paths in the range. :type val: Order @@ -316,7 +316,7 @@ a :any:`Paths` object. The initial value is :any:`Order.shortlex`. :rtype: Paths :raises LibsemigroupsError: - if *val* is not :any:`Order.shortlex` or :any:`Order.lex`. + if *val* is not :any:`Order.lenlex` or :any:`Order.lex`. )pbdoc"); thing1.def( "source", diff --git a/src/present.cpp b/src/present.cpp index aba6bc64..16bc2157 100644 --- a/src/present.cpp +++ b/src/present.cpp @@ -25,7 +25,7 @@ // libsemigroups.... #include // for operator==, UNDEFINED #include // for LibsemigroupsException -#include // for shortlex_compare +#include // for lenlex_cmp #include // for Presentation #include // for is_sorted #include // for word_type @@ -946,10 +946,10 @@ Adds rules to *p* of the form :math:`uv = vu` for every letter :math:`u` in R"pbdoc( :sig=(p: Presentation) -> bool: :only-document-once: -Check the rules are sorted relative to shortlex. +Check the rules are sorted relative to len-lex. Check if the rules :math:`u_1 = v_1, \ldots, u_n = v_n` satisfy -:math:`u_1v_1 < \cdots < u_nv_n` where :math:`<` is shortlex order. +:math:`u_1v_1 < \cdots < u_nv_n` where :math:`<` is len-lex order. :param p: the presentation to check. :type p: Presentation @@ -1496,9 +1496,9 @@ is defined to be the sum of the lengths of its left-hand and right-hand sides. R"pbdoc( :sig=(p: Presentation) -> bool: :only-document-once: -Sort the left-hand and right-hand side of each rule by shortlex. +Sort the left-hand and right-hand side of each rule by len-lex. -Sort each rule :math:`u = v` so that the left-hand side is shortlex greater than +Sort each rule :math:`u = v` so that the left-hand side is len-lex greater than the right-hand side, and return :any:`True` if any of the rules are changed. :param p: the presentation whose rules should be sorted. @@ -1548,10 +1548,10 @@ rules are changed. R"pbdoc( :sig=(p: Presentation) -> None: :only-document-once: -Sort all of the rules by shortlex. +Sort all of the rules by len-lex. Sort the rules :math:`u_1 = v_1, \ldots, u_n = v_n` so that :math:`u_1v_1 < -\cdots < u_nv_n` where :math:`<` is the shortlex order. +\cdots < u_nv_n` where :math:`<` is the len-lex order. :param p: the presentation to sort. :type p: Presentation diff --git a/src/todd-coxeter-impl.cpp b/src/todd-coxeter-impl.cpp index ceb34900..3c4dc5fb 100644 --- a/src/todd-coxeter-impl.cpp +++ b/src/todd-coxeter-impl.cpp @@ -1325,7 +1325,7 @@ The return value of this function indicates the following: - the return values of :any:`todd_coxeter.normal_forms` will be essentially arbitrary; - the classes of the congruence will be indexed in an arbitrary order; -- :any:`Order.shortlex` implies that: +- :any:`Order.lenlex` implies that: - the return value of :any:`reduce` will be the short-lex least word belonging to a given congruence class; @@ -1341,14 +1341,14 @@ The return value of this function indicates the following: essentially arbitrary because there is not necessarily a lexicographically least word in every class; -- :any:`Order.recursive` implies that: +- :any:`Order.rpo` implies that: - - the return value of :any:`reduce` will be the recursive path least + - the return value of :any:`reduce` will be the recursive-path least word belonging to a given congruence class; - the return values of :any:`todd_coxeter.normal_forms` will be ordered by the - recursive path order; - - the classes of the congruence will be indexed in recursive path order - on the recursive path least word. + recursive-path order; + - the classes of the congruence will be indexed in recursive-path order + on the recursive-path least word. :returns: The current standardization order. diff --git a/src/todd-coxeter.cpp b/src/todd-coxeter.cpp index 8916746b..14a4ed54 100644 --- a/src/todd-coxeter.cpp +++ b/src/todd-coxeter.cpp @@ -305,7 +305,7 @@ Returns the index of the class containing a word. This function returns the index of the class containing the word *w*. A full enumeration is triggered by calls to this function. If the :any:`current_word_graph` has not already been standardized, then this -function first standardizes it with respect to :any:`Order.shortlex`; +function first standardizes it with respect to :any:`Order.lenlex`; otherwise the existing standardization order is used. The returned index is obtained by following the path in :any:`current_word_graph` from node ``0`` labelled by the word *w*. Since a full enumeration is triggered by @@ -336,7 +336,7 @@ Returns a current word representing a class with given index. This function returns the current word representing the class with index *i*. No enumeration is triggered by calls to this function, but -:any:`current_word_graph` is standardized (using :any:`Order.shortlex`) if it +:any:`current_word_graph` is standardized (using :any:`Order.lenlex`) if it is not already standardized. The output word is obtained by following a path in :any:`current_spanning_tree` from the node corresponding to index *i* back to the root of that tree. @@ -533,7 +533,7 @@ This function performs a lookbehind using the function *collapser* to decide whether or not to collapse nodes. For example, it might be the case that *collapser* uses a :any:`KnuthBendix` instance to determine whether or not nodes in the graph represent the same class of the congruence. More -specifically, the shortlex least path from the initial node to every node +specifically, the len-lex least path from the initial node to every node ``n`` is rewritten using *collapser*, and if the rewritten word labels a path in the graph to a node ``m``, then it is assumed that ``m`` and ``n`` represent the same class of the congruence, and they are marked for diff --git a/src/word-graph.cpp b/src/word-graph.cpp index f618af4e..e5de68cb 100644 --- a/src/word-graph.cpp +++ b/src/word-graph.cpp @@ -1352,9 +1352,9 @@ order specified by *val*, and replaces the contents of the :any:`Forest` return word_graph::standardize(wg, val); }, py::arg("wg"), - py::arg("val") = Order::shortlex, + py::arg("val") = Order::lenlex, R"pbdoc( -:sig=(wg: WordGraph, val: Order = Order.shortlex) -> tuple[bool, Forest]: +:sig=(wg: WordGraph, val: Order = Order.lenlex) -> tuple[bool, Forest]: Standardizes a word graph in-place. This function standardizes the word graph *wg* according to the reduction @@ -1366,7 +1366,7 @@ spanning tree corresponds to the order *val*. :type wg: WordGraph :param val: - the order to use for standardization (default: :any:`Order.shortlex`). + the order to use for standardization (default: :any:`Order.lenlex`). :type val: Order :returns: diff --git a/src/word-range.cpp b/src/word-range.cpp index 4c1b3bc6..9969fa1f 100644 --- a/src/word-range.cpp +++ b/src/word-range.cpp @@ -78,7 +78,7 @@ Example >>> from libsemigroups_pybind11 import WordRange, Order >>> words = WordRange(); - >>> words.order(Order.shortlex) \ + >>> words.order(Order.lenlex) \ ... .alphabet_size(2) \ ... .min(1) \ ... .max(5) @@ -143,7 +143,7 @@ Constructs an empty range with: * :any:`WordRange.min()` equal to ``0``; * :any:`WordRange.max()` equal to ``0``; -* :any:`WordRange.order()` equal to :any:`Order.shortlex`; +* :any:`WordRange.order()` equal to :any:`Order.lenlex`; * :any:`WordRange.first()` equal to the empty word; * :any:`WordRange.last()` equal to the empty word; * :any:`WordRange.upper_bound()` equal to ``0``; @@ -167,9 +167,9 @@ Returns ``True`` if a :any:`WordRange` object is exhausted, and ``False`` if not The actual size of the range. Returns the number of words in a :any:`WordRange` object. If -:any:`WordRange.order()` is :any:`Order.shortlex`, then +:any:`WordRange.order()` is :any:`Order.lenlex`, then :any:`WordRange.size_hint()` is used. If :any:`WordRange.order()` is not -:any:`Order.shortlex`, then a copy of the range may have to be looped over in +:any:`Order.lenlex`, then a copy of the range may have to be looped over in order to find the return value of this function. :returns: The size of the range. @@ -377,7 +377,7 @@ Sets the order of the words in a :any:`WordRange` object to *val*. :returns: *self*. :rtype: WordRange -:raises LibsemigroupsError: if *val* is not :any:`Order.shortlex` or :any:`Order.lex`. +:raises LibsemigroupsError: if *val* is not :any:`Order.lenlex` or :any:`Order.lex`. )pbdoc"); thing1.def("size_hint", &WordRange::size_hint, @@ -385,8 +385,8 @@ Sets the order of the words in a :any:`WordRange` object to *val*. The possible size of the range. Returns the number of words in a :any:`WordRange` object if -:any:`WordRange.order()` is :any:`Order.shortlex`. If :any:`WordRange.order()` -is not :any:`Order.shortlex`, then the return value of this function is +:any:`WordRange.order()` is :any:`Order.lenlex`. If :any:`WordRange.order()` +is not :any:`Order.lenlex`, then the return value of this function is meaningless. :returns: A value of type ``int``. @@ -479,7 +479,7 @@ Example >>> from libsemigroups_pybind11 import StringRange, Order >>> strings = StringRange(); - >>> strings.order(Order.shortlex) \ + >>> strings.order(Order.lenlex) \ ... .alphabet("ba") \ ... .min(1) \ ... .max(5) @@ -554,7 +554,7 @@ Constructs an empty range with: * :any:`StringRange.min()` equal to ``0``; * :any:`StringRange.max()` equal to ``0``; -* :any:`StringRange.order()` equal to :any:`Order.shortlex`; +* :any:`StringRange.order()` equal to :any:`Order.lenlex`; * :any:`StringRange.first()` equal to the empty string; * :any:`StringRange.last()` equal to the empty string; * :any:`StringRange.upper_bound()` equal to ``0``; @@ -625,8 +625,8 @@ object. The actual size of the range. Returns the number of strings in the range object. If :any:`StringRange.order()` -is :any:`Order.shortlex`, then :any:`StringRange.size_hint()` is used. If -:any:`StringRange.order()` is not :any:`Order.shortlex`, then a copy of the range may have +is :any:`Order.lenlex`, then :any:`StringRange.size_hint()` is used. If +:any:`StringRange.order()` is not :any:`Order.lenlex`, then a copy of the range may have to be looped over in order to find the return value of this function. :returns: The size of the range. @@ -807,7 +807,7 @@ Sets the order of the strings in a :any:`StringRange` object to *val*. :returns: *self*. :rtype: StringRange -:raises LibsemigroupsError: if *val* is not :any:`Order.shortlex` or :any:`Order.lex`. +:raises LibsemigroupsError: if *val* is not :any:`Order.lenlex` or :any:`Order.lex`. )pbdoc"); thing2.def("size_hint", &StringRange::size_hint, @@ -815,8 +815,8 @@ Sets the order of the strings in a :any:`StringRange` object to *val*. The possible size of the range. Returns the number of strings in a :any:`StringRange` object if -:any:`StringRange.order()` is :any:`Order.shortlex`. If :any:`StringRange.order()` is not -:any:`Order.shortlex`, then the return value of this function is meaningless. +:any:`StringRange.order()` is :any:`Order.lenlex`. If :any:`StringRange.order()` is not +:any:`Order.lenlex`, then the return value of this function is meaningless. :returns: A value of type ``int``. :rtype: int diff --git a/tests/test_knuth_bendix.py b/tests/test_knuth_bendix.py index 0adef14b..27811576 100644 --- a/tests/test_knuth_bendix.py +++ b/tests/test_knuth_bendix.py @@ -60,9 +60,9 @@ def test_initialisation(): kb2.run() with pytest.raises(TypeError): - KnuthBendix(kb, rewriting_system="Set", order=Order.shortlex) + KnuthBendix(kb, rewriting_system="Set", order=Order.lenlex) - kb = KnuthBendix(kind, p, rewriting_system="Set", order=Order.shortlex) + kb = KnuthBendix(kind, p, rewriting_system="Set", order=Order.lenlex) def test_attributes(): @@ -342,7 +342,7 @@ def test_rpo(): presentation.add_rule(p, "bbb", "") presentation.add_rule(p, "ababab", "") - kb = KnuthBendix(congruence_kind.twosided, p, order=Order.recursive) + kb = KnuthBendix(congruence_kind.twosided, p, order=Order.rpo) kb.run() assert list(kb.active_rules()) == [("bbb", ""), ("aa", ""), ("abb", "baba"), ("abab", "bba")] diff --git a/tests/test_paths.py b/tests/test_paths.py index f4a4ca44..9ac281c5 100644 --- a/tests/test_paths.py +++ b/tests/test_paths.py @@ -38,7 +38,7 @@ def test_001(): with pytest.raises(LibsemigroupsError): p.count() - assert p.order() == Order.shortlex + assert p.order() == Order.lenlex p.order(Order.lex) assert p.order() == Order.lex diff --git a/tests/test_sims.py b/tests/test_sims.py index e8b36623..e447c88c 100644 --- a/tests/test_sims.py +++ b/tests/test_sims.py @@ -43,7 +43,7 @@ def check_right_generating_pairs(s, wg): tc.add_generating_pair(u, v) tc.run() - tc.standardize(Order.shortlex) + tc.standardize(Order.lenlex) expected = tc.word_graph() result = wg.copy() @@ -59,7 +59,7 @@ def check_right_generating_pairs(s, wg): for u, v in sims.right_generating_pairs(s.presentation(), wg): tc.add_generating_pair(u, v) tc.run() - tc.standardize(Order.shortlex) + tc.standardize(Order.lenlex) expected = tc.word_graph() num = word_graph.number_of_nodes_reachable_from(result, 0) diff --git a/tests/test_to.py b/tests/test_to.py index 682020c1..0e14dd48 100644 --- a/tests/test_to.py +++ b/tests/test_to.py @@ -232,38 +232,34 @@ def check_froidure_pin_to_congruence(Word): def test_to_FroidurePin_000(): - fp = check_cong_to_froidure_pin(KnuthBendix, str, rewriting_system="Set", order=Order.shortlex) + fp = check_cong_to_froidure_pin(KnuthBendix, str, rewriting_system="Set", order=Order.lenlex) assert isinstance(to_cxx(fp), FroidurePinKBEStringLenLexSet) - fp = check_cong_to_froidure_pin(KnuthBendix, str, rewriting_system="Set", order=Order.recursive) + fp = check_cong_to_froidure_pin(KnuthBendix, str, rewriting_system="Set", order=Order.rpo) assert isinstance(to_cxx(fp), FroidurePinKBEStringRevRPOSet) def test_to_FroidurePin_001(): - fp = check_cong_to_froidure_pin(KnuthBendix, str, rewriting_system="Trie", order=Order.shortlex) + fp = check_cong_to_froidure_pin(KnuthBendix, str, rewriting_system="Trie", order=Order.lenlex) assert isinstance(to_cxx(fp), FroidurePinKBEStringLenLexTrie) - fp = check_cong_to_froidure_pin( - KnuthBendix, str, rewriting_system="Trie", order=Order.recursive - ) + fp = check_cong_to_froidure_pin(KnuthBendix, str, rewriting_system="Trie", order=Order.rpo) assert isinstance(to_cxx(fp), FroidurePinKBEStringRevRPOTrie) def test_to_FroidurePin_002(): - fp = check_cong_to_froidure_pin(KnuthBendix, int, rewriting_system="Set", order=Order.shortlex) + fp = check_cong_to_froidure_pin(KnuthBendix, int, rewriting_system="Set", order=Order.lenlex) assert isinstance(to_cxx(fp), FroidurePinKBEWordLenLexSet) - fp = check_cong_to_froidure_pin(KnuthBendix, int, rewriting_system="Set", order=Order.recursive) + fp = check_cong_to_froidure_pin(KnuthBendix, int, rewriting_system="Set", order=Order.rpo) assert isinstance(to_cxx(fp), FroidurePinKBEWordRevRPOSet) def test_to_FroidurePin_003(): - fp = check_cong_to_froidure_pin(KnuthBendix, int, rewriting_system="Trie", order=Order.shortlex) + fp = check_cong_to_froidure_pin(KnuthBendix, int, rewriting_system="Trie", order=Order.lenlex) assert isinstance(to_cxx(fp), FroidurePinKBEWordLenLexTrie) - fp = check_cong_to_froidure_pin( - KnuthBendix, int, rewriting_system="Trie", order=Order.recursive - ) + fp = check_cong_to_froidure_pin(KnuthBendix, int, rewriting_system="Trie", order=Order.rpo) assert isinstance(to_cxx(fp), FroidurePinKBEWordRevRPOTrie) @@ -375,45 +371,41 @@ def test_to_FroidurePin_013(): def test_to_ToddCoxeter_014(): - tc = check_cong_to_todd_coxeter(KnuthBendix, str, rewriting_system="Set", order=Order.shortlex) + tc = check_cong_to_todd_coxeter(KnuthBendix, str, rewriting_system="Set", order=Order.lenlex) assert isinstance(tc, ToddCoxeter) assert tc.py_template_params == (str,) - tc = check_cong_to_todd_coxeter(KnuthBendix, str, rewriting_system="Set", order=Order.recursive) + tc = check_cong_to_todd_coxeter(KnuthBendix, str, rewriting_system="Set", order=Order.rpo) assert isinstance(tc, ToddCoxeter) assert tc.py_template_params == (str,) def test_to_ToddCoxeter_015(): - tc = check_cong_to_todd_coxeter(KnuthBendix, str, rewriting_system="Trie", order=Order.shortlex) + tc = check_cong_to_todd_coxeter(KnuthBendix, str, rewriting_system="Trie", order=Order.lenlex) assert isinstance(tc, ToddCoxeter) assert tc.py_template_params == (str,) - tc = check_cong_to_todd_coxeter( - KnuthBendix, str, rewriting_system="Trie", order=Order.recursive - ) + tc = check_cong_to_todd_coxeter(KnuthBendix, str, rewriting_system="Trie", order=Order.rpo) assert isinstance(tc, ToddCoxeter) assert tc.py_template_params == (str,) def test_to_ToddCoxeter_016(): - tc = check_cong_to_todd_coxeter(KnuthBendix, int, rewriting_system="Set", order=Order.shortlex) + tc = check_cong_to_todd_coxeter(KnuthBendix, int, rewriting_system="Set", order=Order.lenlex) assert isinstance(tc, ToddCoxeter) assert tc.py_template_params == (list[int],) - tc = check_cong_to_todd_coxeter(KnuthBendix, int, rewriting_system="Set", order=Order.recursive) + tc = check_cong_to_todd_coxeter(KnuthBendix, int, rewriting_system="Set", order=Order.rpo) assert isinstance(tc, ToddCoxeter) assert tc.py_template_params == (list[int],) def test_to_ToddCoxeter_017(): - tc = check_cong_to_todd_coxeter(KnuthBendix, int, rewriting_system="Trie", order=Order.shortlex) + tc = check_cong_to_todd_coxeter(KnuthBendix, int, rewriting_system="Trie", order=Order.lenlex) assert isinstance(tc, ToddCoxeter) assert tc.py_template_params == (list[int],) - tc = check_cong_to_todd_coxeter( - KnuthBendix, int, rewriting_system="Trie", order=Order.recursive - ) + tc = check_cong_to_todd_coxeter(KnuthBendix, int, rewriting_system="Trie", order=Order.rpo) assert isinstance(tc, ToddCoxeter) assert tc.py_template_params == (list[int],) @@ -679,31 +671,31 @@ def test_to_Presentation_023(): def test_to_Presentation_024(): - check_knuth_bendix_to_pres(str, str, "Set", Order.shortlex) - check_knuth_bendix_to_pres(str, list[int], "Set", Order.shortlex) - check_knuth_bendix_to_pres(str, str, "Set", Order.recursive) - check_knuth_bendix_to_pres(str, list[int], "Set", Order.recursive) + check_knuth_bendix_to_pres(str, str, "Set", Order.lenlex) + check_knuth_bendix_to_pres(str, list[int], "Set", Order.lenlex) + check_knuth_bendix_to_pres(str, str, "Set", Order.rpo) + check_knuth_bendix_to_pres(str, list[int], "Set", Order.rpo) def test_to_Presentation_025(): - check_knuth_bendix_to_pres(str, str, "Trie", Order.shortlex) - check_knuth_bendix_to_pres(str, list[int], "Trie", Order.shortlex) - check_knuth_bendix_to_pres(str, str, "Trie", Order.recursive) - check_knuth_bendix_to_pres(str, list[int], "Trie", Order.recursive) + check_knuth_bendix_to_pres(str, str, "Trie", Order.lenlex) + check_knuth_bendix_to_pres(str, list[int], "Trie", Order.lenlex) + check_knuth_bendix_to_pres(str, str, "Trie", Order.rpo) + check_knuth_bendix_to_pres(str, list[int], "Trie", Order.rpo) def test_to_Presentation_026(): - check_knuth_bendix_to_pres(list[int], str, "Set", Order.shortlex) - check_knuth_bendix_to_pres(list[int], list[int], "Set", Order.shortlex) - check_knuth_bendix_to_pres(list[int], str, "Set", Order.recursive) - check_knuth_bendix_to_pres(list[int], list[int], "Set", Order.recursive) + check_knuth_bendix_to_pres(list[int], str, "Set", Order.lenlex) + check_knuth_bendix_to_pres(list[int], list[int], "Set", Order.lenlex) + check_knuth_bendix_to_pres(list[int], str, "Set", Order.rpo) + check_knuth_bendix_to_pres(list[int], list[int], "Set", Order.rpo) def test_to_Presentation_027(): - check_knuth_bendix_to_pres(list[int], str, "Trie", Order.shortlex) - check_knuth_bendix_to_pres(list[int], list[int], "Trie", Order.shortlex) - check_knuth_bendix_to_pres(list[int], str, "Trie", Order.recursive) - check_knuth_bendix_to_pres(list[int], list[int], "Trie", Order.recursive) + check_knuth_bendix_to_pres(list[int], str, "Trie", Order.lenlex) + check_knuth_bendix_to_pres(list[int], list[int], "Trie", Order.lenlex) + check_knuth_bendix_to_pres(list[int], str, "Trie", Order.rpo) + check_knuth_bendix_to_pres(list[int], list[int], "Trie", Order.rpo) # From FroidurePin @@ -884,74 +876,74 @@ def test_to_InversePresentation_048(): def test_to_KnuthBendix_049(): - kb = check_froidure_pin_to_knuth_bendix(str, "Set", Order.shortlex) + kb = check_froidure_pin_to_knuth_bendix(str, "Set", Order.lenlex) assert isinstance(kb, KnuthBendix) - assert kb.py_template_params == (str, "Set", Order.shortlex) + assert kb.py_template_params == (str, "Set", Order.lenlex) - kb = check_froidure_pin_to_knuth_bendix(str, "Set", Order.recursive) + kb = check_froidure_pin_to_knuth_bendix(str, "Set", Order.rpo) assert isinstance(kb, KnuthBendix) - assert kb.py_template_params == (str, "Set", Order.recursive) + assert kb.py_template_params == (str, "Set", Order.rpo) def test_to_KnuthBendix_050(): - kb = check_froidure_pin_to_knuth_bendix(str, "Trie", Order.shortlex) + kb = check_froidure_pin_to_knuth_bendix(str, "Trie", Order.lenlex) assert isinstance(kb, KnuthBendix) - kb = check_froidure_pin_to_knuth_bendix(str, "Trie", Order.recursive) + kb = check_froidure_pin_to_knuth_bendix(str, "Trie", Order.rpo) assert isinstance(kb, KnuthBendix) - assert kb.py_template_params == (str, "Trie", Order.recursive) + assert kb.py_template_params == (str, "Trie", Order.rpo) def test_to_KnuthBendix_051(): - kb = check_froidure_pin_to_knuth_bendix(list[int], "Set", Order.shortlex) + kb = check_froidure_pin_to_knuth_bendix(list[int], "Set", Order.lenlex) assert isinstance(kb, KnuthBendix) - kb = check_froidure_pin_to_knuth_bendix(list[int], "Set", Order.recursive) + kb = check_froidure_pin_to_knuth_bendix(list[int], "Set", Order.rpo) assert isinstance(kb, KnuthBendix) - assert kb.py_template_params == (list[int], "Set", Order.recursive) + assert kb.py_template_params == (list[int], "Set", Order.rpo) def test_to_KnuthBendix_052(): - kb = check_froidure_pin_to_knuth_bendix(list[int], "Trie", Order.shortlex) + kb = check_froidure_pin_to_knuth_bendix(list[int], "Trie", Order.lenlex) assert isinstance(kb, KnuthBendix) - kb = check_froidure_pin_to_knuth_bendix(list[int], "Trie", Order.recursive) + kb = check_froidure_pin_to_knuth_bendix(list[int], "Trie", Order.rpo) assert isinstance(kb, KnuthBendix) - assert kb.py_template_params == (list[int], "Trie", Order.recursive) + assert kb.py_template_params == (list[int], "Trie", Order.rpo) # From ToddCoxeter + Rewriter def test_to_KnuthBendix_053(): - kb = check_todd_coxeter_to_knuth_bendix(str, "Set", Order.shortlex) + kb = check_todd_coxeter_to_knuth_bendix(str, "Set", Order.lenlex) assert isinstance(kb, KnuthBendix) - kb = check_todd_coxeter_to_knuth_bendix(str, "Set", Order.recursive) + kb = check_todd_coxeter_to_knuth_bendix(str, "Set", Order.rpo) assert isinstance(kb, KnuthBendix) def test_to_KnuthBendix_054(): - kb = check_todd_coxeter_to_knuth_bendix(str, "Trie", Order.shortlex) + kb = check_todd_coxeter_to_knuth_bendix(str, "Trie", Order.lenlex) assert isinstance(kb, KnuthBendix) - kb = check_todd_coxeter_to_knuth_bendix(str, "Trie", Order.recursive) + kb = check_todd_coxeter_to_knuth_bendix(str, "Trie", Order.rpo) assert isinstance(kb, KnuthBendix) def test_to_KnuthBendix_055(): - kb = check_todd_coxeter_to_knuth_bendix(list[int], "Set", Order.shortlex) + kb = check_todd_coxeter_to_knuth_bendix(list[int], "Set", Order.lenlex) assert isinstance(kb, KnuthBendix) - kb = check_todd_coxeter_to_knuth_bendix(list[int], "Set", Order.recursive) + kb = check_todd_coxeter_to_knuth_bendix(list[int], "Set", Order.rpo) assert isinstance(kb, KnuthBendix) def test_to_KnuthBendix_056(): - kb = check_todd_coxeter_to_knuth_bendix(list[int], "Trie", Order.shortlex) + kb = check_todd_coxeter_to_knuth_bendix(list[int], "Trie", Order.lenlex) assert isinstance(kb, KnuthBendix) - kb = check_todd_coxeter_to_knuth_bendix(list[int], "Trie", Order.recursive) + kb = check_todd_coxeter_to_knuth_bendix(list[int], "Trie", Order.rpo) assert isinstance(kb, KnuthBendix) diff --git a/tests/test_todd_coxeter.py b/tests/test_todd_coxeter.py index 2c9d74cb..3bd860b3 100644 --- a/tests/test_todd_coxeter.py +++ b/tests/test_todd_coxeter.py @@ -160,8 +160,8 @@ def test_settings(): assert not tc.is_standardized() tc.standardize(Order.lex) assert tc.is_standardized() - tc.standardize(Order.shortlex) - tc.standardize(Order.recursive) + tc.standardize(Order.lenlex) + tc.standardize(Order.rpo) with pytest.raises(TypeError): tc.standardize("shooortlex") @@ -332,7 +332,7 @@ def test_current_word_of(): tc.run_for(timedelta(seconds=0.01)) assert not tc.finished() wg = tc.current_word_graph() - tc.standardize(Order.shortlex) + tc.standardize(Order.lenlex) assert tc.current_word_graph() is wg tree = tc.current_spanning_tree() for n in range(tree.number_of_nodes()): diff --git a/tests/test_word_graph.py b/tests/test_word_graph.py index 669ac03c..4ad31a43 100644 --- a/tests/test_word_graph.py +++ b/tests/test_word_graph.py @@ -243,7 +243,7 @@ def test_spanning_tree(word_graphs): def test_standardize(word_graphs): wg1, _ = word_graphs f = Forest(0) - assert not word_graph.standardize(wg1, f, Order.shortlex) + assert not word_graph.standardize(wg1, f, Order.lenlex) assert f == word_graph.spanning_tree(wg1, 0) changed, f = word_graph.standardize(wg1, Order.lex) assert not changed diff --git a/tests/test_word_range.py b/tests/test_word_range.py index 62b9b372..f4a839ec 100644 --- a/tests/test_word_range.py +++ b/tests/test_word_range.py @@ -81,7 +81,7 @@ def test_range_lex(): assert sr.at_end() -def test_range_shortlex(): +def test_range_lenlex(): wr, sr = WordRange(), StringRange() wr.alphabet_size(4).min(2).max(10) sr.alphabet("abcd").min(2).max(10) @@ -112,7 +112,7 @@ def test_init(): assert sr.last() == "" assert wr.first() == [] assert wr.last() == [] - assert sr.order() == wr.order() == Order.shortlex + assert sr.order() == wr.order() == Order.lenlex assert sr.upper_bound() == wr.upper_bound() == 0 @@ -338,7 +338,7 @@ def test_ranges_return_policy(): assert r.init() is r assert r.max(2) is r assert r.min(2) is r - assert r.order(Order.shortlex) is r + assert r.order(Order.lenlex) is r assert r.upper_bound(10) is r r = WordRange()