File: ccl_clausepos.h

package info (click to toggle)
eprover 2.6%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 21,288 kB
  • sloc: ansic: 331,111; csh: 12,026; python: 10,178; awk: 5,825; makefile: 461; sh: 389
file content (246 lines) | stat: -rw-r--r-- 6,362 bytes parent folder | download
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
/*-----------------------------------------------------------------------

File  : ccl_clausepos.h

Author: Stephan Schulz

Contents

  Positions of subterms in clauses (and in equations).

  Copyright 1998, 1999 by the author.
  This code is released under the GNU General Public Licence and
  the GNU Lesser General Public License.
  See the file COPYING in the main E directory for details..
  Run "eprover -h" for contact information.

Changes

<1> Wed May 20 03:34:54 MET DST 1998
    New

-----------------------------------------------------------------------*/

#ifndef CLAUSEPOS

#define CLAUSEPOS

#include <cte_termpos.h>
#include <ccl_clauses.h>


/*---------------------------------------------------------------------*/
/*                    Data type declarations                           */
/*---------------------------------------------------------------------*/



typedef struct clauseposcell
{
   Clause_p  clause;
   Eqn_p     literal;
   EqnSide   side;
   TermPos_p pos;
   void*     data;
}ClausePosCell, *ClausePos_p;

typedef struct match_info_cell {
  int remaining_args;
  ClausePos_p pos;
}MatchResCell, *MatchRes_p;

/*---------------------------------------------------------------------*/
/*                Exported Functions and Variables                     */
/*---------------------------------------------------------------------*/

typedef void (*Deleter)(void*);


#define ClausePosCellAlloc() (ClausePosCell*)SizeMalloc(sizeof(ClausePosCell))
#define ClausePosCellFree(junk)         SizeFree(junk, sizeof(ClausePosCell))
static inline void    ClausePosCellFreeWDeleter(ClausePos_p junk, Deleter del);

#define MatchResAlloc()      (MatchRes_p) SizeMalloc(sizeof(MatchResCell))
#define MatchResFree(junk)   SizeFree(junk, sizeof(MatchResCell))

#ifdef CONSTANT_MEM_ESTIMATE
#define CLAUSEPOSCELL_MEM 20
#else
#define CLAUSEPOSCELL_MEM MEMSIZE(ClausePosCell)
#endif

static inline ClausePos_p ClausePosAlloc(void);
static inline void        ClausePosFreeWDeleter(ClausePos_p junk, Deleter deleter);
#define ClausePosFree(junk) ClausePosFreeWDeleter(junk, NULL)

static inline Term_p   ClausePosGetSide(ClausePos_p pos);
static inline Term_p   ClausePosGetOtherSide(ClausePos_p pos);
static inline Term_p   ClausePosGetSubterm(ClausePos_p pos);
#define ClausePosIsTop(position) ((PStackEmpty((position)->pos)))


void     ClausePosPrint(FILE* out, ClausePos_p pos);
Eqn_p    ClausePosFindPosLiteral(ClausePos_p pos, bool maximal);
Eqn_p    ClausePosFindMaxLiteral(ClausePos_p pos, bool positive);
Term_p   ClausePosFindFirstMaximalSide(ClausePos_p pos, bool positive);
Term_p   ClausePosFindNextMaximalSide(ClausePos_p pos, bool positive);
Term_p   ClausePosFindFirstMaximalSubterm(ClausePos_p pos);
Term_p   ClausePosFindNextMaximalSubterm(ClausePos_p pos);

bool     TermComputeRWSequence(PStack_p stack, Term_p from, Term_p to,
                               int inject_op);


/*---------------------------------------------------------------------*/
/*                Inline Functions                                     */
/*---------------------------------------------------------------------*/


/*-----------------------------------------------------------------------
//
// Function: ClausePosAlloc()
//
//   Allocate an empty, semi-initialized ClausePosCell.
//
// Global Variables: -
//
// Side Effects    : Memory operations
//
/----------------------------------------------------------------------*/

static inline ClausePos_p ClausePosAlloc(void)
{
   ClausePos_p handle = ClausePosCellAlloc();

   handle->literal = NULL;
   handle->side    = LeftSide;
   handle->pos     = TermPosAlloc();

   return handle;
}


/*-----------------------------------------------------------------------
//
// Function:  ClausePosCellFreeWDeleter()
//
//   Free a clause pos cell and use deleter on junk->data
//
// Global Variables: -
//
// Side Effects    : Memory operations
//
/----------------------------------------------------------------------*/

static inline void ClausePosCellFreeWDeleter(ClausePos_p junk, Deleter deleter)
{
   assert(junk);

   if(deleter)
   {
      deleter(junk);
   }
   ClausePosCellFree(junk);
}

/*-----------------------------------------------------------------------
//
// Function:  ClausePosFree()
//
//   Free a clausepos.
//
// Global Variables: -
//
// Side Effects    : Memory operations
//
/----------------------------------------------------------------------*/

static inline void ClausePosFreeWDeleter(ClausePos_p junk, Deleter deleter)
{
   assert(junk);

   TermPosFree(junk->pos);
   ClausePosCellFree(junk);
   if(deleter)
   {
      deleter(junk->data);
   }
}


/*-----------------------------------------------------------------------
//
// Function: ClausePosGetSide()
//
//   Given a clause position, return the designated side of the
//   literal.
//
// Global Variables: -
//
// Side Effects    : -
//
/----------------------------------------------------------------------*/

static inline Term_p ClausePosGetSide(ClausePos_p pos)
{
   if(pos->side == LeftSide)
   {
      return pos->literal->lterm;
   }
   return pos->literal->rterm;
}


/*-----------------------------------------------------------------------
//
// Function: ClausePosGetOtherSide()
//
//   Given a clause position, return the _not_ designated side of the
//   literal - don't ask, this has its use!
//
// Global Variables: -
//
// Side Effects    : -
//
/----------------------------------------------------------------------*/

static inline Term_p ClausePosGetOtherSide(ClausePos_p pos)
{
   if(pos->side == LeftSide)
   {
      return pos->literal->rterm;
   }
   return pos->literal->lterm;
}



/*-----------------------------------------------------------------------
//
// Function: ClausePosGetSubterm()
//
//   Given a clause position, return the designated subterm of the
//   literal.
//
// Global Variables: -
//
// Side Effects    : -
//
/----------------------------------------------------------------------*/

static inline Term_p ClausePosGetSubterm(ClausePos_p pos)
{
   return TermPosGetSubterm(ClausePosGetSide(pos), pos->pos);
}


#endif

/*---------------------------------------------------------------------*/
/*                        End of File                                  */
/*---------------------------------------------------------------------*/