##############################################################################
##
#W  gpdmor.g                     Gpd Package                     Chris Wensley
#W                                                                & Emma Moore
##
#H  @(#)$Id: gpdmor.g,v 1.01 2006/05/12 gap Exp $
##
#Y  Copyright (C) 1999,2001 University of St. Andrews, North Haugh,
#Y                          St. Andrews, Fife KY16 9SS, Scotland
##
Revision.("gpd/examples/gpd_manual.g") :=
   "@(#)$Id: gpdmor.g,v 1.01 2006/05/12 gap Exp $";

SetInfoLevel( InfoGpd, 2 );

Print( "\n================================================================\n");
Print( "<<<< testing morphisms in the Gpd manual (version 12/05/06) >>>>\n" );
Print( "<<<<       functions for groupoids and their morphisms      >>>>\n" );
Print( "================================================================\n\n");

gend8 := GeneratorsOfGroup( d8 );
imhd8 := [ ( ), (15,20)(16,19)(17,18) ];
hd8 := GroupHomomorphismByImages( d8, s3d, gend8, imhd8 );
md8 := MorphismOfConnectedGroupoids( Gd8, Gs3d, [-34,-35,-36], hd8 );
Print( "md8 = ", md8, "\n" );
Print( IsBijectiveOnObjects( md8 ), "\n" );
Print( ImagesOfObjects( md8 ), "\n\n" );

hc6 := GroupHomomorphismByImages( c6, s3d, [(5,6,7)(8,9)], [(15,19)(16,18)] );;
mc6 := GroupoidMorphism( Gc6, Gs3d, [ -36 ], hc6 );
Print( "mc6 = ", mc6, "\n" );

md8c6 := GroupoidMorphism( Gd8c6, Gs3d, [ md8, mc6 ] );
Print( "md8c6 = ", md8c6, "\n" );
Display( md8c6 ); Print("\n");

imd8 := [ (1,2,3,4), (2,4) ];
ad8 := GroupHomomorphismByImages( d8, d8, [(1,2,3,4),(1,3)], imd8 );
aGd8 := MorphismOfConnectedGroupoids( Gd8, Gd8, [-8,-7,-9], ad8 );
Print( "automorphism aGd8 :-\n" );
Display( aGd8 );
Print( "aGd8 is an automorphism? ", IsGroupoidAutomorphism( aGd8 ), "\n" );
Print( "aGd8 has inverse:\n" );
iaGd8 := InverseMorphism( aGd8 );
Display( iaGd8 );
Print( "aGd8 has order ", Order( aGd8 ), "\n\n" );

gens3d := GeneratorsOfGroup( s3d );
imas3d := [ (15,17,19)(16,18,20), (15,16)(17,20)(18,19) ];
as3d := GroupHomomorphismByImages( s3d, s3d, gens3d, imas3d );
aGs3d := MorphismOfConnectedGroupoids( Gs3d, Gs3d, [-35,-34,-36], as3d );
Print( "automorphism aGs3d :-\n" );
Display( aGs3d );
Print( "aGs3d is an automorphism? ", IsGroupoidAutomorphism( aGs3d ), "\n" );
Print( "aGs3d has inverse:\n" );
iaGs3d := InverseMorphism( aGs3d );
Display( iaGs3d );
Print( "aGs3d has order ", Order( aGs3d ), "\n\n" );

Gs3dd8 := GroupoidByUnion( [ Gd8, Gs3d ] );
SetName( Gs3dd8, "Gs3d+Gd8" );
common := GroupoidMorphismWithCommonRange( Gs3dd8, Gs3d, [ aGs3d, md8 ] );
Print( "combining md8 and aGs3d:\n");
Display( common );

Hk4d := SubgroupoidByComponents( Gd8, [ [[-9,-8,-7], k4d] ] );
Print( "\nHk4d = ", Hk4d, "\n" );
SetName( Hk4d, "Hk4d" );
genq8 := GeneratorsOfGroup(q8);
hq8 := GroupHomomorphismByImages( q8,k4d,genq8,[(1,2)(3,4),(1,3)(2,4),()]);
mq8 := GroupoidMorphism( Gq8, Hk4d, [-7,-9], hq8 );
Print( "groupoid morphism mq8:\n" );
Display( mq8 );
iHk4d := InclusionMappingGroupoids( Gd8, Hk4d );
Print( "inclusion mapping of k4d in d8, iHk4d :-\n" );
Display( iHk4d);
comp1 := mq8*iHk4d;
Print( "composing mq8 and iHk4d and then aGd8 to give comp1,comp2 :-\n" );
Display( comp1 );
comp2 := comp1*aGd8;
Display( comp2 );
Gs3dk4d := Groupoid( [ Gs3d, Hk4d ] );
ms3dk4d := GroupoidMorphismByComponents( Gs3dk4d, Gs3dd8, [ iHk4d, aGs3d ] );
Display( ms3dk4d );

Gq8d8c6 := GroupoidByUnion( [ Gd8c6, Gq8 ] );
SetName( Gq8d8c6, "Gd8+Gc6+Gq8" );
Gs3dk4d := GroupoidByUnion( [ Gs3d, Hk4d ] );
SetName( Gs3dk4d, "Gs3d+Hk4d" );
mq8d8c6 := GroupoidMorphismByComponents( Gq8d8c6, Gs3dk4d, [ md8c6, mq8 ] );
Print( mq8d8c6, "\n" );

idGd8 := IdentityMapping( Gd8 );
Print( "idGd8 = ", idGd8, "\n" );
isos3d := IsomorphismNewObjects( Gs3d, [-32,-31,-30] );
Hs3d := Range( isos3d );
SetName( Hs3d, "Hs3d" );
Print( "isomorphism: s3d on ", Gs3d!.objects, 
       " to s3d on ", Hs3d!.objects, "\n", isos3d, "\n" );
Display( isos3d );

SetName( ComponentsOfGroupoid(Ud8)[1], "Ud8a" );
SetName( ComponentsOfGroupoid(Ud8)[2], "Ud8b" );
Print("\nInclusion and Restriction Mappings:\n");
inc := InclusionMappingGroupoids( Gd8, Ud8 );
Display( inc );
res := RestrictionMappingGroupoids( md8, Ud8, Gs3d );
Display( res );

Print("\nIsomorphism from PcGroup to PermGroup:\n");
isoq8 := IsomorphismPermGroupoid( Gq8 );
Pq8 := Range( isoq8 );
SetName( Pq8, "Pq8" );
Display( isoq8 );
e8 := GroupoidElement( Gq8, q8.2, -27, -28 );
Print( "e8 = ", e8, "  has image  ", ImageElm( isoq8, e8 ), "\n\n" );

inc12 := InclusionMappingGroupoids( Gd12, Gs3d );
Print( "inc12 = ", inc12, "\n" );
Display( inc12 );
Print( " injective on objects? ", IsInjectiveOnObjects( inc12 ), "\n" );;
Print( "surjective on objects? ", IsSurjectiveOnObjects( inc12 ), "\n" );;
Print( " bijective on objects? ", IsBijectiveOnObjects( inc12 ), "\n" );;

Print("\nexample of composition of morphisms\n" );

genq8 := GeneratorsOfGroup( q8 );
imq8 := [ q8.2, q8.1*q8.2, q8.3 ];
autq8 := GroupHomomorphismByImages( q8, q8, genq8, imq8 );
autGq8 := GroupoidMorphism( Gq8, Gq8, [-27,-28], autq8 );
Display( autGq8 );
Print( "autGq8 has order ", Order( autGq8 ), "\n" );

Print("=============================================================\n\n");
