Skip to content

Conversation

@user202729
Copy link
Contributor

@user202729 user202729 commented Nov 14, 2025

Replacement for #40563. Fix #40549

Note that FpElementNFFunction is what GAP uses internally for ==

#############################################################################
##
#M  \=( <elm1>, <elm2> )  . . . . . . . . .  for two elements of a f.p. group
##
InstallMethod( \=, "for two f.p. group elements", IsIdenticalObj,
    [ IsElementOfFpGroup, IsElementOfFpGroup ],0,
# this is the only method that may ever be called!
function( left, right )
  if UnderlyingElement(left)=UnderlyingElement(right) then
    return true;
  fi;
  return FpElmEqualityMethod(FamilyObj(left))(left,right);
end );


InstallMethod( FpElmEqualityMethod, "generic dispatcher",
true,[IsElementOfFpGroupFamily],0,MakeFpGroupCompMethod(\=));


BindGlobal( "MakeFpGroupCompMethod", function(CMP)
  return function(fam)
    local hom,f,com;
    # if a normal form method is known, and it is not known to be crummy
    if HasFpElementNFFunction(fam) and not IsBound(fam!.hascrudeFPENFF) then
      f:=FpElementNFFunction(fam);
      com:=x->f(UnderlyingElement(x));
    # if we know a faithful representation, use it
    elif HasFPFaithHom(fam) and
     FPFaithHom(fam)<>fail then
      hom:=FPFaithHom(fam);
      com:=x->Image(hom,x);
	  ...

Sometimes == works better than confluent_rewriting_system. (Although I don't dare to include this as a test, otherwise upgrade to GAP that selects a different algorithm may randomly timeout the test)

sage: F.<a,b,c,d,e> = FreeGroup()
sage: rules = [e*d*c^-1*d*a, b^-1*a, a*e*b*d^-1*c]
sage: G = F / rules
sage: G(a) == G(1)
False
sage: G.confluent_rewriting_system()  # takes forever

Sometimes not. But gap appears to use some sort of caching system, so it might work anyway.

sage: F.<a,b,c> = FreeGroup()
sage: rules = [a^-1*b*c*a*b, a*c^-1*a*c^-1*a, a^2*c]
sage: G = F / rules
sage: G(a) == G(1)	# takes forever

When one compute one confluent_rewriting_system and one hash before the ==, it finishes quickly.

sage: F.<a,b,c> = FreeGroup()
sage: rules = [a^-1*b*c*a*b, a*c^-1*a*c^-1*a, a^2*c]
sage: G = F / rules
sage: ignore = G.confluent_rewriting_system()
sage: G(a)._normal_form_by_gap_nffunction()
a
sage: G(a) == G(1)
False

📝 Checklist

  • The title is concise and informative.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation and checked the documentation preview.

⌛ Dependencies

@user202729 user202729 force-pushed the finitely-presented-hash branch from 5a62283 to b6de2f9 Compare November 14, 2025 18:54
@cxzhong
Copy link
Contributor

cxzhong commented Nov 15, 2025

It still cause timeout issues

src/bin/sage -t --warn-long 5.0 --random-seed=113808444557570614600856870960997183849 src/doc/en/thematic_tutorials/group_theory.rst  # Timed out
src/bin/sage -t --warn-long 5.0 --random-seed=113808444557570614600856870960997183849 src/sage/combinat/designs/incidence_structures.py  # Timed out
src/bin/sage -t --warn-long 5.0 --random-seed=113808444557570614600856870960997183849 src/sage/graphs/bliss.pyx  # Timed out
src/bin/sage -t --warn-long 5.0 --random-seed=113808444557570614600856870960997183849 src/sage/graphs/generic_graph.py  # Timed out
src/bin/sage -t --warn-long 5.0 --random-seed=113808444557570614600856870960997183849 src/sage/groups/finitely_presented_named.py  # Timed out
src/bin/sage -t --warn-long 5.0 --random-seed=113808444557570614600856870960997183849 src/sage/groups/libgap_wrapper.pyx  # Timed out
src/bin/sage -t --warn-long 5.0 --random-seed=113808444557570614600856870960997183849 src/sage/groups/perm_gps/permgroup.py  # Timed out
src/bin/sage -t --warn-long 5.0 --random-seed=113808444557570614600856870960997183849 src/sage/groups/perm_gps/permgroup_morphism.py  # Timed out
src/bin/sage -t --warn-long 5.0 --random-seed=113808444557570614600856870960997183849 src/sage/topology/simplicial_complex_examples.py  # Timed out
src/bin/sage -t --warn-long 5.0 --random-seed=113808444557570614600856870960997183849 src/sage/topology/simplicial_complex.py  # Timed out

@user202729
Copy link
Contributor Author

#39244

@cxzhong
Copy link
Contributor

cxzhong commented Nov 15, 2025

Maybe the serve is down. We may skip the tests?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cayley graphs of free groups have wrong number of vertices.

2 participants