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
|
// Copyright (C) 1994 The New York Group Theory Cooperative
// See magnus/doc/COPYRIGHT for the full notice.
// Contents: Definition of DiffMachineRep class.
//
// Principal Author: Sarah Rees
//
// Status: in progress
//
// Revision History:
//
// * 08/96 Dmitry B. implemented IPC tools.
//
#ifndef _DiffMachineRep_H_
#define _DiffMachineRep_H_
#include "Word.h"
#include "Set.h"
#include "Vector.h"
#include "DFSARep.h"
#include "DFSA.h"
#include "DiffHistory.h"
#include "WordOrder.h"
class DiffMachineRep : public GroupDFSARep {
public:
//@rn Kludge!!?
DiffMachineRep() : GroupDFSARep() {}
DiffMachineRep(const VectorOf<Chars> & genNames) :
GroupDFSARep("",genNames),
diffs(1,1) {
Word w; diffs[0]=w; // position 0 isn't actually used
setNumStrings(2);
}
DiffMachineRep(const VectorOf<Chars> & genNames,const WordOrder & word_order) :
GroupDFSARep("",genNames,word_order),
diffs(1,1) {
Word w; diffs[0]=w; // position 0 isn't actually used
setNumStrings(2);
}
DiffMachineRep( const DiffMachineRep& D ) : // Copy constructor does deep copy.
GroupDFSARep(D), diffs(D.diffs) { }
DiffMachineRep & operator = ( const DiffMachineRep & D )
{
GroupDFSARep& temp = *this;
temp = (GroupDFSARep)D;
(DFSARep)*this = (DFSARep)D;
diffs = D.diffs;
return *this;
}
FSARep *clone() const { return new DiffMachineRep(*this); }
Bool operator == ( const DiffMachineRep& D ) const {
if (equalDFSA(D)==0) return 0;
else for (State s=1;s<=getNumStates();s++){
if (category(s)==1 && diffs[s] != (D.diffs)[s])
return 0;
}
return 1;
}
// Bool nextAcceptedWord(Word w, int*& history) const {}; //@rn bad arg
void minimize() {};
void readFrom(istream &str = cin);
void printAccepting(ostream &str = cout) const ;
void printStates(ostream &str = cout) const ;
// Set/reset the number of states in the automaton to numOfStates
void setNumStates(int numOfStates);
Word getDifference(State s) const {
//cerr << "Got difference number" << s << ": "<< diffs[s] << endl;
return diffs[s];}
void setDifference(State s,Word w) { diffs[s] = w;}
void addDifferencesEqn
(const Word & w1,const Word & w2,const WordOrder & word_order);
void closeUnderSubstrings(int mode,const WordOrder & word_order);
void closeUnderInverses(const WordOrder & word_order);
Bool rewrite(Word & w) const;
Bool rewrite(Word & w,const WordOrder & word_order) const;
GroupDFSA wordAcceptor(const WordOrder & word_order) const;
void buildDifferenceMachine(DiffMachineRep & D,
const SetOf<Word> & differences,const WordOrder & word_order) const;
void rebuildDifferenceMachine(const WordOrder & word_order);
/////////////////////////////////////////////////////////////////////////
// //
// IPC tools: //
// //
/////////////////////////////////////////////////////////////////////////
void write( ostream& ostr ) const
{
GroupDFSARep::write(ostr);
ostr < diffs;
}
void read( istream& istr )
{
GroupDFSARep::read(istr);
istr > diffs;
}
private:
VectorOf<Word> diffs;
void buildWordAcceptor(GroupDFSARep & Wp,const WordOrder & word_order) const;
GroupDFSA convertToGroupDFSA(GroupDFSARep * Wp) const;
Bool reductionAhead(State d,const AheadInfo & ai,const WordOrder & word_order) const;
};
#endif
|