-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclause.c
1222 lines (1036 loc) · 23.6 KB
/
clause.c
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
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "Header.h"
#include "Symbols.h"
#include "Io.h"
#include "List.h"
#include "Clause.h"
/*
* memory management
*/
static Literal_ptr literal_avail;
static Clause_ptr clause_avail;
static List_ptr list_avail;
static List_pos_ptr list_pos_avail;
static long literal_gets, literal_frees, literal_avails;
static long clause_gets, clause_frees, clause_avails;
static long list_gets, list_frees, list_avails;
static long list_pos_gets, list_pos_frees, list_pos_avails;
/*************
*
* Literal_ptr get_literal()
*
*************/
Literal_ptr get_literal(void)
{
Literal_ptr p;
literal_gets++;
if (!literal_avail)
p = tp_alloc(sizeof(struct literal));
else {
literal_avails--;
p = literal_avail;
literal_avail = literal_avail->next;
}
p->next = NULL;
p->atom = NULL;
p->sign = 0;
p->type = 0;
return(p);
} /* get_literal */
/*************
*
* free_literal()
*
*************/
void free_literal(Literal_ptr p)
{
literal_frees++;
literal_avails++;
p->next = literal_avail;
literal_avail = p;
} /* free_literal */
/*************
*
* Clause_ptr get_clause()
*
*************/
Clause_ptr get_clause(void)
{
Clause_ptr p;
clause_gets++;
if (!clause_avail)
p = tp_alloc(sizeof(struct clause));
else {
clause_avails--;
p = clause_avail;
clause_avail = (Clause_ptr) clause_avail->literals;
}
p->literals = NULL;
p->justification = NULL;
p->containers = NULL;
p->id = 0;
p->weight = 0;
p->heuristic_value = -1; /* Peers-mcd, August 2000 */
p->interpreted_value = -1;
/* Init to 0 fields that will be used always, to -1 fields that will be used */
/* only with certain strategies. */
return(p);
} /* get_clause */
/*************
*
* free_clause()
*
*************/
void free_clause(Clause_ptr p)
{
clause_frees++;
clause_avails++;
p->literals = (Literal_ptr) clause_avail;
clause_avail = p;
} /* free_clause */
/*************
*
* List_ptr get_list()
*
*************/
List_ptr get_list(void)
{
List_ptr p;
list_gets++;
if (!list_avail)
p = tp_alloc(sizeof(struct list));
else {
list_avails--;
p = list_avail;
list_avail = list_avail->next;
}
p->first = NULL;
p->last = NULL;
p->next = NULL;
return(p);
} /* get_list */
/*************
*
* free_list()
*
*************/
void free_list(List_ptr p)
{
list_frees++;
list_avails++;
p->next = list_avail;
list_avail = p;
} /* free_list */
/*************
*
* List_pos_ptr get_list_pos()
*
*************/
List_pos_ptr get_list_pos(void)
{
List_pos_ptr p;
list_pos_gets++;
if (!list_pos_avail)
p = tp_alloc(sizeof(struct list_pos));
else {
list_pos_avails--;
p = list_pos_avail;
list_pos_avail = list_pos_avail->next;
}
p->prev = NULL;
p->next = NULL;
p->nocc = NULL;
p->c = NULL;
p->container = NULL;
return(p);
} /* get_list_pos */
/*************
*
* free_list_pos()
*
*************/
void free_list_pos(List_pos_ptr p)
{
list_pos_frees++;
list_pos_avails++;
p->next = list_pos_avail;
list_pos_avail = p;
} /* free_list_pos */
/*************
*
* print_clause_mem()
*
*************/
void print_clause_mem(FILE *fp, int heading)
{
if (heading)
fprintf(fp, " type (bytes each) gets frees in use avail bytes\n");
fprintf(fp, "literal (%4d) %11ld%11ld%11ld%11ld%9.1f K\n", sizeof(struct literal), literal_gets, literal_frees, literal_gets - literal_frees, literal_avails, (((literal_gets - literal_frees) + literal_avails) * sizeof(struct literal)) / 1024.);
fprintf(fp, "clause (%4d) %11ld%11ld%11ld%11ld%9.1f K\n", sizeof(struct clause), clause_gets, clause_frees, clause_gets - clause_frees, clause_avails, (((clause_gets - clause_frees) + clause_avails) * sizeof(struct clause)) / 1024.);
fprintf(fp, "list (%4d) %11ld%11ld%11ld%11ld%9.1f K\n", sizeof(struct list), list_gets, list_frees, list_gets - list_frees, list_avails, (((list_gets - list_frees) + list_avails) * sizeof(struct list)) / 1024.);
fprintf(fp, "list_pos (%4d) %11ld%11ld%11ld%11ld%9.1f K\n", sizeof(struct list_pos), list_pos_gets, list_pos_frees, list_pos_gets - list_pos_frees, list_pos_avails, (((list_pos_gets - list_pos_frees) + list_pos_avails) * sizeof(struct list_pos)) / 1024.);
} /* print_clause_mem */
/*************
*
* p_clause_mem()
*
*************/
void p_clause_mem()
{
print_clause_mem(stdout, 1);
} /* p_clause_mem */
/*
* end of memory management
*/
/*
* The next set of routines is for a simple hash table to
* store and retrieve clauses by ID number.
*/
/*************
*
* init_clause_table_id()
*
* Allocate and return a clause-id table.
*
*************/
Gen_ptr_ptr *init_clause_table_id(void)
{
int i;
Gen_ptr_ptr *p;
p = tp_alloc(CLAUSE_TAB_SIZE * sizeof(Gen_ptr_ptr *));
for (i = 0; i < CLAUSE_TAB_SIZE; i++)
p[i] = NULL;
return(p);
} /* init_clause_table_id */
/*************
*
* store_clause_by_id(c, tab)
*
* Store a clause in a clause-id table.
*
*************/
void store_clause_by_id(Clause_ptr c, Gen_ptr_ptr *tab)
{
int i;
Gen_ptr_ptr p1, p2, p3;
i = c->id % CLAUSE_TAB_SIZE;
for (p2=NULL, p1=tab[i]; p1 && p1->u.c->id < c->id; p2 = p1, p1 = p1->next);
if (p1 && p1->u.c->id == c->id)
abend("store_clause_by_id: clause already there.");
p3 = get_gen_ptr();
p3->u.c = c;
p3->next = p1;
if (p2)
p2->next = p3;
else
tab[i] = p3;
} /* store_clause_by_id */
/*************
*
* delete_clause_by_id(c, tab)
*
*************/
void delete_clause_by_id(Clause_ptr c, Gen_ptr_ptr *tab)
{
int i;
Gen_ptr_ptr p1, p2;
i = c->id % CLAUSE_TAB_SIZE;
for (p2 = NULL, p1 = tab[i]; p1 && p1->u.c->id < c->id; p2 = p1, p1 = p1->next);
if (!p1 || p1->u.c->id != c->id)
abend("delete_clause_by_id: cannot find clause.");
if (p2)
p2->next = p1->next;
else
tab[i] = p1->next;
} /* delete_clause_by_id */
/*************
*
* find_clause_by_id(id, tab)
*
* Given a clause ID and a table, retrieve the clause (or NULL).
*
* Peers-mcd, October 2000:
* Modified to print on Peer_fp instead of stdout and to print
* the id of a clause with the proper structure.
*
*************/
Clause_ptr find_clause_by_id(int id, Gen_ptr_ptr *tab)
{
int i;
Gen_ptr_ptr p1;
i = id % CLAUSE_TAB_SIZE;
for (p1 = tab[i]; p1 && p1->u.c->id < id; p1 = p1->next);
if (p1 && p1->u.c->id == id)
return(p1->u.c);
else {
if (Stats[PROOFS] > 0)
fprintf(Peer_fp, "Clause with id <%d,%d,%d> not found.\n",
owner(id), birth_place(id), num(id));
return((Clause_ptr) NULL);
}
} /* find_clause_by_id */
/*************
*
* print_clause_table_id(fp, tab)
*
*************/
void print_clause_table_id(FILE *fp, Gen_ptr_ptr *tab)
{
int i;
Gen_ptr_ptr p;
fprintf(fp, "\nID clause table:\n");
for (i=0; i<CLAUSE_TAB_SIZE; i++)
for (p = tab[i]; p; p = p->next)
print_clause(fp, p->u.c);
} /* print_clause_table_id */
/*************
*
* p_clause_table_id(tab)
*
*************/
void p_clause_table_id(Gen_ptr_ptr *tab)
{
print_clause_table_id(stdout, tab);
} /* p_clause_table_id */
/*************
*
* zap_clause(c)
*
* Free a clause (including justification list). Nothing (e.g.,
* indexes) should refer to c or any of its subterms.
*
*************/
void zap_clause(Clause_ptr c)
{
Gen_ptr_ptr p1, p2;
Literal_ptr l1, l2;
p1 = c->justification;
while (p1) {
p2 = p1;
p1 = p1->next;
free_gen_ptr(p2);
}
l1 = c->literals;
while(l1) {
zap_term(l1->atom);
l2 = l1;
l1 = l1->next;
free_literal(l2);
}
free_clause(c);
} /* zap_clause */
/*************
*
* pos_clause(c) - Are all literals positive?
*
*************/
int pos_clause(Clause_ptr c)
{
Literal_ptr l;
int ok;
for (l = c->literals, ok = 1; l && ok; l = l->next)
ok = l->sign;
return(ok);
} /* pos_clause */
/*************
*
* neg_clause(c) - Are all literals negative?
*
*************/
int neg_clause(Clause_ptr c)
{
Literal_ptr l;
int ok;
for (l = c->literals, ok = 1; l && ok; l = l->next)
ok = !l->sign;
return(ok);
} /* neg_clause */
/*************
*
* literal_count(c) - Return the number of literals.
*
*************/
int literal_count(Clause_ptr c)
{
Literal_ptr l;
int n;
for (l = c->literals, n = 0; l; l = l->next, n++);
return(n);
} /* literal_count */
/*************
*
* literal_i() - Return the i-th literal (or NULL).
*
*************/
Literal_ptr literal_i(Clause_ptr c, int i)
{
if (i < 1)
return((Literal_ptr) NULL);
else {
Literal_ptr l = c->literals;
int n = 0;
while(l && n < i) {
n++;
if (n < i)
l = l->next;
}
return(l);
}
} /* literal_i */
/*************
*
* unit_clause(c) - Does the clause have exactly one literal?
*
*************/
int unit_clause(Clause_ptr c)
{
return(literal_count(c) == 1);
} /* unit_clause */
/*************
*
* copy_clause(c)
*
* Do not copy id, weight, heuristic_value, bits, or justification.
*
*************/
Clause_ptr copy_clause(Clause_ptr c)
{
Clause_ptr d;
Literal_ptr lit, new, prev;
d = get_clause();
for (lit = c->literals, prev = NULL; lit; lit = lit->next) {
new = get_literal();
if (prev)
prev->next = new;
else
d->literals = new;
new->sign = lit->sign;
new->atom = copy_term(lit->atom);
prev = new;
}
return(d);
} /* copy_clause */
/*************
*
* copy_clause_nonbasic_marks()
*
*************/
void copy_clause_nonbasic_marks(Clause_ptr c1, Clause_ptr c2)
{
Literal_ptr l1, l2;
for (l1 = c1->literals, l2 = c2->literals;
l1 && l2;
l1 = l1->next, l2 = l2->next)
copy_nonbasic_marks(l1->atom, l2->atom);
} /* copy_clause_nonbasic_marks */
/*************
*
* term_to_literals(t, lits)
*
*************/
static Literal_ptr term_to_literals(Term_ptr t, Literal_ptr lits)
{
Literal_ptr l;
if (is_symbol(t->symbol, "|", 2)) {
/* Note that we traverse right-to-left and add to the
* front, so order is preserved.
*/
l = term_to_literals(t->args[1], lits);
l = term_to_literals(t->args[0], l);
}
else {
l = get_literal();
l->next = lits;
l->sign = !is_symbol(t->symbol, "-", 1);
if (l->sign)
l->atom = copy_term(t);
else
l->atom = copy_term(t->args[0]);
}
return(l);
} /* term_to_literals */
/*************
*
* term_to_clause()
*
*************/
Clause_ptr term_to_clause(Term_ptr t)
{
Clause_ptr c = get_clause();
c->literals = term_to_literals(t, (Literal_ptr) NULL);
return(c);
} /* term_to_clause */
/*************
*
* literals_to_term()
*
*************/
static Term_ptr literals_to_term(Literal_ptr l)
{
Term_ptr t, t1, t2;
if (l->sign)
t1 = copy_term(l->atom);
else {
t1 = get_term(1);
t1->symbol = str_to_sn("-", 1);
t1->args[0] = copy_term(l->atom);
}
if (l->next) {
t2 = literals_to_term(l->next);
t = get_term(2);
t->symbol = str_to_sn("|", 2);
t->args[0] = t1;
t->args[1] = t2;
}
else
t = t1;
return(t);
} /* literals_to_term */
/*************
*
* clause_to_term(c)
*
*************/
Term_ptr clause_to_term(Clause_ptr c)
{
Term_ptr t;
if (c->literals)
t = literals_to_term(c->literals);
else {
t = get_term(0);
t->symbol = str_to_sn("$F", 0);
}
return(t);
} /* clause_to_term */
/*************
*
* clause_ident()
*
*************/
int clause_ident(Clause_ptr c1, Clause_ptr c2)
{
fprintf(stderr, "clause_ident not implemented\n");
return(0);
} /* clause_ident */
/*************
*
* list_append(clause, list)
*
*************/
void list_append(Clause_ptr c, List_ptr l)
{
List_pos_ptr p;
p = get_list_pos();
p->container = l;
p->c = c;
p->nocc = c->containers;
c->containers = p;
p->next = NULL;
p->prev = l->last;
l->last = p;
if (p->prev)
p->prev->next = p;
else
l->first = p;
} /* list_append */
/*************
*
* list_prepend(clause, list)
*
*************/
void list_prepend(Clause_ptr c, List_ptr l)
{
List_pos_ptr p;
p = get_list_pos();
p->container = l;
p->c = c;
p->nocc = c->containers;
c->containers = p;
p->prev = NULL;
p->next = l->first;
l->first = p;
if (p->next)
p->next->prev = p;
else
l->last = p;
} /* list_prepend */
/*************
*
* list_insert_before(clause, pos)
*
*************/
void list_insert_before(Clause_ptr c, List_pos_ptr pos)
{
List_pos_ptr p;
p = get_list_pos();
p->container = pos->container;
p->c = c;
p->nocc = c->containers;
c->containers = p;
p->next = pos;
p->prev = pos->prev;
pos->prev = p;
if (p->prev)
p->prev->next = p;
else
pos->container->first = p;
} /* list_insert_before */
/*************
*
* list_insert_after(clause, pos)
*
*************/
void list_insert_after(Clause_ptr c, List_pos_ptr pos)
{
List_pos_ptr p;
p = get_list_pos();
p->container = pos->container;
p->c = c;
p->nocc = c->containers;
c->containers = p;
p->prev = pos;
p->next = pos->next;
pos->next = p;
if (p->next)
p->next->prev = p;
else
pos->container->last = p;
} /* list_insert_after */
/*************
*
* list_remove(clause, list)
*
* Return 1 if deleted.
* Return 0 if it couldn't be deleted because it's not there.
*
*************/
int list_remove(Clause_ptr c, List_ptr l)
{
List_pos_ptr p, prev;
/* Find position from containment list of clause. */
for (p = c->containers, prev = NULL;
p && p->container != l;
prev = p, p = p->nocc);
if (p) {
/* First update normal links. */
if (p->prev)
p->prev->next = p->next;
else
p->container->first = p->next;
if (p->next)
p->next->prev = p->prev;
else
p->container->last = p->prev;
/* Now update containment links. */
if (prev)
prev->nocc = p->nocc;
else
c->containers = p->nocc;
free_list_pos(p);
return(1);
}
else
return(0);
} /* list_remove */
/*************
*
* list_remove_all(clause)
*
* Remove from all lists. Return the number of lists
* from which it was removed.
*
*************/
int list_remove_all(Clause_ptr c)
{
List_pos_ptr p, p2;
int i = 0;
p = c->containers;
while (p) {
i++;
if (p->prev)
p->prev->next = p->next;
else
p->container->first = p->next;
if (p->next)
p->next->prev = p->prev;
else
p->container->last = p->prev;
p2 = p;
p = p->nocc;
free_list_pos(p2);
}
c->containers = NULL;
return(i);
} /* list_remove_all */
/*************
*
* list_member(c, l)
*
*************/
int list_member(Clause_ptr c, List_ptr l)
{
List_pos_ptr p;
int found;
for (p = c->containers, found = 0; p && !found; p = p->nocc) {
if (p->container == l)
found = 1;
}
return(found);
} /* list_member */
/*************
*
* print_list(fp, l)
*
*************/
void print_list(FILE *fp, List_ptr l)
{
List_pos_ptr p;
for(p = l->first; p; p = p->next)
print_clause(fp, p->c);
fprintf(fp, "end_of_list.\n");
} /* print_list */
/*************
*
* p_list(l)
*
*************/
void p_list(List_ptr l)
{
print_list(stdout, l);
} /* p_list */
/*************
*
* list_zap(l)
*
* For each element, remove it, and if it occurs nowhere else, delete it.
*
*************/
void list_zap(List_ptr l)
{
List_pos_ptr p;
Clause_ptr c;
p = l->first;
while (p) {
c = p->c;
p = p->next;
list_remove(c, l);
if (!c->containers)
zap_clause(c);
}
} /* list_zap */
/*************
*
* list_check(l)
*
*************/
void list_check(List_ptr l)
{
List_pos_ptr p;
for (p = l->first; p; p = p->next) {
if (p->container != l)
printf("error0\n");
if (p->next) {
if (p->next->prev != p)
printf("error1\n");
}
else if (p != l->last)
printf("error2\n");
if (p->prev) {
if (p->prev->next != p)
printf("error3\n");
}
else if (p != l->first)
printf("error4\n");
}
} /* list_check */
/*************
*
* clause_in_list(c, l)
*
*************/
int clause_in_list(Clause_ptr c, List_ptr l)
{
List_pos_ptr p;
int found;
for (p = l->first, found = 0; p && !found; p = p->next)
found = clause_ident(c, p->c);
return(found);
} /* clause_in_list */
/*************
*
* clause_up_pointers_term()
*
*************/
static void clause_up_pointers_term(Term_ptr t, Clause_ptr c)
{
int i;
t->containing_clause = c;
for (i = 0; i < t->arity; i++)
clause_up_pointers_term(t->args[i], c);
} /* clause_up_pointers_term */
/*************
*
* clause_up_pointers()
*
*************/
void clause_up_pointers(Clause_ptr c)
{
Literal_ptr l;
for (l = c->literals; l; l = l->next)
clause_up_pointers_term(l->atom, c);
} /* clause_up_pointers */
/*************
*
* print_clause(fp, c)
*
*************/
void print_clause(FILE *fp, Clause_ptr c)
{
Term_ptr t;
Gen_ptr_ptr p;
int i, n;
if (Internal_flags[INTERP_PRESENT]) {
char *s;
switch (c->interpreted_value) {
case 0: s = "FALSE"; break;
case 1: s = "TRUE "; break;
default: s = "?????";
}
fprintf(fp,"%s ", s);
}
fprintf(fp,"<%d,%d,%d> (wt=%d) (hv=%d) [", owner(c->id), birth_place(c->id),
num(c->id), c->weight, c->heuristic_value); /* heuristic_value added in Peers_mcd, April 2000 */
p = c->justification;
while (p) {
if (p != c->justification)
fprintf(fp, ",");
switch (p->u.i) {
case BACK_DEMOD_RULE:
p = p->next;
fprintf(fp, "back_demod(<%d,%d,%d>)", owner(p->u.i),
birth_place(p->u.i), num(p->u.i));
break;
case COPY_RULE:
p = p->next;
fprintf(fp, "copy(<%d,%d,%d>)", owner(p->u.i),
birth_place(p->u.i), num(p->u.i));
break;
case FLIP_RULE:
p = p->next;
fprintf(fp, "flip(<%d,%d,%d>)", owner(p->u.i),
birth_place(p->u.i), num(p->u.i));
break;
case ORIENT_RULE: /* Peers-mcd, September 2000 */
fprintf(fp, "oriented");
break;
case DEMOD_RULE:
p = p->next;
n = -(p->u.i);
fprintf(fp, "demod([");
for (i = 0; i < n; i++) {
p = p->next;
fprintf(fp, "%s<%d,%d,%d>", (i == 0 ? "" : ","), owner(p->u.i),
birth_place(p->u.i), num(p->u.i));
}
fprintf(fp, "])");
break;
case UNIT_CONFLICT_RULE:
p = p->next;
fprintf(fp, "conflict(<%d,%d,%d>,<%d,%d,%d>)",
owner(p->u.i), birth_place(p->u.i), num(p->u.i),
owner(p->next->u.i), birth_place(p->next->u.i), num(p->next->u.i));
p = p->next;
break;
case PARA_RULE:
p = p->next;
fprintf(fp, "para(<%d,%d,%d>,<%d,%d,%d>)",
owner(p->u.i), birth_place(p->u.i), num(p->u.i),
owner(p->next->u.i), birth_place(p->next->u.i), num(p->next->u.i));
p = p->next;