From 1e668592e5aed7713848f923da80cd643d4c0a66 Mon Sep 17 00:00:00 2001 From: Wilf Wilson Date: Wed, 10 Sep 2025 23:06:19 +0100 Subject: [PATCH 1/8] CI: add a Valgrind workflow --- .github/workflows/valgrind.yml | 57 ++++++++++++++++++++++++++++++++++ tst/github_actions/examples.g | 7 +++++ tst/github_actions/extreme.g | 7 +++++ tst/github_actions/install.g | 7 +++++ tst/github_actions/standard.g | 7 +++++ 5 files changed, 85 insertions(+) create mode 100644 .github/workflows/valgrind.yml create mode 100644 tst/github_actions/examples.g create mode 100644 tst/github_actions/extreme.g create mode 100644 tst/github_actions/install.g create mode 100644 tst/github_actions/standard.g diff --git a/.github/workflows/valgrind.yml b/.github/workflows/valgrind.yml new file mode 100644 index 000000000..9067b5cd0 --- /dev/null +++ b/.github/workflows/valgrind.yml @@ -0,0 +1,57 @@ +name: Valgrind +on: + workflow_dispatch: + release: + types: [created] + push: + branches: + - rc-v* + pull_request: + paths: + - src/*.[hc]pp + +concurrency: + # Group by workflow and ref; the last component ensures that for pull + # requests, we limit to 1 concurrent job, but for the main branch we don't + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.ref != 'refs/heads/main' || github.run_number }} + # Only cancel intermediate pull request builds + cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} + +jobs: + test-valgrind: + name: "Ubuntu / GAP stable-4.15 / valgrind" + runs-on: ubuntu-latest + env: + NO_COVERAGE: true + VALGRIND: valgrind --trace-children=yes --leak-check=full --error-exitcode=1 + steps: + - uses: actions/checkout@v5 + - name: "Output g++ version . . ." + run: g++ --version + - name: "Install Valgrind . . ." + run: sudo apt-get install valgrind + - name: "Install GAP . . ." + uses: gap-actions/setup-gap@v3 + with: + gap-version: stable-4.15 + configflags: --enable-valgrind + - name: "Build additional necessary GAP packages . . ." + run: | + cd ${GAPROOT}/pkg + ../bin/BuildPackages.sh --strict digraphs* io* orb* datastructures* profiling* + - name: "Build Semigroups . . ." + uses: gap-actions/build-pkg@v2 + with: + CONFIGFLAGS: --disable-hpcombi + - name: "Run SemigroupsTestInstall . . ." + uses: gap-actions/run-pkg-tests@v4 + with: + testfile: tst/github_actions/install.g + pre-gap: ${{ env.VALGRIND }} + coverage: false + - name: "Run SemigroupsTestStandard . . ." + uses: gap-actions/run-pkg-tests@v4 + with: + testfile: tst/github_actions/standard.g + pre-gap: ${{ env.VALGRIND }} + coverage: false diff --git a/tst/github_actions/examples.g b/tst/github_actions/examples.g new file mode 100644 index 000000000..7f2d5ba66 --- /dev/null +++ b/tst/github_actions/examples.g @@ -0,0 +1,7 @@ +LoadPackage("semigroups", false);; +if SEMIGROUPS.TestManualExamples() then + QUIT_GAP(0); +else + QUIT_GAP(1); +fi; +FORCE_QUIT_GAP(1); diff --git a/tst/github_actions/extreme.g b/tst/github_actions/extreme.g new file mode 100644 index 000000000..b2ea88290 --- /dev/null +++ b/tst/github_actions/extreme.g @@ -0,0 +1,7 @@ +LoadPackage("semigroups", false);; +if SemigroupsTestExtreme(rec(earlyStop := false)) then + QUIT_GAP(0); +else + QUIT_GAP(1); +fi; +FORCE_QUIT_GAP(1); diff --git a/tst/github_actions/install.g b/tst/github_actions/install.g new file mode 100644 index 000000000..7456be72d --- /dev/null +++ b/tst/github_actions/install.g @@ -0,0 +1,7 @@ +LoadPackage("semigroups", false);; +if SemigroupsTestInstall() then + QUIT_GAP(0); +else + QUIT_GAP(1); +fi; +FORCE_QUIT_GAP(1); diff --git a/tst/github_actions/standard.g b/tst/github_actions/standard.g new file mode 100644 index 000000000..ab13b5d1d --- /dev/null +++ b/tst/github_actions/standard.g @@ -0,0 +1,7 @@ +LoadPackage("semigroups", false);; +if SemigroupsTestStandard(rec(earlyStop := false)) then + QUIT_GAP(0); +else + QUIT_GAP(1); +fi; +FORCE_QUIT_GAP(1); From 75b67f45a967fa9d08acd2b2c7d85cfa558aadff Mon Sep 17 00:00:00 2001 From: Wilf Wilson Date: Mon, 15 Sep 2025 19:32:53 +0100 Subject: [PATCH 2/8] Update copyright years in src/*.[ch]pp --- src/bipart.cpp | 2 +- src/bipart.hpp | 2 +- src/cong.cpp | 146 +++++++++++++++++++++++++ src/conglatt.cpp | 2 +- src/conglatt.hpp | 2 +- src/froidure-pin-fallback.cpp | 2 +- src/froidure-pin-fallback.hpp | 2 +- src/init-froidure-pin-base.cpp | 2 +- src/init-froidure-pin-bipart.cpp | 2 +- src/init-froidure-pin-bmat.cpp | 2 +- src/init-froidure-pin-matrix.cpp | 2 +- src/init-froidure-pin-max-plus-mat.cpp | 2 +- src/init-froidure-pin-min-plus-mat.cpp | 2 +- src/init-froidure-pin-pbr.cpp | 2 +- src/init-froidure-pin-pperm.cpp | 2 +- src/init-froidure-pin-transf.cpp | 2 +- src/init-froidure-pin.hpp | 2 +- src/pkg.hpp | 2 +- src/semigroups-debug.hpp | 2 +- src/to-cpp.hpp | 2 +- src/to-gap.cpp | 2 +- src/to-gap.hpp | 2 +- 22 files changed, 167 insertions(+), 21 deletions(-) create mode 100644 src/cong.cpp diff --git a/src/bipart.cpp b/src/bipart.cpp index 52d4b7d98..f1888c1eb 100644 --- a/src/bipart.cpp +++ b/src/bipart.cpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 2016 James D. Mitchell +// Copyright (C) 2016-2025 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/bipart.hpp b/src/bipart.hpp index 44a52236a..9b0e69b3a 100644 --- a/src/bipart.hpp +++ b/src/bipart.hpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 2016 James D. Mitchell +// Copyright (C) 2016-2025 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/cong.cpp b/src/cong.cpp new file mode 100644 index 000000000..4b11bc825 --- /dev/null +++ b/src/cong.cpp @@ -0,0 +1,146 @@ +// +// Semigroups package for GAP +// Copyright (C) 2021-2025 James D. Mitchell +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +#include "cong.hpp" + +#include // for exception +#include // for shared_ptr +#include // for true_type +#include // for vector + +// Semigroups GAP package headers +#include "froidure-pin.hpp" // for to_cpp +#include "pkg.hpp" // for IsGapBind14Type +#include "to_cpp.hpp" // for to_cpp +#include "to_gap.hpp" // for to_gap + +// GAP headers +#include "gap_all.h" // for UInt2, UInt4 + +// GapBind14 headers +#include "gapbind14/gapbind14.hpp" // for class_ etc + +// libsemigroups headers +#include "libsemigroups/bipart.hpp" // for Bipartition +#include "libsemigroups/cong-intf.hpp" // for congruence_kind +#include "libsemigroups/cong.hpp" // for Congruence +#include "libsemigroups/constants.hpp" // for UNDEFINED etc +#include "libsemigroups/froidure-pin.hpp" // for FroidurePin +#include "libsemigroups/matrix.hpp" // for BMat etc +#include "libsemigroups/todd-coxeter.hpp" // for ToddCoxeter +#include "libsemigroups/transf.hpp" // for PPerm etc +#include "libsemigroups/types.hpp" // for word_type + +// Forward decls +namespace libsemigroups { + class FpSemigroup; + class PBR; +} // namespace libsemigroups + +namespace gapbind14 { + template <> + struct IsGapBind14Type : std::true_type {}; + +} // namespace gapbind14 + +//////////////////////////////////////////////////////////////////////// +// Congruence +//////////////////////////////////////////////////////////////////////// + +using gapbind14::overload_cast; + +void init_cong(gapbind14::Module& m) { + using libsemigroups::Congruence; + using libsemigroups::congruence_kind; + using libsemigroups::FpSemigroup; + using libsemigroups::FroidurePin; + using libsemigroups::FroidurePinBase; + using libsemigroups::word_type; + + using libsemigroups::Bipartition; + using libsemigroups::BMat; + using libsemigroups::IntMat; + using libsemigroups::LeastPPerm; + using libsemigroups::LeastTransf; + using libsemigroups::MaxPlusMat; + using libsemigroups::MaxPlusTruncMat; + using libsemigroups::MinPlusMat; + using libsemigroups::MinPlusTruncMat; + using libsemigroups::NTPMat; + using libsemigroups::PBR; + using libsemigroups::PPerm; + using libsemigroups::ProjMaxPlusMat; + using libsemigroups::Transf; + + // Cannot use FroidurePinBase rather than the specialisations because there's + // no constructor for a Congruence from a FroidurePinBase&. + gapbind14::class_("Congruence") + .def(gapbind14::init const&>{}, + "make_from_froidurepin_bipartition") + .def(gapbind14::init> const&>{}, + "make_from_froidurepin_bmat") + .def(gapbind14::init const&>{}, + "make_from_froidurepin_bmat8") + .def(gapbind14::init const&>{}, + "make_from_froidurepin_pbr") +#ifdef LIBSEMIGROUPS_HPCOMBI_ENABLED + .def(gapbind14::init> const&>{}, + "make_from_froidurepin_leastpperm") + .def(gapbind14::init> const&>{}, + "make_from_froidurepin_leasttransf") +#endif + .def(gapbind14::init> const&>{}, + "make_from_froidurepin_transfUInt2") + .def(gapbind14::init> const&>{}, + "make_from_froidurepin_transfUInt4") + .def(gapbind14::init> const&>{}, + "make_from_froidurepin_ppermUInt2") + .def(gapbind14::init> const&>{}, + "make_from_froidurepin_ppermUInt4") + .def(gapbind14::init{}, + "make_from_fpsemigroup") + .def(gapbind14::init>{}, + "make_from_froidurepinbase") + .def(gapbind14::init{}, + "make_from_table") + .def("set_number_of_generators", &Congruence::set_number_of_generators) + .def("number_of_pairs", &Congruence::number_of_generating_pairs) + .def("add_pair", + overload_cast( + &Congruence::add_pair)) + .def("number_of_classes", &Congruence::number_of_classes) + .def("word_to_class_index", &Congruence::word_to_class_index) + .def("class_index_to_word", &Congruence::class_index_to_word) + .def("contains", &Congruence::contains) + .def("less", &Congruence::less) + .def("add_runner", + &Congruence::add_runner) + .def("is_quotient_obviously_infinite", + &Congruence::is_quotient_obviously_infinite) + .def("ntc", + [](Congruence& C) { + return gapbind14::make_iterator(C.cbegin_ntc(), C.cend_ntc()); + }) + .def("quotient_froidure_pin", &Congruence::quotient_froidure_pin); +} diff --git a/src/conglatt.cpp b/src/conglatt.cpp index ef1ada48a..dca2d6ca8 100644 --- a/src/conglatt.cpp +++ b/src/conglatt.cpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 2022 James D. Mitchell +// Copyright (C) 2022-2025 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/conglatt.hpp b/src/conglatt.hpp index 4614c27df..83fa65399 100644 --- a/src/conglatt.hpp +++ b/src/conglatt.hpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 2022 James D. Mitchell +// Copyright (C) 20222-2025 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/froidure-pin-fallback.cpp b/src/froidure-pin-fallback.cpp index a7b5e0f0d..4856be0fe 100644 --- a/src/froidure-pin-fallback.cpp +++ b/src/froidure-pin-fallback.cpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 2016-2022 James D. Mitchell +// Copyright (C) 2016-2025 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/froidure-pin-fallback.hpp b/src/froidure-pin-fallback.hpp index 8981f5f99..3f1df13bf 100644 --- a/src/froidure-pin-fallback.hpp +++ b/src/froidure-pin-fallback.hpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 2016-2022 James D. Mitchell +// Copyright (C) 2016-2025 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/init-froidure-pin-base.cpp b/src/init-froidure-pin-base.cpp index 83f9b418f..56424bf58 100644 --- a/src/init-froidure-pin-base.cpp +++ b/src/init-froidure-pin-base.cpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 2022 James D. Mitchell +// Copyright (C) 2022-2025 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/init-froidure-pin-bipart.cpp b/src/init-froidure-pin-bipart.cpp index 05995012c..c863e01c8 100644 --- a/src/init-froidure-pin-bipart.cpp +++ b/src/init-froidure-pin-bipart.cpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 2021 James D. Mitchell +// Copyright (C) 2021-2025 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/init-froidure-pin-bmat.cpp b/src/init-froidure-pin-bmat.cpp index f1dc38c13..99954e5e3 100644 --- a/src/init-froidure-pin-bmat.cpp +++ b/src/init-froidure-pin-bmat.cpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 2021 James D. Mitchell +// Copyright (C) 2021-2025 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/init-froidure-pin-matrix.cpp b/src/init-froidure-pin-matrix.cpp index 86f497eb9..959ec7818 100644 --- a/src/init-froidure-pin-matrix.cpp +++ b/src/init-froidure-pin-matrix.cpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 2021 James D. Mitchell +// Copyright (C) 2021-2025 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/init-froidure-pin-max-plus-mat.cpp b/src/init-froidure-pin-max-plus-mat.cpp index a877d4421..601adfad6 100644 --- a/src/init-froidure-pin-max-plus-mat.cpp +++ b/src/init-froidure-pin-max-plus-mat.cpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 2021 James D. Mitchell +// Copyright (C) 2021-2025 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/init-froidure-pin-min-plus-mat.cpp b/src/init-froidure-pin-min-plus-mat.cpp index 9346d367d..513020a31 100644 --- a/src/init-froidure-pin-min-plus-mat.cpp +++ b/src/init-froidure-pin-min-plus-mat.cpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 2021 James D. Mitchell +// Copyright (C) 2021-2025 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/init-froidure-pin-pbr.cpp b/src/init-froidure-pin-pbr.cpp index 9c79e2fc6..5c5b6925a 100644 --- a/src/init-froidure-pin-pbr.cpp +++ b/src/init-froidure-pin-pbr.cpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 2021 James D. Mitchell +// Copyright (C) 2021-2025 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/init-froidure-pin-pperm.cpp b/src/init-froidure-pin-pperm.cpp index 39d2e585a..2507fe78c 100644 --- a/src/init-froidure-pin-pperm.cpp +++ b/src/init-froidure-pin-pperm.cpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 2021 James D. Mitchell +// Copyright (C) 2021-2025 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/init-froidure-pin-transf.cpp b/src/init-froidure-pin-transf.cpp index 933a19a60..b681f953a 100644 --- a/src/init-froidure-pin-transf.cpp +++ b/src/init-froidure-pin-transf.cpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 2021 James D. Mitchell +// Copyright (C) 2021-2025 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/init-froidure-pin.hpp b/src/init-froidure-pin.hpp index 3c7f53781..713ac284a 100644 --- a/src/init-froidure-pin.hpp +++ b/src/init-froidure-pin.hpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 2021 James D. Mitchell +// Copyright (C) 2021-2025 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/pkg.hpp b/src/pkg.hpp index ed8d9119a..bc76f6509 100644 --- a/src/pkg.hpp +++ b/src/pkg.hpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 2016-2022 James D. Mitchell +// Copyright (C) 2016-2025 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/semigroups-debug.hpp b/src/semigroups-debug.hpp index 9fb89deca..aec2217ba 100644 --- a/src/semigroups-debug.hpp +++ b/src/semigroups-debug.hpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 2017 James D. Mitchell +// Copyright (C) 2017-2025 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/to-cpp.hpp b/src/to-cpp.hpp index 58423ac99..ae9e6eaa6 100644 --- a/src/to-cpp.hpp +++ b/src/to-cpp.hpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 2020-2022 James D. Mitchell +// Copyright (C) 2020-2025 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/to-gap.cpp b/src/to-gap.cpp index 12698374a..a33ca3718 100644 --- a/src/to-gap.cpp +++ b/src/to-gap.cpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 2021 James D. Mitchell +// Copyright (C) 2021-2025 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/to-gap.hpp b/src/to-gap.hpp index 3b25ad8a0..d40c9da74 100644 --- a/src/to-gap.hpp +++ b/src/to-gap.hpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 2020-2022 James D. Mitchell +// Copyright (C) 2020-2025 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by From 50edf45ea56806cfefd0a989750075ee664a19a0 Mon Sep 17 00:00:00 2001 From: James Mitchell Date: Thu, 19 Feb 2026 16:19:19 +0000 Subject: [PATCH 3/8] Update header years again --- src/bipart.cpp | 2 +- src/bipart.hpp | 2 +- src/cong.cpp | 146 ------------------------- src/conglatt.cpp | 2 +- src/conglatt.hpp | 2 +- src/froidure-pin-fallback.cpp | 2 +- src/froidure-pin-fallback.hpp | 2 +- src/init-cong.cpp | 2 +- src/init-cong.hpp | 2 +- src/init-froidure-pin-base.cpp | 2 +- src/init-froidure-pin-bipart.cpp | 2 +- src/init-froidure-pin-bmat.cpp | 2 +- src/init-froidure-pin-matrix.cpp | 2 +- src/init-froidure-pin-max-plus-mat.cpp | 2 +- src/init-froidure-pin-min-plus-mat.cpp | 2 +- src/init-froidure-pin-pbr.cpp | 2 +- src/init-froidure-pin-pperm.cpp | 2 +- src/init-froidure-pin-transf.cpp | 2 +- src/init-froidure-pin.hpp | 2 +- src/init-to-congruence.cpp | 2 +- src/init-to-froidure-pin.cpp | 2 +- src/pkg.hpp | 2 +- src/semigroups-debug.hpp | 2 +- src/to-cpp.hpp | 2 +- src/to-gap.cpp | 2 +- src/to-gap.hpp | 2 +- 26 files changed, 25 insertions(+), 171 deletions(-) delete mode 100644 src/cong.cpp diff --git a/src/bipart.cpp b/src/bipart.cpp index f1888c1eb..2a4ae24f1 100644 --- a/src/bipart.cpp +++ b/src/bipart.cpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 2016-2025 James D. Mitchell +// Copyright (C) 2016-2026 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/bipart.hpp b/src/bipart.hpp index 9b0e69b3a..e5b2b3ef7 100644 --- a/src/bipart.hpp +++ b/src/bipart.hpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 2016-2025 James D. Mitchell +// Copyright (C) 2016-2026 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/cong.cpp b/src/cong.cpp deleted file mode 100644 index 4b11bc825..000000000 --- a/src/cong.cpp +++ /dev/null @@ -1,146 +0,0 @@ -// -// Semigroups package for GAP -// Copyright (C) 2021-2025 James D. Mitchell -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// - -#include "cong.hpp" - -#include // for exception -#include // for shared_ptr -#include // for true_type -#include // for vector - -// Semigroups GAP package headers -#include "froidure-pin.hpp" // for to_cpp -#include "pkg.hpp" // for IsGapBind14Type -#include "to_cpp.hpp" // for to_cpp -#include "to_gap.hpp" // for to_gap - -// GAP headers -#include "gap_all.h" // for UInt2, UInt4 - -// GapBind14 headers -#include "gapbind14/gapbind14.hpp" // for class_ etc - -// libsemigroups headers -#include "libsemigroups/bipart.hpp" // for Bipartition -#include "libsemigroups/cong-intf.hpp" // for congruence_kind -#include "libsemigroups/cong.hpp" // for Congruence -#include "libsemigroups/constants.hpp" // for UNDEFINED etc -#include "libsemigroups/froidure-pin.hpp" // for FroidurePin -#include "libsemigroups/matrix.hpp" // for BMat etc -#include "libsemigroups/todd-coxeter.hpp" // for ToddCoxeter -#include "libsemigroups/transf.hpp" // for PPerm etc -#include "libsemigroups/types.hpp" // for word_type - -// Forward decls -namespace libsemigroups { - class FpSemigroup; - class PBR; -} // namespace libsemigroups - -namespace gapbind14 { - template <> - struct IsGapBind14Type : std::true_type {}; - -} // namespace gapbind14 - -//////////////////////////////////////////////////////////////////////// -// Congruence -//////////////////////////////////////////////////////////////////////// - -using gapbind14::overload_cast; - -void init_cong(gapbind14::Module& m) { - using libsemigroups::Congruence; - using libsemigroups::congruence_kind; - using libsemigroups::FpSemigroup; - using libsemigroups::FroidurePin; - using libsemigroups::FroidurePinBase; - using libsemigroups::word_type; - - using libsemigroups::Bipartition; - using libsemigroups::BMat; - using libsemigroups::IntMat; - using libsemigroups::LeastPPerm; - using libsemigroups::LeastTransf; - using libsemigroups::MaxPlusMat; - using libsemigroups::MaxPlusTruncMat; - using libsemigroups::MinPlusMat; - using libsemigroups::MinPlusTruncMat; - using libsemigroups::NTPMat; - using libsemigroups::PBR; - using libsemigroups::PPerm; - using libsemigroups::ProjMaxPlusMat; - using libsemigroups::Transf; - - // Cannot use FroidurePinBase rather than the specialisations because there's - // no constructor for a Congruence from a FroidurePinBase&. - gapbind14::class_("Congruence") - .def(gapbind14::init const&>{}, - "make_from_froidurepin_bipartition") - .def(gapbind14::init> const&>{}, - "make_from_froidurepin_bmat") - .def(gapbind14::init const&>{}, - "make_from_froidurepin_bmat8") - .def(gapbind14::init const&>{}, - "make_from_froidurepin_pbr") -#ifdef LIBSEMIGROUPS_HPCOMBI_ENABLED - .def(gapbind14::init> const&>{}, - "make_from_froidurepin_leastpperm") - .def(gapbind14::init> const&>{}, - "make_from_froidurepin_leasttransf") -#endif - .def(gapbind14::init> const&>{}, - "make_from_froidurepin_transfUInt2") - .def(gapbind14::init> const&>{}, - "make_from_froidurepin_transfUInt4") - .def(gapbind14::init> const&>{}, - "make_from_froidurepin_ppermUInt2") - .def(gapbind14::init> const&>{}, - "make_from_froidurepin_ppermUInt4") - .def(gapbind14::init{}, - "make_from_fpsemigroup") - .def(gapbind14::init>{}, - "make_from_froidurepinbase") - .def(gapbind14::init{}, - "make_from_table") - .def("set_number_of_generators", &Congruence::set_number_of_generators) - .def("number_of_pairs", &Congruence::number_of_generating_pairs) - .def("add_pair", - overload_cast( - &Congruence::add_pair)) - .def("number_of_classes", &Congruence::number_of_classes) - .def("word_to_class_index", &Congruence::word_to_class_index) - .def("class_index_to_word", &Congruence::class_index_to_word) - .def("contains", &Congruence::contains) - .def("less", &Congruence::less) - .def("add_runner", - &Congruence::add_runner) - .def("is_quotient_obviously_infinite", - &Congruence::is_quotient_obviously_infinite) - .def("ntc", - [](Congruence& C) { - return gapbind14::make_iterator(C.cbegin_ntc(), C.cend_ntc()); - }) - .def("quotient_froidure_pin", &Congruence::quotient_froidure_pin); -} diff --git a/src/conglatt.cpp b/src/conglatt.cpp index dca2d6ca8..b323b2ec0 100644 --- a/src/conglatt.cpp +++ b/src/conglatt.cpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 2022-2025 James D. Mitchell +// Copyright (C) 2022-2026 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/conglatt.hpp b/src/conglatt.hpp index 83fa65399..852966c87 100644 --- a/src/conglatt.hpp +++ b/src/conglatt.hpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 20222-2025 James D. Mitchell +// Copyright (C) 20222-2026 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/froidure-pin-fallback.cpp b/src/froidure-pin-fallback.cpp index 4856be0fe..746a25f5e 100644 --- a/src/froidure-pin-fallback.cpp +++ b/src/froidure-pin-fallback.cpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 2016-2025 James D. Mitchell +// Copyright (C) 2016-2026 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/froidure-pin-fallback.hpp b/src/froidure-pin-fallback.hpp index 3f1df13bf..35f0b1309 100644 --- a/src/froidure-pin-fallback.hpp +++ b/src/froidure-pin-fallback.hpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 2016-2025 James D. Mitchell +// Copyright (C) 2016-2026 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/init-cong.cpp b/src/init-cong.cpp index 992b2d952..f08c26b6a 100644 --- a/src/init-cong.cpp +++ b/src/init-cong.cpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 2021-26 James D. Mitchell +// Copyright (C) 2021-2026 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/init-cong.hpp b/src/init-cong.hpp index a725b336a..9c35a26fb 100644 --- a/src/init-cong.hpp +++ b/src/init-cong.hpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 2021-26 James D. Mitchell +// Copyright (C) 2021-2026 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/init-froidure-pin-base.cpp b/src/init-froidure-pin-base.cpp index 56424bf58..b5bcd08c7 100644 --- a/src/init-froidure-pin-base.cpp +++ b/src/init-froidure-pin-base.cpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 2022-2025 James D. Mitchell +// Copyright (C) 2022-2026 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/init-froidure-pin-bipart.cpp b/src/init-froidure-pin-bipart.cpp index c863e01c8..4b00aa01c 100644 --- a/src/init-froidure-pin-bipart.cpp +++ b/src/init-froidure-pin-bipart.cpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 2021-2025 James D. Mitchell +// Copyright (C) 2021-2026 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/init-froidure-pin-bmat.cpp b/src/init-froidure-pin-bmat.cpp index 99954e5e3..849f5caf6 100644 --- a/src/init-froidure-pin-bmat.cpp +++ b/src/init-froidure-pin-bmat.cpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 2021-2025 James D. Mitchell +// Copyright (C) 2021-2026 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/init-froidure-pin-matrix.cpp b/src/init-froidure-pin-matrix.cpp index 959ec7818..7e0c73d39 100644 --- a/src/init-froidure-pin-matrix.cpp +++ b/src/init-froidure-pin-matrix.cpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 2021-2025 James D. Mitchell +// Copyright (C) 2021-2026 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/init-froidure-pin-max-plus-mat.cpp b/src/init-froidure-pin-max-plus-mat.cpp index 601adfad6..ee9898c14 100644 --- a/src/init-froidure-pin-max-plus-mat.cpp +++ b/src/init-froidure-pin-max-plus-mat.cpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 2021-2025 James D. Mitchell +// Copyright (C) 2021-2026 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/init-froidure-pin-min-plus-mat.cpp b/src/init-froidure-pin-min-plus-mat.cpp index 513020a31..54b966487 100644 --- a/src/init-froidure-pin-min-plus-mat.cpp +++ b/src/init-froidure-pin-min-plus-mat.cpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 2021-2025 James D. Mitchell +// Copyright (C) 2021-2026 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/init-froidure-pin-pbr.cpp b/src/init-froidure-pin-pbr.cpp index 5c5b6925a..b5527a6c2 100644 --- a/src/init-froidure-pin-pbr.cpp +++ b/src/init-froidure-pin-pbr.cpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 2021-2025 James D. Mitchell +// Copyright (C) 2021-2026 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/init-froidure-pin-pperm.cpp b/src/init-froidure-pin-pperm.cpp index 2507fe78c..3eceb9867 100644 --- a/src/init-froidure-pin-pperm.cpp +++ b/src/init-froidure-pin-pperm.cpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 2021-2025 James D. Mitchell +// Copyright (C) 2021-2026 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/init-froidure-pin-transf.cpp b/src/init-froidure-pin-transf.cpp index b681f953a..c8e1bbed2 100644 --- a/src/init-froidure-pin-transf.cpp +++ b/src/init-froidure-pin-transf.cpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 2021-2025 James D. Mitchell +// Copyright (C) 2021-2026 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/init-froidure-pin.hpp b/src/init-froidure-pin.hpp index 713ac284a..4c6b1b786 100644 --- a/src/init-froidure-pin.hpp +++ b/src/init-froidure-pin.hpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 2021-2025 James D. Mitchell +// Copyright (C) 2021-2026 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/init-to-congruence.cpp b/src/init-to-congruence.cpp index 142e64607..613b0c54d 100644 --- a/src/init-to-congruence.cpp +++ b/src/init-to-congruence.cpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 2021-26 James D. Mitchell +// Copyright (C) 2021-2026 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/init-to-froidure-pin.cpp b/src/init-to-froidure-pin.cpp index dd6578ead..a94cfd03e 100644 --- a/src/init-to-froidure-pin.cpp +++ b/src/init-to-froidure-pin.cpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 2021-26 James D. Mitchell +// Copyright (C) 2021-2026 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/pkg.hpp b/src/pkg.hpp index bc76f6509..63e92eae0 100644 --- a/src/pkg.hpp +++ b/src/pkg.hpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 2016-2025 James D. Mitchell +// Copyright (C) 2016-2026 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/semigroups-debug.hpp b/src/semigroups-debug.hpp index aec2217ba..850511763 100644 --- a/src/semigroups-debug.hpp +++ b/src/semigroups-debug.hpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 2017-2025 James D. Mitchell +// Copyright (C) 2017-2026 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/to-cpp.hpp b/src/to-cpp.hpp index ae9e6eaa6..6d08f853f 100644 --- a/src/to-cpp.hpp +++ b/src/to-cpp.hpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 2020-2025 James D. Mitchell +// Copyright (C) 2020-2026 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/to-gap.cpp b/src/to-gap.cpp index a33ca3718..3df37539a 100644 --- a/src/to-gap.cpp +++ b/src/to-gap.cpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 2021-2025 James D. Mitchell +// Copyright (C) 2021-2026 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/to-gap.hpp b/src/to-gap.hpp index d40c9da74..55eaff7ef 100644 --- a/src/to-gap.hpp +++ b/src/to-gap.hpp @@ -1,6 +1,6 @@ // // Semigroups package for GAP -// Copyright (C) 2020-2025 James D. Mitchell +// Copyright (C) 2020-2026 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by From 6e7d6a4317a5dcf37afa157af2fecd307cfa5a38 Mon Sep 17 00:00:00 2001 From: James Mitchell Date: Fri, 20 Feb 2026 14:29:34 +0000 Subject: [PATCH 4/8] Fix valgrind warnings? --- gapbind14/src/gapbind14.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/gapbind14/src/gapbind14.cpp b/gapbind14/src/gapbind14.cpp index 362777593..54b258388 100644 --- a/gapbind14/src/gapbind14.cpp +++ b/gapbind14/src/gapbind14.cpp @@ -25,10 +25,8 @@ #include "gapbind14/gap_include.hpp" // for Obj etc -#define GVAR_ENTRY(srcfile, name, nparam, params) \ - { \ -#name, nparam, params, (ObjFunc) name, srcfile ":Func" #name \ - } +#define GVAR_ENTRY(srcfile, name, nparam, params) \ + {#name, nparam, params, (ObjFunc) name, srcfile ":Func" #name} namespace gapbind14 { UInt T_GAPBIND14_OBJ = 0; @@ -104,21 +102,21 @@ namespace gapbind14 { void Module::clear() { for (auto &func : _funcs) { - delete func.name; + delete[] func.name; if (func.nargs != 0) { - delete func.args; + delete[] func.args; } - delete func.cookie; + delete[] func.cookie; } _funcs.clear(); for (auto &vec : _mem_funcs) { for (auto &func : vec) { - delete func.name; + delete[] func.name; if (func.nargs != 0) { - delete func.args; + delete[] func.args; } - delete func.cookie; + delete[] func.cookie; } vec.clear(); } From 02913443be444cd3860a24eff3b990541eb58d22 Mon Sep 17 00:00:00 2001 From: James Mitchell Date: Tue, 24 Feb 2026 10:13:11 +0000 Subject: [PATCH 5/8] ci: add apt-get update to valgrind workflow --- .github/workflows/valgrind.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/valgrind.yml b/.github/workflows/valgrind.yml index 9067b5cd0..d81c702e5 100644 --- a/.github/workflows/valgrind.yml +++ b/.github/workflows/valgrind.yml @@ -29,7 +29,9 @@ jobs: - name: "Output g++ version . . ." run: g++ --version - name: "Install Valgrind . . ." - run: sudo apt-get install valgrind + run: | + sudo apt-get update + sudo apt-get install valgrind - name: "Install GAP . . ." uses: gap-actions/setup-gap@v3 with: From cd1e28e48f29f174f2ab62053afdc9737cdfd7f6 Mon Sep 17 00:00:00 2001 From: James Mitchell Date: Wed, 25 Feb 2026 09:24:28 +0000 Subject: [PATCH 6/8] Try figure out why this is still failing --- .github/workflows/valgrind.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/valgrind.yml b/.github/workflows/valgrind.yml index d81c702e5..35a578edc 100644 --- a/.github/workflows/valgrind.yml +++ b/.github/workflows/valgrind.yml @@ -23,7 +23,7 @@ jobs: runs-on: ubuntu-latest env: NO_COVERAGE: true - VALGRIND: valgrind --trace-children=yes --leak-check=full --error-exitcode=1 + VALGRIND: valgrind --trace-children=yes --leak-check=full --show-leak-kinds=all --error-exitcode=1 steps: - uses: actions/checkout@v5 - name: "Output g++ version . . ." From e1d870c2d2565551757661e67a8235b318da45da Mon Sep 17 00:00:00 2001 From: Joseph Edwards Date: Thu, 12 Mar 2026 15:04:21 +0000 Subject: [PATCH 7/8] Allow the option to exclude tests from TestStandard --- gap/tools/utils.gi | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gap/tools/utils.gi b/gap/tools/utils.gi index 283b17a2e..e7dd0d58d 100644 --- a/gap/tools/utils.gi +++ b/gap/tools/utils.gi @@ -197,6 +197,9 @@ SEMIGROUPS.TestDir := function(dir, arg) if "suppressStatusMessage" in RecNames(arg[1]) then opts.suppressStatusMessage := arg[1].suppressStatusMessage; fi; + if "exclude" in RecNames(arg[1]) then + opts.exclude := arg[1].exclude; + fi; elif Length(arg) <> 0 then ErrorNoReturn("there must be no arguments, or the argument ", "must be a record"); From a79684afcb2e184736753d2d37627f126e5fe929 Mon Sep 17 00:00:00 2001 From: Joseph Edwards Date: Thu, 12 Mar 2026 15:04:48 +0000 Subject: [PATCH 8/8] Don't test tietze.tst with valgrind --- .github/workflows/valgrind.yml | 2 +- tst/github_actions/valgrind.g | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 tst/github_actions/valgrind.g diff --git a/.github/workflows/valgrind.yml b/.github/workflows/valgrind.yml index 35a578edc..10e419995 100644 --- a/.github/workflows/valgrind.yml +++ b/.github/workflows/valgrind.yml @@ -54,6 +54,6 @@ jobs: - name: "Run SemigroupsTestStandard . . ." uses: gap-actions/run-pkg-tests@v4 with: - testfile: tst/github_actions/standard.g + testfile: tst/github_actions/valgrind.g pre-gap: ${{ env.VALGRIND }} coverage: false diff --git a/tst/github_actions/valgrind.g b/tst/github_actions/valgrind.g new file mode 100644 index 000000000..5ab3b1686 --- /dev/null +++ b/tst/github_actions/valgrind.g @@ -0,0 +1,8 @@ +LoadPackage("semigroups", false);; +if SemigroupsTestStandard( + rec(earlyStop := false, exclude := ["fp/tietze.tst"])) then + QUIT_GAP(0); +else + QUIT_GAP(1); +fi; +FORCE_QUIT_GAP(1);