##############################################################################
##
#W  example2.g                   Kan Package                     Chris Wensley
#W                                                             & Anne Heyworth
##
##  This file contains generic methods for double coset rewriting systems
##
#H  @(#)$Id: example2.g,v 0.92 2006/03/08 gap Exp $
##
#Y  Copyright (C) 1999,2001 University of St. Andrews, North Haugh,
#Y                          St. Andrews, Fife KY16 9SS, Scotland
##
Revision.("kan/examples/example2_g") := 
   "@(#)$Id: example2.g,v 0.92 2006/03/08 gap Exp $";

SetInfoLevel( InfoKan, 1 );
SetInfoLevel( InfoKnuthBendix, 1 );

Print( "\n===============================================================\n" );
Print( "2-generator example example2.g, trefoil group, version 08/03/06\n" );
Print( "===============================================================\n\n" );

FT := FreeGroup( 2 );;
relsT := [ FT.1^3*FT.2^-2 ];;
T := FT/relsT;;
genT := GeneratorsOfGroup( T );;
x := genT[1];;  y := genT[2];;
alphT := "XxYy";;
ordT := [4,3,2,1];;
orderT := "wreath";;
rwsT := ReducedConfluentRewritingSystem( T, ordT, orderT, 0, alphT );;
Print( "rules for reduced rws for trefoil group with wreath order:\n" );
DisplayRwsRules( rwsT );;
accT := WordAcceptorOfReducedRws( rwsT );
Print( "word acceptor for this rws:\n", accT, "\n" );
langT := SFAtoRatExp( accT );

## find a partial dcrws with a maximum of 20 rules
prwsT :=  PartialDoubleCosetRewritingSystem( T, [x], [y], rwsT, 20 );;
Print("\nrules for partial double coset rws:\n" );
DisplayRwsRules( prwsT );

paccT := WordAcceptorOfPartialDoubleCosetRws( T, prwsT );
Print( "word acceptor for this partial double coset rws:\n", paccT, "\n" );

plangT := SFAtoRatExp( paccT );
wordsT := [ "HK", "HxK", "HyK", "HYK", "HyxK", "HyxxK", "HyyH", "HyxYK"];;
Print( "list of 8 words:\n", wordsT, "\n" );
validT := List( wordsT, w -> IsRecognizedByAutomaton( paccT, w ) );
Print( "these words are or are not recognized?\n", validT, "\n\n" );
