##############################################################################
##
#W  example1.g                   Kan Package                     Chris Wensley
#W                                                             & Anne Heyworth
##
##  This file contains generic methods for double coset rewriting systems
##
#H  @(#)$Id: example1.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/example1_g") := 
   "@(#)$Id: example1.g,v 0.92 2006/03/08 gap Exp $";

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

Print( "\n==============================================================\n" );
Print( "2-generator example example1.g, <a^6>F2<a^4>, version 08/03/06\n" );
Print( "==============================================================\n\n" );

G1 := FreeGroup( 2 );
L1 := [2,1,4,3];
order := "shortlex";
alph1 := "AaBb";
rws1 := ReducedConfluentRewritingSystem( G1, L1, order, 0, alph1 );
Print( "rules for rewriting system rws1:\n" );
DisplayRwsRules( rws1 );

genG1 := GeneratorsOfGroup( G1 );
genH1 := [ genG1[1]^6 ];
genK1 := [ genG1[1]^4 ];
dcrws1 := DoubleCosetRewritingSystem( G1, genH1, genK1, rws1 );;
IsDoubleCosetRewritingSystem( dcrws1 );
Print( "\nrules for double coset rewriting system dcrws1:\n" );
DisplayRwsRules( dcrws1 );
waG1 := WordAcceptorOfReducedRws( rws1 );
Print( "\ngroup word acceptor waG1:\n", waG1, "\n" );
Print( "language of group acceptor:\n", SFAtoRatExp( waG1 ), "\n\n" );

wadc1 := WordAcceptorOfDoubleCosetRws( dcrws1 );
Print( "word acceptor wadc1 of dcrws1:\n", wadc1, "\n" );
words1 := [ "HK","HaK","HbK","HAK","HaaK","HbbK","HabK","HbaK","HbaabK"];;
Print( "list of 9 words:\n", words1, "\n" );
valid1 := List( words1, w -> IsRecognizedByAutomaton( wadc1, w ) );
Print( "these words are or are not recognized?\n", valid1, "\n" );
lang1 := SFAtoRatExp( wadc1 );
Print( "language of double coset word acceptor:\n", lang1, "\n\n" );
