Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/source/data-structures/presentations/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ semigroup or monoid they define.
.. autosummary::
:signatures: short

abacus_jones_monoid
alternating_group
braid_group
brauer_monoid
chinese_monoid
cyclic_inverse_monoid
Expand Down Expand Up @@ -75,6 +77,7 @@ documented in the :ref:`default-presentations` section.
.. autosummary::
:signatures: short

abacus_jones_monoid_AJP25
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should probably also be a braid_group_Bir05, but that's an issue for libsemigruops

alternating_group_Moo97
brauer_monoid_KM07
chinese_monoid_CEKNH01
Expand Down
26 changes: 20 additions & 6 deletions docs/source/libsemigroups.bib
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
%% This BibTeX bibliography file was created using BibDesk.
%% https://bibdesk.sourceforge.io/

%% Created for James Mitchell at 2024-02-01 14:50:47 +0000

@inbook{Birman2005aa,
title = {Braids},
ISBN = {9780444514523},
url = {http://dx.doi.org/10.1016/B978-044451452-3/50003-4},
DOI = {10.1016/b978-044451452-3/50003-4},
booktitle = {Handbook of Knot Theory},
publisher = {Elsevier},
author = {Birman, Joan S. and Brendle, Tara E.},
year = {2005},
pages = {19–103}
}

%% Saved with string encoding Unicode (UTF-8)
@misc{Aicardi2025aa,
title={Framization and Deframization},
author={Francesca Aicardi and Jesús Juyumaya and Paolo Papi},
year={2025},
eprint={2405.10809},
archivePrefix={arXiv},
primaryClass={math.RA},
url={https://arxiv.org/abs/2405.10809},
}

@misc{Guennebaud2010aa,
author = {Ga\"{e}l Guennebaud and Beno\^{i}t Jacob and others},
Expand Down
17 changes: 6 additions & 11 deletions etc/check_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@


def __parse_args():
parser = argparse.ArgumentParser(
prog="check_sync.py", usage="%(prog)s [options]"
)
parser = argparse.ArgumentParser(prog="check_sync.py", usage="%(prog)s [options]")
parser.add_argument(
"things",
nargs="+",
Expand Down Expand Up @@ -219,8 +217,9 @@ def _regex_pattern(args, thing: str, fn: str) -> str:
cxx_fn = fn[:]
fn = translate_to_py(fn)
if is_namespace(args, thing):
namespace = thing.split(":")[-1]
pattern = f"(){namespace}_{fn}"
namespace = thing.split("::")
namespace = namespace[1:]
pattern = f"(){'_'.join(namespace)}_{fn}"
else:
pattern = rf"(\w*){fn}"
if not is_operator(args, thing, cxx_fn):
Expand All @@ -243,9 +242,7 @@ def find_in_cpp(args, thing: str, fn: str, info: dict) -> bool:
lines = "\n".join(_strip_cxx_comments(lines))
matches = [x for x in re.finditer(pattern, lines, re.DOTALL)]
if len(matches) == 0:
console.print(
f":x: [bright_red]{thing}::{fn} not found![/bright_red]"
)
console.print(f":x: [bright_red]{thing}::{fn} not found![/bright_red]")
return

for match in matches:
Expand Down Expand Up @@ -290,9 +287,7 @@ def check_thing(args, thing: str) -> None:

def main():
if not os.getcwd().endswith("libsemigroups_pybind11"):
raise Exception(
"This script must be run in the libsemigroups_pybind11 directory!"
)
raise Exception("This script must be run in the libsemigroups_pybind11 directory!")
args = __parse_args()
for thing in args.things:
check_thing(args, thing)
Expand Down
6 changes: 6 additions & 0 deletions src/libsemigroups_pybind11/presentation/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@
"""

from _libsemigroups_pybind11 import ( # pylint: disable=no-name-in-module
presentation_examples_abacus_jones_monoid as _abacus_jones_monoid,
presentation_examples_abacus_jones_monoid_AJP25 as _abacus_jones_monoid_AJP25,
presentation_examples_alternating_group as _alternating_group,
presentation_examples_alternating_group_Moo97 as _alternating_group_Moo97,
presentation_examples_braid_group as _braid_group,
presentation_examples_brauer_monoid as _brauer_monoid,
presentation_examples_brauer_monoid_KM07 as _brauer_monoid_KM07,
presentation_examples_chinese_monoid as _chinese_monoid,
Expand Down Expand Up @@ -101,9 +104,12 @@
wrap_cxx_free_fn as _wrap_cxx_free_fn,
)

abacus_jones_monoid = _wrap_cxx_free_fn(_abacus_jones_monoid)
abacus_jones_monoid_AJP25 = _wrap_cxx_free_fn(_abacus_jones_monoid_AJP25)
alternating_group = _wrap_cxx_free_fn(_alternating_group)
alternating_group_Moo97 = _wrap_cxx_free_fn(_alternating_group_Moo97)
brauer_monoid = _wrap_cxx_free_fn(_brauer_monoid)
braid_group = _wrap_cxx_free_fn(_braid_group)
brauer_monoid_KM07 = _wrap_cxx_free_fn(_brauer_monoid_KM07)
chinese_monoid = _wrap_cxx_free_fn(_chinese_monoid)
chinese_monoid_CEKNH01 = _wrap_cxx_free_fn(_chinese_monoid_CEKNH01)
Expand Down
86 changes: 86 additions & 0 deletions src/presentation-examples.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ generators, as in Theorem 4.39 of :cite:`Gay1999aa`.

:raises LibsemigroupsError: if ``l < 2``.
)pbdoc");

m.def("presentation_examples_dual_symmetric_inverse_monoid_EEF07",
&examples::dual_symmetric_inverse_monoid_EEF07,
py::arg("n"),
Expand Down Expand Up @@ -1701,6 +1702,7 @@ includes the rules from :any:`plactic_monoid_Knu70`.
alternating group is required, but the specific presentation
is not important.
)pbdoc");

m.def("presentation_examples_sigma_plactic_monoid",
&examples::sigma_plactic_monoid,
py::arg("sigma"),
Expand All @@ -1724,6 +1726,7 @@ and is given in :any:`stylic_monoid`.
:returns: The specified presentation.
:rtype: Presentation
)pbdoc");

m.def("presentation_examples_zero_rook_monoid",
&examples::zero_rook_monoid,
py::arg("n"),
Expand Down Expand Up @@ -1849,6 +1852,7 @@ When ``q == 1``, this corresponds to Theorem 8.4.43 of :cite:`Gay2018aa`.
alternating group is required, but the specific presentation
is not important.
)pbdoc");

m.def("presentation_examples_not_renner_type_D_monoid",
&examples::not_renner_type_D_monoid,
py::arg("l"),
Expand Down Expand Up @@ -1879,6 +1883,88 @@ When ``q == 1``, this corresponds to Section 3.3 of :cite:`Godelle2009aa`.
and exists as a convenience function for when a presentation for the
alternating group is required, but the specific presentation
is not important.
)pbdoc");

m.def("presentation_examples_abacus_jones_monoid",
&presentation::examples::abacus_jones_monoid,
py::arg("n"),
py::arg("d"),
R"pbdoc(
:sig=(n: int, d: int) -> Presentation:

A presentation for the abacus Jones monoid.

This function returns a monoid presentation defining the abacus Jones monoid of
degree *n*; as defined in Proposition 3.2 of :cite:`Aicardi2025aa`. The
abacus Jones monoid is formed by the diagrams of the Jones monoid
(aka the Temperley-Lieb monoid) whose arcs have at most ``d − 1``
beads sliding on each arc. This presentation has :math:`2n - 1`
generators, :math:`5n ^ 2 - 5n + 2 + 2(n - 1)(d - 1)` relations, and
defines a monoid of size :math:`C_n\ d ^n` where :math:`C_n` is the
:math:`n`-th Catalan number :math:`\frac{1}{n + 1}\binom{2n}{n}`.

:param n: the degree.
:type n: int

:param d: one more than the maximum number of beads on each arc of the abacus.
:type d: int

:returns: The specified presentation.
:rtype: Presentation

:raises LibsemigroupsError: if ``n < 3`` or if ``d = 0``.

.. seealso:: :any:`abacus_jones_monoid_AJP25`.
)pbdoc");

m.def("presentation_examples_abacus_jones_monoid_AJP25",
&presentation::examples::abacus_jones_monoid_AJP25,
py::arg("n"),
py::arg("d"),
R"pbdoc(
:sig=(n: int, d: int) -> Presentation:

A presentation for the abacus Jones monoid.

This function returns a monoid presentation defining the abacus Jones monoid of
degree *n*; as defined in Proposition 3.2 of :cite:`Aicardi2025aa`. The
abacus Jones monoid is formed by the diagrams of the Jones monoid
(aka the Temperley-Lieb monoid) whose arcs have at most ``d − 1``
beads sliding on each arc. This presentation has :math:`2n - 1`
generators, :math:`5n ^ 2 - 5n + 2 + 2(n - 1)(d - 1)` relations, and
defines a monoid of size :math:`C_n\ d ^n` where :math:`C_n` is the
:math:`n`-th Catalan number :math:`\frac{1}{n + 1}\binom{2n}{n}`.

:param n: the degree.
:type n: int

:param d: one more than the maximum number of beads on each arc of the abacus.
:type d: int

:returns: The specified presentation.
:rtype: Presentation

:raises LibsemigroupsError: if ``n < 3`` or if ``d = 0``.
)pbdoc");

m.def("presentation_examples_braid_group",
&presentation::examples::braid_group,
py::arg("n"),
R"pbdoc(
:sig=(n: int) -> Presentation:

A presentation for the Braid group.

This function returns a monoid presentation defining the Braid group with
:math:`n - 1` generators, as described in Equation (2) of :any:`Birman2005aa`.

:param n: the degree, or equivalently the number of generators plus 1.
:type n: int

:returns: The specified presentation.
:rtype: Presentation

:raises LibsemigroupsError: if ``n < 3``.
)pbdoc");
} // init_presentation_examples

Expand Down
38 changes: 38 additions & 0 deletions tests/test_presentation_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
congruence_kind,
LibsemigroupsError,
ReportGuard,
POSITIVE_INFINITY,
)

from libsemigroups_pybind11.presentation import examples
Expand Down Expand Up @@ -391,3 +392,40 @@ def test_orientation_preserving_reversing_monoid_AR00():
p = examples.orientation_preserving_reversing_monoid_AR00(5)
tc = ToddCoxeter(congruence_kind.twosided, p)
assert tc.number_of_classes() == 1015


def test_abacus_jones():
ReportGuard(False)
with pytest.raises(LibsemigroupsError):
examples.abacus_jones_monoid(0, 1)
with pytest.raises(LibsemigroupsError):
examples.abacus_jones_monoid(1, 1)
with pytest.raises(LibsemigroupsError):
examples.abacus_jones_monoid(2, 1)
with pytest.raises(LibsemigroupsError):
examples.abacus_jones_monoid(3, 0)

p = examples.abacus_jones_monoid(3, 2)
tc = ToddCoxeter(congruence_kind.twosided, p)
assert tc.number_of_classes() == 40
assert tc.number_of_classes() == 5 * 2**3

p = examples.abacus_jones_monoid_AJP25(3, 2)
tc = ToddCoxeter(congruence_kind.twosided, p)
assert tc.number_of_classes() == 40
assert tc.number_of_classes() == 5 * 2**3


def test_braid_group():
ReportGuard(False)
with pytest.raises(LibsemigroupsError):
examples.braid_group(0)
with pytest.raises(LibsemigroupsError):
examples.braid_group(1)
with pytest.raises(LibsemigroupsError):
examples.braid_group(2)

p = examples.braid_group(3)
assert len(p.alphabet()) == 4
tc = ToddCoxeter(congruence_kind.twosided, p)
assert tc.number_of_classes() == POSITIVE_INFINITY
Loading