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 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933
|
/*-----------------------------------------------------------------------
File : ccl_overlap_index.c
Author: Stephan Schulz (schulz@eprover.org)
Contents
Maintaining an index from subterms to clause positions.
Copyright 2010 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 Apr 14 09:27:17 CEST 2010
New
-----------------------------------------------------------------------*/
#include "ccl_overlap_index.h"
/*---------------------------------------------------------------------*/
/* Global Variables */
/*---------------------------------------------------------------------*/
/*---------------------------------------------------------------------*/
/* Forward Declarations */
/*---------------------------------------------------------------------*/
/*---------------------------------------------------------------------*/
/* Internal Functions */
/*---------------------------------------------------------------------*/
/*-----------------------------------------------------------------------
//
// Function: term_collect_into_terms()
//
// Collect all potential into-subterms into terms.
//
// Global Variables: -
//
// Side Effects : -
//
/----------------------------------------------------------------------*/
long term_collect_into_terms(Term_p t, PTree_p *terms)
{
long res = 0;
int i;
if(TermIsVar(t))
{
return res;
}
PTreeStore(terms, t);
res++;
for(i=0; i<t->arity; i++)
{
res += term_collect_into_terms(t->args[i], terms);
}
return res;
}
/*-----------------------------------------------------------------------
//
// Function: term_collect_into_terms2()
//
// Collect all potential into-subterms into terms/natoms.
//
// Global Variables: -
//
// Side Effects : -
//
/----------------------------------------------------------------------*/
long term_collect_into_terms2(Term_p t, PTree_p *terms, PTree_p *natoms)
{
long res = 0;
int i;
if(TermIsVar(t))
{
return res;
}
PTreeStore(natoms, t);
res++;
for(i=0; i<t->arity; i++)
{
res += term_collect_into_terms(t->args[i], terms);
}
return res;
}
/*-----------------------------------------------------------------------
//
// Function: eqn_collect_into_terms()
//
// Collect all paramod-into terms in lit into terms.
//
// Global Variables: -
//
// Side Effects : -
//
/----------------------------------------------------------------------*/
long eqn_collect_into_terms(Eqn_p lit, PTree_p *terms)
{
long res;
res = term_collect_into_terms(lit->lterm, terms);
if(!EqnIsOriented(lit))
{
res += term_collect_into_terms(lit->rterm, terms);
}
return res;
}
/*-----------------------------------------------------------------------
//
// Function: eqn_collect_into_terms2()
//
// Collect all paramod-into terms in lit into terms/natoms.
//
// Global Variables: -
//
// Side Effects : -
//
/----------------------------------------------------------------------*/
long eqn_collect_into_terms2(Eqn_p lit, PTree_p *terms, PTree_p *natoms)
{
long res;
if(EqnIsNegative(lit) && !EqnIsEquLit(lit))
{
res = term_collect_into_terms2(lit->lterm, terms, natoms);
}
else
{
res = term_collect_into_terms(lit->lterm, terms);
}
if(!EqnIsOriented(lit))
{
res += term_collect_into_terms(lit->rterm, terms);
}
return res;
}
/*-----------------------------------------------------------------------
//
// Function: term_collect_into_terms_pos()
//
// Collect all potential into-subterms/pos position onto terms.
//
// Global Variables: -
//
// Side Effects : -
//
/----------------------------------------------------------------------*/
long term_collect_into_terms_pos(Term_p t, CompactPos pos, PStack_p terms)
{
long res = 0;
int i;
if(TermIsVar(t))
{
return res;
}
PStackPushP(terms, t);
PStackPushInt(terms, pos);
res++;
pos += DEFAULT_FWEIGHT*(TermIsAppliedVar(t) ? 0 : 1);
for(i=0; i<t->arity; i++)
{
res += term_collect_into_terms_pos(t->args[i], pos, terms);
pos += TermStandardWeight(t->args[i]);
}
return res;
}
/*-----------------------------------------------------------------------
//
// Function: term_collect_into_terms_pos2()
//
// Collect all potential into-subterms/pos positions of the LHS of a
// negative non-equational literal onto terms/natoms.
//
// Global Variables: -
//
// Side Effects : -
//
/----------------------------------------------------------------------*/
long term_collect_into_terms_pos2(Term_p t, CompactPos pos,
PStack_p terms, PStack_p natoms)
{
long res = 0;
int i;
if(TermIsVar(t))
{
return res;
}
PStackPushP(natoms, t);
PStackPushInt(natoms, pos);
res++;
pos += DEFAULT_FWEIGHT*(TermIsAppliedVar(t) ? 0 : 1);
for(i=0; i<t->arity; i++)
{
/* It's term_collect_into_terms_pos() on purpose - subterm need
to be indexed in the normal index for equational inferences!
*/
res += term_collect_into_terms_pos(t->args[i], pos, terms);
pos += TermStandardWeight(t->args[i]);
}
return res;
}
/*-----------------------------------------------------------------------
//
// Function: eqn_collect_into_terms_pos()
//
// Collect all paramod-into terms with position in lit into terms.
//
// Global Variables: -
//
// Side Effects : -
//
/----------------------------------------------------------------------*/
long eqn_collect_into_terms_pos(Eqn_p lit, CompactPos litpos,
PStack_p terms)
{
long res;
res = term_collect_into_terms_pos(lit->lterm, litpos, terms);
if(!EqnIsOriented(lit))
{
litpos += TermStandardWeight(lit->lterm);
res += term_collect_into_terms_pos(lit->rterm, litpos, terms);
}
return res;
}
/*-----------------------------------------------------------------------
//
// Function: eqn_collect_into_terms_pos2()
//
// Collect all paramod-into terms with position in lit into
// terms/natoms.
//
// Global Variables: -
//
// Side Effects : -
//
/----------------------------------------------------------------------*/
long eqn_collect_into_terms_pos2(Eqn_p lit, CompactPos litpos,
PStack_p terms, PStack_p natoms)
{
long res;
if(EqnIsNegative(lit) && !EqnIsEquLit(lit))
{
res = term_collect_into_terms_pos2(lit->lterm, litpos, terms, natoms);
}
else
{
res = term_collect_into_terms_pos(lit->lterm, litpos, terms);
}
if(!EqnIsOriented(lit))
{
litpos += TermStandardWeight(lit->lterm);
res += term_collect_into_terms_pos(lit->rterm, litpos, terms);
}
return res;
}
/*---------------------------------------------------------------------*/
/* Exported Functions */
/*---------------------------------------------------------------------*/
/*-----------------------------------------------------------------------
//
// Function: OverlapIndexInsertPos()
//
// Insert a position with clause|pos = iterm into the index. If
// iterm is NULL, it will be computed from clause.
//
// Global Variables: -
//
// Side Effects : Memory operations
//
/----------------------------------------------------------------------*/
void OverlapIndexInsertPos(OverlapIndex_p index, Clause_p clause,
CompactPos pos, Term_p iterm)
{
FPTree_p fp_node;
SubtermOcc_p subterm_node;
if(!iterm)
{
iterm = ClauseCPosGetSubterm(clause, pos);
}
fp_node = FPIndexInsert(index, iterm);
/* printf("OverlapIndexInsertPos()..\n");
SubtermTreePrint(stdout, fp_node->payload,
clause->literals->bank->sig); */
subterm_node = SubtermTreeInsertTerm((void*)&(fp_node->payload), iterm);
ClauseTPosTreeInsertPos(&(subterm_node->pl.pos.clauses), clause, pos);
}
/*-----------------------------------------------------------------------
//
// Function: OverlapIndexDeletePos()
//
// Delete a term->clause/position association from the index.
//
// Global Variables: -
//
// Side Effects : Memory operations
//
/----------------------------------------------------------------------*/
void OverlapIndexDeletePos(OverlapIndex_p index, Clause_p clause,
CompactPos pos, Term_p iterm)
{
FPTree_p fp_node;
SubtermOcc_p subterm_node;
if(!iterm)
{
iterm = ClauseCPosGetSubterm(clause, pos);
}
fp_node = FPIndexFind(index, iterm);
if(!fp_node)
{
return;
}
subterm_node = SubtermTreeFindTerm((void*)&(fp_node->payload), iterm);
if(!subterm_node)
{
return;
}
ClauseTPosTreeDeletePos(&(subterm_node->pl.pos.clauses), clause, pos);
if(!subterm_node->pl.pos.clauses)
{
SubtermTreeDeleteTerm((void*)&(fp_node->payload), iterm);
}
if(fp_node->payload == NULL)
{
FPIndexDelete(index, iterm);
}
return;
}
/*-----------------------------------------------------------------------
//
// Function: OverlapIndexDeleteClauseOcc()
//
// Delete all associations clause->pos via term from the index. This
// is an optimization - we usually index and unindex full clauses.
//
// Global Variables: -
//
// Side Effects : Changes the index
//
/----------------------------------------------------------------------*/
void OverlapIndexDeleteClauseOcc(OverlapIndex_p index,
Clause_p clause, Term_p term)
{
FPTree_p fp_node;
SubtermOcc_p subterm_node;
/* printf("OverlapIndexDeleteClauseOcc()...\n");
ClausePrint(stdout, clause, true);
printf("\n");
TermPrint(stdout, term, clause->literals->bank->sig, DEREF_NEVER);
printf("\n"); */
fp_node = FPIndexFind(index, term);
if(!fp_node)
{
return;
}
/* SubtermTreePrint(stdout, fp_node->payload,
* clause->literals->bank->sig); */
subterm_node = SubtermTreeFindTerm((PTree_p*)&(fp_node->payload), term);
/* printf("Found: %p\n", subterm_node); */
if(!subterm_node)
{
return;
}
ClauseTPosTreeDeleteClause(&(subterm_node->pl.pos.clauses), clause);
//printf("Del\n");
if(!subterm_node->pl.pos.clauses)
{
SubtermTreeDeleteTerm((PTree_p*)&(fp_node->payload), term);
}
if(fp_node->payload == NULL)
{
FPIndexDelete(index, term);
}
return;
}
/*-----------------------------------------------------------------------
//
// Function: ClauseCollectIntoTerms()
//
// Collect all term for paramodulation _into_ into tree. These are
// non-variable terms in maximal sides of maximal literals. Return
// number of term positions affected.
//
// Global Variables: -
//
// Side Effects : Memory operations
//
/----------------------------------------------------------------------*/
long ClauseCollectIntoTerms(Clause_p clause, PTree_p *terms)
{
long res = 0;
Eqn_p handle;
for(handle = clause->literals; handle; handle = handle->next)
{
if(EqnIsMaximal(handle))
{
res+=eqn_collect_into_terms(handle, terms);
}
}
return res;
}
/*-----------------------------------------------------------------------
//
// Function: ClauseCollectIntoTermsPos()
//
// Collect tuples cpos, t on stack, so that c|cpos = t and t is a
// paramod-into position.
//
// Global Variables: -
//
// Side Effects : -
//
/----------------------------------------------------------------------*/
long ClauseCollectIntoTermsPos(Clause_p clause, PStack_p terms)
{
long res = 0;
Eqn_p handle;
CompactPos pos = 0;
for(handle = clause->literals; handle; handle = handle->next)
{
if(EqnIsMaximal(handle))
{
res += eqn_collect_into_terms_pos(handle, pos, terms);
}
pos += EqnStandardWeight(handle);
}
return res;
}
/*-----------------------------------------------------------------------
//
// Function: ClauseCollectFromTerms()
//
// Collect all "from" terms (i.e. potential left hand sides of the
// rule of a clause seen as a conditional rewrite rule) into terms.
//
// Global Variables: -
//
// Side Effects : Memory operations
//
/----------------------------------------------------------------------*/
long ClauseCollectFromTerms(Clause_p clause, PTree_p *terms)
{
long res = 0;
Eqn_p handle;
for(handle = clause->literals; handle; handle = handle->next)
{
if(EqnIsMaximal(handle) && EqnIsPositive(handle) && !EqnIsSelected(handle))
{
res++;
PTreeStore(terms, handle->lterm);
if(!EqnIsOriented(handle))
{
res++;
PTreeStore(terms, handle->rterm);
}
}
}
return res;
}
/*-----------------------------------------------------------------------
//
// Function: ClauseCollectFromTermsPos()
//
// Collect all t|p tuples such that c|p=t and this is a paramod-from
// position.
//
// Global Variables: -
//
// Side Effects : -
//
/----------------------------------------------------------------------*/
long ClauseCollectFromTermsPos(Clause_p clause, PStack_p terms)
{
long res = 0;
Eqn_p handle;
CompactPos pos = 0;
for(handle = clause->literals; handle; handle = handle->next)
{
if(EqnIsMaximal(handle) && EqnIsPositive(handle) && !EqnIsSelected(handle))
{
res++;
PStackPushP(terms, handle->lterm);
PStackPushInt(terms, pos);
if(!EqnIsOriented(handle))
{
res++;
PStackPushP(terms, handle->rterm);
PStackPushInt(terms, pos+TermStandardWeight(handle->lterm));
}
}
pos += EqnStandardWeight(handle);
}
return res;
}
/*-----------------------------------------------------------------------
//
// Function: OverlapIndexInsertIntoClause()
//
// Insert a clause into an overlap-into index
//
// Global Variables: -
//
// Side Effects : Memory operations
//
/----------------------------------------------------------------------*/
void OverlapIndexInsertIntoClause(OverlapIndex_p index, Clause_p clause)
{
PStack_p collector = PStackAlloc();
CompactPos pos;
Term_p term;
ClauseCollectIntoTermsPos(clause, collector);
while(!PStackEmpty(collector))
{
pos = PStackPopInt(collector);
term = PStackPopP(collector);
OverlapIndexInsertPos(index, clause, pos, term);
}
PStackFree(collector);
}
/*-----------------------------------------------------------------------
//
// Function: OverlapIndexDeleteIntoClause()
//
// Delete a clause from the overlap-into index.
//
// Global Variables: -
//
// Side Effects : Memory operations
//
/----------------------------------------------------------------------*/
void OverlapIndexDeleteIntoClause(OverlapIndex_p index, Clause_p clause)
{
PStack_p trans;
Term_p term;
PTree_p collector = NULL, cell;
ClauseCollectIntoTerms(clause, &collector);
trans = PTreeTraverseInit(collector);
while((cell = PTreeTraverseNext(trans)))
{
term = cell->key;
OverlapIndexDeleteClauseOcc(index, clause, term);
}
PTreeTraverseExit(trans);
PTreeFree(collector);
}
/*-----------------------------------------------------------------------
//
// Function: OverlapIndexInsertFromClause()
//
// Insert a clause into an overlap-from index
//
// Global Variables: -
//
// Side Effects : Memory operations
//
/----------------------------------------------------------------------*/
void OverlapIndexInsertFromClause(OverlapIndex_p index, Clause_p clause)
{
PStack_p collector = PStackAlloc();
CompactPos pos;
Term_p term;
ClauseCollectFromTermsPos(clause, collector);
while(!PStackEmpty(collector))
{
pos = PStackPopInt(collector);
term = PStackPopP(collector);
OverlapIndexInsertPos(index, clause, pos, term);
}
PStackFree(collector);
}
/*-----------------------------------------------------------------------
//
// Function: OverlapIndexDeleteFromClause()
//
// Delete a clause from an overlap-from index
//
// Global Variables: -
//
// Side Effects : Memory operations
//
/----------------------------------------------------------------------*/
void OverlapIndexDeleteFromClause(OverlapIndex_p index, Clause_p clause)
{
PStack_p trans;
Term_p term;
PTree_p collector = NULL, cell;
ClauseCollectFromTerms(clause, &collector);
trans = PTreeTraverseInit(collector);
while((cell = PTreeTraverseNext(trans)))
{
term = cell->key;
OverlapIndexDeleteClauseOcc(index, clause, term);
}
PTreeTraverseExit(trans);
PTreeFree(collector);
}
/*-----------------------------------------------------------------------
//
// Function: OverlapIndexClauseTreePrint()
//
// Print an overlapIndex.
//
// Global Variables:
//
// Side Effects :
//
/----------------------------------------------------------------------*/
void OverlapIndexClauseTreePrint(FILE* out, PObjTree_p root)
{
if(root)
{
OverlapIndexClauseTreePrint(out, root->lson);
ClauseTPosTreePrint(out, root->key);
OverlapIndexClauseTreePrint(out, root->rson);
}
}
/*-----------------------------------------------------------------------
//
// Function: OverlapIndexSubtermTreePrint()
//
// Print a suberm tree (only for debugging)
//
// Global Variables: -
//
// Side Effects : -
//
/----------------------------------------------------------------------*/
void OverlapIndexSubtermTreePrint(FILE* out, SubtermTree_p root)
{
SubtermOcc_p data;
if(root)
{
OverlapIndexSubtermTreePrint(out, root->lson);
data = root->key;
fprintf(out, "Node: %p data=%p\n", root, data);
fprintf(out, "Key: %ld = ", data->term->entry_no);
if(data->pl.pos.clauses)
{
ClauseTPos_p clause_tpos = data->pl.pos.clauses->key;
Clause_p clause = clause_tpos->clause;
if(clause->literals)
{
TermPrint(out, data->term, clause->literals->bank->sig, DEREF_ALWAYS);
}
fprintf(out, "\n");
OverlapIndexClauseTreePrint(out, data->pl.pos.clauses);
}
else
{
fprintf(out, "\nlson=%p, rson=%p\n\n", root->lson, root->rson);
}
OverlapIndexSubtermTreePrint(out, root->rson);
}
}
/*-----------------------------------------------------------------------
//
// Function: OverlapIndexFPLeafPrint()
//
// Print a leaf as the path leading to it and the number of direct
// entries in the subterm.
//
// Global Variables: -
//
// Side Effects : Output
//
/----------------------------------------------------------------------*/
void OverlapIndexFPLeafPrint(FILE* out, PStack_p stack, FPTree_p leaf)
{
PStack_p iter = PStackAlloc();
fprintf(out, "# ");
PStackPrintInt(out, "%4ld.", stack);
fprintf(out, ":%ld terms\n", PObjTreeNodes(leaf->payload));
OverlapIndexSubtermTreePrint(out, leaf->payload);
PStackFree(iter);
}
/*-----------------------------------------------------------------------
//
// Function: ClauseCollectIntoTerms2()
//
// Collect all term for paramodulation _into_ into two trees. These
// are non-variable terms in maximal sides of maximal
// literals. Negative atom-terms go into the second tree, all others
// into the first. Return number of term positions affected.
//
// Global Variables: -
//
// Side Effects : Memory operations
//
/----------------------------------------------------------------------*/
long ClauseCollectIntoTerms2(Clause_p clause, PTree_p *terms, PTree_p *natoms)
{
long res = 0;
Eqn_p handle;
for(handle = clause->literals; handle; handle = handle->next)
{
if(EqnIsMaximal(handle))
{
res+=eqn_collect_into_terms2(handle, terms, natoms);
}
}
return res;
}
/*-----------------------------------------------------------------------
//
// Function: ClauseCollectIntoTermsPos2()
//
// Collect tuples cpos, t on stack(s), so that c|cpos = t and t is a
// paramod-into position. Negative non-equational predicate terms go
// onto natoms, the rest onto terms.
//
// Global Variables: -
//
// Side Effects : -
//
/----------------------------------------------------------------------*/
long ClauseCollectIntoTermsPos2(Clause_p clause,
PStack_p terms,
PStack_p natoms)
{
long res = 0;
Eqn_p handle;
CompactPos pos = 0;
for(handle = clause->literals; handle; handle = handle->next)
{
if(EqnIsMaximal(handle))
{
res += eqn_collect_into_terms_pos2(handle, pos, terms, natoms);
}
pos += EqnStandardWeight(handle);
}
return res;
}
/*-----------------------------------------------------------------------
//
// Function: OverlapIndexInsertIntoClause2()
//
// Insert a clause into two overlap-into indices.
//
// Global Variables: -
//
// Side Effects : Memory operations
//
/----------------------------------------------------------------------*/
void OverlapIndexInsertIntoClause2(OverlapIndex_p tindex,
OverlapIndex_p naindex,
Clause_p clause)
{
PStack_p terms = PStackAlloc();
PStack_p natoms = PStackAlloc();
CompactPos pos;
Term_p term;
ClauseCollectIntoTermsPos2(clause, terms, natoms);
while(!PStackEmpty(terms))
{
pos = PStackPopInt(terms);
term = PStackPopP(terms);
OverlapIndexInsertPos(tindex, clause, pos, term);
}
while(!PStackEmpty(natoms))
{
pos = PStackPopInt(natoms);
term = PStackPopP(natoms);
OverlapIndexInsertPos(naindex, clause, pos, term);
}
PStackFree(natoms);
PStackFree(terms);
}
/*-----------------------------------------------------------------------
//
// Function: OverlapIndexDeleteIntoClause2()
//
// Delete a clause from the two overlap-into indeces.
//
// Global Variables: -
//
// Side Effects : Memory operations
//
/----------------------------------------------------------------------*/
void OverlapIndexDeleteIntoClause2(OverlapIndex_p tindex,
OverlapIndex_p naindex,
Clause_p clause)
{
PStack_p trans;
Term_p term;
PTree_p terms = NULL,
natoms= NULL,
cell;
ClauseCollectIntoTerms2(clause, &terms, &natoms);
trans = PTreeTraverseInit(terms);
while((cell = PTreeTraverseNext(trans)))
{
term = cell->key;
OverlapIndexDeleteClauseOcc(tindex, clause, term);
}
PTreeTraverseExit(trans);
PTreeFree(terms);
trans = PTreeTraverseInit(natoms);
while((cell = PTreeTraverseNext(trans)))
{
term = cell->key;
OverlapIndexDeleteClauseOcc(naindex, clause, term);
}
PTreeTraverseExit(trans);
PTreeFree(natoms);
}
/*---------------------------------------------------------------------*/
/* End of File */
/*---------------------------------------------------------------------*/
|