forked from gap-packages/SimplicialSurfaces
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_colSimpSurf.g
491 lines (418 loc) · 18.2 KB
/
test_colSimpSurf.g
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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
##
## Test the consistency of a coloured simplicial surface.
##
TestColouredSimplicialSurfaceConsistency := function( surface, messageSurfaceOrigin )
local i, numbersAsSet, classesByNumbers, el;
if not IsColouredSimplicialSurface( surface ) then
Print( messageSurfaceOrigin );
Print( " is not a coloured simplicial surface.\n");
fi;
# Test the underlying simplicial surface
if not IsSimplicialSurface( UnderlyingSimplicialSurface(surface) ) then
Print( messageSurfaceOrigin );
Print( ": Underlying simplicial surface is not a simplicial surface.\n");
fi;
# Test the quotient simplicial surface
if not IsSimplicialSurface( QuotientSimplicialSurface(surface) ) then
Print( messageSurfaceOrigin );
Print( ": Quotient simplicial surface is not a simplicial surface.\n");
fi;
##
## Test the consistency of the vertices
##
# Compare NumbersAsSet and NumbersByElements
if VertexEquivalenceNumbersAsSet(surface) <> Set( VertexEquivalenceNumbersByElements(surface) ) then
Print( messageSurfaceOrigin );
Print( " has inconsistent vertex equivalence numbers (in comparing AsSet with ByElements).\n");
fi;
# Compare ClassesByNumbers and ClassesByElements
if Set( VertexEquivalenceClassesByNumbers(surface) ) <> Set( VertexEquivalenceClassesByElements(surface) ) then
Print( messageSurfaceOrigin );
Print( " has inconsistent vertex equivalence classes (in comparing ByNumbers with ByElements).\n");
fi;
# Check ClassesByElements internally
for i in Vertices( UnderlyingSimplicialSurface( surface ) ) do
if not i in VertexEquivalenceClassesByElements(surface)[i] then
Print( messageSurfaceOrigin );
Print( " has an inconsistent vertex equivalence class for the vertex " );
Print( i );
Print( ".\n");
fi;
od;
# Compare NumbersAsSet and ClassesByNumbers
numbersAsSet := VertexEquivalenceNumbersAsSet(surface);
classesByNumbers := VertexEquivalenceClassesByNumbers(surface);
for i in [1..Length(classesByNumbers)] do
if i in numbersAsSet and not IsBound( classesByNumbers[i] ) then
Print( messageSurfaceOrigin );
Print( ": the vertex equivalence number " );
Print( i );
Print( " has no associated equivalence class.\n" );
elif not i in numbersAsSet and IsBound( classesByNumbers[i] ) then
Print( messageSurfaceOrigin );
Print( ": " );
Print( i );
Print( " is no vertex equivalence number but has an associated equivalence class.\n" );
fi;
od;
# Check if the class separation works
if Vertices( UnderlyingSimplicialSurface( surface ) ) <> Union( Set( VertexEquivalenceClassesByNumbers(surface) ) ) then
Print( messageSurfaceOrigin );
Print( ": vertex equivalence classes (by numbers) don't partition the vertex set.\n");
fi;
if Vertices( UnderlyingSimplicialSurface( surface ) ) <> Union( Set( VertexEquivalenceClassesByElements(surface) ) ) then
Print( messageSurfaceOrigin );
Print( ": vertex equivalence classes (by elements) don't partition the vertex set.\n");
fi;
##
## Test the consistency of the edges
##
# Compare NumbersAsSet and NumbersByElements
if EdgeEquivalenceNumbersAsSet(surface) <> Set( EdgeEquivalenceNumbersByElements(surface) ) then
Print( messageSurfaceOrigin );
Print( " has inconsistent edge equivalence numbers (in comparing AsSet with ByElements).\n");
fi;
# Compare ClassesByNumbers and ClassesByElements
if Set( EdgeEquivalenceClassesByNumbers(surface) ) <> Set( EdgeEquivalenceClassesByElements(surface) ) then
Print( messageSurfaceOrigin );
Print( " has inconsistent edge equivalence classes (in comparing ByNumbers with ByElements).\n");
fi;
# Check ClassesByElements internally
for i in Edges( UnderlyingSimplicialSurface( surface ) ) do
if not i in EdgeEquivalenceClassesByElements(surface)[i] then
Print( messageSurfaceOrigin );
Print( " has an inconsistent edge equivalence class for the edge " );
Print( i );
Print( ".\n");
fi;
od;
# Compare NumbersAsSet and ClassesByNumbers
numbersAsSet := EdgeEquivalenceNumbersAsSet(surface);
classesByNumbers := EdgeEquivalenceClassesByNumbers(surface);
for i in [1..Length(classesByNumbers)] do
if i in numbersAsSet and not IsBound( classesByNumbers[i] ) then
Print( messageSurfaceOrigin );
Print( ": the edge equivalence number " );
Print( i );
Print( " has no associated equivalence class.\n" );
elif not i in numbersAsSet and IsBound( classesByNumbers[i] ) then
Print( messageSurfaceOrigin );
Print( ": " );
Print( i );
Print( " is no edge equivalence number but has an associated equivalence class.\n" );
fi;
od;
# Check if the class separation works
if Edges( UnderlyingSimplicialSurface( surface ) ) <> Union( Set( EdgeEquivalenceClassesByNumbers(surface) ) ) then
Print( messageSurfaceOrigin );
Print( ": edge equivalence classes (by numbers) don't partition the edge set.\n");
fi;
if Edges( UnderlyingSimplicialSurface( surface ) ) <> Union( Set( EdgeEquivalenceClassesByElements(surface) ) ) then
Print( messageSurfaceOrigin );
Print( ": edge equivalence classes (by elements) don't partition the edge set.\n");
fi;
##
## Test the consistency of the faces
##
# Compare NumbersAsSet and NumbersByElements
if FaceEquivalenceNumbersAsSet(surface) <> Set( FaceEquivalenceNumbersByElements(surface) ) then
Print( messageSurfaceOrigin );
Print( " has inconsistent face equivalence numbers (in comparing AsSet with ByElements).\n");
fi;
# Compare ClassesByNumbers and ClassesByElements
if Set( FaceEquivalenceClassesByNumbers(surface) ) <> Set( FaceEquivalenceClassesByElements(surface) ) then
Print( messageSurfaceOrigin );
Print( " has inconsistent face equivalence classes (in comparing ByNumbers with ByElements).\n");
fi;
# Check ClassesByElements internally
for i in Faces( UnderlyingSimplicialSurface( surface ) ) do
if not i in FaceEquivalenceClassesByElements(surface)[i] then
Print( messageSurfaceOrigin );
Print( " has an inconsistent face equivalence class for the face " );
Print( i );
Print( ".\n");
fi;
od;
# Compare NumbersAsSet and ClassesByNumbers
numbersAsSet := FaceEquivalenceNumbersAsSet(surface);
classesByNumbers := FaceEquivalenceClassesByNumbers(surface);
for i in [1..Length(classesByNumbers)] do
if i in numbersAsSet and not IsBound( classesByNumbers[i] ) then
Print( messageSurfaceOrigin );
Print( ": the face equivalence number " );
Print( i );
Print( " has no associated equivalence class.\n" );
elif not i in numbersAsSet and IsBound( classesByNumbers[i] ) then
Print( messageSurfaceOrigin );
Print( ": " );
Print( i );
Print( " is no face equivalence number but has an associated equivalence class.\n" );
fi;
od;
# Check if the class separation works
if Faces( UnderlyingSimplicialSurface( surface ) ) <> Union( Set( FaceEquivalenceClassesByNumbers(surface) ) ) then
Print( messageSurfaceOrigin );
Print( ": face equivalence classes (by numbers) don't partition the face set.\n");
fi;
if Faces( UnderlyingSimplicialSurface( surface ) ) <> Union( Set( FaceEquivalenceClassesByElements(surface) ) ) then
Print( messageSurfaceOrigin );
Print( ": face equivalence classes (by elements) don't partition the face set.\n");
fi;
# Check vertex binding relation
for i in VertexEquivalenceNumbersAsSet(surface) do
if VertexEquivalenceClassesByNumbers(surface)[i] <> Set( Union( EquivalenceClasses( VertexBindingRelation(surface,i ) ) ) ) then
Print( messageSurfaceOrigin );
Print( ": vertex equivalence relation of number ");
Print( i );
Print( " does not partition the vertex equivalence class.\n");
fi;
od;
# Check edge binding relation
for i in EdgeEquivalenceNumbersAsSet(surface) do
if EdgeEquivalenceClassesByNumbers(surface)[i] <> Set( Union( EquivalenceClasses( EdgeBindingRelation(surface,i ) ) ) ) then
Print( messageSurfaceOrigin );
Print( ": edge equivalence relation of number ");
Print( i );
Print( " does not partition the edge equivalence class.\n");
fi;
od;
# Check local orientation
#TODO check whether the elements in the cycles match
#TODO test equivalence methods
##
## Convenience methods
##
# Check VertexEquivalenceNumberOfElement
for el in Vertices( UnderlyingSimplicialSurface( surface ) ) do
if VertexEquivalenceNumberOfElement(surface,el) <> VertexEquivalenceNumberOfElementNC(surface,el) then
Print( messageSurfaceOrigin );
Print( " has different vertex equivalence number results for NC.\n");
fi;
if VertexEquivalenceNumberOfElement(surface,el) <> VertexEquivalenceNumbersByElements(surface)[el] then
Print( messageSurfaceOrigin );
Print( " has inconsistent convenience method to determine vertex equivalence numbers.\n");
fi;
od;
# Check EdgeEquivalenceNumberOfElement
for el in Edges( UnderlyingSimplicialSurface( surface ) ) do
if EdgeEquivalenceNumberOfElement(surface,el) <> EdgeEquivalenceNumberOfElementNC(surface,el) then
Print( messageSurfaceOrigin );
Print( " has different edge equivalence number results for NC.\n");
fi;
if EdgeEquivalenceNumberOfElement(surface,el) <> EdgeEquivalenceNumbersByElements(surface)[el] then
Print( messageSurfaceOrigin );
Print( " has inconsistent convenience method to determine edge equivalence numbers.\n");
fi;
od;
# Check FaceEquivalenceNumberOfElement
for el in Faces( UnderlyingSimplicialSurface( surface ) ) do
if FaceEquivalenceNumberOfElement(surface,el) <> FaceEquivalenceNumberOfElementNC(surface,el) then
Print( messageSurfaceOrigin );
Print( " has different face equivalence number results for NC.\n");
fi;
if FaceEquivalenceNumberOfElement(surface,el) <> FaceEquivalenceNumbersByElements(surface)[el] then
Print( messageSurfaceOrigin );
Print( " has inconsistent convenience method to determine face equivalence numbers.\n");
fi;
od;
# Check VertexEquivalenceClassOfElement
for el in Vertices( UnderlyingSimplicialSurface( surface ) ) do
if VertexEquivalenceClassOfElement(surface,el) <> VertexEquivalenceClassOfElementNC(surface,el) then
Print( messageSurfaceOrigin );
Print( " has different vertex equivalence class (by element) results for NC.\n");
fi;
if VertexEquivalenceClassOfElement(surface,el) <> VertexEquivalenceClassesByElements(surface)[el] then
Print( messageSurfaceOrigin );
Print( " has inconsistent convenience method to determine vertex equivalence classes (by element).\n");
fi;
od;
# Check EdgeEquivalenceClassOfElement
for el in Edges( UnderlyingSimplicialSurface( surface ) ) do
if EdgeEquivalenceClassOfElement(surface,el) <> EdgeEquivalenceClassOfElementNC(surface,el) then
Print( messageSurfaceOrigin );
Print( " has different edge equivalence class (by element) results for NC.\n");
fi;
if EdgeEquivalenceClassOfElement(surface,el) <> EdgeEquivalenceClassesByElements(surface)[el] then
Print( messageSurfaceOrigin );
Print( " has inconsistent convenience method to determine edge equivalence classes (by element).\n");
fi;
od;
# Check FaceEquivalenceClassOfElement
for el in Faces( UnderlyingSimplicialSurface( surface ) ) do
if FaceEquivalenceClassOfElement(surface,el) <> FaceEquivalenceClassOfElementNC(surface,el) then
Print( messageSurfaceOrigin );
Print( " has different face equivalence class (by element) results for NC.\n");
fi;
if FaceEquivalenceClassOfElement(surface,el) <> FaceEquivalenceClassesByElements(surface)[el] then
Print( messageSurfaceOrigin );
Print( " has inconsistent convenience method to determine face equivalence classes (by element).\n");
fi;
od;
# Check VertexEquivalenceClassByNumber
for el in Vertices( UnderlyingSimplicialSurface( surface ) ) do
if VertexEquivalenceClassByNumber(surface,el) <> VertexEquivalenceClassByNumberNC(surface,el) then
Print( messageSurfaceOrigin );
Print( " has different vertex equivalence class (by number) results for NC.\n");
fi;
if VertexEquivalenceClassByNumber(surface,el) <> VertexEquivalenceClassesByNumbers(surface)[el] then
Print( messageSurfaceOrigin );
Print( " has inconsistent convenience method to determine vertex equivalence classes (by number).\n");
fi;
od;
# Check EdgeEquivalenceClassByNumber
for el in Edges( UnderlyingSimplicialSurface( surface ) ) do
if EdgeEquivalenceClassByNumber(surface,el) <> EdgeEquivalenceClassByNumberNC(surface,el) then
Print( messageSurfaceOrigin );
Print( " has different edge equivalence class (by number) results for NC.\n");
fi;
if EdgeEquivalenceClassByNumber(surface,el) <> EdgeEquivalenceClassesByNumbers(surface)[el] then
Print( messageSurfaceOrigin );
Print( " has inconsistent convenience method to determine edge equivalence classes (by number).\n");
fi;
od;
# Check FaceEquivalenceClassByNumber
for el in Faces( UnderlyingSimplicialSurface( surface ) ) do
if FaceEquivalenceClassByNumber(surface,el) <> FaceEquivalenceClassByNumberNC(surface,el) then
Print( messageSurfaceOrigin );
Print( " has different face equivalence class (by number) results for NC.\n");
fi;
if FaceEquivalenceClassByNumber(surface,el) <> FaceEquivalenceClassesByNumbers(surface)[el] then
Print( messageSurfaceOrigin );
Print( " has inconsistent convenience method to determine face equivalence classes (by number).\n");
fi;
od;
end;
##
## Test the consistency of a simplicial surface identification.
##
TestSimplicialSurfaceIdentificationConsistency := function( id, messageIdOrigin )
if not IsSimplicialSurfaceIdentification( id ) then
Print( messageIdOrigin );
Print( " is not a simplicial surface identification.\n");
fi;
# Check vertex map
if not IsMapping( VertexMap(id) ) then
Print( messageIdOrigin );
Print( ": Vertex map is not a mapping.\n" );
fi;
if not IsBijective( VertexMap(id) ) then
Print( messageIdOrigin );
Print( ": Vertex map is not bijective.\n" );
fi;
# Check edge map
if not IsMapping( EdgeMap(id) ) then
Print( messageIdOrigin );
Print( ": Edge map is not a mapping.\n" );
fi;
if not IsBijective( EdgeMap(id) ) then
Print( messageIdOrigin );
Print( ": Edge map is not bijective.\n" );
fi;
# Check face map
if not IsMapping( FaceMap(id) ) then
Print( messageIdOrigin );
Print( ": Face map is not a mapping.\n" );
fi;
if not IsBijective( FaceMap(id) ) then
Print( messageIdOrigin );
Print( ": Face map is not bijective.\n" );
fi;
# Check whether the map-constructor leads to the given identification
if id <> SimplicialSurfaceIdentification( VertexMap(id), EdgeMap(id), FaceMap(id) ) then
Print( messageIdOrigin );
Print( " is different from an identification with the same maps.\n" );
fi;
if id <> SimplicialSurfaceIdentificationNC( VertexMap(id), EdgeMap(id), FaceMap(id) ) then
Print( messageIdOrigin );
Print( " is different from an identification with the same maps (NC).\n" );
fi;
end;
##
## Test the consistency of a simplicial surface identification together with
## a coloured simplicial surface. This method only checks the interaction
## of these two objects, not the consistency of the objects themselves.
##
TestColouredIdentificationConsistency := function( surface, id, messageConnection )
local wellDef, constOnInter, applicable, extension;
wellDef := IsWellDefinedIdentification( surface, id );
constOnInter := IsConstantOnIntersection( surface, id );
applicable := IsApplicableExtension( surface, id );
# Check if wellDef is consistent for both inputs
if wellDef <> IsWellDefinedIdentification( UnderlyingSimplicialSurface(surface), id ) then
Print( messageConnection );
Print( ": well-defined is inconsistent.\n" );
fi;
# Constant on intersection should be false if it is not well defined
if not wellDef and constOnInter then
Print( messageConnection );
Print( " is not well-defined but constant on the intersection.\n" );
fi;
# If it is well-defined, constOnInter may be called as NC-version
if wellDef then
if constOnInter <> IsConstantOnIntersectionNCWellDefined( surface, id ) then
Print( messageConnection );
Print( " has inconsistent ConstantOnIntersection.\n" );
fi;
fi;
#
# To check applicable we proceed in several steps
#
# if wellDef is false, then applicable is false
if not wellDef and applicable then
Print( messageConnection );
Print( " is not well-defined but applicable.\n" );
fi;
# if constOnInter is false, then applicable is false
if not constOnInter and applicable then
Print( messageConnection );
Print( " is not constant on the intersection but applicable.\n" );
fi;
# if wellDef is true, then the NC-version may be called
if wellDef then
if applicable <> IsApplicableExtensionNCWellDefined(surface, id) then
Print( messageConnection );
Print( " has inconsistent applicability (controlling for well-definedness).\n" );
fi;
if not constOnInter and IsApplicableExtensionNCWellDefined(surface, id) then
Print( messageConnection );
Print( " is not constant on the intersection but applicable (NC well-defined).\n" );
fi;
fi;
# if constOnInter is true, then the NC-version may be called
if constOnInter then
if applicable <> IsApplicableExtensionNCIntersection(surface, id) then
Print( messageConnection );
Print( " has inconsistent applicability (controlling for intersection).\n" );
fi;
fi;
# if applicable is true, we can extend the surface
if applicable then
extension := ExtendByIdentification(surface, id);
if not IsColouredSimplicialSurface( extension ) then
Print( messageConnection );
Print( " has an extension that is not a coloured simplicial surface.\n" );
fi;
if not IsSubcolouring( extension, surface ) then
Print( messageConnection );
Print( " has an extension that is not a subcolouring of the original coloured simplicial surface.\n" );
fi;
if extension <> ExtendByIdentificationNC(surface, id) then
Print( messageConnection );
Print( " has different extensions for the NC-version.\n" );
fi;
# After extending the identification should still be applicable but
# should not change the surface further
if not IsConstantOnIntersection(extension, id) then
Print( messageConnection );
Print(": after extension the identification should be still constant on the intersection.\n");
fi;
if not IsApplicableExtension(extension, id) then
Print( messageConnection );
Print(": after extension the identification should still be applicable.\n");
fi;
if extension <> ExtendByIdentificationNC( extension, id ) then
Print( messageConnection );
Print(": after extension the same identification should not modify the surface further.\n");
fi;
fi;
end;