File: rewrite.g

package info (click to toggle)
gap-scscp 2.4.3%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,704 kB
  • sloc: xml: 1,231; sh: 406; makefile: 19
file content (227 lines) | stat: -rw-r--r-- 6,587 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# Exec("date");Rewritability(AlternatingGroup(5),10);time;Exec("date");
Rewritability:=function(G,limit)
local eltsG, s, A, orbsA, x, q, n, isnrw, nrw, S, i, j, u, K, y, orbsK, v, tw; 
eltsG:=Filtered( G, s -> s <> () );
A:=AutomorphismGroup(G);
orbsA:=Orbits(A,G);
x:=Filtered( List(orbsA, q -> q[1] ), q -> q <> () );
x:=List( x, q -> [q] );
n:=1;
repeat
    n:=n+1;
    Print("Started enumeration of NRW of length ", n, "\n");
    nrw:=[];
    S := SymmetricGroup( n );
    S := Filtered( S, s -> s <> () );
    for i in [1..Length(x)] do   
        # Print( i, "/", Length(nrw), "\r");
        u := x[i]; 
        K:=Stabilizer(A,u[1]);
        for j in [ 2 .. Length(u) ] do
            K:=Intersection( K, Stabilizer( A,u[j] ) );
            if Size(K) = 1 then
                y := eltsG;
                break;
             fi;
        od;
        if Size(K) > 1 then
            orbsK:=Orbits(K,G);
            y:=Filtered( List(orbsK, q -> q[1] ), q -> q <> () );
        fi;    
        tw := u;
        for v in y do
            tw[n] := v;
            isnrw:=true;
            for s in S do
                if Product(tw)=Product(Permuted(tw,s)) then
                    isnrw := false;
                    break;
                fi;    
            od;
            if isnrw then     
                Add( nrw, ShallowCopy(tw) );
            fi;
        od;
    od;
    Print( Length(nrw), " NRW of length ", n, " constructed\n");
    if nrw=[] then
        return n;
    fi;
    x := ShallowCopy( nrw );
until n=limit;
return fail;
end;


# Exec("date");RewritabilityWithCache(AlternatingGroup(5),10);time;Exec("date");
RewritabilityWithCache:=function(G,limit)
local eltsG, s, A, orbsA, x, q, n, isnrw, nrw, S, i, j, u, K, y, orbsK, v, tw; 
eltsG:=Filtered( G, s -> s <> () );
A:=AutomorphismGroup(G);
orbsA:=Orbits(A,G);
x:=Filtered( List(orbsA, q -> q[1] ), q -> q <> () );
x:=List( x, q -> [ [ q ], Stabilizer( A,q ) ] );
n:=1;
repeat
    n:=n+1;
    Print("Started enumeration of NRW of length ", n, "\n");
    nrw:=[];
    S := SymmetricGroup( n );
    S := Filtered( S, s -> s <> () );
    for i in [1..Length(x)] do   
        # Print( i, "/", Length(nrw), "\r");
        u := x[i][1]; 
        K := x[i][2];
        if Size(K) = 1 then
            y := eltsG;        
        else
            orbsK:=Orbits(K,G);
            y:=Filtered( List(orbsK, q -> q[1] ), q -> q <> () );
        fi;    
        tw := u;
        for v in y do
            tw[n] := v;
            isnrw:=true;
            for s in S do
                if Product(tw)=Product(Permuted(tw,s)) then
                    isnrw := false;
                    break;
                fi;    
            od;
            if isnrw then     
                Add( nrw, [ ShallowCopy(tw), Intersection( K, Stabilizer( A,v ) ) ] );
            fi;
        od;
    od;
    Print( Length(nrw), " NRW of length ", n, " constructed\n");
    if nrw=[] then
        return n;
    fi;
    x := ShallowCopy( nrw );
until n=limit;
return fail;
end;


RewritabilityWorker:=function( a )
local G, w, stab, limit, x ,eltsG, s, A, orbsA, q, n, isnrw, nrw, S, 
      i, j, u, K, y, orbsK, v, tw, res, g;
G:=a[1];       
w:=a[2];
stab:=a[3];
limit:=a[4];
eltsG:=Filtered( G, s -> s <> () );
A:=AutomorphismGroup(G);
if stab=[] then
    x:=[ [ w, Subgroup(A, [One(A)] ) ] ];
else
    x:=[ [ w, Subgroup( A, List(stab, g -> GroupHomomorphismByImages( G, G, g[1], g[2] ) ) ) ] ];
fi;    
#orbsA:=Orbits(A,G);
#x:=Filtered( List(orbsA, q -> q[1] ), q -> q <> () );
#x:=List( x, q -> [ [ q ], Stabilizer( A,q ) ] );
n:=Length(w);
res:=[];
repeat
    n:=n+1;
    Print("Started enumeration of NRW of length ", n, " on worker\n");
    nrw:=[];
    S := SymmetricGroup( n );
    S := Filtered( S, s -> s <> () );
    for i in [1..Length(x)] do   
        # Print( i, "/", Length(nrw), "\r");
        u := x[i][1]; 
        K := x[i][2];
        if Size(K) = 1 then
            y := eltsG;        
        else
            orbsK:=Orbits(K,G);
            y:=Filtered( List(orbsK, q -> q[1] ), q -> q <> () );
        fi;    
        tw := u;
        for v in y do
            tw[n] := v;
            isnrw:=true;
            for s in S do
                if Product(tw)=Product(Permuted(tw,s)) then
                    isnrw := false;
                    break;
                fi;    
            od;
            if isnrw then     
                Add( nrw, [ ShallowCopy(tw), Intersection( K, Stabilizer( A,v ) ) ] );
            fi;
        od;
    od;
    Print( Length(nrw), " NRW of length ", n, " constructed on worker\n");
    res[n]:=Length(nrw);
    if nrw=[] then
        return res;
    fi;
    x := ShallowCopy( nrw );
until n=limit;
return res;
end;

RewritabilityParallel:=function(G,limit,depth)
local eltsG, s, A, orbsA, x, q, n, isnrw, nrw, S, 
      i, j, u, K, y, orbsK, v, tw, res, res1, w, r; 
if depth<3 then
    Error("the third argument should be bigger than 2 \n");
fi;
eltsG:=Filtered( G, s -> s <> () );
A:=AutomorphismGroup(G);
orbsA:=Orbits(A,G);
x:=Filtered( List(orbsA, q -> q[1] ), q -> q <> () );
x:=List( x, q -> [ [ q ], Stabilizer( A,q ) ] );
n:=1;
res:=[];
repeat
  n:=n+1;
  Print("Started enumeration of NRW of length ", n, "\n");
  if n>=depth then
    res1 := Sum( ParListWithSCSCP( 
                    List( x, w -> [ G, w[1], List( GeneratorsOfGroup(w[2]),MappingGeneratorsImages), limit ] ), 
                          "RewritabilityWorker" ) );
    res := res + Concatenation( ListWithIdenticalEntries( n-1, 0), res1 );                      
    return res;
  else
    nrw:=[];
    S := SymmetricGroup( n );
    S := Filtered( S, s -> s <> () );
    for i in [1..Length(x)] do   
        # Print( i, "/", Length(nrw), "\r");
        u := x[i][1]; 
        K := x[i][2];
        if Size(K) = 1 then
            y := eltsG;        
        else
            orbsK:=Orbits(K,G);
            y:=Filtered( List(orbsK, q -> q[1] ), q -> q <> () );
        fi;    
        tw := u;
        for v in y do
            tw[n] := v;
            isnrw:=true;
            for s in S do
                if Product(tw)=Product(Permuted(tw,s)) then
                    isnrw := false;
                    break;
                fi;    
            od;
            if isnrw then     
                Add( nrw, [ ShallowCopy(tw), Intersection( K, Stabilizer( A,v ) ) ] );
            fi;
        od;
    od;
  fi;  
  Print( Length(nrw), " NRW of length ", n, " constructed\n");
  res[n]:=Length(nrw);
  if nrw=[] then
      return res;
  fi;
  x := ShallowCopy( nrw );
until n=limit;
return res;
end;