Skip to content
Open
4 changes: 4 additions & 0 deletions deps/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ add_library(libsemigroups_julia SHARED
kambites.cpp
congruence.cpp
to-cong.cpp
to-todd-coxeter.cpp
to-knuth-bendix.cpp
to-froidure-pin.cpp
to-presentation.cpp
)

# Include directories
Expand Down
4 changes: 2 additions & 2 deletions deps/src/knuth-bendix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ namespace libsemigroups_julia {

using CongruenceCommon = libsemigroups::detail::CongruenceCommon;
using KBImpl = libsemigroups::detail::KnuthBendixImpl<
libsemigroups::detail::RewriteTrie,
libsemigroups::ShortLexCompare>;
libsemigroups::detail::RewriteTrie,
libsemigroups::ShortLexCompare>;
using KB = libsemigroups::KnuthBendix<word_type,
libsemigroups::detail::RewriteTrie,
libsemigroups::ShortLexCompare>;
Expand Down
6 changes: 5 additions & 1 deletion deps/src/libsemigroups_julia.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,19 @@ namespace libsemigroups_julia {
define_word_range(mod);
define_word_graph(mod);
define_paths(mod);
define_presentation(mod);
define_froidure_pin_base(mod);
define_froidure_pin(mod);
define_presentation(mod);
define_presentation_examples(mod);
define_knuth_bendix(mod);
define_todd_coxeter(mod);
define_kambites(mod);
define_congruence(mod);
define_to_cong(mod);
define_to_todd_coxeter(mod);
define_to_knuth_bendix(mod);
define_to_froidure_pin(mod);
define_to_presentation(mod);
}

} // namespace libsemigroups_julia
4 changes: 4 additions & 0 deletions deps/src/libsemigroups_julia.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ namespace libsemigroups_julia {
void define_kambites(jl::Module& mod);
void define_congruence(jl::Module& mod);
void define_to_cong(jl::Module& mod);
void define_to_todd_coxeter(jl::Module& mod);
void define_to_knuth_bendix(jl::Module& mod);
void define_to_froidure_pin(jl::Module& mod);
void define_to_presentation(jl::Module& mod);

} // namespace libsemigroups_julia

Expand Down
41 changes: 41 additions & 0 deletions deps/src/to-froidure-pin.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//
// Semigroups.jl
// Copyright (C) 2026, Joseph E. Macgowan
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//

// CRITICAL: libsemigroups_julia.hpp MUST be included first (fmt consteval fix)
#include "libsemigroups_julia.hpp"

#include <cstdint>

#include <libsemigroups/froidure-pin.hpp>
#include <libsemigroups/to-froidure-pin.hpp>
#include <libsemigroups/transf.hpp>
#include <libsemigroups/word-graph.hpp>

namespace libsemigroups_julia {

void define_to_froidure_pin(jl::Module& m) {
using FP = libsemigroups::FroidurePin<libsemigroups::Transf<0, uint8_t>>;

// Complete WordGraph to FroidurePin<Transf<0, uint8_t>>.
m.method("to_froidure_pin_from_wg",
[](libsemigroups::WordGraph<uint32_t> const& wg) {
return libsemigroups::to<FP>(wg);
});
}

} // namespace libsemigroups_julia
50 changes: 50 additions & 0 deletions deps/src/to-knuth-bendix.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//
// Semigroups.jl
// Copyright (C) 2026, Joseph E. Macgowan
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//

// CRITICAL: libsemigroups_julia.hpp MUST be included first (fmt consteval fix)
#include "libsemigroups_julia.hpp"

#include <libsemigroups/froidure-pin-base.hpp>
#include <libsemigroups/knuth-bendix-class.hpp>
#include <libsemigroups/to-knuth-bendix.hpp>
#include <libsemigroups/todd-coxeter-class.hpp>
#include <libsemigroups/types.hpp>

namespace libsemigroups_julia {

void define_to_knuth_bendix(jl::Module& m) {
using KB = libsemigroups::KnuthBendix<libsemigroups::word_type,
libsemigroups::detail::RewriteTrie,
libsemigroups::ShortLexCompare>;

// FroidurePinBase and congruence kind to KnuthBendix<word_type>.
m.method("to_knuth_bendix_from_fpb",
[](libsemigroups::congruence_kind knd,
libsemigroups::FroidurePinBase& fpb) {
return libsemigroups::to<KB>(knd, fpb);
});

// ToddCoxeter and congruence kind to KnuthBendix<word_type>.
m.method("to_knuth_bendix_from_tc",
[](libsemigroups::congruence_kind knd,
libsemigroups::ToddCoxeter<libsemigroups::word_type>& tc) {
return libsemigroups::to<KB>(knd, tc);
});
}

} // namespace libsemigroups_julia
79 changes: 79 additions & 0 deletions deps/src/to-presentation.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#include "libsemigroups_julia.hpp"

#include <libsemigroups/bmat8.hpp>
#include <libsemigroups/cong-class.hpp>
#include <libsemigroups/froidure-pin.hpp>
#include <libsemigroups/kambites-class.hpp>
#include <libsemigroups/knuth-bendix-class.hpp>
#include <libsemigroups/presentation.hpp>
#include <libsemigroups/to-presentation.hpp>
#include <libsemigroups/todd-coxeter-class.hpp>
#include <libsemigroups/transf.hpp>
#include <libsemigroups/types.hpp>

namespace libsemigroups_julia {

namespace {

// Register the conversion for one concrete FroidurePin<E> instantiation.
template <typename E>
void define_froidure_pin_to_presentation(jl::Module& m) {
using FP = libsemigroups::FroidurePin<E>;
m.method("to_presentation_word", [](FP& self) {
return libsemigroups::to<
libsemigroups::Presentation<libsemigroups::word_type>>(self);
});
}

} // namespace

void define_to_presentation(jl::Module& m) {
// Presentation<word_type> to InversePresentation<word_type>.
m.method(
"to_inverse_presentation_word",
[](libsemigroups::Presentation<libsemigroups::word_type> const& p) {
return libsemigroups::to<libsemigroups::InversePresentation>(p);
});
m.method(
"to_inverse_presentation_word",
[](libsemigroups::InversePresentation<libsemigroups::word_type> const&
ip) {
return libsemigroups::InversePresentation<libsemigroups::word_type>(
ip);
});
// Congruence, Kambites, ToddCoxeter, or KnuthBendix to Presentation.
m.method("to_presentation_word",
[](libsemigroups::Congruence<libsemigroups::word_type>& c) {
return libsemigroups::to<
libsemigroups::Presentation<libsemigroups::word_type>>(c);
});
m.method("to_presentation_word",
[](libsemigroups::Kambites<libsemigroups::word_type>& k) {
return libsemigroups::to<
libsemigroups::Presentation<libsemigroups::word_type>>(k);
});
m.method("to_presentation_word",
[](libsemigroups::ToddCoxeter<libsemigroups::word_type>& tc) {
return libsemigroups::to<
libsemigroups::Presentation<libsemigroups::word_type>>(tc);
});
m.method("to_presentation_word",
[](libsemigroups::KnuthBendix<libsemigroups::word_type>& kb) {
return libsemigroups::to<
libsemigroups::Presentation<libsemigroups::word_type>>(kb);
});

// FroidurePin<E> to Presentation<word_type> for all 10 E instantiations.
define_froidure_pin_to_presentation<libsemigroups::Transf<0, uint8_t>>(m);
define_froidure_pin_to_presentation<libsemigroups::Transf<0, uint16_t>>(m);
define_froidure_pin_to_presentation<libsemigroups::Transf<0, uint32_t>>(m);
define_froidure_pin_to_presentation<libsemigroups::PPerm<0, uint8_t>>(m);
define_froidure_pin_to_presentation<libsemigroups::PPerm<0, uint16_t>>(m);
define_froidure_pin_to_presentation<libsemigroups::PPerm<0, uint32_t>>(m);
define_froidure_pin_to_presentation<libsemigroups::Perm<0, uint8_t>>(m);
define_froidure_pin_to_presentation<libsemigroups::Perm<0, uint16_t>>(m);
define_froidure_pin_to_presentation<libsemigroups::Perm<0, uint32_t>>(m);
define_froidure_pin_to_presentation<libsemigroups::BMat8>(m);
}

} // namespace libsemigroups_julia
51 changes: 51 additions & 0 deletions deps/src/to-todd-coxeter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//
// Semigroups.jl
// Copyright (C) 2026, Joseph E. Macgowan
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//

// CRITICAL: libsemigroups_julia.hpp MUST be included first (fmt consteval fix)
#include "libsemigroups_julia.hpp"

#include <cstdint>

#include <libsemigroups/froidure-pin-base.hpp>
#include <libsemigroups/knuth-bendix-class.hpp>
#include <libsemigroups/to-todd-coxeter.hpp>
#include <libsemigroups/types.hpp>
#include <libsemigroups/word-graph.hpp>

namespace libsemigroups_julia {

void define_to_todd_coxeter(jl::Module& m) {
// FroidurePinBase graph and congruence kind to ToddCoxeter<word_type>.
m.method("to_todd_coxeter_from_fpb",
[](libsemigroups::congruence_kind knd,
libsemigroups::FroidurePinBase& fpb,
libsemigroups::WordGraph<uint32_t> const& wg) {
return libsemigroups::to<
libsemigroups::ToddCoxeter<libsemigroups::word_type>>(
knd, fpb, wg);
});

// KnuthBendix<word_type> and congruence kind to ToddCoxeter<word_type>.
m.method("to_todd_coxeter_from_kb",
[](libsemigroups::congruence_kind knd,
libsemigroups::KnuthBendix<libsemigroups::word_type>& kb) {
return libsemigroups::to<libsemigroups::ToddCoxeter>(knd, kb);
});
}

} // namespace libsemigroups_julia
3 changes: 1 addition & 2 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ makedocs(;
"Package Info" => [
"Installation" => "package-info/installation.md",
"Authors" => "package-info/authors.md",
#= "Bibliography" => "package-info/bibliography.md", =#
"Exceptions" => "package-info/exceptions.md",
#= "Bibliography" => "package-info/bibliography.md", =# "Exceptions" => "package-info/exceptions.md",
],
"Data Structures" => [
"Constants" => "data-structures/constants/index.md",
Expand Down
8 changes: 7 additions & 1 deletion src/Semigroups.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ include("transf.jl")

# Algorithm types (must come after element types)
include("froidure-pin.jl")
include("to-cong.jl")
include("to-todd-coxeter.jl")
include("to-presentation.jl")
include("to-knuth-bendix.jl")
include("to-froidure-pin.jl")
include("to-inverse-presentation.jl")

function _version_string(v::Union{Nothing,VersionNumber})
return isnothing(v) ? "unknown" : string(v)
Expand Down Expand Up @@ -260,7 +266,7 @@ end
export enable_debug, is_debug, LibsemigroupsError, ReportGuard
export UNDEFINED, POSITIVE_INFINITY, NEGATIVE_INFINITY, LIMIT_MAX
export Runner, RunnerState
export CongruenceCommon
export CongruenceCommon, Congruence
export STATE_NEVER_RUN, STATE_RUNNING_TO_FINISH, STATE_RUNNING_FOR
export STATE_RUNNING_UNTIL, STATE_TIMED_OUT, STATE_STOPPED_BY_PREDICATE
export STATE_NOT_RUNNING, STATE_DEAD
Expand Down
2 changes: 2 additions & 0 deletions src/cong-common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ algorithm.
"""
const CongruenceCommon = LibSemigroups.CongruenceCommon

const Congruence = LibSemigroups.CongruenceWord

_words_to_cpp(words::AbstractVector{<:AbstractVector{<:Integer}}) =
Any[_word_to_cpp(word) for word in words]

Expand Down
20 changes: 20 additions & 0 deletions src/to-cong.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""
to-cong.jl - conversions to Congruence
"""

"""
to(::Type{Congruence}, kind::congruence_kind, fp::FroidurePin,
wg) -> Congruence

Convert a Froidure-Pin graph to a Congruence.
"""
to(::Type{Congruence}, kind::congruence_kind, fp::FroidurePin, wg) =
LibSemigroups.to_congruence_from_fpb(kind, fp.cxx_obj, wg)

"""
to(::Type{Congruence}, kind::congruence_kind, wg::WordGraph) -> Congruence

Convert a WordGraph to a Congruence.
"""
to(::Type{Congruence}, kind::congruence_kind, wg::WordGraph) =
LibSemigroups.to_congruence_from_wg(kind, wg)
11 changes: 11 additions & 0 deletions src/to-froidure-pin.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""
to-froidure-pin.jl - conversions to FroidurePin
"""

"""
to(::Type{FroidurePin}, wg::WordGraph) -> FroidurePin{Transf{UInt8}}

Convert a complete WordGraph to a Froidure-Pin.
"""
to(::Type{FroidurePin}, wg::WordGraph) =
FroidurePin{Transf{UInt8}}(LibSemigroups.to_froidure_pin_from_wg(wg))
18 changes: 18 additions & 0 deletions src/to-inverse-presentation.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""
to-inverse-presentation.jl - conversions to InversePresentation
"""

"""
to(::Type{InversePresentation}, p::Presentation) -> InversePresentation

Convert a Presentation to an InversePresentation.
"""
to(::Type{InversePresentation}, p::Presentation) =
LibSemigroups.to_inverse_presentation_word(p)

"""
to(ip::InversePresentation) -> InversePresentation

Convert an InversePresentation to an InversePresentation.
"""
to(ip::InversePresentation) = InversePresentation(ip)
19 changes: 19 additions & 0 deletions src/to-knuth-bendix.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""
to-knuth-bendix.jl - conversions to KnuthBendix
"""

"""
to(::Type{KnuthBendix}, kind::congruence_kind, fp::FroidurePin) -> KnuthBendix

Convert a Froidure-Pin to a Knuth-Bendix.
"""
to(::Type{KnuthBendix}, kind::congruence_kind, fp::FroidurePin) =
LibSemigroups.to_knuth_bendix_from_fpb(kind, fp.cxx_obj)

"""
to(::Type{KnuthBendix}, kind::congruence_kind, tc::ToddCoxeter) -> KnuthBendix

Convert a Todd-Coxeter to a Knuth-Bendix.
"""
to(::Type{KnuthBendix}, kind::congruence_kind, tc::ToddCoxeter) =
LibSemigroups.to_knuth_bendix_from_tc(kind, tc)
Loading
Loading