From c328bb36a61fb6b72f68cb5b4c2df0fe3f470744 Mon Sep 17 00:00:00 2001 From: "James D. Mitchell" Date: Sat, 21 May 2022 14:41:25 +0100 Subject: [PATCH] conglatt: avoid recomputing principal congs --- gap/congruences/conglatt.gi | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/gap/congruences/conglatt.gi b/gap/congruences/conglatt.gi index e93c33fee..151e0bbb6 100644 --- a/gap/congruences/conglatt.gi +++ b/gap/congruences/conglatt.gi @@ -507,7 +507,12 @@ end); InstallMethod(LatticeOfCongruences, "for a semigroup", [IsSemigroup], function(S) - return LatticeOfCongruencesNC(S, GeneratingPairsOfPrincipalCongruences(S)); + local poset; + # Although this duplicates code from LatticeOfCongruencesNC above, it avoids + # recomputation of the PosetOfPrincipalCongruences if it's already known. + poset := PosetOfPrincipalCongruences(S); + poset := JoinSemilatticeOfCongruences(poset, WrappedTwoSidedCongruence); + return SEMIGROUPS.AddTrivialCongruence(poset, SemigroupCongruence); end); InstallMethod(LatticeOfRightCongruencesNC, @@ -530,8 +535,13 @@ end); InstallMethod(LatticeOfRightCongruences, "for a semigroup", [IsSemigroup], function(S) - return LatticeOfRightCongruencesNC(S, - GeneratingPairsOfPrincipalRightCongruences(S)); + local poset; + # Although this duplicates code from LatticeOfRightCongruencesNC above, it + # avoids recomputation of the PosetOfPrincipalCongruences if it's already + # known. + poset := PosetOfPrincipalRightCongruences(S); + poset := JoinSemilatticeOfCongruences(poset, WrappedRightCongruence); + return SEMIGROUPS.AddTrivialCongruence(poset, RightSemigroupCongruence); end); InstallMethod(LatticeOfLeftCongruencesNC, @@ -554,8 +564,13 @@ end); InstallMethod(LatticeOfLeftCongruences, "for a semigroup", [IsSemigroup], function(S) - return LatticeOfLeftCongruencesNC(S, - GeneratingPairsOfPrincipalLeftCongruences(S)); + local poset; + # Although this duplicates code from LatticeOfLeftCongruencesNC above, it + # avoids recomputation of the PosetOfPrincipalCongruences if it's already + # known. + poset := PosetOfPrincipalLeftCongruences(S); + poset := JoinSemilatticeOfCongruences(poset, WrappedLeftCongruence); + return SEMIGROUPS.AddTrivialCongruence(poset, LeftSemigroupCongruence); end); ########################################################################