1
/**************************************************************/
2
/* ********************************************************** */
4
/* * REPRESENTATION OF PROOF SEARCH * */
6
/* * $Module: PROOF SEARCH * */
8
/* * Copyright (C) 1997, 1998, 1999, 2000 * */
9
/* * MPI fuer Informatik * */
11
/* * This program is free software; you can redistribute * */
12
/* * it and/or modify it under the terms of the FreeBSD * */
15
/* * This program is distributed in the hope that it will * */
16
/* * be useful, but WITHOUT ANY WARRANTY; without even * */
17
/* * the implied warranty of MERCHANTABILITY or FITNESS * */
18
/* * FOR A PARTICULAR PURPOSE. See the LICENCE file * */
19
/* * for more details. * */
22
/* $Revision: 1.7 $ * */
24
/* $Date: 2010-02-22 14:09:59 $ * */
25
/* $Author: weidenb $ * */
28
/* * Christoph Weidenbach * */
29
/* * MPI fuer Informatik * */
30
/* * Stuhlsatzenhausweg 85 * */
31
/* * 66123 Saarbruecken * */
32
/* * Email: spass@mpi-inf.mpg.de * */
35
/* ********************************************************** */
36
/**************************************************************/
39
/* $RCSfile: search.h,v $ */
47
/**************************************************************/
48
/* Data Structures and Constants */
49
/**************************************************************/
51
/* <isleft>: true iff the split is a left branch */
52
/* <blockedClauses>: list of (unshared) clauses containing the */
53
/* "remainder" of the clause splitted at this */
54
/* level and the negation of the first branch */
55
/* if this branch created a ground clause. */
56
/* The right clause has clause number 0, and */
57
/* the negation clauses have number -1. */
58
/* <deletedClauses>: list of (unshared) clauses made redundant */
59
/* by a clause of this level. The split level */
60
/* of these clauses may be above or below the */
61
/* current level, but not equal to the current */
63
/* <father>: the unshared clause that was splitted. */
64
/* <leftSplitfield>: the used splits of the left branch */
65
/* corresponding to current split if it is a */
66
/* right branch; not used for left splits */
67
/* <rightSplitfield>: the used splits of the current split if it */
68
/* is a right branch; not used for left splits */
70
/* == 0 -> TOPLEVEL, 1,2,... */
74
LIST blockedClauses, deletedClauses;
76
SPLITFIELD leftSplitfield, rightSplitfield;
77
unsigned leftSplitfield_length, rightSplitfield_length;
81
typedef struct PROOFSEARCH_HELP {
84
LIST usedemptyclauses;
95
PRECEDENCE precedence;
105
NAT nontrivclausenumber;
106
} PROOFSEARCH_NODE,*PROOFSEARCH;
108
/* There are two sets of clauses with their respective clause list: worked-off clauses */
109
/* contained in <woindex>, <wolist> and usable clauses, contained in <usindex>,<uslist>. */
110
/* The assoc list <finitepreds> is a list of pairs (<pred>.(<gterm1>,...,<gtermn>)) */
111
/* where <pred> (monadic) has (at most) the extension <gterm1>,...,<gtermn> */
112
/* Three sort theories: <astatic> is the static overall approximation, only available */
113
/* in a non-equality setting, <adynamic> is the dynamic approximation only considering */
114
/* maximal declarations, and <dynamic> is the (not approximated) dynamic sort theory of */
115
/* all maximal declarations. Clauses that are no longer needed for the search, but for */
116
/* proof documentation are stored in <dpindex>, <dplist>. If <dpindex> is NULL, then */
117
/* this means that no proof documentation is required. */
118
/* A search is also heavily influenced by the used <precedence> and flag values in */
120
/* The next components deal with splitting: the split stack, the current level */
121
/* of splitting, the last backtrack level (for branch condensing) and the overall number */
122
/* of splittings stored in <splitcounter>. */
123
/* Finally some statistics is stored: the number of kept, derived clauses ... */
124
/* and the clause number of some clause that implies a non-trivial domain . */
126
/**************************************************************/
127
/* Inline Functions */
128
/**************************************************************/
130
static __inline__ LIST prfs_EmptyClauses(PROOFSEARCH Prf)
132
return Prf->emptyclauses;
135
static __inline__ void prfs_SetEmptyClauses(PROOFSEARCH Prf, LIST Clauses)
137
Prf->emptyclauses = Clauses;
140
static __inline__ LIST prfs_Definitions(PROOFSEARCH Prf)
142
return Prf->definitions;
145
static __inline__ void prfs_SetDefinitions(PROOFSEARCH Prf, LIST Definitions)
147
Prf->definitions = Definitions;
150
static __inline__ LIST prfs_UsedEmptyClauses(PROOFSEARCH Prf)
152
return Prf->usedemptyclauses;
155
static __inline__ void prfs_SetUsedEmptyClauses(PROOFSEARCH Prf, LIST Clauses)
157
Prf->usedemptyclauses = Clauses;
161
static __inline__ LIST prfs_WorkedOffClauses(PROOFSEARCH Prf)
166
static __inline__ void prfs_SetWorkedOffClauses(PROOFSEARCH Prf, LIST Clauses)
168
Prf->wolist = Clauses;
171
static __inline__ SHARED_INDEX prfs_WorkedOffSharingIndex(PROOFSEARCH Prf)
176
static __inline__ LIST prfs_UsableClauses(PROOFSEARCH Prf)
181
static __inline__ void prfs_SetUsableClauses(PROOFSEARCH Prf, LIST Clauses)
183
Prf->uslist = Clauses;
186
static __inline__ SHARED_INDEX prfs_UsableSharingIndex(PROOFSEARCH Prf)
191
static __inline__ LIST prfs_DocProofClauses(PROOFSEARCH Prf)
196
static __inline__ void prfs_SetDocProofClauses(PROOFSEARCH Prf, LIST Clauses)
198
Prf->dplist = Clauses;
201
static __inline__ SHARED_INDEX prfs_DocProofSharingIndex(PROOFSEARCH Prf)
206
static __inline__ void prfs_AddDocProofSharingIndex(PROOFSEARCH Prf)
208
Prf->dpindex = sharing_IndexCreate();
211
static __inline__ LIST prfs_GetFinMonPreds(PROOFSEARCH Prf)
213
return Prf->finmonpreds;
216
static __inline__ void prfs_SetFinMonPreds(PROOFSEARCH Prf, LIST Preds)
218
Prf->finmonpreds = Preds;
221
static __inline__ void prfs_DeleteFinMonPreds(PROOFSEARCH Prf)
223
list_DeleteAssocListWithValues(Prf->finmonpreds,
224
(void (*)(POINTER)) term_DeleteTermList);
225
prfs_SetFinMonPreds(Prf, list_Nil());
228
static __inline__ SORTTHEORY prfs_StaticSortTheory(PROOFSEARCH Prf)
233
static __inline__ void prfs_SetStaticSortTheory(PROOFSEARCH Prf, SORTTHEORY Theory)
235
Prf->astatic = Theory;
238
static __inline__ SORTTHEORY prfs_DynamicSortTheory(PROOFSEARCH Prf)
243
static __inline__ void prfs_SetDynamicSortTheory(PROOFSEARCH Prf, SORTTHEORY Theory)
245
Prf->dynamic = Theory;
248
static __inline__ SORTTHEORY prfs_ApproximatedDynamicSortTheory(PROOFSEARCH Prf)
250
return Prf->adynamic;
253
static __inline__ void prfs_SetApproximatedDynamicSortTheory(PROOFSEARCH Prf, SORTTHEORY Theory)
255
Prf->adynamic = Theory;
258
static __inline__ PRECEDENCE prfs_Precedence(PROOFSEARCH Prf)
260
return Prf->precedence;
263
static __inline__ FLAGSTORE prfs_Store(PROOFSEARCH Prf)
268
static __inline__ BOOL prfs_SplitLevelCondition(NAT OriginLevel, NAT RedundantLevel, NAT BacktrackLevel)
270
/*return (OriginLevel != RedundantLevel && OriginLevel != 0);*/
271
/*return OriginLevel != 0;*/
272
return (OriginLevel > RedundantLevel);
275
static __inline__ BOOL prfs_IsClauseValid(CLAUSE C, int Level)
277
return clause_SplitLevel(C) <= Level;
280
static __inline__ SPLIT prfs_GetSplitOfLevel(int L, PROOFSEARCH Prf)
284
while (!list_Empty(Scan) &&
285
(((SPLIT)list_Car(Scan))->splitlevel != L))
286
Scan = list_Cdr(Scan);
288
if (list_Empty(Scan)) {
291
return (SPLIT) list_Car(Scan);
295
static __inline__ LIST prfs_SplitStack(PROOFSEARCH Prf)
300
static __inline__ SPLIT prfs_SplitStackTop(PROOFSEARCH Prf)
302
return (SPLIT) list_Car(Prf->stack);
305
static __inline__ void prfs_SplitStackPop(PROOFSEARCH Prf)
307
Prf->stack = list_Pop(Prf->stack);
310
static __inline__ void prfs_SplitStackPush(PROOFSEARCH Prf, SPLIT S)
312
Prf->stack = list_Cons(S, Prf->stack);
315
static __inline__ BOOL prfs_SplitStackEmpty(PROOFSEARCH Prf)
317
return list_StackEmpty(prfs_SplitStack(Prf));
320
static __inline__ int prfs_TopLevel(void)
325
static __inline__ int prfs_ValidLevel(PROOFSEARCH Prf)
327
return Prf->validlevel;
330
static __inline__ void prfs_SetValidLevel(PROOFSEARCH Prf, int Value)
332
Prf->validlevel = Value;
335
static __inline__ void prfs_IncValidLevel(PROOFSEARCH Prf)
340
static __inline__ void prfs_DecValidLevel(PROOFSEARCH Prf)
345
static __inline__ int prfs_LastBacktrackLevel(PROOFSEARCH Prf)
347
return Prf->lastbacktrack;
350
static __inline__ void prfs_SetLastBacktrackLevel(PROOFSEARCH Prf, int Value)
352
Prf->lastbacktrack = Value;
355
static __inline__ int prfs_SplitCounter(PROOFSEARCH Prf)
357
return Prf->splitcounter;
360
static __inline__ void prfs_SetSplitCounter(PROOFSEARCH Prf, int c)
362
Prf->splitcounter = c;
365
static __inline__ void prfs_IncSplitCounter(PROOFSEARCH Prf)
367
(Prf->splitcounter)++;
370
static __inline__ int prfs_KeptClauses(PROOFSEARCH Prf)
372
return Prf->keptclauses;
375
static __inline__ void prfs_IncKeptClauses(PROOFSEARCH Prf)
380
static __inline__ int prfs_DerivedClauses(PROOFSEARCH Prf)
382
return Prf->derivedclauses;
385
static __inline__ void prfs_IncDerivedClauses(PROOFSEARCH Prf, int k)
387
Prf->derivedclauses += k;
390
static __inline__ int prfs_Loops(PROOFSEARCH Prf)
395
static __inline__ void prfs_SetLoops(PROOFSEARCH Prf, int k)
400
static __inline__ void prfs_DecLoops(PROOFSEARCH Prf)
405
static __inline__ int prfs_BacktrackedClauses(PROOFSEARCH Prf)
407
return Prf->backtracked;
410
static __inline__ void prfs_SetBacktrackedClauses(PROOFSEARCH Prf, int k)
412
Prf->backtracked = k;
415
static __inline__ void prfs_IncBacktrackedClauses(PROOFSEARCH Prf, int k)
417
Prf->backtracked += k;
420
static __inline__ NAT prfs_NonTrivClauseNumber(PROOFSEARCH Prf)
422
return Prf->nontrivclausenumber;
425
static __inline__ void prfs_SetNonTrivClauseNumber(PROOFSEARCH Prf, NAT Number)
427
Prf->nontrivclausenumber = Number;
431
/**************************************************************/
432
/* Functions for accessing SPLIT objects */
433
/**************************************************************/
435
static __inline__ void prfs_SplitFree(SPLIT Sp)
437
memory_Free(Sp, sizeof(SPLIT_NODE));
440
static __inline__ void prfs_SplitDelete(SPLIT S)
441
/**************************************************************
444
MEMORY: Deletes blocked and deleted clauses. Frees the split.
445
***************************************************************/
447
clause_DeleteClauseList(S->blockedClauses);
448
clause_DeleteClauseList(S->deletedClauses);
449
if (S->father != (CLAUSE)NULL)
450
clause_Delete(S->father);
451
if (S->leftSplitfield != NULL) {
452
memory_Free(S->leftSplitfield,
453
sizeof(SPLITFIELDENTRY) * S->leftSplitfield_length);
454
S->leftSplitfield = NULL;
456
if (S->rightSplitfield != NULL) {
457
memory_Free(S->rightSplitfield,
458
sizeof(SPLITFIELDENTRY) * S->rightSplitfield_length);
459
S->rightSplitfield = NULL;
465
static __inline__ LIST prfs_SplitBlockedClauses(SPLIT S)
467
return S->blockedClauses;
470
static __inline__ void prfs_SplitAddBlockedClause(SPLIT S, CLAUSE C)
472
S->blockedClauses = list_Cons(C,S->blockedClauses);
475
static __inline__ void prfs_SplitSetBlockedClauses(SPLIT S, LIST L)
477
S->blockedClauses = L;
480
static __inline__ LIST prfs_SplitDeletedClauses(SPLIT S)
482
return S->deletedClauses;
485
static __inline__ void prfs_SplitSetDeletedClauses(SPLIT S, LIST L)
487
S->deletedClauses = L;
490
static __inline__ int prfs_SplitSplitLevel(SPLIT S)
492
return S->splitlevel;
495
static __inline__ BOOL prfs_SplitIsLeft(SPLIT S)
500
static __inline__ void prfs_SplitSetLeft(SPLIT S)
505
static __inline__ void prfs_SplitSetRight(SPLIT S)
510
static __inline__ BOOL prfs_SplitIsUsed(SPLIT S)
515
static __inline__ BOOL prfs_SplitIsUnused(SPLIT S)
520
static __inline__ void prfs_SplitSetUsed(SPLIT S)
525
static __inline__ CLAUSE prfs_SplitFatherClause(SPLIT S)
530
static __inline__ void prfs_SplitSetFatherClause(SPLIT S, CLAUSE C)
535
static __inline__ SPLITFIELD prfs_LeftSplitfield(SPLIT S, unsigned *Length)
537
*Length = S->leftSplitfield_length;
538
return S->leftSplitfield;
541
static __inline__ SPLITFIELD prfs_RightSplitfield(SPLIT S, unsigned *Length)
543
*Length = S->rightSplitfield_length;
544
return S->rightSplitfield;
547
static __inline void prfs_SplitFreeSplitfields(SPLIT S)
549
if (S->leftSplitfield != NULL) {
550
memory_Free(S->leftSplitfield,
551
sizeof(SPLITFIELDENTRY) * S->leftSplitfield_length);
552
S->leftSplitfield = NULL;
554
if (S->rightSplitfield != NULL) {
555
memory_Free(S->rightSplitfield,
556
sizeof(SPLITFIELDENTRY) * S->rightSplitfield_length);
557
S->rightSplitfield = NULL;
562
static __inline__ BOOL prfs_ExistsSplitOfLevel(int L, PROOFSEARCH PS)
567
while (!list_Empty(Scan) &&
568
(((SPLIT)list_Car(Scan))->splitlevel != L || ((SPLIT)list_Car(Scan))->used))
569
Scan = list_Cdr(Scan);
571
if (list_Empty(Scan)) {
578
static __inline__ BOOL prfs_SplitsAvailable(PROOFSEARCH PS, FLAGSTORE Store)
580
return (flag_GetFlagIntValue(Store, flag_SPLITS) < 0 ||
581
prfs_SplitCounter(PS) < flag_GetFlagIntValue(Store, flag_SPLITS));
585
/**************************************************************/
587
/**************************************************************/
589
PROOFSEARCH prfs_Create(void);
590
BOOL prfs_Check(PROOFSEARCH);
591
void prfs_CopyIndices(PROOFSEARCH, PROOFSEARCH);
592
void prfs_Delete(PROOFSEARCH);
593
void prfs_DeleteDocProof(PROOFSEARCH);
594
void prfs_Clean(PROOFSEARCH);
595
void prfs_Print(PROOFSEARCH);
596
void prfs_PrintSplit(SPLIT);
597
void prfs_PrintSplitStack(PROOFSEARCH);
598
void prfs_InsertWorkedOffClause(PROOFSEARCH,CLAUSE);
599
void prfs_InsertUsableClause(PROOFSEARCH,CLAUSE);
600
void prfs_InsertDocProofClause(PROOFSEARCH,CLAUSE);
601
void prfs_MoveUsableWorkedOff(PROOFSEARCH, CLAUSE);
602
void prfs_MoveWorkedOffDocProof(PROOFSEARCH, CLAUSE);
603
void prfs_MoveUsableDocProof(PROOFSEARCH, CLAUSE);
604
void prfs_ExtractWorkedOff(PROOFSEARCH, CLAUSE);
605
void prfs_DeleteWorkedOff(PROOFSEARCH, CLAUSE);
606
void prfs_ExtractUsable(PROOFSEARCH, CLAUSE);
607
void prfs_DeleteUsable(PROOFSEARCH, CLAUSE);
608
void prfs_ExtractDocProof(PROOFSEARCH, CLAUSE);
609
void prfs_DeleteDocProofClause(PROOFSEARCH, CLAUSE);
610
void prfs_MoveInvalidClausesDocProof(PROOFSEARCH);
611
void prfs_SwapIndexes(PROOFSEARCH);
613
void prfs_InstallFiniteMonadicPredicates(PROOFSEARCH, LIST, LIST);
615
CLAUSE prfs_PerformSplitting(PROOFSEARCH, CLAUSE);
616
CLAUSE prfs_DoSplitting(PROOFSEARCH, CLAUSE, LIST);
617
NAT prfs_GetNumberOfInstances(PROOFSEARCH, LITERAL, BOOL);
619
void prfs_SetLeftSplitfield(SPLIT, SPLITFIELD, unsigned);
620
void prfs_SetRightSplitfield(SPLIT, SPLITFIELD, unsigned);
621
BOOL prfs_SplitfieldContainsLevel(SPLITFIELD, unsigned, NAT);
622
NAT prfs_SplitfieldHighestLevel(SPLITFIELD, unsigned);
623
void prfs_AddLevelToSplitfield(SPLITFIELD*, unsigned*, NAT);
624
void prfs_RemoveLevelFromSplitfield(SPLITFIELD*, unsigned*, NAT);
625
BOOL prfs_SplitfieldIsSubset(SPLITFIELD, unsigned, SPLITFIELD, unsigned);
626
SPLITFIELD prfs_SplitfieldUnion(SPLITFIELD, unsigned, SPLITFIELD, unsigned, unsigned*);
627
SPLITFIELD prfs_SplitfieldIntersection(SPLITFIELD, unsigned, SPLITFIELD, unsigned, unsigned*);
628
SPLITFIELD prfs_CombineSplitfields(SPLITFIELD, unsigned, SPLITFIELD, unsigned, NAT, unsigned*);