CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

| Download

GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it

Views: 418346
1
<Chapter Label="Examples">
2
<Heading>Examples of &SCSCP; usage</Heading>
3
4
In this chapter we are going to demonstrate some examples of communication
5
between client and server using the SCSCP.
6
7
<Section Label="ProvidingServices">
8
<Heading>Providing services with the SCSCP package</Heading>
9
10
You can try to run the SCSCP server with the configuration file
11
<File>scscp/example/myserver.g</File>. To do this, go to that directory
12
and enter <C>gap myserver.g</C>. After this you will see some information
13
messages and finally the server will start to wait for the connection. The
14
final part of the startup screen may look as follows:
15
16
<Log>
17
<![CDATA[
18
#I Installed SCSCP procedure Factorial
19
#I Installed SCSCP procedure WS_Factorial
20
#I Installed SCSCP procedure GroupIdentificationService
21
#I Installed SCSCP procedure IdGroup512ByCode
22
#I Installed SCSCP procedure WS_IdGroup
23
#I Installed SCSCP procedure WS_Karatsuba
24
#I Installed SCSCP procedure EvaluateOpenMathCode
25
#I Ready to accept TCP/IP connections at localhost:26133 ...
26
#I Waiting for new client connection at localhost:26133 ...
27
]]>
28
</Log>
29
30
See further self-explanatory comments in the file
31
<File>scscp/example/myserver.g</File>.
32
There also some test files in the directory <File>scscp/tst/</File>
33
supplied with detailed comments. First, you may use demonstration
34
files, preliminary turning on the demonstration mode as it is
35
explained in these files, or just executing step by step each command
36
from <File>scscp/tst/demo.g</File> and <File>scscp/tst/omdemo.g</File>.
37
Then you can try to use files <File>scscp/tst/id512.g</File>,
38
<File>scscp/tst/idperm.g</File> and <File>scscp/tst/factor.g</File>
39
for further tests of &SCSCP; services.
40
</Section>
41
42
<Section Label="Id512">
43
<Heading>Identifying groups of order 512</Heading>
44
45
We will give an example guiding you through all steps
46
of creation of your own &SCSCP; service.
47
<P/>
48
49
The &GAP; Small Group Library does not provide identification for
50
groups of order 512 using the function <C>IdGroup</C>:
51
52
<Log>
53
<![CDATA[
54
gap> IdGroup( DihedralGroup( 256 ) );
55
[ 256, 539 ]
56
gap> IdGroup(DihedralGroup(512));
57
Error, the group identification for groups of size 512 is not available
58
called from
59
<function "unknown">( <arguments> )
60
called from read-eval loop at line 71 of *stdin*
61
you can 'quit;' to quit to outer loop, or
62
you can 'return;' to continue
63
brk>
64
]]>
65
</Log>
66
67
However, the &GAP; package &ANUPQ; <Cite Key="ANUPQ"/> has a function
68
<C>IdStandardPresented512Group</C> that does this work as demonstrated
69
below:
70
71
<Example>
72
<![CDATA[
73
gap> LoadPackage("anupq");
74
---------------------------------------------------------------------------
75
Loading ANUPQ (ANU p-Quotient) 3.1.4
76
GAP code by Greg Gamble <[email protected]> (address for correspondence)
77
Werner Nickel (http://www.mathematik.tu-darmstadt.de/~nickel/)
78
[uses ANU pq binary (C code program) version: 1.9]
79
C code by Eamonn O'Brien (http://www.math.auckland.ac.nz/~obrien)
80
Co-maintained by Max Horn <[email protected]>
81
82
For help, type: ?ANUPQ
83
---------------------------------------------------------------------------
84
true
85
gap> G := DihedralGroup( 512 );
86
<pc group of size 512 with 9 generators>
87
gap> F := PqStandardPresentation( G );
88
<fp group on the generators [ f1, f2, f3, f4, f5, f6, f7, f8, f9 ]>
89
gap> H := PcGroupFpGroup( F );
90
<pc group of size 512 with 9 generators>
91
gap> IdStandardPresented512Group( H );
92
[ 512, 2042 ]
93
]]>
94
</Example>
95
96
The package &ANUPQ; requires <Package>UNIX</Package> environment
97
and it is natural to provide an identification service for groups of
98
order 512 to make it available for other platforms.
99
<P/>
100
101
Now we need to decide how the client will transmit a group to the server.
102
Can we encode this group in &OpenMath;? But there is no content dictionary
103
for PcGroups. Should we convert it to a permutation representation to be
104
able to use existing content dictionaries? But then the resulting &OpenMath;
105
code will be not compact. However, the &SCSCP; protocol provides enough
106
freedom for the user to select its own data representation, and since we
107
are linking together two copies of the same system, we may use the
108
<E>pcgs code</E> to pass the data to the server
109
(see <Ref BookName="ref" Func="CodePcGroup" />.
110
<P/>
111
112
First we create a function which accepts the integer number that is the code for
113
pcgs of a group of order 512 and returns the number of this group in the
114
GAP Small Groups library:
115
116
<Log>
117
<![CDATA[
118
IdGroup512ByCode := function( code )
119
local G, F, H;
120
G := PcGroupCode( code, 512 );
121
F := PqStandardPresentation( G );
122
H := PcGroupFpGroup( F );
123
return IdStandardPresented512Group( H );
124
end;
125
]]>
126
</Log>
127
128
After such function was created on the server, we need to make it
129
<Q>visible</Q> as an &SCSCP; procedure:
130
131
<Log>
132
<![CDATA[
133
gap> InstallSCSCPprocedure("IdGroup512", IdGroup512ByCode );
134
InstallSCSCPprocedure : procedure IdGroup512 installed.
135
]]>
136
</Log>
137
138
Note that this function assumes that the argument is a valid code
139
for some group of order 512, and we wish the client to make it
140
sure that this is the case. To do this, and also for the client's
141
convenience, we provide the client's counterpart for this
142
service. Here the group must be a pc-group of order 512, otherwise
143
an error message will appear.
144
145
<Example>
146
<![CDATA[
147
gap> IdGroup512 := function( G )
148
> local code, result;
149
> if Size( G ) <> 512 then
150
> Error( "G must be a group of order 512 \n" );
151
> fi;
152
> code := CodePcGroup( G );
153
> result := EvaluateBySCSCP( "IdGroup512ByCode", [ code ],
154
> "localhost", 26133 );
155
> return result.object;
156
> end;;
157
]]>
158
</Example>
159
160
Now the client can call the function <C>IdGroup512</C>, and the procedure
161
of getting result is as much straightforward as using <C>IdGroup</C> for
162
those groups where it works:
163
164
<Example>
165
<![CDATA[
166
gap> IdGroup512(DihedralGroup(512));
167
[ 512, 2042 ]
168
]]>
169
</Example>
170
171
</Section>
172
173
</Chapter>
174