File: WordOrder.h

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 (144 lines) | stat: -rw-r--r-- 6,087 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
// Copyright (C) 1994 The New York Group Theory Cooperative
// See magnus/doc/COPYRIGHT for the full notice.

// Contents: Definition of WordOrder.
//
// Principal Author: Sarah Rees
//
// Status: in progress
//
// Revision History:
//

#ifndef _WordOrder_H_
#define _WordOrder_H_

#include "Word.h"
#include "Vector.h"
// #include "DFSARep.h"
#include "Set.h"
#include "DiffHistoryRep.h"
#include "WordOrderRep.h"
typedef int State; 
// @sr for now this file needs to be independent of DFSARep.
// So for now we'll typedef State to be int, but that's only temporary.
// That's because a declaration of SetOf<DiffHistory> is necessary in Set.C
// (for each of the various DiffHistory types)
// and that can't be dependent on the FSA hierarchy.

class WordOrder : public ObjectOf<WordOrderRep> {
public:
//constructor
  WordOrder() : ObjectOf< WordOrderRep > (new WordOrderRep()){};

  WordOrder(const Chars & oType) : 
    ObjectOf< WordOrderRep > (
    (oType==Chars("ShortLex")? new ShortLexRep() :
      (oType==Chars("WtShortLex")? new WtShortLexRep():
        (oType==Chars("WtLex")? new WtLexRep(): new WordOrderRep())))) {};

  WordOrder(const Chars & oType, int numOfSymbols) : 
    ObjectOf< WordOrderRep > (
    (oType==Chars("ShortLex")? new ShortLexRep(numOfSymbols) :
      (oType==Chars("WtShortLex")? new WtShortLexRep(numOfSymbols):
        (oType==Chars("WtLex")? new WtLexRep(numOfSymbols): new WordOrderRep(numOfSymbols))))) {};

  WordOrder(const Chars & oType,const VectorOf<int> & v) : 
    ObjectOf< WordOrderRep > (
    (oType==Chars("ShortLex")? new ShortLexRep(v) :
      (oType==Chars("WtShortLex")? new WtShortLexRep(v):
        (oType==Chars("WtLex")? new WtLexRep(v): new WordOrderRep(v))))) {};
// v is interpreted as specifying an order of generators for shortlex,
// but as weights for the weighted orders.
// To specify both orders and weights for the weighted orders, two
// vectors must be given as arguments

// The next constructor cannot be used for ShortLex
  WordOrder(const Chars & oType,const VectorOf<int> & o,const VectorOf<int> & w)
   : ObjectOf< WordOrderRep > (
     (oType==Chars("WtShortLex")? new WtShortLexRep(o,w):
        (oType==Chars("WtLex")? new WtLexRep(o,w): new WordOrderRep(o)))) {};

  int signature(const Word & w1,const Word & w2) const {
    return look()->signature(w1,w2); }
  // return 1 if w1<w2, -1 if w1>w2, 0 if w1=w2
    
  int signature(Generator g,Generator h) const { return look()->signature(g,h);};
  // return 1 if g<h, -1 if g>h and 0 if g=h
  int signature(int i,int j) const { return look()->signature(i,j);}
  // returns signature(g,h), where g is the i-th and h the j-th generator in
  // the order.

  void balancedEquationFromRelator(const Word & w,Word & lhs,Word & rhs) const
    { look()->balancedEquationFromRelator(w,lhs,rhs);}
  // sets lhs equal to w1, rhs to w2, where w1>=w2 in the word order
  // w=w1*w2^-1 and w1 is as short as possible such that this can happen.

  int historyBound(const VectorOf<Word> & diffs) const{ 
    return look()->historyBound(diffs);}
  DiffHistoryRep * buildDiffHistoryRep() const { 
    return look()->buildDiffHistoryRep();};
  DiffHistoryRep * buildDiffHistoryRep(State d,int g,int h) const  {
    return look()->buildDiffHistoryRep(d,g,h);};
// build a difference history for the word difference g^-1h, attached
// to state d of the difference machine, bearing in mind the mysterious bound M,
// which might mean the history becomes trivial.

  DiffHistoryRep * update 
     (const DiffHistoryRep & dh,State d,int g,int h,const Word & wd) const {
    return look()->update(dh,d,g,h,wd); };
// Given a difference history dh associated with pairs of words w,u,
// construct the difference history associated with pairs wg,uh and the
// state d of the difference machine (which is of course the target
// of the state for dh under the pair of symbols (g,h)

  Bool reduction(const DiffHistoryRep & dh,int g,int h) const {
    return look()->reduction(dh,g,h); };
// returns YES if the difference history contains a pair w,u of words
// such that wg=_G uh and uh < wg in the word order.

  Bool possibleReduction(const AheadInfoRep & ai,int g) const {
    return look()->possibleReduction(ai,g); };

  AheadInfoRep *  update(const AheadInfoRep & ai,int g) const {
    return look()->update(ai,g); };


  DiffHistoryVtxRep * buildDiffHistoryVtxRep() const { 
    return look()->buildDiffHistoryVtxRep();};
  DiffHistoryVtxRep * buildDiffHistoryVtxRep(State d,int g,int h)
const  {
    return look()->buildDiffHistoryVtxRep(d,g,h);};
// build a difference history for the word difference g^-1h

  DiffHistoryVtxRep * update 
     (const DiffHistoryVtxRep & dh,State d,int g,int h,DiffHistoryVtx * ptr) const
{
    return look()->update(dh,d,g,h,ptr); };
// Given a DiffHistoryVtx * dhp associated with pairs of words w,u, 
// construct the difference history associated with pairs wg,uh

  Bool reduction(const DiffHistoryVtxRep & dh,int g,int h) const {
    return look()->reduction(dh,g,h); };
// returns YES if the difference history contains a pair w,u of words
// such that wg=_G uh and uh < wg in the word order.

  Bool possibleReductionAhead(const DiffHistoryVtxRep & dh,int g) const {
    return look()->possibleReductionAhead(dh,g); };

  Chars getOrderType() const { return look()->getOrderType(); }
  int getNumSymbols() const { return look()->getNumSymbols(); }
  int getSymbolIndex(int i) const { return look()->getSymbolIndex(i);}
// i takes values from 1 to getNumSymbols() below
  Generator getWeight(int i) const { return look()->getWeight(i); }
  int getWeight(const Word & w) const { return look()->getWeight(w); }
  Generator getSymbol(int i) const { return look()->getSymbol(i); }
// getPosition(0 is the inverse of getSymbol()
  int getPosition(Generator g) const { return look()->getPosition(g); }
  int selfInverse(Generator g) const { return look()->selfInverse(g); }
  Word inverse(const Word & w) const { return look()->inverse(w); }
protected:
  typedef ObjectOf<WordOrderRep> R;
  WordOrder( WordOrderRep *p ) : R(p) {}
};
#endif