~a-j-delaney/libamore/cunit-dev

« back to all changes in this revision

Viewing changes to src/libAMoRE/mon.h

  • Committer: buraq
  • Date: 2004-04-16 17:04:28 UTC
  • Revision ID: vcs-imports@canonical.com-20040416170428-ko6l3kyx1c5jyrll
initial

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*!\file  mon.h
 
2
 * \brief declarations for monoids, d-class decompositions
 
3
 *  Copyright (c) ?    - 2000 Lehrstuhl fuer Informatik VII, RWTH Aachen
 
4
 *  Copyright (c) 2000 - 2002 Burak Emir
 
5
 *  This file is part of the libAMoRE library.
 
6
 *
 
7
 *  libAMoRE is  free software; you can redistribute it and/or
 
8
 *  modify it under the terms of the GNU Lesser General Public
 
9
 *  License as published by the Free Software Foundation; either
 
10
 *  version 2.1 of the License, or (at your option) any later version.
 
11
 *  You should have received a copy of the GNU Lesser General Public
 
12
 *  License along with the GNU C Library; if not, write to the Free
 
13
 *  Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 
14
 *  02111-1307 USA.  
 
15
 */
 
16
#ifndef _MON_H
 
17
#define _MON_H
 
18
 
 
19
#include "global.h"
 
20
#include "dfa.h"
 
21
 
 
22
/** D-class (Green's relations) 
 
23
 */
 
24
struct dclass { 
 
25
    /** element in the upper left hclass */
 
26
    posint    org;           
 
27
    /** #r-classes,#lclasses */
 
28
    posint    rno,lno;         
 
29
    /** #elements in a h-class */
 
30
    posint    hsize;          
 
31
    /** array of prefixes(suffixes)
 
32
     * of representatives of
 
33
     * each r(l)-class (0 to r(l)no-1) 
 
34
     */
 
35
    array     lrep,rrep;     
 
36
    /** one full h-class (0 to hsize-1) */
 
37
    array     hclass;         
 
38
    /** true iff regular d-class */
 
39
    boole     regular;        
 
40
    /** rang of d-class */
 
41
    posint    rang;           
 
42
    /** max.\ length of an element */
 
43
    posint    maxlen;         
 
44
    /** height of dclass in partial order */   
 
45
    posint    hei;            
 
46
} ;
 
47
/** pointer to a D-class */
 
48
typedef struct dclass *d_class;
 
49
 
 
50
/** array of D-classes */
 
51
typedef d_class *darray;
 
52
 
 
53
/** D-class decomposition */
 
54
struct d_struct {
 
55
    /** (0 to dno-1) */
 
56
    darray dclassarray;  
 
57
    /** #dclasses */
 
58
    posint dno;      
 
59
    /** #lclasses */
 
60
    posint lno;      
 
61
    /** #rclasses */
 
62
    posint rno;      
 
63
    /** height of d-class partial order */
 
64
    posint height;       
 
65
    /** partialorder */     
 
66
    arrayofarray  partial;    
 
67
    /** number of succ */
 
68
    array  numberofsucc;      
 
69
} ;
 
70
 
 
71
/** pointer to a D-class decomposition */
 
72
typedef struct d_struct *dstruct;
 
73
 
 
74
/** relation */
 
75
struct r_struct { 
 
76
  posint    rno;    /**<no of relations*/            
 
77
       array lside; /**< leftside(number of a monoidelement) (0 .. rno-1) */
 
78
       array rside; /**< rightside(number of a generator)    (0 .. rno-1) */
 
79
 
 
80
} ;
 
81
/** pointer to a relation */
 
82
typedef struct r_struct *rstruct;
 
83
 
 
84
/** monoid 
 
85
 *  @ingroup LDO_DECL
 
86
 */
 
87
struct mono { 
 
88
    /** #states */ 
 
89
    posint  qno;
 
90
    /** #letters */
 
91
    posint  sno;
 
92
    /** #elements */
 
93
    posint  mno;     
 
94
    /** #generators */
 
95
    posint  gno;             
 
96
    /** list of generators (0 to gno)*/
 
97
    array   generator;       
 
98
    /** let2gen[i]=j iff 
 
99
     * j is the least letter with the 
 
100
     * transformation of generator i 
 
101
     */
 
102
    array   let2gen;         
 
103
    /** transf_ of elements(0 to mno-1, 0 to qno) */
 
104
    arrayofarray no2trans;   
 
105
    /** gensucc[i][0]= predecessor of i      
 
106
     *
 
107
     *  gensucc[i][gen]=i*gen (0 to mno-1,0gno) 
 
108
     */
 
109
    arrayofarray gensucc;    
 
110
    /** last letter of a shortest 
 
111
     *  representation of a element (0 to mno-1) 
 
112
     */
 
113
    array     lastletter;    
 
114
    /** length of the representation (0 to mno-1) */
 
115
    array     no2length;     
 
116
    /** number of the zero if one exists
 
117
     *
 
118
     *  stamon->mno if no zero exists 
 
119
     */
 
120
    posint    zero;          
 
121
    /** syn.\ monoid = syn.\ semigroup */
 
122
    boole     mequals;       
 
123
    /** d-classes are computed */
 
124
    boole     dclassiscomputed;
 
125
    /** dclass structure if computed */
 
126
    dstruct   ds;              
 
127
    /** no2rang is computed */
 
128
    boole     relationcomputed;
 
129
    /** relation if computed */
 
130
    rstruct   rs;              
 
131
    /** free space used for the computation 
 
132
     * of a representative with
 
133
     * lastletter and gensucc[0] 
 
134
     */    
 
135
    array     word;            
 
136
    /** free space for display of repr. */
 
137
    string    repr;            
 
138
} ;
 
139
/** pointer to a monoid 
 
140
 *  @ingroup LDO_DECL
 
141
*/
 
142
typedef struct mono *monoid;
 
143
 
 
144
/** allocates a new monoid
 
145
 */
 
146
monoid   newmon() ;
 
147
/** frees the memory used by the monoid mon
 
148
 */
 
149
void     freemon(monoid mon) ;
 
150
 
 
151
/** frees the memory used by the D-class structure dcl
 
152
 *
 
153
 * i is the number of the used entries in dclassarray
 
154
 */
 
155
void     freedcl(dstruct dcl, posint i) ;
 
156
 
 
157
/** allocates a new dclass
 
158
 */
 
159
d_class  newdclass() ;
 
160
 
 
161
/** allorcates a new dstruct
 
162
 */
 
163
dstruct  newdstruct() ;
 
164
 
 
165
/** allocates a new rstruct
 
166
 */
 
167
rstruct newrstruct() ;
 
168
/** allocates a new darray
 
169
 */
 
170
darray   newdarray(posint a) ;
 
171
 
 
172
/** same as prword1((char **)NULL,FALSE,(posint *)NULL,no,mon,with,TRUE));
 
173
 */
 
174
char *prword( posint no,
 
175
              monoid mon,
 
176
              boole with ) ;
 
177
 
 
178
/** returns the shortest representative of the element no in monoid mon
 
179
 *
 
180
 * if (copy) word contains a copy of the output
 
181
 *
 
182
 * in this case length is the size of word
 
183
 *
 
184
 * if (with) mark idempotent elements with a star
 
185
 *
 
186
 * if (zeroone) print 0 for mon->zero else the representative of the zero
 
187
 *
 
188
 *              print 1 for the identity else ""
 
189
 */
 
190
char* prword1( char **word,
 
191
               boole copy,
 
192
               posint *length,
 
193
               posint no,
 
194
               monoid mon,
 
195
               boole with,
 
196
               boole zeroone) ;
 
197
 
 
198
/** multiplication of 2 monoidelements a and b */
 
199
 
 
200
posint mult(monoid mon,posint a,posint b) ;
 
201
 
 
202
/** needed when loading... from file */
 
203
void comprestofmon(monoid mon,dfa indfa) ;
 
204
 
 
205
/** compute length of longest representative of monoid mon */
 
206
posint monmaxlen(monoid mon) ;
 
207
 
 
208
#endif