Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

/magnus/back_end/KB/include/WordOrder.h

Go to the documentation of this file.
00001 /*
00002  *   $Id: WordOrder.h,v 1.2 1999/11/23 20:28:54 bormotov Exp $
00003  */
00004 
00005 // Copyright (C) 1994 The New York Group Theory Cooperative
00006 // See magnus/doc/COPYRIGHT for the full notice.
00007 
00008 // Contents: Definition of WordOrder.
00009 //
00010 // Principal Author: Sarah Rees
00011 //
00012 // Status: in progress
00013 //
00014 // Revision History:
00015 //
00016 
00017 #ifndef _WordOrder_H_
00018 #define _WordOrder_H_
00019 
00020 #include "Word.h"
00021 #include "Vector.h"
00022 // #include "DFSARep.h"
00023 #include "Set.h"
00024 #include "DiffHistoryRep.h"
00025 #include "WordOrderRep.h"
00026 typedef int State; 
00027 // @sr for now this file needs to be independent of DFSARep.
00028 // So for now we'll typedef State to be int, but that's only temporary.
00029 // That's because a declaration of SetOf<DiffHistory> is necessary in Set.C
00030 // (for each of the various DiffHistory types)
00031 // and that can't be dependent on the FSA hierarchy.
00032 
00033 class WordOrder : public ObjectOf<WordOrderRep> {
00034 public:
00035 //constructor
00036   WordOrder() : ObjectOf< WordOrderRep > (new WordOrderRep()){};
00037 
00038   WordOrder(const Chars & oType) : 
00039     ObjectOf< WordOrderRep > (
00040     (oType==Chars("ShortLex")? new ShortLexRep() :
00041       (oType==Chars("WtShortLex")? new WtShortLexRep():
00042         (oType==Chars("WtLex")? new WtLexRep(): new WordOrderRep())))) {};
00043 
00044   WordOrder(const Chars & oType, int numOfSymbols) : 
00045     ObjectOf< WordOrderRep > (
00046     (oType==Chars("ShortLex")? new ShortLexRep(numOfSymbols) :
00047       (oType==Chars("WtShortLex")? new WtShortLexRep(numOfSymbols):
00048         (oType==Chars("WtLex")? new WtLexRep(numOfSymbols): new WordOrderRep(numOfSymbols))))) {};
00049 
00050   WordOrder(const Chars & oType,const VectorOf<int> & v) : 
00051     ObjectOf< WordOrderRep > (
00052     (oType==Chars("ShortLex")? new ShortLexRep(v) :
00053       (oType==Chars("WtShortLex")? new WtShortLexRep(v):
00054         (oType==Chars("WtLex")? new WtLexRep(v): new WordOrderRep(v))))) {};
00055 // v is interpreted as specifying an order of generators for shortlex,
00056 // but as weights for the weighted orders.
00057 // To specify both orders and weights for the weighted orders, two
00058 // vectors must be given as arguments
00059 
00060 // The next constructor cannot be used for ShortLex
00061   WordOrder(const Chars & oType,const VectorOf<int> & o,const VectorOf<int> & w)
00062    : ObjectOf< WordOrderRep > (
00063      (oType==Chars("WtShortLex")? new WtShortLexRep(o,w):
00064         (oType==Chars("WtLex")? new WtLexRep(o,w): new WordOrderRep(o)))) {};
00065 
00066   int signature(const Word & w1,const Word & w2) const {
00067     return look()->signature(w1,w2); }
00068   // return 1 if w1<w2, -1 if w1>w2, 0 if w1=w2
00069     
00070   int signature(Generator g,Generator h) const { return look()->signature(g,h);};
00071   // return 1 if g<h, -1 if g>h and 0 if g=h
00072   int signature(int i,int j) const { return look()->signature(i,j);}
00073   // returns signature(g,h), where g is the i-th and h the j-th generator in
00074   // the order.
00075 
00076   void balancedEquationFromRelator(const Word & w,Word & lhs,Word & rhs) const
00077     { look()->balancedEquationFromRelator(w,lhs,rhs);}
00078   // sets lhs equal to w1, rhs to w2, where w1>=w2 in the word order
00079   // w=w1*w2^-1 and w1 is as short as possible such that this can happen.
00080 
00081   int historyBound(const VectorOf<Word> & diffs) const{ 
00082     return look()->historyBound(diffs);}
00083   DiffHistoryRep * buildDiffHistoryRep() const { 
00084     return look()->buildDiffHistoryRep();};
00085   DiffHistoryRep * buildDiffHistoryRep(State d,int g,int h) const  {
00086     return look()->buildDiffHistoryRep(d,g,h);};
00087 // build a difference history for the word difference g^-1h, attached
00088 // to state d of the difference machine, bearing in mind the mysterious bound M,
00089 // which might mean the history becomes trivial.
00090 
00091   DiffHistoryRep * update 
00092      (const DiffHistoryRep & dh,State d,int g,int h,const Word & wd) const {
00093     return look()->update(dh,d,g,h,wd); };
00094 // Given a difference history dh associated with pairs of words w,u,
00095 // construct the difference history associated with pairs wg,uh and the
00096 // state d of the difference machine (which is of course the target
00097 // of the state for dh under the pair of symbols (g,h)
00098 
00099   Bool reduction(const DiffHistoryRep & dh,int g,int h) const {
00100     return look()->reduction(dh,g,h); };
00101 // returns YES if the difference history contains a pair w,u of words
00102 // such that wg=_G uh and uh < wg in the word order.
00103 
00104   Bool possibleReduction(const AheadInfoRep & ai,int g) const {
00105     return look()->possibleReduction(ai,g); };
00106 
00107   AheadInfoRep *  update(const AheadInfoRep & ai,int g) const {
00108     return look()->update(ai,g); };
00109 
00110 
00111   DiffHistoryVtxRep * buildDiffHistoryVtxRep() const { 
00112     return look()->buildDiffHistoryVtxRep();};
00113   DiffHistoryVtxRep * buildDiffHistoryVtxRep(State d,int g,int h)
00114 const  {
00115     return look()->buildDiffHistoryVtxRep(d,g,h);};
00116 // build a difference history for the word difference g^-1h
00117 
00118   DiffHistoryVtxRep * update 
00119      (const DiffHistoryVtxRep & dh,State d,int g,int h,DiffHistoryVtx * ptr) const
00120 {
00121     return look()->update(dh,d,g,h,ptr); };
00122 // Given a DiffHistoryVtx * dhp associated with pairs of words w,u, 
00123 // construct the difference history associated with pairs wg,uh
00124 
00125   Bool reduction(const DiffHistoryVtxRep & dh,int g,int h) const {
00126     return look()->reduction(dh,g,h); };
00127 // returns YES if the difference history contains a pair w,u of words
00128 // such that wg=_G uh and uh < wg in the word order.
00129 
00130   Bool possibleReductionAhead(const DiffHistoryVtxRep & dh,int g) const {
00131     return look()->possibleReductionAhead(dh,g); };
00132 
00133   Chars getOrderType() const { return look()->getOrderType(); }
00134   int getNumSymbols() const { return look()->getNumSymbols(); }
00135   int getSymbolIndex(int i) const { return look()->getSymbolIndex(i);}
00136 // i takes values from 1 to getNumSymbols() below
00137   Generator getWeight(int i) const { return look()->getWeight(i); }
00138   int getWeight(const Word & w) const { return look()->getWeight(w); }
00139   Generator getSymbol(int i) const { return look()->getSymbol(i); }
00140 // getPosition(0 is the inverse of getSymbol()
00141   int getPosition(Generator g) const { return look()->getPosition(g); }
00142   int selfInverse(Generator g) const { return look()->selfInverse(g); }
00143   Word inverse(const Word & w) const { return look()->inverse(w); }
00144 protected:
00145   typedef ObjectOf<WordOrderRep> R;
00146   WordOrder( WordOrderRep *p ) : R(p) {}
00147 };
00148 #endif

Generated at Tue Jun 19 09:49:36 2001 for Magnus Classes by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001