File: test-KBmag.C

package info (click to toggle)
magnus 20060324-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 19,404 kB
  • ctags: 20,466
  • sloc: cpp: 130,118; ansic: 37,076; tcl: 10,970; perl: 1,109; makefile: 963; sh: 403; yacc: 372; csh: 57; awk: 33; asm: 10
file content (149 lines) | stat: -rw-r--r-- 4,337 bytes parent folder | download | duplicates (3)
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
// Copyright (C) 1994 The New York Group Theory Cooperative
// See magnus/doc/COPYRIGHT for the full notice.

// Contents: Test of KBmagPackage.
//           Should produce output identical to test-KBmagPackage.mastertestout,
//           given test-KBmagPackage.data as input.
//
// Principal Author: Sarah Rees
//
// Status: in progress
//
// Revision History:
//

#include "KBmagPackage.h"
#include "FPGroup.h"
#include "Set.h"
#include "Word.h"
#include "DiffMachine.h" 
#include "GenMult.h" 
#include "WordOrder.h"


main()
{
  FPGroup G;
  VectorOf<int> order;
  cin >> G;
  char ch;
  cin >> ch;
  if (ch != '[') { cerr << "Unexpected input, aborted"<<endl; exit(1);}
  do {
    int i;
    cin >> i;
    order.append(i);
    cin>> ch;
    if (ch==']') break;
    else if (ch!=','){ cerr << "Unexpected input, aborted"<<endl; exit(1);}
  } while (ch==',');
  WordOrder word_order("ShortLex",order);
  KBmagPackage kbmag(G.namesOfGenerators(),G.getRelators(),word_order,20);
  if ( !kbmag.sanityCheck() ) {
    error("kbmag failed sanity check.\n");
  }
  if (kbmag.autgroup()==yes){
    cout << "Group "<< G << " is proved shortlex automatic"<<endl;
    GroupDFSA WA = kbmag.wordAcceptor();
    WA.setName("Word_acceptor");
    WA.printOn();
    GenMult GM = kbmag.generalMultiplier();
    GM.setName("General_multiplier");
    GM.printOn();
    DiffMachine D1 = kbmag.differenceMachine(1);
    D1.setName("1stDiffMachine");
    D1.printOn();
    DiffMachine D2 = kbmag.differenceMachine(2);
    D2.setName("2ndDiffMachine");
    D2.printOn();
  }
  else 
    cout << "Group "<< G << " is not proved shortlex automatic"<<endl;
  cout << endl;
  
  FPGroup G2;
  cin >> G2;
  KBmagPackage kbmag2(G2.namesOfGenerators(),G2.getRelators());
  if ( !kbmag2.sanityCheck() ) {
    error("kbmag2 failed sanity check.\n");
  }
  if (kbmag2.kbprog()==yes && kbmag2.gpmakefsa()==yes && kbmag2.gpaxioms()==yes){
    cout << "Group "<< G2 << " is proved shortlex automatic"<<endl;
    GroupDFSA WA = kbmag2.wordAcceptor();
    WA.setName("Word_acceptor");
    WA.printOn();
    GenMult GM = kbmag2.generalMultiplier();
    GM.setName("General_multiplier");
    GM.printOn();
    DiffMachine D1 = kbmag2.differenceMachine(1);
    D1.setName("1stDiffMachine");
    D1.printOn();
    DiffMachine D2 = kbmag2.differenceMachine(2);
    D2.setName("2ndDiffMachine");
    D2.printOn();
  }
  else 
    cout << "Group "<< G2 << " is not proved shortlex automatic"<<endl;
  cout << endl;
  FPGroup G3;
  cin >> G3;
  KBmagPackage kbmag3(G3.namesOfGenerators(),G3.getRelators());
  if ( !kbmag3.sanityCheck() ) {
    error("kbmag3 failed sanity check.\n");
  }
  if (kbmag3.kbprog()>0){
    Bool abort=NO;
    int loop=0;
    do {
      loop++;
      cout << "Trying to built automata."<< endl;
      if (loop>1) cout << "Pass no. " << loop <<" though loop."<< endl; 
      if (kbmag3.gpwa()!=yes || kbmag3.gpgenmult()!=yes) abort=YES; 
      if (abort){ cout << "Failed, giving up!"<< endl; break;}
      GroupDFSA WA = kbmag3.wordAcceptor();
      WA.setName("Word_acceptor");
      WA.printOn();
      GenMult GM = kbmag3.generalMultiplier();
      GM.setName("GeneralMultiplier");
      GM.printOn();
      DiffMachine D1 = kbmag3.differenceMachine(1);
      D1.setName("1stDiffMachine");
      D1.printOn();
      DiffMachineRep D2 = kbmag3.differenceMachineRep(2);
      D2.setName("2ndDiffMachine");
      D2.printOn();
    } while (kbmag3.gpcheckmult()==no);
    if (abort==NO && kbmag3.gpaxioms()==yes)
      cout << "Group "<< G3 << " is proved shortlex automatic"<<endl;
    else 
      cout << "Group "<< G3 << " is not proved shortlex automatic"<<endl;
   }
   GroupDFSARep WA2 = kbmag3.wordAcceptorRep();
   DiffMachineRep D3 = kbmag3.differenceMachineRep(2);
   KBmagPackage kbmag4(G3.namesOfGenerators(),G3.getRelators());
   kbmag4.setWordAcceptor(WA2);
   kbmag4.setDifferenceMachine(D3,2);
   kbmag4.gpgenmult();
   DFSA F;
   F.readFrom();
   kbmag4.minimize(F);
   F.printOn();
   GroupDFSARep F2;
   F2.readFrom();
   kbmag4.minimize(F2);
   F2.printOn();
   GroupDFSA M1;
   M1.readFrom();
   GroupDFSA M2;
   M2.readFrom();
   GroupDFSA M3;
   kbmag4.gpcomp(M1,M2,M3);
   M3.printOn();
   GroupDFSARep N1;
   N1.readFrom();
   GroupDFSARep N2;
   N2.readFrom();
   GroupDFSARep N3;
   kbmag4.gpcomp(N1,N2,N3);
   N3.printOn();
}