Biddy  2.1.1
A multi-platform Binary Decision Diagrams package
biddyOp.c
Go to the documentation of this file.
1 /***************************************************************************/
44 #include "biddyInt.h"
45 
46 /*----------------------------------------------------------------------------*/
47 /* Constant declarations */
48 /*----------------------------------------------------------------------------*/
49 
50 /*----------------------------------------------------------------------------*/
51 /* Variable declarations */
52 /*----------------------------------------------------------------------------*/
53 
54 /*----------------------------------------------------------------------------*/
55 /* Static function prototypes */
56 /*----------------------------------------------------------------------------*/
57 
58 static Biddy_Edge replaceByKeyword(Biddy_Manager MNG, Biddy_Edge f, Biddy_Variable topv, const unsigned int key);
59 
60 static void exchangeEdges(Biddy_Edge *f, Biddy_Edge *g);
61 
62 /* static void complExchangeEdges(Biddy_Edge *f, Biddy_Edge *g); */
63 
64 static Biddy_Edge createMinterm(Biddy_Manager MNG, Biddy_Edge support, long long unsigned int n, long long unsigned int x);
65 
66 static Biddy_Edge createFunction(Biddy_Manager MNG, Biddy_Edge support, long long unsigned int n, long long unsigned int m, long long unsigned int x);
67 
68 static inline unsigned int op3Hash(Biddy_Edge a, Biddy_Edge b, Biddy_Edge c, unsigned int size);
69 
70 static inline unsigned int keywordHash(Biddy_Edge a, unsigned int k, unsigned int size);
71 
72 static inline void addOp3Cache(BiddyOp3CacheTable cache, Biddy_Edge a, Biddy_Edge b, Biddy_Edge c, Biddy_Edge r, unsigned int index);
73 
74 static inline Biddy_Boolean findOp3Cache(BiddyOp3CacheTable cache, Biddy_Edge a, Biddy_Edge b, Biddy_Edge c, Biddy_Edge *r, unsigned int *index);
75 
76 static inline void addKeywordCache(BiddyKeywordCacheTable cache, Biddy_Edge a, unsigned int k, Biddy_Edge r, unsigned int index);
77 
78 static inline Biddy_Boolean findKeywordCache(BiddyKeywordCacheTable cache, Biddy_Edge a, unsigned int k, Biddy_Edge *r, unsigned int *index);
79 
80 /*----------------------------------------------------------------------------*/
81 /* Definition of exported functions */
82 /*----------------------------------------------------------------------------*/
83 
84 /***************************************************************************/
98 #ifdef __cplusplus
99 extern "C" {
100 #endif
101 
104 {
105  Biddy_Edge r;
106 
107  assert( f != NULL );
108 
109  if (!MNG) MNG = biddyAnonymousManager;
110  ZF_LOGI("Biddy_Not");
111 
112  if (!BiddyIsOK(f)) {
113  printf("BiddyNot: biddySystemAge=%u, top=%u\n",biddySystemAge,BiddyN(f)->expiry);
114  }
115 
116  assert( BiddyIsOK(f) == TRUE );
117 
118  r = biddyNull;
119 
120  if (biddyManagerType == BIDDYTYPEOBDD) {
121  /* IMPLEMENTED */
122  r = BiddyManagedNot(MNG,f);
123  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedXor */
124  } else if (biddyManagerType == BIDDYTYPEOBDDC) {
125  /* IMPLEMENTED */
126  r = BiddyInv(f);
127  /* BiddyRefresh() */ /* not needed because the same node is returned */
128  }
129 #ifndef COMPACT
130  else if (biddyManagerType == BIDDYTYPEZBDD) {
131  /* IMPLEMENTED */
132  r = BiddyManagedNot(MNG,f);
133  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedNot */
134  } else if (biddyManagerType == BIDDYTYPEZBDDC) {
135  /* IMPLEMENTED */
136  r = BiddyManagedNot(MNG,f);
137  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedNot */
138  } else if (biddyManagerType == BIDDYTYPETZBDD) {
139  /* IMPLEMENTED */
140  r = BiddyManagedNot(MNG,f);
141  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedNot */
142  } else if (biddyManagerType == BIDDYTYPETZBDDC)
143  {
144  fprintf(stderr,"Biddy_Not: this BDD type is not supported, yet!\n");
145  return biddyNull;
146  } else if ((biddyManagerType == BIDDYTYPEOFDDC) || (biddyManagerType == BIDDYTYPEOFDD) ||
147  (biddyManagerType == BIDDYTYPEZFDDC) || (biddyManagerType == BIDDYTYPEZFDD) ||
148  (biddyManagerType == BIDDYTYPETZFDDC) || (biddyManagerType == BIDDYTYPETZFDD))
149  {
150  fprintf(stderr,"Biddy_Not: this BDD type is not supported, yet!\n");
151  return biddyNull;
152  } else {
153  fprintf(stderr,"Biddy_Not: Unsupported BDD type!\n");
154  return biddyNull;
155  }
156 #endif
157 
158  return r;
159 }
160 
161 #ifdef __cplusplus
162 }
163 #endif
164 
165 /***************************************************************************/
179 #ifdef __cplusplus
180 extern "C" {
181 #endif
182 
185 {
186  Biddy_Edge r;
187 
188  assert( f != NULL );
189  assert( g != NULL );
190  assert( h != NULL );
191 
192  if (!MNG) MNG = biddyAnonymousManager;
193  ZF_LOGI("Biddy_ITE");
194 
195  assert( BiddyIsOK(f) == TRUE );
196  assert( BiddyIsOK(g) == TRUE );
197  assert( BiddyIsOK(h) == TRUE );
198 
199  biddyNodeTable.funite++;
200 
201  r = biddyNull;
202 
203  if (biddyManagerType == BIDDYTYPEOBDD) {
204  /* IMPLEMENTED */
205  r = BiddyManagedITE(MNG,f,g,h);
206  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedITE */
207  } else if (biddyManagerType == BIDDYTYPEOBDDC) {
208  /* IMPLEMENTED */
209  r = BiddyManagedITE(MNG,f,g,h);
210  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedITE */
211  }
212 #ifndef COMPACT
213  else if (biddyManagerType == BIDDYTYPEZBDD) {
214  /* IMPLEMENTED */
215  r = BiddyManagedITE(MNG,f,g,h);
216  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedITE */
217  } else if (biddyManagerType == BIDDYTYPEZBDDC) {
218  /* IMPLEMENTED */
219  r = BiddyManagedITE(MNG,f,g,h);
220  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedITE */
221  } else if (biddyManagerType == BIDDYTYPETZBDD) {
222  /* IMPLEMENTED */
223  r = BiddyManagedITE(MNG,f,g,h);
224  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedITE */
225  } else if (biddyManagerType == BIDDYTYPETZBDDC)
226  {
227  fprintf(stderr,"Biddy_ITE: this BDD type is not supported, yet!\n");
228  return biddyNull;
229  } else if ((biddyManagerType == BIDDYTYPEOFDDC) || (biddyManagerType == BIDDYTYPEOFDD) ||
230  (biddyManagerType == BIDDYTYPEZFDDC) || (biddyManagerType == BIDDYTYPEZFDD) ||
231  (biddyManagerType == BIDDYTYPETZFDDC) || (biddyManagerType == BIDDYTYPETZFDD))
232  {
233  fprintf(stderr,"Biddy_ITE: this BDD type is not supported, yet!\n");
234  return biddyNull;
235  } else {
236  fprintf(stderr,"Biddy_ITE: Unsupported BDD type!\n");
237  return biddyNull;
238  }
239 #endif
240 
241  return r;
242 }
243 
244 #ifdef __cplusplus
245 }
246 #endif
247 
248 /***************************************************************************/
265 #ifdef __cplusplus
266 extern "C" {
267 #endif
268 
271 {
272  Biddy_Edge r;
273 
274  assert( f != NULL );
275  assert( g != NULL );
276 
277  if (!MNG) MNG = biddyAnonymousManager;
278  ZF_LOGI("Biddy_And");
279 
280  assert( BiddyIsOK(f) == TRUE );
281  assert( BiddyIsOK(g) == TRUE );
282 
283  biddyNodeTable.funandor++;
284 
285  r = biddyNull;
286 
287  if (biddyManagerType == BIDDYTYPEOBDD) {
288  /* IMPLEMENTED */
289  r = BiddyManagedAnd(MNG,f,g);
290  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedAnd */
291  } else if (biddyManagerType == BIDDYTYPEOBDDC) {
292  /* IMPLEMENTED */
293  r = BiddyManagedAnd(MNG,f,g);
294  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedAnd */
295  }
296 #ifndef COMPACT
297  else if (biddyManagerType == BIDDYTYPEZBDD) {
298  /* IMPLEMENTED */
299  r = BiddyManagedAnd(MNG,f,g);
300  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedAnd */
301  } else if (biddyManagerType == BIDDYTYPEZBDDC) {
302  /* IMPLEMENTED */
303  r = BiddyManagedAnd(MNG,f,g);
304  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedAnd */
305  } else if (biddyManagerType == BIDDYTYPETZBDD) {
306  /* IMPLEMENTED */
307  r = BiddyManagedAnd(MNG,f,g);
308  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedAnd */
309  } else if (biddyManagerType == BIDDYTYPETZBDDC)
310  {
311  fprintf(stderr,"Biddy_And: this BDD type is not supported, yet!\n");
312  return biddyNull;
313  } else if ((biddyManagerType == BIDDYTYPEOFDDC) || (biddyManagerType == BIDDYTYPEOFDD) ||
314  (biddyManagerType == BIDDYTYPEZFDDC) || (biddyManagerType == BIDDYTYPEZFDD) ||
315  (biddyManagerType == BIDDYTYPETZFDDC) || (biddyManagerType == BIDDYTYPETZFDD))
316  {
317  fprintf(stderr,"Biddy_And: this BDD type is not supported, yet!\n");
318  return biddyNull;
319  } else {
320  fprintf(stderr,"Biddy_And: Unsupported BDD type!\n");
321  return biddyNull;
322  }
323 #endif
324 
325  return r;
326 }
327 
328 #ifdef __cplusplus
329 }
330 #endif
331 
332 /***************************************************************************/
348 #ifdef __cplusplus
349 extern "C" {
350 #endif
351 
354 {
355  Biddy_Edge r;
356 
357  assert( f != NULL );
358  assert( g != NULL );
359 
360  if (!MNG) MNG = biddyAnonymousManager;
361  ZF_LOGI("Biddy_Or");
362 
363  assert( BiddyIsOK(f) == TRUE );
364  assert( BiddyIsOK(g) == TRUE );
365 
366  biddyNodeTable.funandor++;
367 
368  r = biddyNull;
369 
370  if (biddyManagerType == BIDDYTYPEOBDD) {
371  /* PROCEED BY CALCULATING NOT-AND */
372  /*
373  r = BiddyManagedNot(MNG,BiddyManagedAnd(MNG,BiddyManagedNot(MNG,f),BiddyManagedNot(MNG,g)));
374  */
375  /* PROCEED BY CALCULATING XOR-AND */
376  /*
377  r = BiddyManagedXor(MNG,BiddyManagedXor(MNG,f,g),BiddyManagedAnd(MNG,f,g));
378  */
379  /* IMPLEMENTED */
380  r = BiddyManagedOr(MNG,f,g);
381  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedOr */
382  } else if (biddyManagerType == BIDDYTYPEOBDDC) {
383  /* PROCEED BY CALCULATING NOT-AND */
384  /*
385  r = BiddyInv(BiddyManagedAnd(MNG,BiddyInv(f),BiddyInv(g)));
386  */
387  /* PROCEED BY CALCULATING XOR-AND */
388  /*
389  r = BiddyManagedXor(MNG,BiddyManagedXor(MNG,f,g),BiddyManagedAnd(MNG,f,g));
390  */
391  /* IMPLEMENTED */
392  r = BiddyManagedOr(MNG,f,g);
393  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedOr */
394  }
395 #ifndef COMPACT
396  else if (biddyManagerType == BIDDYTYPEZBDD) {
397  /* PROCEED BY CALCULATING NOT-AND */
398  /*
399  r = BiddyManagedNot(MNG,BiddyManagedAnd(MNG,BiddyManagedNot(MNG,f),BiddyManagedNot(MNG,g)));
400  */
401  /* PROCEED BY CALCULATING XOR-AND */
402  /*
403  r = BiddyManagedXor(MNG,BiddyManagedXor(MNG,f,g),BiddyManagedAnd(MNG,f,g));
404  */
405  /* IMPLEMENTED */
406  r = BiddyManagedOr(MNG,f,g);
407  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedOr */
408  } else if (biddyManagerType == BIDDYTYPEZBDDC) {
409  /* PROCEED BY CALCULATING NOT-AND */
410  /*
411  r = BiddyManagedNot(MNG,BiddyManagedAnd(MNG,BiddyManagedNot(MNG,f),BiddyManagedNot(MNG,g)));
412  */
413  /* PROCEED BY CALCULATING XOR-AND */
414  /*
415  r = BiddyManagedXor(MNG,BiddyManagedXor(MNG,f,g),BiddyManagedAnd(MNG,f,g));
416  */
417  /* IMPLEMENTED */
418  r = BiddyManagedOr(MNG,f,g);
419  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedOr */
420  } else if (biddyManagerType == BIDDYTYPETZBDD) {
421  /* PROCEED BY CALCULATING NOT-AND */
422  /*
423  r = BiddyManagedNot(MNG,BiddyManagedAnd(MNG,BiddyManagedNot(MNG,f),BiddyManagedNot(MNG,g)));
424  */
425  /* PROCEED BY CALCULATING XOR-AND */
426  /*
427  r = BiddyManagedXor(MNG,BiddyManagedXor(MNG,f,g),BiddyManagedAnd(MNG,f,g));
428  */
429  /* IMPLEMENTED */
430  r = BiddyManagedOr(MNG,f,g);
431  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedOr */
432  } else if (biddyManagerType == BIDDYTYPETZBDDC)
433  {
434  fprintf(stderr,"Biddy_Or: this BDD type is not supported, yet!\n");
435  return biddyNull;
436  } else if ((biddyManagerType == BIDDYTYPEOFDDC) || (biddyManagerType == BIDDYTYPEOFDD) ||
437  (biddyManagerType == BIDDYTYPEZFDDC) || (biddyManagerType == BIDDYTYPEZFDD) ||
438  (biddyManagerType == BIDDYTYPETZFDDC) || (biddyManagerType == BIDDYTYPETZFDD))
439  {
440  fprintf(stderr,"Biddy_Or: this BDD type is not supported, yet!\n");
441  return biddyNull;
442  } else {
443  fprintf(stderr,"Biddy_Or: Unsupported BDD type!\n");
444  return biddyNull;
445  }
446 #endif
447 
448  return r;
449 }
450 
451 #ifdef __cplusplus
452 }
453 #endif
454 
455 /***************************************************************************/
469 #ifdef __cplusplus
470 extern "C" {
471 #endif
472 
475 {
476  Biddy_Edge r;
477 
478  assert( f != NULL );
479  assert( g != NULL );
480 
481  if (!MNG) MNG = biddyAnonymousManager;
482  ZF_LOGI("Biddy_Nand");
483 
484  assert( BiddyIsOK(f) == TRUE );
485  assert( BiddyIsOK(g) == TRUE );
486 
487  r = biddyNull;
488 
489  if (biddyManagerType == BIDDYTYPEOBDD) {
490  /* PROTOTYPED */
491  r = BiddyManagedNot(MNG,BiddyManagedAnd(MNG,f,g));
492  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedNot */
493  } else if (biddyManagerType == BIDDYTYPEOBDDC) {
494  /* IMPLEMENTED */
495  r = BiddyManagedNand(MNG,f,g);
496  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedNand */
497  }
498 #ifndef COMPACT
499  else if (biddyManagerType == BIDDYTYPEZBDD) {
500  /* PROTOTYPED */
501  r = BiddyManagedNot(MNG,BiddyManagedAnd(MNG,f,g));
502  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedNot */
503  } else if (biddyManagerType == BIDDYTYPEZBDDC) {
504  /* PROTOTYPED */
505  r = BiddyManagedNot(MNG,BiddyManagedAnd(MNG,f,g));
506  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedNot */
507  } else if (biddyManagerType == BIDDYTYPETZBDD) {
508  /* PROTOTYPED */
509  r = BiddyManagedNot(MNG,BiddyManagedAnd(MNG,f,g));
510  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedNot */
511  } else if (biddyManagerType == BIDDYTYPETZBDDC)
512  {
513  fprintf(stderr,"Biddy_Nand: this BDD type is not supported, yet!\n");
514  return biddyNull;
515  } else if ((biddyManagerType == BIDDYTYPEOFDDC) || (biddyManagerType == BIDDYTYPEOFDD) ||
516  (biddyManagerType == BIDDYTYPEZFDDC) || (biddyManagerType == BIDDYTYPEZFDD) ||
517  (biddyManagerType == BIDDYTYPETZFDDC) || (biddyManagerType == BIDDYTYPETZFDD))
518  {
519  fprintf(stderr,"Biddy_Nand: this BDD type is not supported, yet!\n");
520  return biddyNull;
521  } else {
522  fprintf(stderr,"Biddy_Nand: Unsupported BDD type!\n");
523  return biddyNull;
524  }
525 #endif
526 
527  return r;
528 }
529 
530 #ifdef __cplusplus
531 }
532 #endif
533 
534 /***************************************************************************/
548 #ifdef __cplusplus
549 extern "C" {
550 #endif
551 
554 {
555  Biddy_Edge r;
556 
557  assert( f != NULL );
558  assert( g != NULL );
559 
560  if (!MNG) MNG = biddyAnonymousManager;
561  ZF_LOGI("Biddy_Nor");
562 
563  assert( BiddyIsOK(f) == TRUE );
564  assert( BiddyIsOK(g) == TRUE );
565 
566  r = biddyNull;
567 
568  if (biddyManagerType == BIDDYTYPEOBDD) {
569  /* PROTOTYPED */
570  r = BiddyManagedNot(MNG,BiddyManagedOr(MNG,f,g));
571  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedNot */
572  } else if (biddyManagerType == BIDDYTYPEOBDDC) {
573  /* IMPLEMENTED */
574  r = BiddyManagedNor(MNG,f,g);
575  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedNor */
576  }
577 #ifndef COMPACT
578  else if (biddyManagerType == BIDDYTYPEZBDD) {
579  /* PROTOTYPED */
580  r = BiddyManagedNot(MNG,BiddyManagedOr(MNG,f,g));
581  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedNot */
582  } else if (biddyManagerType == BIDDYTYPEZBDDC) {
583  /* PROTOTYPED */
584  r = BiddyManagedNot(MNG,BiddyManagedOr(MNG,f,g));
585  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedNot */
586  } else if (biddyManagerType == BIDDYTYPETZBDD) {
587  /* PROTOTYPED */
588  r = BiddyManagedNot(MNG,BiddyManagedOr(MNG,f,g));
589  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedNot */
590  } else if (biddyManagerType == BIDDYTYPETZBDDC)
591  {
592  fprintf(stderr,"Biddy_Nor: this BDD type is not supported, yet!\n");
593  return biddyNull;
594  } else if ((biddyManagerType == BIDDYTYPEOFDDC) || (biddyManagerType == BIDDYTYPEOFDD) ||
595  (biddyManagerType == BIDDYTYPEZFDDC) || (biddyManagerType == BIDDYTYPEZFDD) ||
596  (biddyManagerType == BIDDYTYPETZFDDC) || (biddyManagerType == BIDDYTYPETZFDD))
597  {
598  fprintf(stderr,"Biddy_Nor: this BDD type is not supported, yet!\n");
599  return biddyNull;
600  } else {
601  fprintf(stderr,"Biddy_Nor: Unsupported BDD type!\n");
602  return biddyNull;
603  }
604 #endif
605 
606  return r;
607 }
608 
609 #ifdef __cplusplus
610 }
611 #endif
612 
613 /***************************************************************************/
626 #ifdef __cplusplus
627 extern "C" {
628 #endif
629 
632 {
633  Biddy_Edge r;
634 
635  assert( f != NULL );
636  assert( g != NULL );
637 
638  if (!MNG) MNG = biddyAnonymousManager;
639  ZF_LOGI("Biddy_Xor");
640 
641  assert( BiddyIsOK(f) == TRUE );
642  assert( BiddyIsOK(g) == TRUE );
643 
644  biddyNodeTable.funxor++;
645 
646  r = biddyNull;
647 
648  if (biddyManagerType == BIDDYTYPEOBDD) {
649  /* IMPLEMENTED */
650  r = BiddyManagedXor(MNG,f,g);
651  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedXor */
652  } else if (biddyManagerType == BIDDYTYPEOBDDC) {
653  /* IMPLEMENTED */
654  r = BiddyManagedXor(MNG,f,g);
655  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedXor */
656  }
657 #ifndef COMPACT
658  else if (biddyManagerType == BIDDYTYPEZBDD) {
659  /* IMPLEMENTED */
660  r = BiddyManagedXor(MNG,f,g);
661  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedXor */
662  } else if (biddyManagerType == BIDDYTYPEZBDDC) {
663  /* IMPLEMENTED */
664  r = BiddyManagedXor(MNG,f,g);
665  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedXor */
666  } else if (biddyManagerType == BIDDYTYPETZBDD) {
667  /* IMPLEMENTED */
668  r = BiddyManagedXor(MNG,f,g);
669  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedXor */
670  } else if (biddyManagerType == BIDDYTYPETZBDDC)
671  {
672  fprintf(stderr,"Biddy_Xor: this BDD type is not supported, yet!\n");
673  return biddyNull;
674  } else if ((biddyManagerType == BIDDYTYPEOFDDC) || (biddyManagerType == BIDDYTYPEOFDD) ||
675  (biddyManagerType == BIDDYTYPEZFDDC) || (biddyManagerType == BIDDYTYPEZFDD) ||
676  (biddyManagerType == BIDDYTYPETZFDDC) || (biddyManagerType == BIDDYTYPETZFDD))
677  {
678  fprintf(stderr,"Biddy_Xor: this BDD type is not supported, yet!\n");
679  return biddyNull;
680  } else {
681  fprintf(stderr,"Biddy_Xor: Unsupported BDD type!\n");
682  return biddyNull;
683  }
684 #endif
685 
686  return r;
687 }
688 
689 #ifdef __cplusplus
690 }
691 #endif
692 
693 /***************************************************************************/
706 #ifdef __cplusplus
707 extern "C" {
708 #endif
709 
712 {
713  Biddy_Edge r;
714 
715  assert( f != NULL );
716  assert( g != NULL );
717 
718  if (!MNG) MNG = biddyAnonymousManager;
719  ZF_LOGI("Biddy_Xnor");
720 
721  assert( BiddyIsOK(f) == TRUE );
722  assert( BiddyIsOK(g) == TRUE );
723 
724  r = biddyNull;
725 
726  if (biddyManagerType == BIDDYTYPEOBDD) {
727  /* PROTOTYPED */
728  r = BiddyManagedNot(MNG,BiddyManagedXor(MNG,f,g));
729  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedXor */
730  } else if (biddyManagerType == BIDDYTYPEOBDDC) {
731  /* IMPLEMENTED */
732  r = BiddyManagedXnor(MNG,f,g);
733  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedXnor */
734  }
735 #ifndef COMPACT
736  else if (biddyManagerType == BIDDYTYPEZBDD) {
737  /* PROTOTYPED */
738  r = BiddyManagedNot(MNG,BiddyManagedXor(MNG,f,g));
739  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedXor */
740  } else if (biddyManagerType == BIDDYTYPEZBDDC) {
741  /* PROTOTYPED */
742  r = BiddyManagedNot(MNG,BiddyManagedXor(MNG,f,g));
743  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedXor */
744  } else if (biddyManagerType == BIDDYTYPETZBDD) {
745  /* PROTOTYPED */
746  r = BiddyManagedNot(MNG,BiddyManagedXor(MNG,f,g));
747  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedXor */
748  } else if (biddyManagerType == BIDDYTYPETZBDDC)
749  {
750  fprintf(stderr,"Biddy_Xnor: this BDD type is not supported, yet!\n");
751  return biddyNull;
752  } else if ((biddyManagerType == BIDDYTYPEOFDDC) || (biddyManagerType == BIDDYTYPEOFDD) ||
753  (biddyManagerType == BIDDYTYPEZFDDC) || (biddyManagerType == BIDDYTYPEZFDD) ||
754  (biddyManagerType == BIDDYTYPETZFDDC) || (biddyManagerType == BIDDYTYPETZFDD))
755  {
756  fprintf(stderr,"Biddy_Xnor: this BDD type is not supported, yet!\n");
757  return biddyNull;
758  } else {
759  fprintf(stderr,"Biddy_Xnor: Unsupported BDD type!\n");
760  return biddyNull;
761  }
762 #endif
763 
764  return r;
765 }
766 
767 #ifdef __cplusplus
768 }
769 #endif
770 
771 /***************************************************************************/
785 #ifdef __cplusplus
786 extern "C" {
787 #endif
788 
791 {
792  Biddy_Edge r;
793 
794  assert( f != NULL );
795  assert( g != NULL );
796 
797  if (!MNG) MNG = biddyAnonymousManager;
798  ZF_LOGI("Biddy_Leq");
799 
800  assert( BiddyIsOK(f) == TRUE );
801  assert( BiddyIsOK(g) == TRUE );
802 
803  r = biddyNull;
804 
805  if (biddyManagerType == BIDDYTYPEOBDD) {
806  /* IMPLEMENTED */
807  r = BiddyManagedLeq(MNG,f,g);
808  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedLeq */
809  } else if (biddyManagerType == BIDDYTYPEOBDDC) {
810  /* IMPLEMENTED */
811  r = BiddyManagedLeq(MNG,f,g);
812  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedLeq */
813  }
814 #ifndef COMPACT
815  else if (biddyManagerType == BIDDYTYPEZBDD) {
816  /* IMPLEMENTED */
817  r = BiddyManagedLeq(MNG,f,g);
818  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedLeq */
819  } else if (biddyManagerType == BIDDYTYPEZBDDC) {
820  /* IMPLEMENTED */
821  r = BiddyManagedLeq(MNG,f,g);
822  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedLeq */
823  } else if (biddyManagerType == BIDDYTYPETZBDD) {
824  /* IMPLEMENTED */
825  r = BiddyManagedLeq(MNG,f,g);
826  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedLeq */
827  } else if (biddyManagerType == BIDDYTYPETZBDDC)
828  {
829  fprintf(stderr,"Biddy_Leq: this BDD type is not supported, yet!\n");
830  return biddyNull;
831  } else if ((biddyManagerType == BIDDYTYPEOFDDC) || (biddyManagerType == BIDDYTYPEOFDD) ||
832  (biddyManagerType == BIDDYTYPEZFDDC) || (biddyManagerType == BIDDYTYPEZFDD) ||
833  (biddyManagerType == BIDDYTYPETZFDDC) || (biddyManagerType == BIDDYTYPETZFDD))
834  {
835  fprintf(stderr,"Biddy_Leq: this BDD type is not supported, yet!\n");
836  return biddyNull;
837  } else {
838  fprintf(stderr,"Biddy_Leq: Unsupported BDD type!\n");
839  return biddyNull;
840  }
841 #endif
842 
843  return r;
844 }
845 
846 #ifdef __cplusplus
847 }
848 #endif
849 
850 /***************************************************************************/
866 #ifdef __cplusplus
867 extern "C" {
868 #endif
869 
872 {
873  Biddy_Edge r;
874 
875  assert( f != NULL );
876  assert( g != NULL );
877 
878  if (!MNG) MNG = biddyAnonymousManager;
879  ZF_LOGI("Biddy_Gt");
880 
881  assert( BiddyIsOK(f) == TRUE );
882  assert( BiddyIsOK(g) == TRUE );
883 
884  r = biddyNull;
885 
886  if (biddyManagerType == BIDDYTYPEOBDD) {
887  /* IMPLEMENTED */
888  r = BiddyManagedGt(MNG,f,g);
889  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedGt */
890  } else if (biddyManagerType == BIDDYTYPEOBDDC) {
891  /* IMPLEMENTED */
892  r = BiddyManagedGt(MNG,f,g);
893  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedGt */
894  }
895 #ifndef COMPACT
896  else if (biddyManagerType == BIDDYTYPEZBDD) {
897  /* IMPLEMENTED */
898  r = BiddyManagedGt(MNG,f,g);
899  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedGt */
900  } else if (biddyManagerType == BIDDYTYPEZBDDC) {
901  /* IMPLEMENTED */
902  r = BiddyManagedGt(MNG,f,g);
903  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedGt */
904  } else if (biddyManagerType == BIDDYTYPETZBDD) {
905  /* IMPLEMENTED */
906  r = BiddyManagedGt(MNG,f,g);
907  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedGt */
908  } else if (biddyManagerType == BIDDYTYPETZBDDC)
909  {
910  fprintf(stderr,"Biddy_Gt: this BDD type is not supported, yet!\n");
911  return biddyNull;
912  } else if ((biddyManagerType == BIDDYTYPEOFDDC) || (biddyManagerType == BIDDYTYPEOFDD) ||
913  (biddyManagerType == BIDDYTYPEZFDDC) || (biddyManagerType == BIDDYTYPEZFDD) ||
914  (biddyManagerType == BIDDYTYPETZFDDC) || (biddyManagerType == BIDDYTYPETZFDD))
915  {
916  fprintf(stderr,"Biddy_Gt: this BDD type is not supported, yet!\n");
917  return biddyNull;
918  } else {
919  fprintf(stderr,"Biddy_Gt: Unsupported BDD type!\n");
920  return biddyNull;
921  }
922 #endif
923 
924  return r;
925 }
926 
927 #ifdef __cplusplus
928 }
929 #endif
930 
931 /***************************************************************************/
943 #ifdef __cplusplus
944 extern "C" {
945 #endif
946 
949 {
950  Biddy_Edge imp;
951  Biddy_Boolean r;
952 
953  if (!MNG) MNG = biddyAnonymousManager;
954  ZF_LOGI("Biddy_IsLeq");
955 
956  r = FALSE;
957 
958  if (biddyManagerType == BIDDYTYPEOBDD) {
959  /* PROTOTYPED */
960  imp = BiddyManagedLeq(MNG,f,g);
961  r = (imp == biddyOne);
962  } else if (biddyManagerType == BIDDYTYPEOBDDC) {
963  /* PROTOTYPED */
964  imp = BiddyManagedLeq(MNG,f,g);
965  r = (imp == biddyOne);
966  }
967 #ifndef COMPACT
968  else if (biddyManagerType == BIDDYTYPEZBDD) {
969  /* PROTOTYPED */
970  imp = BiddyManagedLeq(MNG,f,g);
971  r = (imp == biddyOne);
972  } else if (biddyManagerType == BIDDYTYPEZBDDC) {
973  /* PROTOTYPED */
974  imp = BiddyManagedLeq(MNG,f,g);
975  r = (imp == biddyOne);
976  } else if (biddyManagerType == BIDDYTYPETZBDD) {
977  /* PROTOTYPED */
978  imp = BiddyManagedLeq(MNG,f,g);
979  r = (imp == biddyOne);
980  } else if (biddyManagerType == BIDDYTYPETZBDDC)
981  {
982  fprintf(stderr,"Biddy_IsLeq: this BDD type is not supported, yet!\n");
983  return FALSE;
984  } else if ((biddyManagerType == BIDDYTYPEOFDDC) || (biddyManagerType == BIDDYTYPEOFDD) ||
985  (biddyManagerType == BIDDYTYPEZFDDC) || (biddyManagerType == BIDDYTYPEZFDD) ||
986  (biddyManagerType == BIDDYTYPETZFDDC) || (biddyManagerType == BIDDYTYPETZFDD))
987  {
988  fprintf(stderr,"Biddy_IsLeq: this BDD type is not supported, yet!\n");
989  return FALSE;
990  } else {
991  fprintf(stderr,"Biddy_IsLeq: Unsupported BDD type!\n");
992  return FALSE;
993  }
994 #endif
995 
996  return r;
997 }
998 
999 #ifdef __cplusplus
1000 }
1001 #endif
1002 
1003 /***************************************************************************/
1018 #ifdef __cplusplus
1019 extern "C" {
1020 #endif
1021 
1022 Biddy_Edge
1024  Biddy_Boolean value)
1025 {
1026  Biddy_Edge r;
1027 
1028  assert( f != NULL );
1029 
1030  if (!MNG) MNG = biddyAnonymousManager;
1031  ZF_LOGI("Biddy_Restrict");
1032 
1033  if (!v) return biddyNull;
1034 
1035  assert( BiddyIsOK(f) == TRUE );
1036 
1037  r = biddyNull;
1038 
1039  if (biddyManagerType == BIDDYTYPEOBDD) {
1040  /* IMPLEMENTED */
1041  r = BiddyManagedRestrict(MNG,f,v,value);
1042  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedRestrict */
1043  } else if (biddyManagerType == BIDDYTYPEOBDDC) {
1044  /* IMPLEMENTED */
1045  r = BiddyManagedRestrict(MNG,f,v,value);
1046  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedRestrict */
1047  }
1048 #ifndef COMPACT
1049  else if (biddyManagerType == BIDDYTYPEZBDD) {
1050  /* IMPLEMENTED */
1051  r = BiddyManagedRestrict(MNG,f,v,value);
1052  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedRestrict */
1053  } else if (biddyManagerType == BIDDYTYPEZBDDC) {
1054  /* IMPLEMENTED */
1055  r = BiddyManagedRestrict(MNG,f,v,value);
1056  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedRestrict */
1057  } else if (biddyManagerType == BIDDYTYPETZBDD) {
1058  /* IMPLEMENTED */
1059  r = BiddyManagedRestrict(MNG,f,v,value);
1060  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedRestrict */
1061  } else if (biddyManagerType == BIDDYTYPETZBDDC)
1062  {
1063  fprintf(stderr,"Biddy_Restrict: this BDD type is not supported, yet!\n");
1064  return biddyNull;
1065  } else if ((biddyManagerType == BIDDYTYPEOFDDC) || (biddyManagerType == BIDDYTYPEOFDD) ||
1066  (biddyManagerType == BIDDYTYPEZFDDC) || (biddyManagerType == BIDDYTYPEZFDD) ||
1067  (biddyManagerType == BIDDYTYPETZFDDC) || (biddyManagerType == BIDDYTYPETZFDD))
1068  {
1069  fprintf(stderr,"Biddy_Restrict: this BDD type is not supported, yet!\n");
1070  return biddyNull;
1071  } else {
1072  fprintf(stderr,"Biddy_Restrict: Unsupported BDD type!\n");
1073  return biddyNull;
1074  }
1075 #endif
1076 
1077  return r;
1078 }
1079 
1080 #ifdef __cplusplus
1081 }
1082 #endif
1083 
1084 /***************************************************************************/
1097 #ifdef __cplusplus
1098 extern "C" {
1099 #endif
1100 
1101 Biddy_Edge
1103  Biddy_Variable v)
1104 {
1105  Biddy_Edge r;
1106 
1107  assert( f != NULL );
1108  assert( g != NULL );
1109 
1110  if (!MNG) MNG = biddyAnonymousManager;
1111  ZF_LOGI("Biddy_Compose");
1112 
1113  assert( BiddyIsOK(f) == TRUE );
1114  assert( BiddyIsOK(g) == TRUE );
1115 
1116  if (!v) return biddyNull;
1117 
1118  r = biddyNull;
1119 
1120  if (biddyManagerType == BIDDYTYPEOBDD) {
1121  /* IMPLEMENTED */
1122  r = BiddyManagedCompose(MNG,f,g,v);
1123  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedCompose */
1124  } else if (biddyManagerType == BIDDYTYPEOBDDC) {
1125  /* IMPLEMENTED */
1126  r = BiddyManagedCompose(MNG,f,g,v);
1127  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedCompose */
1128  }
1129 #ifndef COMPACT
1130  else if (biddyManagerType == BIDDYTYPEZBDD) {
1131  /* IMPLEMENTED */
1132  r = BiddyManagedCompose(MNG,f,g,v);
1133  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedCompose */
1134  } else if (biddyManagerType == BIDDYTYPEZBDDC) {
1135  /* IMPLEMENTED */
1136  r = BiddyManagedCompose(MNG,f,g,v);
1137  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedCompose */
1138  } else if (biddyManagerType == BIDDYTYPETZBDD) {
1139  /* IMPLEMENTED */
1140  r = BiddyManagedCompose(MNG,f,g,v);
1141  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedCompose */
1142  } else if (biddyManagerType == BIDDYTYPETZBDDC)
1143  {
1144  fprintf(stderr,"Biddy_Compose: this BDD type is not supported, yet!\n");
1145  return biddyNull;
1146  } else if ((biddyManagerType == BIDDYTYPEOFDDC) || (biddyManagerType == BIDDYTYPEOFDD) ||
1147  (biddyManagerType == BIDDYTYPEZFDDC) || (biddyManagerType == BIDDYTYPEZFDD) ||
1148  (biddyManagerType == BIDDYTYPETZFDDC) || (biddyManagerType == BIDDYTYPETZFDD))
1149  {
1150  fprintf(stderr,"Biddy_Compose: this BDD type is not supported, yet!\n");
1151  return biddyNull;
1152  } else {
1153  fprintf(stderr,"Biddy_Compose: Unsupported BDD type!\n");
1154  return biddyNull;
1155  }
1156 #endif
1157 
1158  return r;
1159 }
1160 
1161 #ifdef __cplusplus
1162 }
1163 #endif
1164 
1165 /***************************************************************************/
1179 #ifdef __cplusplus
1180 extern "C" {
1181 #endif
1182 
1183 Biddy_Edge
1185 {
1186  Biddy_Edge r;
1187 
1188  assert( f != NULL );
1189 
1190  if (!MNG) MNG = biddyAnonymousManager;
1191  ZF_LOGI("Biddy_E");
1192 
1193  if (!v) return biddyNull;
1194 
1195  assert( BiddyIsOK(f) == TRUE );
1196 
1197  r = biddyNull;
1198 
1199  if (biddyManagerType == BIDDYTYPEOBDD) {
1200  /* IMPLEMENTED */
1201  r = BiddyManagedE(MNG,f,v);
1202  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedE */
1203  } else if (biddyManagerType == BIDDYTYPEOBDDC) {
1204  /* IMPLEMENTED */
1205  r = BiddyManagedE(MNG,f,v);
1206  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedE */
1207  }
1208 #ifndef COMPACT
1209  else if (biddyManagerType == BIDDYTYPEZBDD) {
1210  /* IMPLEMENTED */
1211  r = BiddyManagedE(MNG,f,v);
1212  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedE */
1213  } else if (biddyManagerType == BIDDYTYPEZBDDC) {
1214  /* IMPLEMENTED */
1215  r = BiddyManagedE(MNG,f,v);
1216  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedE */
1217  } else if (biddyManagerType == BIDDYTYPETZBDD) {
1218  /* IMPLEMENTED */
1219  r = BiddyManagedE(MNG,f,v);
1220  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedE */
1221  } else if (biddyManagerType == BIDDYTYPETZBDDC)
1222  {
1223  fprintf(stderr,"Biddy_E: this BDD type is not supported, yet!\n");
1224  return biddyNull;
1225  } else if ((biddyManagerType == BIDDYTYPEOFDDC) || (biddyManagerType == BIDDYTYPEOFDD) ||
1226  (biddyManagerType == BIDDYTYPEZFDDC) || (biddyManagerType == BIDDYTYPEZFDD) ||
1227  (biddyManagerType == BIDDYTYPETZFDDC) || (biddyManagerType == BIDDYTYPETZFDD))
1228  {
1229  fprintf(stderr,"Biddy_E: this BDD type is not supported, yet!\n");
1230  return biddyNull;
1231  } else {
1232  fprintf(stderr,"Biddy_E: Unsupported BDD type!\n");
1233  return biddyNull;
1234  }
1235 #endif
1236 
1237  return r;
1238 }
1239 
1240 #ifdef __cplusplus
1241 }
1242 #endif
1243 
1244 /***************************************************************************/
1259 #ifdef __cplusplus
1260 extern "C" {
1261 #endif
1262 
1263 Biddy_Edge
1265 {
1266  Biddy_Edge r;
1267 
1268  assert( f != NULL );
1269 
1270  if (!MNG) MNG = biddyAnonymousManager;
1271  ZF_LOGI("Biddy_A");
1272 
1273  assert( BiddyIsOK(f) == TRUE );
1274 
1275  if (!v) return biddyNull;
1276 
1277  r = biddyNull;
1278 
1279  if (biddyManagerType == BIDDYTYPEOBDD) {
1280  /* PROTOTYPED */
1281  r = BiddyManagedNot(MNG,BiddyManagedE(MNG,BiddyManagedNot(MNG,f),v));
1282  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedXor */
1283  } else if (biddyManagerType == BIDDYTYPEOBDDC) {
1284  /* IMPLEMENTED */
1285  r = BiddyManagedA(MNG,f,v);
1286  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedA */
1287  }
1288 #ifndef COMPACT
1289  else if (biddyManagerType == BIDDYTYPEZBDD) {
1290  /* PROTOTYPED */
1291  r = BiddyManagedNot(MNG,BiddyManagedE(MNG,BiddyManagedNot(MNG,f),v));
1292  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedXor */
1293  } else if (biddyManagerType == BIDDYTYPEZBDDC) {
1294  /* PROTOTYPED */
1295  r = BiddyManagedNot(MNG,BiddyManagedE(MNG,BiddyManagedNot(MNG,f),v));
1296  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedXor */
1297  } else if (biddyManagerType == BIDDYTYPETZBDD) {
1298  /* PROTOTYPED */
1299  r = BiddyManagedNot(MNG,BiddyManagedE(MNG,BiddyManagedNot(MNG,f),v));
1300  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedXor */
1301  } else if (biddyManagerType == BIDDYTYPETZBDDC)
1302  {
1303  fprintf(stderr,"Biddy_A: this BDD type is not supported, yet!\n");
1304  return biddyNull;
1305  } else if ((biddyManagerType == BIDDYTYPEOFDDC) || (biddyManagerType == BIDDYTYPEOFDD) ||
1306  (biddyManagerType == BIDDYTYPEZFDDC) || (biddyManagerType == BIDDYTYPEZFDD) ||
1307  (biddyManagerType == BIDDYTYPETZFDDC) || (biddyManagerType == BIDDYTYPETZFDD))
1308  {
1309  fprintf(stderr,"Biddy_A: this BDD type is not supported, yet!\n");
1310  return biddyNull;
1311  } else {
1312  fprintf(stderr,"Biddy_A: Unsupported BDD type!\n");
1313  return biddyNull;
1314  }
1315 #endif
1316 
1317  return r;
1318 }
1319 
1320 #ifdef __cplusplus
1321 }
1322 #endif
1323 
1324 /***************************************************************************/
1339 #ifdef __cplusplus
1340 extern "C" {
1341 #endif
1342 
1345 {
1346  Biddy_Edge xa;
1347  Biddy_Boolean r;
1348 
1349  if (!MNG) MNG = biddyAnonymousManager;
1350  ZF_LOGI("Biddy_IsVariableDependent");
1351 
1352  r = FALSE;
1353 
1354  if (biddyManagerType == BIDDYTYPEOBDD) {
1355  /* PROTOTYPED */
1356  xa = BiddyManagedA(MNG,f,v);
1357  r = (xa == biddyZero);
1358  } else if (biddyManagerType == BIDDYTYPEOBDDC) {
1359  /* PROTOTYPED */
1360  xa = BiddyManagedA(MNG,f,v);
1361  r = (xa == biddyZero);
1362  }
1363 #ifndef COMPACT
1364  else if ((biddyManagerType == BIDDYTYPEZBDD) ||
1365  (biddyManagerType == BIDDYTYPEZBDDC) ||
1366  (biddyManagerType == BIDDYTYPETZBDD))
1367  {
1368  fprintf(stderr,"Biddy_IsVariableDependent: this BDD type is not supported, yet!\n");
1369  return FALSE;
1370  } else if (biddyManagerType == BIDDYTYPETZBDDC)
1371  {
1372  fprintf(stderr,"Biddy_IsVariableDependent: this BDD type is not supported, yet!\n");
1373  return FALSE;
1374  } else if ((biddyManagerType == BIDDYTYPEOFDDC) || (biddyManagerType == BIDDYTYPEOFDD) ||
1375  (biddyManagerType == BIDDYTYPEZFDDC) || (biddyManagerType == BIDDYTYPEZFDD) ||
1376  (biddyManagerType == BIDDYTYPETZFDDC) || (biddyManagerType == BIDDYTYPETZFDD))
1377  {
1378  fprintf(stderr,"Biddy_IsVariableDependent: this BDD type is not supported, yet!\n");
1379  return FALSE;
1380  } else {
1381  fprintf(stderr,"Biddy_IsVariableDependent: Unsupported BDD type!\n");
1382  return FALSE;
1383  }
1384 #endif
1385 
1386  return r;
1387 }
1388 
1389 #ifdef __cplusplus
1390 }
1391 #endif
1392 
1393 /***************************************************************************/
1405 #ifdef __cplusplus
1406 extern "C" {
1407 #endif
1408 
1409 Biddy_Edge
1411 {
1412  Biddy_Edge r;
1413 
1414  assert( f != NULL );
1415  assert( cube != NULL );
1416 
1417  if (!MNG) MNG = biddyAnonymousManager;
1418  ZF_LOGI("Biddy_ExistAbstract");
1419 
1420  assert( BiddyIsOK(f) == TRUE );
1421  assert( BiddyIsOK(cube) == TRUE );
1422 
1423  r = biddyNull;
1424 
1425  if (biddyManagerType == BIDDYTYPEOBDD) {
1426  /* IMPLEMENTED */
1427  r = BiddyManagedExistAbstract(MNG,f,cube);
1428  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedExistAbstract */
1429  } else if (biddyManagerType == BIDDYTYPEOBDDC) {
1430  /* IMPLEMENTED */
1431  r = BiddyManagedExistAbstract(MNG,f,cube);
1432  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedExistAbstract */
1433  }
1434 #ifndef COMPACT
1435  else if (biddyManagerType == BIDDYTYPEZBDD) {
1436  /* IMPLEMENTED */
1437  r = BiddyManagedExistAbstract(MNG,f,cube);
1438  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedExistAbstract */
1439  } else if (biddyManagerType == BIDDYTYPEZBDDC) {
1440  /* IMPLEMENTED */
1441  r = BiddyManagedExistAbstract(MNG,f,cube);
1442  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedExistAbstract */
1443  } else if (biddyManagerType == BIDDYTYPETZBDD) {
1444  /* IMPLEMENTED */
1445  r = BiddyManagedExistAbstract(MNG,f,cube);
1446  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedExistAbstract */
1447  } else if (biddyManagerType == BIDDYTYPETZBDDC)
1448  {
1449  fprintf(stderr,"Biddy_ExistAbstract: this BDD type is not supported, yet!\n");
1450  return biddyNull;
1451  } else if ((biddyManagerType == BIDDYTYPEOFDDC) || (biddyManagerType == BIDDYTYPEOFDD) ||
1452  (biddyManagerType == BIDDYTYPEZFDDC) || (biddyManagerType == BIDDYTYPEZFDD) ||
1453  (biddyManagerType == BIDDYTYPETZFDDC) || (biddyManagerType == BIDDYTYPETZFDD))
1454  {
1455  fprintf(stderr,"Biddy_ExistAbstract: this BDD type is not supported, yet!\n");
1456  return biddyNull;
1457  } else {
1458  fprintf(stderr,"Biddy_ExistAbstract: Unsupported BDD type!\n");
1459  return biddyNull;
1460  }
1461 #endif
1462 
1463  return r;
1464 }
1465 
1466 #ifdef __cplusplus
1467 }
1468 #endif
1469 
1470 /***************************************************************************/
1483 #ifdef __cplusplus
1484 extern "C" {
1485 #endif
1486 
1487 Biddy_Edge
1489 {
1490  Biddy_Edge r;
1491 
1492  assert( f != NULL );
1493  assert( cube != NULL );
1494 
1495  if (!MNG) MNG = biddyAnonymousManager;
1496  ZF_LOGI("Biddy_UnivAbstract");
1497 
1498  assert( BiddyIsOK(f) == TRUE );
1499  assert( BiddyIsOK(cube) == TRUE );
1500 
1501  r = biddyNull;
1502 
1503  if (biddyManagerType == BIDDYTYPEOBDD) {
1504  /* PROTOTYPED */
1505  r = BiddyManagedNot(MNG,BiddyManagedExistAbstract(MNG,BiddyManagedNot(MNG,f),cube));
1506  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedXor */
1507  } else if (biddyManagerType == BIDDYTYPEOBDDC) {
1508  /* IMPLEMENTED */
1509  r = BiddyManagedUnivAbstract(MNG,f,cube);
1510  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedUnivAbstract */
1511  }
1512 #ifndef COMPACT
1513  else if (biddyManagerType == BIDDYTYPEZBDD) {
1514  /* PROTOTYPED */
1515  r = BiddyManagedNot(MNG,BiddyManagedExistAbstract(MNG,BiddyManagedNot(MNG,f),cube));
1516  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedXor */
1517  } else if (biddyManagerType == BIDDYTYPEZBDDC) {
1518  /* PROTOTYPED */
1519  r = BiddyManagedNot(MNG,BiddyManagedExistAbstract(MNG,BiddyManagedNot(MNG,f),cube));
1520  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedXor */
1521  } else if (biddyManagerType == BIDDYTYPETZBDD) {
1522  /* PROTOTYPED */
1523  r = BiddyManagedNot(MNG,BiddyManagedExistAbstract(MNG,BiddyManagedNot(MNG,f),cube));
1524  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedXor */
1525  } else if (biddyManagerType == BIDDYTYPETZBDDC)
1526  {
1527  fprintf(stderr,"Biddy_UnivAbstract: this BDD type is not supported, yet!\n");
1528  return biddyNull;
1529  } else if ((biddyManagerType == BIDDYTYPEOFDDC) || (biddyManagerType == BIDDYTYPEOFDD) ||
1530  (biddyManagerType == BIDDYTYPEZFDDC) || (biddyManagerType == BIDDYTYPEZFDD) ||
1531  (biddyManagerType == BIDDYTYPETZFDDC) || (biddyManagerType == BIDDYTYPETZFDD))
1532  {
1533  fprintf(stderr,"Biddy_UnivAbstract: this BDD type is not supported, yet!\n");
1534  return biddyNull;
1535  } else {
1536  fprintf(stderr,"Biddy_UnivAbstract: Unsupported BDD type!\n");
1537  return biddyNull;
1538  }
1539 #endif
1540 
1541  return r;
1542 }
1543 
1544 #ifdef __cplusplus
1545 }
1546 #endif
1547 
1548 /***************************************************************************/
1560 #ifdef __cplusplus
1561 extern "C" {
1562 #endif
1563 
1564 Biddy_Edge
1566  Biddy_Edge cube)
1567 {
1568  Biddy_Edge r;
1569 
1570  assert( f != NULL );
1571  assert( g != NULL );
1572  assert( cube != NULL );
1573 
1574  if (!MNG) MNG = biddyAnonymousManager;
1575  ZF_LOGI("Biddy_AndAbstract");
1576 
1577  assert( BiddyIsOK(f) == TRUE );
1578  assert( BiddyIsOK(g) == TRUE );
1579  assert( BiddyIsOK(cube) == TRUE );
1580 
1581  r = biddyNull;
1582 
1583  if (biddyManagerType == BIDDYTYPEOBDD) {
1584  /* IMPLEMENTED */
1585  r = BiddyManagedAndAbstract(MNG,f,g,cube);
1586  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedAndAbstract */
1587  } else if (biddyManagerType == BIDDYTYPEOBDDC) {
1588  /* IMPLEMENTED */
1589  r = BiddyManagedAndAbstract(MNG,f,g,cube);
1590  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedAndAbstract */
1591  }
1592 #ifndef COMPACT
1593  else if (biddyManagerType == BIDDYTYPEZBDD) {
1594  /* IMPLEMENTED */
1595  r = BiddyManagedAndAbstract(MNG,f,g,cube);
1596  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedAndAbstract */
1597  } else if (biddyManagerType == BIDDYTYPEZBDDC) {
1598  /* IMPLEMENTED */
1599  r = BiddyManagedAndAbstract(MNG,f,g,cube);
1600  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedAndAbstract */
1601  } else if (biddyManagerType == BIDDYTYPETZBDD) {
1602  /* IMPLEMENTED */
1603  r = BiddyManagedAndAbstract(MNG,f,g,cube);
1604  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedAndAbstract */
1605  } else if (biddyManagerType == BIDDYTYPETZBDDC)
1606  {
1607  fprintf(stderr,"Biddy_AndAbstract: this BDD type is not supported, yet!\n");
1608  return biddyNull;
1609  } else if ((biddyManagerType == BIDDYTYPEOFDDC) || (biddyManagerType == BIDDYTYPEOFDD) ||
1610  (biddyManagerType == BIDDYTYPEZFDDC) || (biddyManagerType == BIDDYTYPEZFDD) ||
1611  (biddyManagerType == BIDDYTYPETZFDDC) || (biddyManagerType == BIDDYTYPETZFDD))
1612  {
1613  fprintf(stderr,"Biddy_AndAbstract: this BDD type is not supported, yet!\n");
1614  return biddyNull;
1615  } else {
1616  fprintf(stderr,"Biddy_AndAbstract: Unsupported BDD type!\n");
1617  return biddyNull;
1618  }
1619 #endif
1620 
1621  return r;
1622 }
1623 
1624 #ifdef __cplusplus
1625 }
1626 #endif
1627 
1628 /***************************************************************************/
1650 /* SOME REFERENCES FOR Biddy_Constrain AND Biddy_Simplify */
1651 /* O. Coudert et al. Verification of synchronous sequential machines based on symbolic execution, 1989, 1990 */
1652 /* O. Coudert et al. A unified framework for the formal verification of sequential circuits, 1990 */
1653 /* B. Lin et al. Don't care minimization of multi-level sequential logic networks. 1990. */
1654 /* Thomas R. Shiple et al. Heuristic minimization of BDDs using don't cares, 1994 */
1655 /* Mark D. Aagaard. et al. Formal verification using parametric representations of Boolean constraints, 1999 */
1656 
1657 #ifdef __cplusplus
1658 extern "C" {
1659 #endif
1660 
1661 Biddy_Edge
1663 {
1664  Biddy_Edge r;
1665 
1666  assert( f != NULL );
1667  assert( c != NULL );
1668 
1669  if (!MNG) MNG = biddyAnonymousManager;
1670  ZF_LOGI("Biddy_Constrain");
1671 
1672  assert( BiddyIsOK(f) == TRUE );
1673  assert( BiddyIsOK(c) == TRUE );
1674 
1675  r = biddyNull;
1676 
1677  if (biddyManagerType == BIDDYTYPEOBDD) {
1678  /* IMPLEMENTED */
1679  r = BiddyManagedConstrain(MNG,f,c);
1680  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedConstrain */
1681  } else if (biddyManagerType == BIDDYTYPEOBDDC) {
1682  /* IMPLEMENTED */
1683  r = BiddyManagedConstrain(MNG,f,c);
1684  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedConstrain */
1685  }
1686 #ifndef COMPACT
1687  else if ((biddyManagerType == BIDDYTYPEZBDD) ||
1688  (biddyManagerType == BIDDYTYPEZBDDC) ||
1689  (biddyManagerType == BIDDYTYPETZBDD))
1690  {
1691  fprintf(stderr,"Biddy_Constrain: this BDD type is not supported, yet!\n");
1692  return f;
1693  } else if (biddyManagerType == BIDDYTYPETZBDDC)
1694  {
1695  fprintf(stderr,"Biddy_Constrain: this BDD type is not supported, yet!\n");
1696  return biddyNull;
1697  } else if ((biddyManagerType == BIDDYTYPEOFDDC) || (biddyManagerType == BIDDYTYPEOFDD) ||
1698  (biddyManagerType == BIDDYTYPEZFDDC) || (biddyManagerType == BIDDYTYPEZFDD) ||
1699  (biddyManagerType == BIDDYTYPETZFDDC) || (biddyManagerType == BIDDYTYPETZFDD))
1700  {
1701  fprintf(stderr,"Biddy_Constrain: this BDD type is not supported, yet!\n");
1702  return biddyNull;
1703  } else {
1704  fprintf(stderr,"Biddy_Constrain: Unsupported BDD type!\n");
1705  return biddyNull;
1706  }
1707 #endif
1708 
1709  return r;
1710 }
1711 
1712 #ifdef __cplusplus
1713 }
1714 #endif
1715 
1716 /***************************************************************************/
1742 /* SOME REFERENCES FOR Biddy_Constrain AND Biddy_Simplify */
1743 /* O. Coudert et al. Verification of synchronous sequential machines based on symbolic execution, 1989, 1990 */
1744 /* O. Coudert et al. A unified framework for the formal verification of sequential circuits, 1990 */
1745 /* B. Lin et al. Don't care minimization of multi-level sequential logic networks. 1990. */
1746 /* Thomas R. Shiple et al. Heuristic minimization of BDDs using don't cares, 1994 */
1747 /* Mark D. Aagaard. et al. Formal verification using parametric representations of Boolean constraints, 1999 */
1748 
1749 #ifdef __cplusplus
1750 extern "C" {
1751 #endif
1752 
1753 Biddy_Edge
1755 {
1756  Biddy_Edge r;
1757 
1758  assert( f != NULL );
1759  assert( c != NULL );
1760 
1761  if (!MNG) MNG = biddyAnonymousManager;
1762  ZF_LOGI("Biddy_Simplify");
1763 
1764  assert( BiddyIsOK(f) == TRUE );
1765  assert( BiddyIsOK(c) == TRUE );
1766 
1767  r = biddyNull;
1768 
1769  if (biddyManagerType == BIDDYTYPEOBDD) {
1770  /* IMPLEMENTED */
1771  r = BiddyManagedSimplify(MNG,f,c);
1772  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedSimplify */
1773  } else if (biddyManagerType == BIDDYTYPEOBDDC) {
1774  /* IMPLEMENTED */
1775  r = BiddyManagedSimplify(MNG,f,c);
1776  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedSimplify */
1777  }
1778 #ifndef COMPACT
1779  else if ((biddyManagerType == BIDDYTYPEZBDD) ||
1780  (biddyManagerType == BIDDYTYPEZBDDC) ||
1781  (biddyManagerType == BIDDYTYPETZBDD))
1782  {
1783  fprintf(stderr,"Biddy_Simplify: this BDD type is not supported, yet!\n");
1784  return f;
1785  } else if (biddyManagerType == BIDDYTYPETZBDDC)
1786  {
1787  fprintf(stderr,"Biddy_Simplify: this BDD type is not supported, yet!\n");
1788  return biddyNull;
1789  } else if ((biddyManagerType == BIDDYTYPEOFDDC) || (biddyManagerType == BIDDYTYPEOFDD) ||
1790  (biddyManagerType == BIDDYTYPEZFDDC) || (biddyManagerType == BIDDYTYPEZFDD) ||
1791  (biddyManagerType == BIDDYTYPETZFDDC) || (biddyManagerType == BIDDYTYPETZFDD))
1792  {
1793  fprintf(stderr,"Biddy_Simplify: this BDD type is not supported, yet!\n");
1794  return biddyNull;
1795  } else {
1796  fprintf(stderr,"Biddy_Simplify: Unsupported BDD type!\n");
1797  return biddyNull;
1798  }
1799 #endif
1800 
1801  return r;
1802 }
1803 
1804 #ifdef __cplusplus
1805 }
1806 #endif
1807 
1808 /***************************************************************************/
1824 #ifdef __cplusplus
1825 extern "C" {
1826 #endif
1827 
1828 Biddy_Edge
1830 {
1831  Biddy_Edge r;
1832 
1833  if (!MNG) MNG = biddyAnonymousManager;
1834  ZF_LOGI("Biddy_Support");
1835 
1836  assert( (f == NULL) || (BiddyIsOK(f) == TRUE) );
1837 
1838  r = biddyNull;
1839 
1840  if (biddyManagerType == BIDDYTYPEOBDD) {
1841  /* IMPLEMENTED */
1842  r = BiddyManagedSupport(MNG,f);
1843  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedSupport */
1844  } else if (biddyManagerType == BIDDYTYPEOBDDC) {
1845  /* IMPLEMENTED */
1846  r = BiddyManagedSupport(MNG,f);
1847  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedSupport */
1848  }
1849 #ifndef COMPACT
1850  else if (biddyManagerType == BIDDYTYPEZBDD) {
1851  /* PROTOTYPED USING Restrict */
1852  /*
1853  Biddy_Variable v;
1854  r = biddyTerminal;
1855  for (v=1;v<biddyVariableTable.num;v++) {
1856  if (BiddyManagedRestrict(MNG,f,v,FALSE) != BiddyManagedRestrict(MNG,f,v,TRUE)) {
1857  r = BiddyManagedChange(MNG,r,v);
1858  }
1859  }
1860  */
1861  /* IMPLEMENTED */
1862  r = BiddyManagedSupport(MNG,f);
1863  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedSupport */
1864  } else if (biddyManagerType == BIDDYTYPEZBDDC) {
1865  /* PROTOTYPED USING Restrict */
1866  /*
1867  Biddy_Variable v;
1868  r = biddyTerminal;
1869  for (v=1;v<biddyVariableTable.num;v++) {
1870  if (BiddyManagedRestrict(MNG,f,v,FALSE) != BiddyManagedRestrict(MNG,f,v,TRUE)) {
1871  r = BiddyManagedChange(MNG,r,v);
1872  }
1873  }
1874  */
1875  /* IMPLEMENTED */
1876  r = BiddyManagedSupport(MNG,f);
1877  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedSupport */
1878  } else if (biddyManagerType == BIDDYTYPETZBDD) {
1879  /* PROTOTYPED USING Restrict */
1880  /*
1881  Biddy_Variable v;
1882  r = biddyOne;
1883  for (v=1;v<biddyVariableTable.num;v++) {
1884  if (BiddyManagedRestrict(MNG,f,v,FALSE) != BiddyManagedRestrict(MNG,f,v,TRUE)) {
1885  r = BiddyManagedAnd(MNG,r,biddyVariableTable.table[v].variable);
1886  }
1887  }
1888  */
1889  /* IMPLEMENTED */
1890  r = BiddyManagedSupport(MNG,f);
1891  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedSupport */
1892  } else if (biddyManagerType == BIDDYTYPETZBDDC)
1893  {
1894  fprintf(stderr,"Biddy_Support: this BDD type is not supported, yet!\n");
1895  return biddyNull;
1896  } else if ((biddyManagerType == BIDDYTYPEOFDDC) || (biddyManagerType == BIDDYTYPEOFDD) ||
1897  (biddyManagerType == BIDDYTYPEZFDDC) || (biddyManagerType == BIDDYTYPEZFDD) ||
1898  (biddyManagerType == BIDDYTYPETZFDDC) || (biddyManagerType == BIDDYTYPETZFDD))
1899  {
1900  fprintf(stderr,"Biddy_Support: this BDD type is not supported, yet!\n");
1901  return biddyNull;
1902  } else {
1903  fprintf(stderr,"Biddy_Support: Unsupported BDD type!\n");
1904  return biddyNull;
1905  }
1906 #endif
1907 
1908  return r;
1909 }
1910 
1911 #ifdef __cplusplus
1912 }
1913 #endif
1914 
1915 /***************************************************************************/
1939 #ifdef __cplusplus
1940 extern "C" {
1941 #endif
1942 
1943 Biddy_Edge
1945  Biddy_String keyword)
1946 {
1947  Biddy_Edge r;
1948 
1949 #ifndef COMPACT
1950  Biddy_Edge tmp, e, t;
1951  Biddy_Variable v;
1952 #endif
1953 
1954  assert( f != NULL );
1955 
1956  if (!MNG) MNG = biddyAnonymousManager;
1957  ZF_LOGI("Biddy_ReplaceByKeyword");
1958 
1959  assert( BiddyIsOK(f) == TRUE );
1960 
1961  r = biddyNull;
1962 
1963  if (biddyManagerType == BIDDYTYPEOBDD) {
1964  /* IMPLEMENTED */
1965  r = BiddyManagedReplaceByKeyword(MNG,f,keyword);
1966  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedReplaceByKeyword */
1967  } else if (biddyManagerType == BIDDYTYPEOBDDC) {
1968  /* IMPLEMENTED */
1969  r = BiddyManagedReplaceByKeyword(MNG,f,keyword);
1970  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedReplaceByKeyword */
1971  }
1972 #ifndef COMPACT
1973  else if (biddyManagerType == BIDDYTYPEZBDD) {
1974  /* PROTOTYPED */
1975  r = f;
1976  for (v=1;v<biddyVariableTable.num;v++) {
1977  if ((tmp=biddyVariableTable.table[v].value) != biddyZero) {
1978  /* Restrict is avoided because it uses RC Cache */
1979  /*
1980  e = BiddyManagedRestrict(MNG,r,v,FALSE);
1981  t = BiddyManagedRestrict(MNG,r,v,TRUE);
1982  */
1983  e = BiddyManagedE(MNG,BiddyManagedVarSubset(MNG,r,v,FALSE),v);
1984  t = BiddyManagedE(MNG,BiddyManagedVarSubset(MNG,r,v,TRUE),v);
1985  tmp = BiddyManagedGetVariableEdge(MNG,BiddyV(tmp));
1986  r = BiddyManagedXor(MNG,
1987  BiddyManagedAnd(MNG,tmp,t),
1988  BiddyManagedAnd(MNG,BiddyManagedNot(MNG,tmp),e));
1989  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedXor */
1990  }
1991  }
1992  } else if (biddyManagerType == BIDDYTYPEZBDDC) {
1993  /* PROTOTYPED */
1994  r = f;
1995  for (v=1;v<biddyVariableTable.num;v++) {
1996  if ((tmp=biddyVariableTable.table[v].value) != biddyZero) {
1997  /* Restrict is avoided because it uses RC Cache */
1998  /*
1999  e = BiddyManagedRestrict(MNG,r,v,FALSE);
2000  t = BiddyManagedRestrict(MNG,r,v,TRUE);
2001  */
2002  e = BiddyManagedE(MNG,BiddyManagedVarSubset(MNG,r,v,FALSE),v);
2003  t = BiddyManagedE(MNG,BiddyManagedVarSubset(MNG,r,v,TRUE),v);
2004  tmp = BiddyManagedGetVariableEdge(MNG,BiddyV(tmp));
2005  r = BiddyManagedXor(MNG,
2006  BiddyManagedAnd(MNG,tmp,t),
2007  BiddyManagedAnd(MNG,BiddyManagedNot(MNG,tmp),e));
2008  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedXor */
2009  }
2010  }
2011  } else if (biddyManagerType == BIDDYTYPETZBDD) {
2012  /* IMPLEMENTED */
2013  r = BiddyManagedReplaceByKeyword(MNG,f,keyword);
2014  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedReplaceByKeyword */
2015  } else if (biddyManagerType == BIDDYTYPETZBDDC)
2016  {
2017  fprintf(stderr,"Biddy_ReplaceByKeyword: this BDD type is not supported, yet!\n");
2018  return biddyNull;
2019  } else if ((biddyManagerType == BIDDYTYPEOFDDC) || (biddyManagerType == BIDDYTYPEOFDD) ||
2020  (biddyManagerType == BIDDYTYPEZFDDC) || (biddyManagerType == BIDDYTYPEZFDD) ||
2021  (biddyManagerType == BIDDYTYPETZFDDC) || (biddyManagerType == BIDDYTYPETZFDD))
2022  {
2023  fprintf(stderr,"Biddy_ReplaceByKeyword: this BDD type is not supported, yet!\n");
2024  return biddyNull;
2025  } else {
2026  fprintf(stderr,"Biddy_ReplaceByKeyword: Unsupported BDD type!\n");
2027  return biddyNull;
2028  }
2029 #endif
2030 
2031  return r;
2032 }
2033 
2034 #ifdef __cplusplus
2035 }
2036 #endif
2037 
2038 /***************************************************************************/
2051 #ifdef __cplusplus
2052 extern "C" {
2053 #endif
2054 
2055 Biddy_Edge
2057 {
2058  Biddy_Edge r;
2059 
2060  assert( f != NULL );
2061 
2062  if (!MNG) MNG = biddyAnonymousManager;
2063  ZF_LOGI("Biddy_Change");
2064 
2065  assert( BiddyIsOK(f) == TRUE );
2066 
2067  if (!v) return biddyNull;
2068 
2069  r = biddyNull;
2070 
2071  if (biddyManagerType == BIDDYTYPEOBDD) {
2072  /* IMPLEMENTED */
2073  r = BiddyManagedChange(MNG,f,v);
2074  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedChange */
2075  } else if (biddyManagerType == BIDDYTYPEOBDDC) {
2076  /* IMPLEMENTED */
2077  r = BiddyManagedChange(MNG,f,v);
2078  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedChange */
2079  }
2080 #ifndef COMPACT
2081  else if (biddyManagerType == BIDDYTYPEZBDD) {
2082  /* IMPLEMENTED */
2083  r = BiddyManagedChange(MNG,f,v);
2084  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedChange */
2085  } else if (biddyManagerType == BIDDYTYPEZBDDC) {
2086  /* IMPLEMENTED */
2087  r = BiddyManagedChange(MNG,f,v);
2088  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedChange */
2089  } else if (biddyManagerType == BIDDYTYPETZBDD) {
2090  /* IMPLEMENTED */
2091  r = BiddyManagedChange(MNG,f,v);
2092  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedChange */
2093  } else if (biddyManagerType == BIDDYTYPETZBDDC)
2094  {
2095  fprintf(stderr,"Biddy_Change: this BDD type is not supported, yet!\n");
2096  return biddyNull;
2097  } else if ((biddyManagerType == BIDDYTYPEOFDDC) || (biddyManagerType == BIDDYTYPEOFDD) ||
2098  (biddyManagerType == BIDDYTYPEZFDDC) || (biddyManagerType == BIDDYTYPEZFDD) ||
2099  (biddyManagerType == BIDDYTYPETZFDDC) || (biddyManagerType == BIDDYTYPETZFDD))
2100  {
2101  fprintf(stderr,"Biddy_Change: this BDD type is not supported, yet!\n");
2102  return biddyNull;
2103  } else {
2104  fprintf(stderr,"Biddy_Change: Unsupported BDD type!\n");
2105  return biddyNull;
2106  }
2107 #endif
2108 
2109  return r;
2110 }
2111 
2112 #ifdef __cplusplus
2113 }
2114 #endif
2115 
2116 /***************************************************************************/
2144 #ifdef __cplusplus
2145 extern "C" {
2146 #endif
2147 
2148 Biddy_Edge
2150  Biddy_Boolean value)
2151 {
2152  Biddy_Edge r;
2153 
2154  assert( f != NULL );
2155 
2156  if (!MNG) MNG = biddyAnonymousManager;
2157  ZF_LOGI("Biddy_VarSubset");
2158 
2159  assert( BiddyIsOK(f) == TRUE );
2160 
2161  if (!v) return biddyNull;
2162 
2163  r = biddyNull;
2164 
2165  if (biddyManagerType == BIDDYTYPEOBDD) {
2166  /* IMPLEMENTED */
2167  r = BiddyManagedVarSubset(MNG,f,v,value);
2168  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedVarSubset */
2169  } else if (biddyManagerType == BIDDYTYPEOBDDC) {
2170  /* IMPLEMENTED */
2171  r = BiddyManagedVarSubset(MNG,f,v,value);
2172  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedVarSubset */
2173  }
2174 #ifndef COMPACT
2175  else if (biddyManagerType == BIDDYTYPEZBDD) {
2176  /* IMPLEMENTED */
2177  r = BiddyManagedVarSubset(MNG,f,v,value);
2178  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedVarSubset */
2179  } else if (biddyManagerType == BIDDYTYPEZBDDC) {
2180  /* IMPLEMENTED */
2181  r = BiddyManagedVarSubset(MNG,f,v,value);
2182  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedVarSubset */
2183  } else if (biddyManagerType == BIDDYTYPETZBDD) {
2184  /* IMPLEMENTED */
2185  r = BiddyManagedVarSubset(MNG,f,v,value);
2186  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedVarSubset */
2187  } else if (biddyManagerType == BIDDYTYPETZBDDC)
2188  {
2189  fprintf(stderr,"Biddy_VarSubset: this BDD type is not supported, yet!\n");
2190  return biddyNull;
2191  } else if ((biddyManagerType == BIDDYTYPEOFDDC) || (biddyManagerType == BIDDYTYPEOFDD) ||
2192  (biddyManagerType == BIDDYTYPEZFDDC) || (biddyManagerType == BIDDYTYPEZFDD) ||
2193  (biddyManagerType == BIDDYTYPETZFDDC) || (biddyManagerType == BIDDYTYPETZFDD))
2194  {
2195  fprintf(stderr,"Biddy_VarSubset: this BDD type is not supported, yet!\n");
2196  return biddyNull;
2197  } else {
2198  fprintf(stderr,"Biddy_VarSubset: Unsupported BDD type!\n");
2199  return biddyNull;
2200  }
2201 #endif
2202 
2203  return r;
2204 }
2205 
2206 #ifdef __cplusplus
2207 }
2208 #endif
2209 
2210 /***************************************************************************/
2224 #ifdef __cplusplus
2225 extern "C" {
2226 #endif
2227 
2228 Biddy_Edge
2230 {
2231  Biddy_Edge r;
2232 
2233  assert( f != NULL );
2234 
2235  if (!MNG) MNG = biddyAnonymousManager;
2236  ZF_LOGI("Biddy_ElementAbstract");
2237 
2238  if (!v) return biddyNull;
2239 
2240  assert( BiddyIsOK(f) == TRUE );
2241 
2242  r = biddyNull;
2243 
2244  if (biddyManagerType == BIDDYTYPEOBDD) {
2245  /* IMPLEMENTED */
2246  r = BiddyManagedElementAbstract(MNG,f,v);
2247  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedElementAbstract */
2248  } else if (biddyManagerType == BIDDYTYPEOBDDC) {
2249  /* IMPLEMENTED */
2250  r = BiddyManagedElementAbstract(MNG,f,v);
2251  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedElementAbstract */
2252  }
2253 #ifndef COMPACT
2254  else if (biddyManagerType == BIDDYTYPEZBDD) {
2255  /* IMPLEMENTED */
2256  r = BiddyManagedElementAbstract(MNG,f,v);
2257  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedElementAbstract */
2258  } else if (biddyManagerType == BIDDYTYPEZBDDC) {
2259  /* IMPLEMENTED */
2260  r = BiddyManagedElementAbstract(MNG,f,v);
2261  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedElementAbstract */
2262  } else if (biddyManagerType == BIDDYTYPETZBDD) {
2263  /* IMPLEMENTED */
2264  r = BiddyManagedElementAbstract(MNG,f,v);
2265  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedElementAbstract */
2266  } else if (biddyManagerType == BIDDYTYPETZBDDC)
2267  {
2268  fprintf(stderr,"Biddy_ElementAbstract: this BDD type is not supported, yet!\n");
2269  return biddyNull;
2270  } else if ((biddyManagerType == BIDDYTYPEOFDDC) || (biddyManagerType == BIDDYTYPEOFDD) ||
2271  (biddyManagerType == BIDDYTYPEZFDDC) || (biddyManagerType == BIDDYTYPEZFDD) ||
2272  (biddyManagerType == BIDDYTYPETZFDDC) || (biddyManagerType == BIDDYTYPETZFDD))
2273  {
2274  fprintf(stderr,"Biddy_ElementAbstract: this BDD type is not supported, yet!\n");
2275  return biddyNull;
2276  } else {
2277  fprintf(stderr,"Biddy_ElementAbstract: Unsupported BDD type!\n");
2278  return biddyNull;
2279  }
2280 #endif
2281 
2282  return r;
2283 }
2284 
2285 #ifdef __cplusplus
2286 }
2287 #endif
2288 
2289 /***************************************************************************/
2303 #ifdef __cplusplus
2304 extern "C" {
2305 #endif
2306 
2307 Biddy_Edge
2309 {
2310  Biddy_Edge r;
2311 
2312  assert( f != NULL );
2313  assert( g != NULL );
2314 
2315  if (!MNG) MNG = biddyAnonymousManager;
2316  ZF_LOGI("Biddy_Product");
2317 
2318  assert( BiddyIsOK(f) == TRUE );
2319  assert( BiddyIsOK(g) == TRUE );
2320 
2321  r = biddyNull;
2322 
2323  if (biddyManagerType == BIDDYTYPEOBDD) {
2324  /* IMPLEMENTED */
2325  r = BiddyManagedProduct(MNG,f,g);
2326  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedProduct */
2327  } else if (biddyManagerType == BIDDYTYPEOBDDC) {
2328  /* IMPLEMENTED */
2329  r = BiddyManagedProduct(MNG,f,g);
2330  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedProduct */
2331  }
2332 #ifndef COMPACT
2333  else if (biddyManagerType == BIDDYTYPEZBDD) {
2334  /* IMPLEMENTED */
2335  r = BiddyManagedProduct(MNG,f,g);
2336  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedProduct */
2337  } else if (biddyManagerType == BIDDYTYPEZBDDC) {
2338  /* IMPLEMENTED */
2339  r = BiddyManagedProduct(MNG,f,g);
2340  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedProduct */
2341  } else if (biddyManagerType == BIDDYTYPETZBDD) {
2342  /* IMPLEMENTED */
2343  r = BiddyManagedProduct(MNG,f,g);
2344  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedProduct */
2345  } else if (biddyManagerType == BIDDYTYPETZBDDC)
2346  {
2347  fprintf(stderr,"Biddy_Product: this BDD type is not supported, yet!\n");
2348  return biddyNull;
2349  } else if ((biddyManagerType == BIDDYTYPEOFDDC) || (biddyManagerType == BIDDYTYPEOFDD) ||
2350  (biddyManagerType == BIDDYTYPEZFDDC) || (biddyManagerType == BIDDYTYPEZFDD) ||
2351  (biddyManagerType == BIDDYTYPETZFDDC) || (biddyManagerType == BIDDYTYPETZFDD))
2352  {
2353  fprintf(stderr,"Biddy_Product: this BDD type is not supported, yet!\n");
2354  return biddyNull;
2355  } else {
2356  fprintf(stderr,"Biddy_Product: Unsupported BDD type!\n");
2357  return biddyNull;
2358  }
2359 #endif
2360 
2361  return r;
2362 }
2363 
2364 #ifdef __cplusplus
2365 }
2366 #endif
2367 
2368 /***************************************************************************/
2408 #ifdef __cplusplus
2409 extern "C" {
2410 #endif
2411 
2412 Biddy_Edge
2414  Biddy_Edge pncube)
2415 {
2416  Biddy_Edge r;
2417 
2418  assert( f != NULL );
2419  assert( g != NULL );
2420 
2421  if (!MNG) MNG = biddyAnonymousManager;
2422  ZF_LOGI("Biddy_SelectiveProduct");
2423 
2424  assert( BiddyIsOK(f) == TRUE );
2425  assert( BiddyIsOK(g) == TRUE );
2426  assert( BiddyIsOK(pncube) == TRUE );
2427 
2428  r = biddyNull;
2429 
2430  if (biddyManagerType == BIDDYTYPEOBDD) {
2431  /* IMPLEMENTED */
2432  r = BiddyManagedSelectiveProduct(MNG,f,g,pncube);
2433  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedSelectiveProduct */
2434  } else if (biddyManagerType == BIDDYTYPEOBDDC) {
2435  /* IMPLEMENTED */
2436  r = BiddyManagedSelectiveProduct(MNG,f,g,pncube);
2437  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedSelectiveProduct */
2438  }
2439 #ifndef COMPACT
2440  else if (biddyManagerType == BIDDYTYPEZBDD) {
2441  /* IMPLEMENTED */
2442  /* TO DO: CHECK THIS OPTIMIZATION
2443  if (pncube == biddyTerminal) {
2444  r = BiddyManagedProduct(MNG,f,g);
2445  }
2446  */
2447  r = BiddyManagedSelectiveProduct(MNG,f,g,pncube);
2448  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedSelectiveProduct */
2449  } else if (biddyManagerType == BIDDYTYPEZBDDC) {
2450  /* IMPLEMENTED */
2451  /* TO DO: CHECK THIS OPTIMIZATION
2452  if (pncube == biddyTerminal) {
2453  r = BiddyManagedProduct(MNG,f,g);
2454  }
2455  */
2456  r = BiddyManagedSelectiveProduct(MNG,f,g,pncube);
2457  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedSelectiveProduct */
2458  } else if (biddyManagerType == BIDDYTYPETZBDD) {
2459  /* IMPLEMENTED */
2460  r = BiddyManagedSelectiveProduct(MNG,f,g,pncube);
2461  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedSelectiveProduct */
2462  } else if (biddyManagerType == BIDDYTYPETZBDDC)
2463  {
2464  fprintf(stderr,"Biddy_SelectiveProduct: this BDD type is not supported, yet!\n");
2465  return biddyNull;
2466  } else if ((biddyManagerType == BIDDYTYPEOFDDC) || (biddyManagerType == BIDDYTYPEOFDD) ||
2467  (biddyManagerType == BIDDYTYPEZFDDC) || (biddyManagerType == BIDDYTYPEZFDD) ||
2468  (biddyManagerType == BIDDYTYPETZFDDC) || (biddyManagerType == BIDDYTYPETZFDD))
2469  {
2470  fprintf(stderr,"Biddy_SelectiveProduct: this BDD type is not supported, yet!\n");
2471  return biddyNull;
2472  } else {
2473  fprintf(stderr,"Biddy_SelectiveProduct: Unsupported BDD type!\n");
2474  return biddyNull;
2475  }
2476 #endif
2477 
2478  return r;
2479 }
2480 
2481 #ifdef __cplusplus
2482 }
2483 #endif
2484 
2485 /***************************************************************************/
2504 #ifdef __cplusplus
2505 extern "C" {
2506 #endif
2507 
2508 Biddy_Edge
2510 {
2511  Biddy_Edge r;
2512 
2513  assert( f != NULL );
2514  assert( g != NULL );
2515 
2516  if (!MNG) MNG = biddyAnonymousManager;
2517  ZF_LOGI("Biddy_Supset");
2518 
2519  assert( BiddyIsOK(f) == TRUE );
2520  assert( BiddyIsOK(g) == TRUE );
2521 
2522  r = biddyNull;
2523 
2524  if (biddyManagerType == BIDDYTYPEOBDD) {
2525  /* IMPLEMENTED */
2526  r = BiddyManagedSupset(MNG,f,g);
2527  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedSupset */
2528  } else if (biddyManagerType == BIDDYTYPEOBDDC) {
2529  /* IMPLEMENTED */
2530  r = BiddyManagedSupset(MNG,f,g);
2531  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedSupset */
2532  }
2533 #ifndef COMPACT
2534  else if (biddyManagerType == BIDDYTYPEZBDD) {
2535  /* IMPLEMENTED */
2536  r = BiddyManagedSupset(MNG,f,g);
2537  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedSupset */
2538  } else if (biddyManagerType == BIDDYTYPEZBDDC) {
2539  /* IMPLEMENTED */
2540  r = BiddyManagedSupset(MNG,f,g);
2541  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedSupset */
2542  } else if (biddyManagerType == BIDDYTYPETZBDD) {
2543  /* IMPLEMENTED */
2544  r = BiddyManagedSupset(MNG,f,g);
2545  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedSupset */
2546  } else if (biddyManagerType == BIDDYTYPETZBDDC)
2547  {
2548  fprintf(stderr,"Biddy_Supset: this BDD type is not supported, yet!\n");
2549  return biddyNull;
2550  } else if ((biddyManagerType == BIDDYTYPEOFDDC) || (biddyManagerType == BIDDYTYPEOFDD) ||
2551  (biddyManagerType == BIDDYTYPEZFDDC) || (biddyManagerType == BIDDYTYPEZFDD) ||
2552  (biddyManagerType == BIDDYTYPETZFDDC) || (biddyManagerType == BIDDYTYPETZFDD))
2553  {
2554  fprintf(stderr,"Biddy_Supset: this BDD type is not supported, yet!\n");
2555  return biddyNull;
2556  } else {
2557  fprintf(stderr,"Biddy_Supset: Unsupported BDD type!\n");
2558  return biddyNull;
2559  }
2560 #endif
2561 
2562  /* DEBUGGING */
2563  /*
2564  printf("SUPSET f: ");
2565  BiddyManagedPrintfMinterms(MNG,f,FALSE);
2566  printf("SUPSET g: ");
2567  BiddyManagedPrintfMinterms(MNG,g,FALSE);
2568  printf("SUPSET result: ");
2569  BiddyManagedPrintfMinterms(MNG,r,FALSE);
2570  */
2571 
2572  return r;
2573 }
2574 
2575 #ifdef __cplusplus
2576 }
2577 #endif
2578 
2579 /***************************************************************************/
2598 #ifdef __cplusplus
2599 extern "C" {
2600 #endif
2601 
2602 Biddy_Edge
2604 {
2605  Biddy_Edge r;
2606 
2607  assert( f != NULL );
2608  assert( g != NULL );
2609 
2610  if (!MNG) MNG = biddyAnonymousManager;
2611  ZF_LOGI("Biddy_Subset");
2612 
2613  assert( BiddyIsOK(f) == TRUE );
2614  assert( BiddyIsOK(g) == TRUE );
2615 
2616  r = biddyNull;
2617 
2618  if (biddyManagerType == BIDDYTYPEOBDD) {
2619  /* IMPLEMENTED */
2620  r = BiddyManagedSubset(MNG,f,g);
2621  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedSubset */
2622  } else if (biddyManagerType == BIDDYTYPEOBDDC) {
2623  /* IMPLEMENTED */
2624  r = BiddyManagedSubset(MNG,f,g);
2625  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedSubset */
2626  }
2627 #ifndef COMPACT
2628  else if (biddyManagerType == BIDDYTYPEZBDD) {
2629  /* IMPLEMENTED */
2630  r = BiddyManagedSubset(MNG,f,g);
2631  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedSubset */
2632  } else if (biddyManagerType == BIDDYTYPEZBDDC) {
2633  /* IMPLEMENTED */
2634  r = BiddyManagedSubset(MNG,f,g);
2635  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedSubset */
2636  } else if (biddyManagerType == BIDDYTYPETZBDD) {
2637  /* IMPLEMENTED */
2638  r = BiddyManagedSubset(MNG,f,g);
2639  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedSubset */
2640  } else if (biddyManagerType == BIDDYTYPETZBDDC)
2641  {
2642  fprintf(stderr,"Biddy_Subset: this BDD type is not supported, yet!\n");
2643  return biddyNull;
2644  } else if ((biddyManagerType == BIDDYTYPEOFDDC) || (biddyManagerType == BIDDYTYPEOFDD) ||
2645  (biddyManagerType == BIDDYTYPEZFDDC) || (biddyManagerType == BIDDYTYPEZFDD) ||
2646  (biddyManagerType == BIDDYTYPETZFDDC) || (biddyManagerType == BIDDYTYPETZFDD))
2647  {
2648  fprintf(stderr,"Biddy_Subset: this BDD type is not supported, yet!\n");
2649  return biddyNull;
2650  } else {
2651  fprintf(stderr,"Biddy_Subset: Unsupported BDD type!\n");
2652  return biddyNull;
2653  }
2654 #endif
2655 
2656  /* DEBUGGING */
2657  /*
2658  printf("SUBSET f: ");
2659  BiddyManagedPrintfMinterms(MNG,f,FALSE);
2660  printf("SUBSET g: ");
2661  BiddyManagedPrintfMinterms(MNG,g,FALSE);
2662  printf("SUBSET result: ");
2663  BiddyManagedPrintfMinterms(MNG,r,FALSE);
2664  */
2665 
2666  return r;
2667 }
2668 
2669 #ifdef __cplusplus
2670 }
2671 #endif
2672 
2673 /***************************************************************************/
2686 #ifdef __cplusplus
2687 extern "C" {
2688 #endif
2689 
2690 Biddy_Edge
2692 {
2693  Biddy_Edge r;
2694 
2695  assert( f != NULL );
2696 
2697  if (!MNG) MNG = biddyAnonymousManager;
2698  ZF_LOGI("Biddy_Permitsym");
2699 
2700  assert( BiddyIsOK(f) == TRUE );
2701 
2702  if (n == 0) return BiddyManagedIntersect(MNG,f,BiddyManagedGetBaseSet(MNG));
2703 
2704  r = biddyNull;
2705 
2706  if (biddyManagerType == BIDDYTYPEOBDD) {
2707  /* IMPLEMENTED */
2708  r = BiddyManagedPermitsym(MNG,f,BiddyManagedGetLowestVariable(MNG),n);
2709  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedPermitsym */
2710  } else if (biddyManagerType == BIDDYTYPEOBDDC) {
2711  /* IMPLEMENTED */
2712  r = BiddyManagedPermitsym(MNG,f,BiddyManagedGetLowestVariable(MNG),n);
2713  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedPermitsym */
2714  }
2715 #ifndef COMPACT
2716  else if (biddyManagerType == BIDDYTYPEZBDD) {
2717  /* IMPLEMENTED */
2718  r = BiddyManagedPermitsym(MNG,f,0,n);
2719  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedPermitsym */
2720  } else if (biddyManagerType == BIDDYTYPEZBDDC) {
2721  /* IMPLEMENTED */
2722  r = BiddyManagedPermitsym(MNG,f,0,n);
2723  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedPermitsym */
2724  } else if (biddyManagerType == BIDDYTYPETZBDD) {
2725  /* IMPLEMENTED */
2726  r = BiddyManagedPermitsym(MNG,f,BiddyManagedGetLowestVariable(MNG),n);
2727  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedPermitsym */
2728  } else if (biddyManagerType == BIDDYTYPETZBDDC)
2729  {
2730  fprintf(stderr,"Biddy_Permitsym: this BDD type is not supported, yet!\n");
2731  return biddyNull;
2732  } else if ((biddyManagerType == BIDDYTYPEOFDDC) || (biddyManagerType == BIDDYTYPEOFDD) ||
2733  (biddyManagerType == BIDDYTYPEZFDDC) || (biddyManagerType == BIDDYTYPEZFDD) ||
2734  (biddyManagerType == BIDDYTYPETZFDDC) || (biddyManagerType == BIDDYTYPETZFDD))
2735  {
2736  fprintf(stderr,"Biddy_Permitsym: this BDD type is not supported, yet!\n");
2737  return biddyNull;
2738  } else {
2739  fprintf(stderr,"Biddy_Permitsym: Unsupported BDD type!\n");
2740  return biddyNull;
2741  }
2742 #endif
2743 
2744  return r;
2745 }
2746 
2747 #ifdef __cplusplus
2748 }
2749 #endif
2750 
2751 /***************************************************************************/
2770 /* TO DO: use selection instead of cache */
2771 
2772 #ifdef __cplusplus
2773 extern "C" {
2774 #endif
2775 
2776 Biddy_Edge
2778 {
2779  Biddy_Edge support,r;
2780  Biddy_Variable v;
2781 
2782  assert( f != NULL );
2783 
2784  if (!MNG) MNG = biddyAnonymousManager;
2785  ZF_LOGI("Biddy_Subset");
2786 
2787  assert( BiddyIsOK(f) == TRUE );
2788 
2789  r = biddyNull;
2790  support = biddyNull;
2791 
2792  if ((biddyManagerType == BIDDYTYPEOBDD) || (biddyManagerType == BIDDYTYPEOBDDC) ||
2793  (biddyManagerType == BIDDYTYPETZBDD))
2794  {
2795  support = biddyOne;
2796  if (BiddyManagedGetLowestVariable(MNG) != 0) {
2797  v = BiddyManagedGetPrevVariable(MNG,0); /* highest (bottommost) variable */
2798  while (v != BiddyManagedGetLowestVariable(MNG)) {
2799  support = BiddyManagedTaggedFoaNode(MNG,v,biddyZero,support,v,TRUE);
2800  BiddyRefresh(support); /* FoaNode returns an obsolete node! */
2801  v = BiddyManagedGetPrevVariable(MNG,v);
2802  }
2803  support = BiddyManagedTaggedFoaNode(MNG,v,biddyZero,support,v,TRUE);
2804  BiddyRefresh(support); /* FoaNode returns an obsolete node! */
2805  }
2806  }
2807 
2808  if (biddyManagerType == BIDDYTYPEOBDD) {
2809  /* IMPLEMENTED */
2810  r = BiddyManagedStretch(MNG,support,f);
2811  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedStretch */
2812  } else if (biddyManagerType == BIDDYTYPEOBDDC) {
2813  /* IMPLEMENTED */
2814  r = BiddyManagedStretch(MNG,support,f);
2815  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedStretch*/
2816  }
2817 #ifndef COMPACT
2818  else if (biddyManagerType == BIDDYTYPEZBDD) {
2819  /* IMPLEMENTED */
2820  r = BiddyManagedStretch(MNG,support,f);
2821  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedStretch */
2822  } else if (biddyManagerType == BIDDYTYPEZBDDC) {
2823  /* IMPLEMENTED */
2824  r = BiddyManagedStretch(MNG,support,f);
2825  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedStretch */
2826  } else if (biddyManagerType == BIDDYTYPETZBDD) {
2827  /* IMPLEMENTED */
2828  r = BiddyManagedStretch(MNG,support,f);
2829  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedStretch */
2830  } else if (biddyManagerType == BIDDYTYPETZBDDC)
2831  {
2832  fprintf(stderr,"Biddy_Stretch: this BDD type is not supported, yet!\n");
2833  return biddyNull;
2834  } else if ((biddyManagerType == BIDDYTYPEOFDDC) || (biddyManagerType == BIDDYTYPEOFDD) ||
2835  (biddyManagerType == BIDDYTYPEZFDDC) || (biddyManagerType == BIDDYTYPEZFDD) ||
2836  (biddyManagerType == BIDDYTYPETZFDDC) || (biddyManagerType == BIDDYTYPETZFDD))
2837  {
2838  fprintf(stderr,"Biddy_Stretch this BDD type is not supported, yet!\n");
2839  return biddyNull;
2840  } else {
2841  fprintf(stderr,"Biddy_Stretch: Unsupported BDD type!\n");
2842  return biddyNull;
2843  }
2844 #endif
2845 
2846  return r;
2847 }
2848 
2849 #ifdef __cplusplus
2850 }
2851 #endif
2852 
2853 /***************************************************************************/
2866 #ifdef __cplusplus
2867 extern "C" {
2868 #endif
2869 
2870 Biddy_Edge
2872  long long unsigned int x)
2873 {
2874  Biddy_Edge r;
2875 
2876  assert( support != NULL );
2877 
2878  if (!MNG) MNG = biddyAnonymousManager;
2879  ZF_LOGI("Biddy_CreateMinterm");
2880 
2881  assert( BiddyIsOK(support) == TRUE );
2882 
2883  r = biddyNull;
2884 
2885  if (biddyManagerType == BIDDYTYPEOBDD) {
2886  /* IMPLEMENTED */
2887  r = BiddyManagedCreateMinterm(MNG,support,x);
2888  BiddyRefresh(r); /* not always refreshed by BiddyManagedCreateMinterm */
2889  } else if (biddyManagerType == BIDDYTYPEOBDDC) {
2890  /* IMPLEMENTED */
2891  r = BiddyManagedCreateMinterm(MNG,support,x);
2892  BiddyRefresh(r); /* not always refreshed by BiddyManagedCreateMinterm */
2893  }
2894 #ifndef COMPACT
2895  else if (biddyManagerType == BIDDYTYPEZBDD) {
2896  /* IMPLEMENTED */
2897  r = BiddyManagedCreateMinterm(MNG,support,x);
2898  BiddyRefresh(r); /* not always refreshed by BiddyManagedCreateMinterm */
2899  } else if (biddyManagerType == BIDDYTYPEZBDDC) {
2900  /* IMPLEMENTED */
2901  r = BiddyManagedCreateMinterm(MNG,support,x);
2902  BiddyRefresh(r); /* not always refreshed by BiddyManagedCreateMinterm */
2903  } else if (biddyManagerType == BIDDYTYPETZBDD) {
2904  /* IMPLEMENTED */
2905  r = BiddyManagedCreateMinterm(MNG,support,x);
2906  BiddyRefresh(r); /* not always refreshed by BiddyManagedCreateMinterm */
2907  } else if (biddyManagerType == BIDDYTYPETZBDDC)
2908  {
2909  fprintf(stderr,"Biddy_CreateMinterm: this BDD type is not supported, yet!\n");
2910  return biddyNull;
2911  } else if ((biddyManagerType == BIDDYTYPEOFDDC) || (biddyManagerType == BIDDYTYPEOFDD) ||
2912  (biddyManagerType == BIDDYTYPEZFDDC) || (biddyManagerType == BIDDYTYPEZFDD) ||
2913  (biddyManagerType == BIDDYTYPETZFDDC) || (biddyManagerType == BIDDYTYPETZFDD))
2914  {
2915  fprintf(stderr,"Biddy_CreateMinterm: this BDD type is not supported, yet!\n");
2916  return biddyNull;
2917  } else {
2918  fprintf(stderr,"Biddy_CreateMinterm: Unsupported BDD type!\n");
2919  return biddyNull;
2920  }
2921 #endif
2922 
2923  return r;
2924 }
2925 
2926 #ifdef __cplusplus
2927 }
2928 #endif
2929 
2930 /***************************************************************************/
2943 #ifdef __cplusplus
2944 extern "C" {
2945 #endif
2946 
2947 Biddy_Edge
2948 Biddy_Managed_CreateFunction(Biddy_Manager MNG, Biddy_Edge support, long long unsigned int x)
2949 {
2950  Biddy_Edge r;
2951 
2952  assert( support != NULL );
2953 
2954  if (!MNG) MNG = biddyAnonymousManager;
2955  ZF_LOGI("Biddy_CreateFunction");
2956 
2957  assert( BiddyIsOK(support) == TRUE );
2958 
2959  r = biddyNull;
2960 
2961  if (biddyManagerType == BIDDYTYPEOBDD) {
2962  /* IMPLEMENTED */
2963  r = BiddyManagedCreateFunction(MNG,support,x);
2964  BiddyRefresh(r); /* not always refreshed by BiddyManagedCreateFunction */
2965  } else if (biddyManagerType == BIDDYTYPEOBDDC) {
2966  /* IMPLEMENTED */
2967  r = BiddyManagedCreateFunction(MNG,support,x);
2968  BiddyRefresh(r); /* not always refreshed by BiddyManagedCreateFunction */
2969  }
2970 #ifndef COMPACT
2971  else if (biddyManagerType == BIDDYTYPEZBDD) {
2972  /* IMPLEMENTED */
2973  r = BiddyManagedCreateFunction(MNG,support,x);
2974  BiddyRefresh(r); /* not always refreshed by BiddyManagedCreateFunction */
2975  } else if (biddyManagerType == BIDDYTYPEZBDDC) {
2976  /* IMPLEMENTED */
2977  r = BiddyManagedCreateFunction(MNG,support,x);
2978  BiddyRefresh(r); /* not always refreshed by BiddyManagedCreateFunction */
2979  } else if (biddyManagerType == BIDDYTYPETZBDD) {
2980  /* IMPLEMENTED */
2981  r = BiddyManagedCreateFunction(MNG,support,x);
2982  BiddyRefresh(r); /* not always refreshed by BiddyManagedCreateFunction */
2983  } else if (biddyManagerType == BIDDYTYPETZBDDC)
2984  {
2985  fprintf(stderr,"Biddy_CreateFunction: this BDD type is not supported, yet!\n");
2986  return biddyNull;
2987  } else if ((biddyManagerType == BIDDYTYPEOFDDC) || (biddyManagerType == BIDDYTYPEOFDD) ||
2988  (biddyManagerType == BIDDYTYPEZFDDC) || (biddyManagerType == BIDDYTYPEZFDD) ||
2989  (biddyManagerType == BIDDYTYPETZFDDC) || (biddyManagerType == BIDDYTYPETZFDD))
2990  {
2991  fprintf(stderr,"Biddy_CreateFunction: this BDD type is not supported, yet!\n");
2992  return biddyNull;
2993  } else {
2994  fprintf(stderr,"Biddy_CreateFunction: Unsupported BDD type!\n");
2995  return biddyNull;
2996  }
2997 #endif
2998 
2999  return r;
3000 }
3001 
3002 #ifdef __cplusplus
3003 }
3004 #endif
3005 
3006 /***************************************************************************/
3024 #ifdef __cplusplus
3025 extern "C" {
3026 #endif
3027 
3028 Biddy_Edge
3030 {
3031  Biddy_Edge r;
3032 
3033  assert( support != NULL );
3034 
3035  if (!MNG) MNG = biddyAnonymousManager;
3036  ZF_LOGI("Biddy_RandomFunction");
3037 
3038  assert( BiddyIsOK(support) == TRUE );
3039 
3040  r = biddyNull;
3041 
3042  if (biddyManagerType == BIDDYTYPEOBDD) {
3043  /* IMPLEMENTED */
3044  r = BiddyManagedRandomFunction(MNG,support,ratio);
3045  BiddyRefresh(r); /* not always refreshed by BiddyManagedRandomFunction */
3046  } else if (biddyManagerType == BIDDYTYPEOBDDC) {
3047  /* IMPLEMENTED */
3048  r = BiddyManagedRandomFunction(MNG,support,ratio);
3049  BiddyRefresh(r); /* not always refreshed by BiddyManagedRandomFunction */
3050  }
3051 #ifndef COMPACT
3052  else if (biddyManagerType == BIDDYTYPEZBDD) {
3053  /* IMPLEMENTED */
3054  r = BiddyManagedRandomFunction(MNG,support,ratio);
3055  BiddyRefresh(r); /* not always refreshed by BiddyManagedRandomFunction */
3056  } else if (biddyManagerType == BIDDYTYPEZBDDC) {
3057  /* IMPLEMENTED */
3058  r = BiddyManagedRandomFunction(MNG,support,ratio);
3059  BiddyRefresh(r); /* not always refreshed by BiddyManagedRandomFunction */
3060  } else if (biddyManagerType == BIDDYTYPETZBDD) {
3061  /* IMPLEMENTED */
3062  r = BiddyManagedRandomFunction(MNG,support,ratio);
3063  BiddyRefresh(r); /* not always refreshed by BiddyManagedRandomFunction */
3064  } else if (biddyManagerType == BIDDYTYPETZBDDC)
3065  {
3066  fprintf(stderr,"Biddy_RandomFunction: this BDD type is not supported, yet!\n");
3067  return biddyNull;
3068  } else if ((biddyManagerType == BIDDYTYPEOFDDC) || (biddyManagerType == BIDDYTYPEOFDD) ||
3069  (biddyManagerType == BIDDYTYPEZFDDC) || (biddyManagerType == BIDDYTYPEZFDD) ||
3070  (biddyManagerType == BIDDYTYPETZFDDC) || (biddyManagerType == BIDDYTYPETZFDD))
3071  {
3072  fprintf(stderr,"Biddy_RandomFunction: this BDD type is not supported, yet!\n");
3073  return biddyNull;
3074  } else {
3075  fprintf(stderr,"Biddy_RandomFunction: Unsupported BDD type!\n");
3076  return biddyNull;
3077  }
3078 #endif
3079 
3080  return r;
3081 }
3082 
3083 #ifdef __cplusplus
3084 }
3085 #endif
3086 
3087 /***************************************************************************/
3106 #ifdef __cplusplus
3107 extern "C" {
3108 #endif
3109 
3110 Biddy_Edge
3112 {
3113  Biddy_Edge r;
3114 
3115  assert( unit != NULL );
3116 
3117  if (!MNG) MNG = biddyAnonymousManager;
3118  ZF_LOGI("Biddy_RandomSet");
3119 
3120  assert( BiddyIsOK(unit) == TRUE );
3121 
3122  r = biddyNull;
3123 
3124  if (biddyManagerType == BIDDYTYPEOBDD) {
3125  /* IMPLEMENTED */
3126  r = BiddyManagedRandomSet(MNG,unit,ratio);
3127  BiddyRefresh(r); /* not always refreshed by BiddyManagedRandomSet */
3128  } else if (biddyManagerType == BIDDYTYPEOBDDC) {
3129  /* IMPLEMENTED */
3130  r = BiddyManagedRandomSet(MNG,unit,ratio);
3131  BiddyRefresh(r); /* not always refreshed by BiddyManagedRandomSet */
3132  }
3133 #ifndef COMPACT
3134  else if (biddyManagerType == BIDDYTYPEZBDD) {
3135  /* IMPLEMENTED */
3136  r = BiddyManagedRandomSet(MNG,unit,ratio);
3137  BiddyRefresh(r); /* not always refreshed by BiddyManagedRandomSet */
3138  } else if (biddyManagerType == BIDDYTYPEZBDDC) {
3139  /* IMPLEMENTED */
3140  r = BiddyManagedRandomSet(MNG,unit,ratio);
3141  BiddyRefresh(r); /* not always refreshed by BiddyManagedRandomSet */
3142  } else if (biddyManagerType == BIDDYTYPETZBDD) {
3143  /* IMPLEMENTED */
3144  r = BiddyManagedRandomSet(MNG,unit,ratio);
3145  BiddyRefresh(r); /* not always refreshed by BiddyManagedRandomSet */
3146  } else if (biddyManagerType == BIDDYTYPETZBDDC)
3147  {
3148  fprintf(stderr,"Biddy_RandomSet: this BDD type is not supported, yet!\n");
3149  return biddyNull;
3150  } else if ((biddyManagerType == BIDDYTYPEOFDDC) || (biddyManagerType == BIDDYTYPEOFDD) ||
3151  (biddyManagerType == BIDDYTYPEZFDDC) || (biddyManagerType == BIDDYTYPEZFDD) ||
3152  (biddyManagerType == BIDDYTYPETZFDDC) || (biddyManagerType == BIDDYTYPETZFDD))
3153  {
3154  fprintf(stderr,"Biddy_RandomSet: this BDD type is not supported, yet!\n");
3155  return biddyNull;
3156  } else {
3157  fprintf(stderr,"Biddy_RandomSet: Unsupported BDD type!\n");
3158  return biddyNull;
3159  }
3160 #endif
3161 
3162  return r;
3163 }
3164 
3165 #ifdef __cplusplus
3166 }
3167 #endif
3168 
3169 /***************************************************************************/
3181 #ifdef __cplusplus
3182 extern "C" {
3183 #endif
3184 
3185 Biddy_Edge
3187 {
3188  Biddy_Edge support,r;
3189  Biddy_Variable v;
3190 
3191  assert( f != NULL );
3192 
3193  if (!MNG) MNG = biddyAnonymousManager;
3194  ZF_LOGI("Biddy_ExtractMinterm");
3195 
3196  assert( BiddyIsOK(f) == TRUE );
3197 
3198  r = biddyNull;
3199  support = biddyNull;
3200 
3201  /* create support - not needed for ZBDD and ZBDDC */
3202  if ((biddyManagerType == BIDDYTYPEOBDD) || (biddyManagerType == BIDDYTYPEOBDDC) ||
3203  (biddyManagerType == BIDDYTYPETZBDD))
3204  {
3205  support = biddyOne;
3206  if (BiddyManagedGetLowestVariable(MNG) != 0) {
3207  v = BiddyManagedGetPrevVariable(MNG,0); /* highest (bottommost) variable */
3208  while (v != BiddyManagedGetLowestVariable(MNG)) {
3209  support = BiddyManagedTaggedFoaNode(MNG,v,biddyZero,support,v,TRUE);
3210  BiddyRefresh(support); /* FoaNode returns an obsolete node! */
3211  v = BiddyManagedGetPrevVariable(MNG,v);
3212  }
3213  support = BiddyManagedTaggedFoaNode(MNG,v,biddyZero,support,v,TRUE);
3214  BiddyRefresh(support); /* FoaNode returns an obsolete node! */
3215  }
3216  }
3217 
3218  if ((biddyManagerType == BIDDYTYPEOBDDC) || (biddyManagerType == BIDDYTYPEOBDD)) {
3219  /* IMPLEMENTED */
3220  r = BiddyManagedExtractMinterm(MNG,support,f);
3221  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedExtractMinterm */
3222  }
3223 #ifndef COMPACT
3224  else if ((biddyManagerType == BIDDYTYPEZBDDC) || (biddyManagerType == BIDDYTYPEZBDD)) {
3225  /* IMPLEMENTED */
3226  r = BiddyManagedExtractMinterm(MNG,NULL,f);
3227  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedExtractMinterm */
3228  } else if (biddyManagerType == BIDDYTYPETZBDD) {
3229  /* IMPLEMENTED */
3230  r = BiddyManagedExtractMinterm(MNG,support,f);
3231  /* BiddyRefresh(r); */ /* TESTING */ /* not always refreshed by BiddyManagedExtractMinterm */
3232  } else if (biddyManagerType == BIDDYTYPETZBDDC)
3233  {
3234  fprintf(stderr,"Biddy_ExtractMinterm: this BDD type is not supported, yet!\n");
3235  return biddyNull;
3236  } else if ((biddyManagerType == BIDDYTYPEOFDDC) || (biddyManagerType == BIDDYTYPEOFDD) ||
3237  (biddyManagerType == BIDDYTYPEZFDDC) || (biddyManagerType == BIDDYTYPEZFDD) ||
3238  (biddyManagerType == BIDDYTYPETZFDDC) || (biddyManagerType == BIDDYTYPETZFDD))
3239  {
3240  fprintf(stderr,"Biddy_ExtractMinterm: this BDD type is not supported, yet!\n");
3241  return biddyNull;
3242  } else {
3243  fprintf(stderr,"Biddy_ExtractMinterm: Unsupported BDD type!\n");
3244  return biddyNull;
3245  }
3246 #endif
3247 
3248  return r;
3249 }
3250 
3251 #ifdef __cplusplus
3252 }
3253 #endif
3254 
3255 /*----------------------------------------------------------------------------*/
3256 /* Definition of internal functions used to implement external functions */
3257 /*----------------------------------------------------------------------------*/
3258 
3259 /***************************************************************************/
3268 Biddy_Edge
3269 BiddyManagedNot(const Biddy_Manager MNG, const Biddy_Edge f)
3270 {
3271  Biddy_Edge r, T, E, Fv, Fneg_v;
3272  Biddy_Edge FF, GG, HH;
3273  Biddy_Variable v;
3274  unsigned int cindex;
3275 
3276 #ifndef COMPACT
3277  Biddy_Edge Gv, Gneg_v;
3278  Biddy_Variable nt;
3279 #endif
3280 
3281  assert( MNG != NULL );
3282  assert( f != NULL );
3283 
3284  /* IMPLEMENTED FOR OBDD, OBDDC, ZBDD, ZBDDC, AND TZBDD */
3285  assert(
3286  (biddyManagerType == BIDDYTYPEOBDD) ||
3287  (biddyManagerType == BIDDYTYPEOBDDC) ||
3288  (biddyManagerType == BIDDYTYPEZBDD) ||
3289  (biddyManagerType == BIDDYTYPEZBDDC) ||
3290  (biddyManagerType == BIDDYTYPETZBDD)
3291  );
3292 
3293  r = biddyNull;
3294 
3295  /* LOOKING FOR SIMPLE CASE */
3296 
3297  if (f == biddyZero) {
3298  return biddyOne;
3299  }
3300  if (f == biddyOne) {
3301  return biddyZero;
3302  }
3303 
3304  /* THIS IS NOT A SIMPLE CASE */
3305 
3306  FF = GG = HH = biddyNull;
3307  Fneg_v = Fv = biddyNull;
3308 
3309 #ifndef COMPACT
3310  Gneg_v = Gv = biddyNull;
3311 #endif
3312 
3313  v = 0;
3314 
3315  if (biddyManagerType == BIDDYTYPEOBDDC) {
3316 
3317  /* FOR OBDDC, CACHE TABLE IS NOT NEEDED */
3318 
3319  BiddyRefresh(f); /* return non-obsolete node even if the parameter is an obsolete node */
3320  r = BiddyInv(f);
3321 
3322  }
3323 
3324  else if (biddyManagerType == BIDDYTYPEOBDD) {
3325 
3326  /* FOR OBDD, 'NOT' USES CACHE TABLE DIRECTLY */
3327  /* THIS IS NOT ITE CACHE! */
3328 
3329  FF = f;
3330  GG = biddyZero;
3331  HH = biddyOne;
3332 
3333  /* IF RESULT IS NOT IN THE CACHE TABLE... */
3334  cindex = 0;
3335  if (!findOp3Cache(biddyOPCache,FF,GG,HH,&r,&cindex))
3336  {
3337 
3338  /* DETERMINING PARAMETERS FOR RECURSIVE CALLS */
3339  v = BiddyV(f);
3340  Fneg_v = BiddyE(f);
3341  Fv = BiddyT(f);
3342 
3343  /* RECURSIVE CALLS */
3344  if (Fneg_v == biddyZero) {
3345  E = biddyOne;
3346  } else if (Fneg_v == biddyOne) {
3347  E = biddyZero;
3348  } else {
3349  E = BiddyManagedNot(MNG,Fneg_v);
3350  }
3351  if (Fv == biddyZero) {
3352  T = biddyOne;
3353  } else if (Fv == biddyOne) {
3354  T = biddyZero;
3355  } else {
3356  T = BiddyManagedNot(MNG,Fv);
3357  }
3358 
3359  r = BiddyManagedTaggedFoaNode(MNG,v,E,T,v,TRUE);
3360  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
3361 
3362  addOp3Cache(biddyOPCache,FF,GG,HH,r,cindex);
3363 
3364  } else {
3365 
3366  /* IF THE RESULT IS FROM CACHE TABLE, REFRESH IT! */
3367  BiddyRefresh(r);
3368 
3369  }
3370 
3371  }
3372 
3373 #ifndef COMPACT
3374  else if ((biddyManagerType == BIDDYTYPEZBDDC) || (biddyManagerType == BIDDYTYPEZBDD)) {
3375 
3376  /* FOR ZBDD AND ZBDDC, RECURSIVE CALLS ARE VIA 'XOR' AND THUS ITS CACHE TABLE IS USED */
3377 
3378  v = BiddyV(biddyOne); /* biddyOne includes all variables */
3379 
3380  /* DETERMINING PARAMETERS FOR RECURSIVE CALLS */
3381  /* COMPLEMENTED EDGES MUST BE TRANSFERED */
3382  if (BiddyV(f) == v) {
3383  Fneg_v = BiddyInvCond(BiddyE(f),BiddyGetMark(f));
3384  Fv = BiddyT(f);
3385  } else {
3386  Fneg_v = f;
3387  Fv = biddyZero;
3388  }
3389  Gneg_v = BiddyE(biddyOne); /* biddyOne does not have complement */
3390  Gv = BiddyT(biddyOne);
3391 
3392  /* RECURSIVE CALLS */
3393  if (Fneg_v == biddyZero) {
3394  E = Gneg_v;
3395  } else if (Gneg_v == biddyZero) {
3396  E = Fneg_v;
3397  } else {
3398  E = BiddyManagedXor(MNG,Fneg_v,Gneg_v);
3399  }
3400  if (Fv == biddyZero) {
3401  T = Gv;
3402  } else if (Gv == biddyZero) {
3403  T = Fv;
3404  } else {
3405  T = BiddyManagedXor(MNG,Fv,Gv);
3406  }
3407 
3408  r = BiddyManagedTaggedFoaNode(MNG,v,E,T,v,TRUE);
3409  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
3410 
3411  }
3412 
3413  else if (biddyManagerType == BIDDYTYPETZBDD) {
3414 
3415  /* FOR TZBDD, 'NOT' USES CACHE TABLE DIRECTLY */
3416  /* THIS IS NOT ITE CACHE! */
3417 
3418  FF = f;
3419  GG = biddyZero;
3420  HH = biddyOne;
3421 
3422  /* IF RESULT IS NOT IN THE CACHE TABLE... */
3423  cindex = 0;
3424  if (!findOp3Cache(biddyOPCache,FF,GG,HH,&r,&cindex))
3425  {
3426 
3427  v = BiddyV(f);
3428  nt = BiddyGetTag(f);
3429  if (!v) {
3430  r = biddyZero;
3431  } else {
3432  Fneg_v = BiddyE(f);
3433  Fv = BiddyT(f);
3434 
3435  /* RECURSIVE CALLS */
3436  if (Fneg_v == biddyZero) {
3437  E = biddyOne;
3438  } else if (Fneg_v == biddyOne) {
3439  E = biddyZero;
3440  } else {
3441  E = BiddyManagedNot(MNG,Fneg_v);
3442  }
3443  if (Fv == biddyZero) {
3444  T = biddyOne;
3445  } else if (Fv == biddyOne) {
3446  T = biddyZero;
3447  } else {
3448  T = BiddyManagedNot(MNG,Fv);
3449  }
3450 
3451  r = BiddyManagedTaggedFoaNode(MNG,v,E,T,v,TRUE);
3452  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
3453  }
3454 
3455  while (v != nt) {
3456  v = biddyVariableTable.table[v].prev;
3457  r = BiddyManagedTaggedFoaNode(MNG,v,r,biddyOne,v,TRUE);
3458  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
3459  }
3460 
3461  addOp3Cache(biddyOPCache,FF,GG,HH,r,cindex);
3462 
3463  } else {
3464 
3465  /* IF THE RESULT IS FROM CACHE TABLE, REFRESH IT! */
3466  BiddyRefresh(r);
3467 
3468  }
3469 
3470  }
3471 #endif
3472 
3473  return r;
3474 }
3475 
3476 /***************************************************************************/
3485 Biddy_Edge
3486 BiddyManagedITE(const Biddy_Manager MNG, Biddy_Edge f, Biddy_Edge g, Biddy_Edge h)
3487 {
3488  Biddy_Edge r, T, E, Fv, Gv, Hv, Fneg_v, Gneg_v, Hneg_v;
3489  Biddy_Edge FF, GG, HH;
3490  Biddy_Boolean NN;
3491  Biddy_Variable v,rtag;
3492  unsigned cindex;
3493 
3494  static Biddy_Variable topF; /* CAN BE STATIC, WHAT IS BETTER? */
3495  static Biddy_Variable topG; /* CAN BE STATIC, WHAT IS BETTER? */
3496  static Biddy_Variable topH; /* CAN BE STATIC, WHAT IS BETTER? */
3497 
3498 #ifndef COMPACT
3499  static Biddy_Variable tagF; /* CAN BE STATIC, WHAT IS BETTER? */
3500  static Biddy_Variable tagG; /* CAN BE STATIC, WHAT IS BETTER? */
3501  static Biddy_Variable tagH; /* CAN BE STATIC, WHAT IS BETTER? */
3502 #endif
3503 
3504  /* DEBUGGING */
3505  /*
3506  static int mm = 0;
3507  int nn;
3508  nn = ++mm;
3509  printf("BiddyManagedITE (%d) F\n",nn);
3510  BiddyManagedPrintfBDD(MNG,f);
3511  printf("\n");
3512  printf("BiddyManagedITE (%d) G\n",nn);
3513  BiddyManagedPrintfBDD(MNG,g);
3514  printf("\n");
3515  printf("BiddyManagedITE (%d) H\n",nn);
3516  BiddyManagedPrintfBDD(MNG,h);
3517  printf("\n");
3518  mm = nn;
3519  */
3520 
3521  assert( MNG != NULL );
3522  assert( f != NULL );
3523  assert( g != NULL );
3524  assert( h != NULL );
3525 
3526  /* IMPLEMENTED FOR OBDD, OBDDC, ZBDD, ZBDDC, AND TZBDD */
3527  assert(
3528  (biddyManagerType == BIDDYTYPEOBDD) ||
3529  (biddyManagerType == BIDDYTYPEOBDDC) ||
3530  (biddyManagerType == BIDDYTYPEZBDD) ||
3531  (biddyManagerType == BIDDYTYPEZBDDC) ||
3532  (biddyManagerType == BIDDYTYPETZBDD)
3533  );
3534 
3535 #ifdef BIDDYEXTENDEDSTATS_YES
3536  biddyNodeTable.iterecursive++;
3537 #endif
3538 
3539  r = biddyNull;
3540 
3541  /* LOOKING FOR SIMPLE CASE */
3542  /* using Not/Leq and returning biddyOne in a recursive call is wrong for ZBDD and ZBDDC, */
3543  /* because top variable of the result may be lower (topmore) than top variables of the arguments */
3544  /* (i.e. because the result depends on domain) */
3545 
3546  if (f == biddyOne) {
3547  BiddyRefresh(g); /* return non-obsolete node even if the parameter is an obsolete node */
3548  return g;
3549  } else if (f == biddyZero) {
3550  BiddyRefresh(h); /* return non-obsolete node even if the parameter is an obsolete node */
3551  return h;
3552  } else if (g == biddyOne) {
3553  if (h == biddyOne) {
3554  /* FOR ZBDD AND ZBDDC THIS LINE IS NOT REACHABLE IN RECURSIVE CALLS */
3555  return biddyOne;
3556  } else if (h == biddyZero) {
3557  BiddyRefresh(f); /* return non-obsolete node even if the parameter is an obsolete node */
3558  return f;
3559  } else {
3560  return BiddyManagedOr(MNG,f,h);
3561  }
3562  } else if (g == biddyZero) {
3563  if (h == biddyOne) {
3564  /* FOR ZBDD AND ZBDDC THIS LINE IS NOT REACHABLE IN RECURSIVE CALLS */
3565  return BiddyManagedNot(MNG,f);
3566  } else if (h == biddyZero) {
3567  return biddyZero;
3568  } else {
3569  return BiddyManagedGt(MNG,h,f);
3570  }
3571  } else if (h == biddyOne) {
3572  if ((biddyManagerType != BIDDYTYPEZBDDC) && (biddyManagerType != BIDDYTYPEZBDD)) {
3573  /* FOR ZBDD AND ZBDDC THIS LINE IS NOT REACHABLE IN RECURSIVE CALLS */
3574  /* FOR ZBDD AND ZBDDC ITE CANNOT BE RESOLVED BY LEQ, BECAUSE LEQ IS RESOLVED BY ITE */
3575  return BiddyManagedLeq(MNG,f,g);
3576  }
3577  } else if (h == biddyZero) {
3578  return BiddyManagedAnd(MNG,f,g);
3579  } else if (g == h) {
3580  BiddyRefresh(g); /* return non-obsolete node even if the parameter is an obsolete node */
3581  return g;
3582  } else if (f == g) {
3583  return BiddyManagedOr(MNG,f,h);
3584  } else if (f == h) {
3585  return BiddyManagedAnd(MNG,f,g);
3586  }
3587 
3588  if (biddyManagerType == BIDDYTYPEOBDDC) {
3589  if (BiddyIsEqvPointer(g,h)) {
3590  return BiddyManagedXor(MNG,f,h);
3591  } else if (BiddyIsEqvPointer(f,g)) {
3592  return BiddyManagedAnd(MNG,g,h);
3593  } else if (BiddyIsEqvPointer(f,h)) {
3594  return BiddyManagedOr(MNG,g,h);
3595  }
3596  }
3597 
3598  /* THIS IS NOT A SIMPLE CASE */
3599 
3600  FF = GG = HH = biddyNull;
3601  NN = FALSE;
3602  Fneg_v = Fv = biddyNull;
3603  Gneg_v = Gv = biddyNull;
3604  Hneg_v = Hv = biddyNull;
3605  rtag = 0;
3606  v = 0;
3607 
3608  /* NORMALIZATION OF COMPLEMENTED EDGES */
3609  /* APLICABLE ONLY TO OBDDC */
3610  /* FF, GG, HH, and NN ARE USED FOR CACHE LOOKUP, ONLY */
3611 
3612  if (biddyManagerType == BIDDYTYPEOBDDC) {
3613  if (BiddyGetMark(f)) {
3614  if (BiddyGetMark(h)) {
3615  NN = TRUE;
3616  FF = BiddyInv(f);
3617  GG = BiddyInv(h);
3618  HH = BiddyInv(g);
3619  } else {
3620  FF = BiddyInv(f);
3621  GG = h;
3622  HH = g;
3623  }
3624  } else if (BiddyGetMark(g)) {
3625  NN = TRUE;
3626  FF = f;
3627  GG = BiddyInv(g);
3628  HH = BiddyInv(h);
3629  } else {
3630  FF = f;
3631  GG = g;
3632  HH = h;
3633  }
3634  }
3635 
3636  else {
3637 
3638  /* IF NOT OBDDC THEN ITE CACHE IS NOT SHARED WITH OTHER OPERATIONS! */
3639 
3640  FF = f;
3641  GG = g;
3642  HH = h;
3643  }
3644 
3645  /* IF RESULT IS NOT IN THE CACHE TABLE... */
3646  cindex = 0;
3647  if (!findOp3Cache(biddyOPCache,FF,GG,HH,&r,&cindex))
3648  {
3649 
3650  if ((biddyManagerType == BIDDYTYPEOBDDC) || (biddyManagerType == BIDDYTYPEOBDD)) {
3651 
3652  /* LOOKING FOR THE SMALLEST TOP VARIABLE */
3653  topF = BiddyV(f);
3654  topG = BiddyV(g);
3655  topH = BiddyV(h);
3656 
3657  /* CONSTANT VARIABLE MUST HAVE MAX ORDER */
3658  if (BiddyIsSmaller(biddyOrderingTable,topF,topG)) {
3659  v = BiddyIsSmaller(biddyOrderingTable,topF,topH) ? topF : topH;
3660  } else {
3661  v = BiddyIsSmaller(biddyOrderingTable,topH,topG) ? topH : topG;
3662  }
3663 
3664  /* DETERMINING PARAMETERS FOR RECURSIVE CALLS */
3665  if (topF == v) {
3666  Fneg_v = BiddyInvCond(BiddyE(f),BiddyGetMark(f));
3667  Fv = BiddyInvCond(BiddyT(f),BiddyGetMark(f));
3668  } else {
3669  Fneg_v = Fv = f;
3670  }
3671  if (topG == v) {
3672  Gneg_v = BiddyInvCond(BiddyE(g),BiddyGetMark(g));
3673  Gv = BiddyInvCond(BiddyT(g),BiddyGetMark(g));
3674  } else {
3675  Gneg_v = Gv = g;
3676  }
3677  if (topH == v) {
3678  Hneg_v = BiddyInvCond(BiddyE(h),BiddyGetMark(h));
3679  Hv = BiddyInvCond(BiddyT(h),BiddyGetMark(h));
3680  } else {
3681  Hneg_v = Hv = h;
3682  }
3683 
3684  rtag = v;
3685 
3686  }
3687 
3688 #ifndef COMPACT
3689  else if ((biddyManagerType == BIDDYTYPEZBDDC) || (biddyManagerType == BIDDYTYPEZBDD)) {
3690 
3691  /* LOOKING FOR THE SMALLEST TOP VARIABLE */
3692  topF = BiddyV(f);
3693  topG = BiddyV(g);
3694  topH = BiddyV(h);
3695 
3696  /* CONSTANT VARIABLE MUST HAVE MAX ORDER */
3697  if (BiddyIsSmaller(biddyOrderingTable,topF,topG)) {
3698  v = BiddyIsSmaller(biddyOrderingTable,topF,topH) ? topF : topH;
3699  } else {
3700  v = BiddyIsSmaller(biddyOrderingTable,topH,topG) ? topH : topG;
3701  }
3702 
3703  /* DETERMINING PARAMETERS FOR RECURSIVE CALLS */
3704  if (topF == v) {
3705  Fneg_v = BiddyInvCond(BiddyE(f),BiddyGetMark(f));
3706  Fv = BiddyT(f);
3707  } else {
3708  Fv = biddyZero;
3709  Fneg_v = f;
3710  }
3711  if (topG == v) {
3712  Gneg_v = BiddyInvCond(BiddyE(g),BiddyGetMark(g));
3713  Gv = BiddyT(g);
3714  } else {
3715  Gv = biddyZero;
3716  Gneg_v = g;
3717  }
3718  if (topH == v) {
3719  Hneg_v = BiddyInvCond(BiddyE(h),BiddyGetMark(h));
3720  Hv = BiddyT(h);
3721  } else {
3722  Hv = biddyZero;
3723  Hneg_v = h;
3724  }
3725 
3726  rtag = v;
3727 
3728  }
3729 
3730  else if (biddyManagerType == BIDDYTYPETZBDD) {
3731 
3732  /* LOOKING FOR THE SMALLEST TAG AND THE SMALLEST TOP VARIABLE */
3733  /* CONSTANT VARIABLE MUST HAVE MAX ORDER */
3734  tagF = BiddyGetTag(f);
3735  tagG = BiddyGetTag(g);
3736  tagH = BiddyGetTag(h);
3737  topF = BiddyV(f);
3738  topG = BiddyV(g);
3739  topH = BiddyV(h);
3740 
3741  /* CONSTANT VARIABLE MUST HAVE MAX ORDER */
3742  if (BiddyIsSmaller(biddyOrderingTable,tagF,tagG)) {
3743  rtag = BiddyIsSmaller(biddyOrderingTable,tagF,tagH) ? tagF : tagH;
3744  } else {
3745  rtag = BiddyIsSmaller(biddyOrderingTable,tagH,tagG) ? tagH : tagG;
3746  }
3747  if (BiddyIsSmaller(biddyOrderingTable,topF,topG)) {
3748  v = BiddyIsSmaller(biddyOrderingTable,topF,topH) ? topF : topH;
3749  } else {
3750  v = BiddyIsSmaller(biddyOrderingTable,topH,topG) ? topH : topG;
3751  }
3752 
3753  if ((tagF != tagG) || (tagF != tagH)) v = rtag;
3754 
3755  if (tagF == rtag) {
3756  if (topF == v) {
3757  Fneg_v = BiddyE(f);
3758  Fv = BiddyT(f);
3759  } else {
3760  Fneg_v = f;
3761  BiddySetTag(Fneg_v,v);
3762  Fneg_v = BiddyManagedIncTag(MNG,Fneg_v);
3763  Fv = biddyZero;
3764  }
3765  } else {
3766  Fneg_v = Fv = f;
3767  }
3768  if (tagG == rtag) {
3769  if (topG == v) {
3770  Gneg_v = BiddyE(g);
3771  Gv = BiddyT(g);
3772  } else {
3773  Gneg_v = g;
3774  BiddySetTag(Gneg_v,v);
3775  Gneg_v = BiddyManagedIncTag(MNG,Gneg_v);
3776  Gv = biddyZero;
3777  }
3778  } else {
3779  Gneg_v = Gv = g;
3780  }
3781  if (tagH == rtag) {
3782  if (topH == v) {
3783  Hneg_v = BiddyE(h);
3784  Hv = BiddyT(h);
3785  } else {
3786  Hneg_v = h;
3787  BiddySetTag(Hneg_v,v);
3788  Hneg_v = BiddyManagedIncTag(MNG,Hneg_v);
3789  Hv = biddyZero;
3790  }
3791  } else {
3792  Hneg_v = Hv = h;
3793  }
3794 
3795  }
3796 #endif
3797 
3798  /* RECURSIVE CALLS */
3799  if (Fneg_v == biddyOne) {
3800  E = Gneg_v;
3801  } else if (Fneg_v == biddyZero) {
3802  E = Hneg_v;
3803  } else if (Gneg_v == Hneg_v) {
3804  E = Gneg_v;
3805  } else {
3806  E = BiddyManagedITE(MNG,Fneg_v,Gneg_v,Hneg_v);
3807  }
3808  if (Fv == biddyOne) {
3809  T = Gv;
3810  } else if (Fv == biddyZero) {
3811  T = Hv;
3812  } else if (Gv == Hv) {
3813  T = Gv;
3814  } else {
3815  T = BiddyManagedITE(MNG,Fv,Gv,Hv);
3816  }
3817 
3818  r = BiddyManagedTaggedFoaNode(MNG,v,E,T,rtag,TRUE);
3819  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
3820 
3821  /* CACHE EVERYTHING */
3822  if (NN) {
3823  addOp3Cache(biddyOPCache,FF,GG,HH,BiddyInv(r),cindex);
3824  } else {
3825  addOp3Cache(biddyOPCache,FF,GG,HH,r,cindex);
3826  }
3827 
3828  /* DEBUGGING */
3829  /*
3830  printf("ITE has not used cache\n");
3831  */
3832 
3833  } else {
3834 
3835  if (NN) {
3836  BiddyInvertMark(r);
3837  }
3838 
3839  /* IF THE RESULT IS FROM CACHE TABLE, REFRESH IT! */
3840  BiddyRefresh(r);
3841 
3842  }
3843 
3844  /* DEBUGGING */
3845  /*
3846  printf("BiddyManagedITE: (%d) result\n",nn);
3847  BiddyManagedPrintfBDD(MNG,r);
3848  */
3849 
3850  return r;
3851 }
3852 
3853 /***************************************************************************/
3862 Biddy_Edge
3863 BiddyManagedAnd(const Biddy_Manager MNG, const Biddy_Edge f, const Biddy_Edge g)
3864 {
3865  Biddy_Edge r, T, E, Fv, Gv, Fneg_v, Gneg_v;
3866  Biddy_Edge FF, GG, HH;
3867  Biddy_Boolean NN;
3868  Biddy_Variable v,rtag;
3869  unsigned int cindex;
3870 
3871  static Biddy_Variable topF; /* CAN BE STATIC, WHAT IS BETTER? */
3872  static Biddy_Variable topG; /* CAN BE STATIC, WHAT IS BETTER? */
3873 
3874 #ifndef COMPACT
3875  static Biddy_Variable tagF; /* CAN BE STATIC, WHAT IS BETTER? */
3876  static Biddy_Variable tagG; /* CAN BE STATIC, WHAT IS BETTER? */
3877 #endif
3878 
3879  assert( MNG != NULL );
3880  assert( f != NULL );
3881  assert( g != NULL );
3882 
3883  /* IMPLEMENTED FOR OBDD, OBDDC, ZBDD, ZBDDC, AND TZBDD */
3884  assert(
3885  (biddyManagerType == BIDDYTYPEOBDD) ||
3886  (biddyManagerType == BIDDYTYPEOBDDC) ||
3887  (biddyManagerType == BIDDYTYPEZBDD) ||
3888  (biddyManagerType == BIDDYTYPEZBDDC) ||
3889  (biddyManagerType == BIDDYTYPETZBDD)
3890  );
3891 
3892 #ifdef BIDDYEXTENDEDSTATS_YES
3893  biddyNodeTable.andorrecursive++;
3894 #endif
3895 
3896  /* LOOKING FOR SIMPLE CASE */
3897  if (f == biddyZero) {
3898  return biddyZero;
3899  } else if (g == biddyZero) {
3900  return biddyZero;
3901  } else if (f == biddyOne) {
3902  BiddyRefresh(g); /* return non-obsolete node even if the parameter is an obsolete node */
3903  return g;
3904  } else if (g == biddyOne) {
3905  BiddyRefresh(f); /* return non-obsolete node even if the parameter is an obsolete node */
3906  return f;
3907  } else if (f == g) {
3908  BiddyRefresh(f); /* return non-obsolete node even if the parameter is an obsolete node */
3909  return f;
3910  }
3911 
3912  if (biddyManagerType == BIDDYTYPEOBDDC) {
3913  if (BiddyIsEqvPointer(f,g)) {
3914  return biddyZero;
3915  }
3916  }
3917 
3918 #ifndef COMPACT
3919  else if (biddyManagerType == BIDDYTYPETZBDD) {
3920  if (BiddyR(f) == BiddyR(g)) {
3921  if (BiddyIsSmaller(biddyOrderingTable,BiddyGetTag(f),BiddyGetTag(g))) {
3922  BiddyRefresh(f); /* return non-obsolete node even if the parameter is an obsolete node */
3923  return f;
3924  } else {
3925  BiddyRefresh(g); /* return non-obsolete node even if the parameter is an obsolete node */
3926  return g;
3927  }
3928  }
3929  }
3930 #endif
3931 
3932  /* THIS IS NOT A SIMPLE CASE */
3933 
3934  FF = GG = HH = biddyNull;
3935  NN = FALSE;
3936  Fneg_v = Fv = biddyNull;
3937  Gneg_v = Gv = biddyNull;
3938  rtag = 0;
3939  v = 0;
3940 
3941  /* NORMALIZATION OF COMPLEMENTED EDGES */
3942  /* FF, GG, and HH ARE USED FOR CACHE LOOKUP, ONLY */
3943  /* FF AND GG SHOULD NOT BE COMPLEMENTED */
3944  /* ((uintptr_t) f) SHOULD BE GREATER THAN ((uintptr_t) g) */
3945 
3946  if (biddyManagerType == BIDDYTYPEOBDDC) {
3947 
3948  if (((uintptr_t) f) > ((uintptr_t) g)) {
3949  if (BiddyGetMark(f)) {
3950  NN = TRUE;
3951  FF = BiddyInv(f);
3952  GG = biddyOne; /* BiddyInv(h) */
3953  HH = BiddyInv(g);
3954  } else {
3955  if (BiddyGetMark(g)) {
3956  NN = TRUE;
3957  FF = f;
3958  GG = BiddyInv(g);
3959  HH = biddyOne; /* BiddyInv(h) */
3960  } else {
3961  FF = f;
3962  GG = g;
3963  HH = biddyZero; /* h */
3964  }
3965  }
3966  } else {
3967  if (BiddyGetMark(g)) {
3968  NN = TRUE;
3969  FF = BiddyInv(g);
3970  GG = biddyOne; /* BiddyInv(h) */
3971  HH = BiddyInv(f);
3972  } else {
3973  if (BiddyGetMark(f)) {
3974  NN = TRUE;
3975  FF = g;
3976  GG = BiddyInv(f);
3977  HH = biddyOne; /* BiddyInv(h) */
3978  } else {
3979  FF = g;
3980  GG = f;
3981  HH = biddyZero; /* h */
3982  }
3983  }
3984  }
3985 
3986  }
3987 
3988  else {
3989 
3990  /* THIS IS NOT ITE CACHE! */
3991 
3992  if (((uintptr_t) f) > ((uintptr_t) g)) {
3993  FF = f;
3994  GG = g;
3995  HH = biddyZero;
3996  } else {
3997  FF = g;
3998  GG = f;
3999  HH = biddyZero;
4000  }
4001 
4002  }
4003 
4004  /* IF RESULT IS NOT IN THE CACHE TABLE... */
4005  /* FOR ZBDDs, NOT EVERYTHING IS CACHED */
4006  cindex = 0;
4007  if ((((biddyManagerType == BIDDYTYPEZBDDC) || (biddyManagerType == BIDDYTYPEZBDD)) &&
4008  ((topF = BiddyV(f)) != (topG = BiddyV(g)))
4009  ) || !findOp3Cache(biddyOPCache,FF,GG,HH,&r,&cindex))
4010  {
4011 
4012  if ((biddyManagerType == BIDDYTYPEOBDDC) || (biddyManagerType == BIDDYTYPEOBDD)) {
4013 
4014  /* LOOKING FOR THE SMALLEST TOP VARIABLE */
4015  /* CONSTANT VARIABLE MUST HAVE MAX ORDER */
4016  topF = BiddyV(f);
4017  topG = BiddyV(g);
4018  v = BiddyIsSmaller(biddyOrderingTable,topF,topG) ? topF : topG;
4019 
4020  /* DETERMINING PARAMETERS FOR RECURSIVE CALLS */
4021  /* COMPLEMENTED EDGES MUST BE TRANSFERED */
4022 
4023  if (topF == v) {
4024  Fneg_v = BiddyInvCond(BiddyE(f),BiddyGetMark(f));
4025  Fv = BiddyInvCond(BiddyT(f),BiddyGetMark(f));
4026  } else {
4027  Fneg_v = Fv = f;
4028  }
4029 
4030  if (topG == v) {
4031  Gneg_v = BiddyInvCond(BiddyE(g),BiddyGetMark(g));
4032  Gv = BiddyInvCond(BiddyT(g),BiddyGetMark(g));
4033  } else {
4034  Gneg_v = Gv = g;
4035  }
4036 
4037  rtag = v;
4038 
4039  }
4040 
4041 #ifndef COMPACT
4042  else if ((biddyManagerType == BIDDYTYPEZBDDC) || (biddyManagerType == BIDDYTYPEZBDD)) {
4043 
4044  /* LOOKING FOR THE SMALLEST TOP VARIABLE */
4045  /* CONSTANT VARIABLE MUST HAVE MAX ORDER */
4046  /* FOR ZBDD, topF AND topG HAVE BEEN ALREADY CALCULATED */
4047  /* topF = BiddyV(f); */ /* ALREADY CALCULATED */
4048  /* topG = BiddyV(g); */ /* ALREADY CALCULATED */
4049  v = BiddyIsSmaller(biddyOrderingTable,topF,topG) ? topF : topG;
4050 
4051  /* THIS CALL IS NOT INTRODUCING NEW NODES */
4052  /* COMPLEMENTED EDGES MUST BE TRANSFERED */
4053  /* IT SEEMS THAT CACHING THIS RESULTS IS NOT A GOOD IDEA */
4054  if (topF != topG) {
4055  if (topF == v) {
4056  r = BiddyManagedAnd(MNG,BiddyInvCond(BiddyE(f),BiddyGetMark(f)),g);
4057  return r;
4058  } else {
4059  r = BiddyManagedAnd(MNG,f,BiddyInvCond(BiddyE(g),BiddyGetMark(g)));
4060  return r;
4061  }
4062  }
4063 
4064  /* DETERMINING PARAMETERS FOR RECURSIVE CALLS, topF == topG */
4065  /* COMPLEMENTED EDGES MUST BE TRANSFERED */
4066  Fneg_v = BiddyInvCond(BiddyE(f),BiddyGetMark(f));
4067  Fv = BiddyT(f);
4068  Gneg_v = BiddyInvCond(BiddyE(g),BiddyGetMark(g));
4069  Gv = BiddyT(g);
4070 
4071  rtag = v;
4072 
4073  }
4074 
4075  else if (biddyManagerType == BIDDYTYPETZBDD) {
4076 
4077  /* LOOKING FOR THE SMALLEST TAG AND SMALLEST TOP VARIABLE */
4078  /* CONSTANT VARIABLE MUST HAVE MAX ORDER */
4079  tagF = BiddyGetTag(f);
4080  tagG = BiddyGetTag(g);
4081  topF = BiddyV(f);
4082  topG = BiddyV(g);
4083  rtag = BiddyIsSmaller(biddyOrderingTable,tagF,tagG) ? tagF : tagG;
4084  v = BiddyIsSmaller(biddyOrderingTable,topF,topG) ? topF : topG;
4085 
4086  /* VARIANT 1 */
4087  /*
4088  if (BiddyIsSmaller(biddyOrderingTable,topF,tagG)) {
4089  Fneg_v = BiddyE(f);
4090  Fv = BiddyT(f);
4091  Gneg_v = Gv = g;
4092  } else if (BiddyIsSmaller(biddyOrderingTable,topG,tagF)) {
4093  Fneg_v = Fv = f;
4094  Gneg_v = BiddyE(g);
4095  Gv = BiddyT(g);
4096  } else {
4097  if (topF == v) {
4098  Fneg_v = BiddyE(f);
4099  Fv = BiddyT(f);
4100  } else {
4101  Fneg_v = f;
4102  BiddySetTag(Fneg_v,v);
4103  Fneg_v = BiddyManagedIncTag(MNG,Fneg_v);
4104  Fv = biddyZero;
4105  }
4106  if (topG == v) {
4107  Gneg_v = BiddyE(g);
4108  Gv = BiddyT(g);
4109  } else {
4110  Gneg_v = g;
4111  BiddySetTag(Gneg_v,v);
4112  Gneg_v = BiddyManagedIncTag(MNG,Gneg_v);
4113  Gv = biddyZero;
4114  }
4115  }
4116  */
4117 
4118  /* VARIANT 2 */
4119  /*
4120  if (topF == v) {
4121  Fneg_v = BiddyE(f);
4122  Fv = BiddyT(f);
4123  } else {
4124  if (BiddyIsSmaller(biddyOrderingTable,v,tagF)) {
4125  Fneg_v = Fv = f;
4126  } else {
4127  Fneg_v = f;
4128  BiddySetTag(Fneg_v,v);
4129  Fneg_v = BiddyManagedIncTag(MNG,Fneg_v);
4130  Fv = biddyZero;
4131  }
4132  }
4133  if (topG == v) {
4134  Gneg_v = BiddyE(g);
4135  Gv = BiddyT(g);
4136  } else {
4137  if (BiddyIsSmaller(biddyOrderingTable,v,tagG)) {
4138  Gneg_v = Gv = g;
4139  } else {
4140  Gneg_v = g;
4141  BiddySetTag(Gneg_v,v);
4142  Gneg_v = BiddyManagedIncTag(MNG,Gneg_v);
4143  Gv = biddyZero;
4144  }
4145  }
4146  */
4147 
4148  /* VARIANT 3 */
4149 
4150  if (BiddyIsSmaller(biddyOrderingTable,v,tagF)) {
4151  Fneg_v = Fv = f;
4152  } else if (v == topF) {
4153  Fneg_v = BiddyE(f);
4154  Fv = BiddyT(f);
4155  } else {
4156  Fneg_v = f;
4157  BiddySetTag(Fneg_v,v);
4158  Fneg_v = BiddyManagedIncTag(MNG,Fneg_v);
4159  Fv = biddyZero;
4160  }
4161  if (BiddyIsSmaller(biddyOrderingTable,v,tagG)) {
4162  Gneg_v = Gv = g;
4163  } else if (v == topG) {
4164  Gneg_v = BiddyE(g);
4165  Gv = BiddyT(g);
4166  } else {
4167  Gneg_v = g;
4168  BiddySetTag(Gneg_v,v);
4169  Gneg_v = BiddyManagedIncTag(MNG,Gneg_v);
4170  Gv = biddyZero;
4171  }
4172 
4173 
4174  }
4175 #endif
4176 
4177  /* RECURSIVE CALLS */
4178  if (Fneg_v == biddyZero) {
4179  E = biddyZero;
4180  } else if (Gneg_v == biddyZero) {
4181  E = biddyZero;
4182  } else if (Fneg_v == biddyOne) {
4183  E = Gneg_v;
4184  } else if (Gneg_v == biddyOne) {
4185  E = Fneg_v;
4186  } else {
4187  E = BiddyManagedAnd(MNG,Fneg_v,Gneg_v);
4188  }
4189  if (Fv == biddyZero) {
4190  T = biddyZero;
4191  } else if (Gv == biddyZero) {
4192  T = biddyZero;
4193  } else if (Fv == biddyOne) {
4194  T = Gv;
4195  } else if (Gv == biddyOne) {
4196  T = Fv;
4197  } else {
4198  T = BiddyManagedAnd(MNG,Fv,Gv);
4199  }
4200 
4201  r = BiddyManagedTaggedFoaNode(MNG,v,E,T,rtag,TRUE);
4202  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
4203 
4204  if (NN) {
4205  addOp3Cache(biddyOPCache,FF,GG,HH,BiddyInv(r),cindex);
4206  } else {
4207  addOp3Cache(biddyOPCache,FF,GG,HH,r,cindex);
4208  }
4209 
4210  } else {
4211 
4212  if (NN) {
4213  BiddyInvertMark(r);
4214  }
4215 
4216  /* IF THE RESULT IS FROM CACHE TABLE, REFRESH IT! */
4217  BiddyRefresh(r);
4218 
4219  }
4220 
4221  return r;
4222 
4223 }
4224 
4225 /***************************************************************************/
4234 Biddy_Edge
4235 BiddyManagedOr(const Biddy_Manager MNG, const Biddy_Edge f, const Biddy_Edge g)
4236 {
4237  Biddy_Edge r, T, E, Fv, Gv, Fneg_v, Gneg_v;
4238  Biddy_Edge FF, GG, HH;
4239  Biddy_Boolean NN;
4240  Biddy_Variable v,rtag;
4241  unsigned int cindex;
4242 
4243  static Biddy_Variable topF; /* CAN BE STATIC, WHAT IS BETTER? */
4244  static Biddy_Variable topG; /* CAN BE STATIC, WHAT IS BETTER? */
4245 
4246 #ifndef COMPACT
4247  static Biddy_Variable tagF; /* CAN BE STATIC, WHAT IS BETTER? */
4248  static Biddy_Variable tagG; /* CAN BE STATIC, WHAT IS BETTER? */
4249 #endif
4250 
4251  assert( MNG != NULL );
4252  assert( f != NULL );
4253  assert( g != NULL );
4254 
4255  /* IMPLEMENTED FOR OBDD, OBDDC, ZBDD, ZBDDC, AND TZBDD */
4256  assert(
4257  (biddyManagerType == BIDDYTYPEOBDD) ||
4258  (biddyManagerType == BIDDYTYPEOBDDC) ||
4259  (biddyManagerType == BIDDYTYPEZBDD) ||
4260  (biddyManagerType == BIDDYTYPEZBDDC) ||
4261  (biddyManagerType == BIDDYTYPETZBDD)
4262  );
4263 
4264 #ifdef BIDDYEXTENDEDSTATS_YES
4265  biddyNodeTable.andorrecursive++;
4266 #endif
4267 
4268  r = biddyNull;
4269 
4270  /* LOOKING FOR SIMPLE CASE */
4271  /* returning biddyOne in a recursive call is wrong for ZBDD and ZBDDC, */
4272  /* because top variable of the result may be lower (topmore) than top variables of the arguments */
4273  /* (i.e. because the result depends on domain) */
4274 
4275  if (f == biddyZero) {
4276  BiddyRefresh(g); /* return non-obsolete node even if the parameter is an obsolete node */
4277  return g;
4278  } else if (g == biddyZero) {
4279  BiddyRefresh(f); /* return non-obsolete node even if the parameter is an obsolete node */
4280  return f;
4281  } else if (f == biddyOne) {
4282  /* FOR ZBDD AND ZBDDC THIS LINE IS NOT REACHABLE IN RECURSIVE CALLS */
4283  return biddyOne;
4284  } else if (g == biddyOne) {
4285  /* FOR ZBDD AND ZBDDC THIS LINE IS NOT REACHABLE IN RECURSIVE CALLS */
4286  return biddyOne;
4287  } else if (f == g) {
4288  BiddyRefresh(f); /* return non-obsolete node even if the parameter is an obsolete node */
4289  return f;
4290  }
4291 
4292  if (biddyManagerType == BIDDYTYPEOBDDC) {
4293  if (BiddyIsEqvPointer(f,g)) {
4294  return biddyOne;
4295  }
4296  }
4297 
4298 #ifndef COMPACT
4299  if (biddyManagerType == BIDDYTYPETZBDD) {
4300  if (BiddyR(f) == BiddyR(g)) {
4301  if (BiddyIsSmaller(biddyOrderingTable,BiddyGetTag(f),BiddyGetTag(g))) {
4302  BiddyRefresh(g); /* return non-obsolete node even if the parameter is an obsolete node */
4303  return g;
4304  } else {
4305  BiddyRefresh(f); /* return non-obsolete node even if the parameter is an obsolete node */
4306  return f;
4307  }
4308  }
4309  }
4310 #endif
4311 
4312  /* THIS IS NOT A SIMPLE CASE */
4313 
4314  FF = GG = HH = biddyNull;
4315  NN = FALSE;
4316  Fneg_v = Fv = biddyNull;
4317  Gneg_v = Gv = biddyNull;
4318  rtag = 0;
4319  v = 0;
4320 
4321  /* NORMALIZATION OF COMPLEMENTED EDGES */
4322  /* FF, GG, and HH ARE USED FOR CACHE LOOKUP, ONLY */
4323  /* FF AND GG SHOULD NOT BE COMPLEMENTED */
4324  /* ((uintptr_t) f) SHOULD BE GREATER THAN ((uintptr_t) g) */
4325 
4326  if (biddyManagerType == BIDDYTYPEOBDDC) {
4327 
4328  if (((uintptr_t) f) > ((uintptr_t) g)) {
4329  if (BiddyGetMark(f)) {
4330  if (BiddyGetMark(g)) {
4331  NN = TRUE;
4332  FF = BiddyInv(f);
4333  GG = BiddyInv(g);
4334  HH = biddyZero; /* BiddyInv(g) */
4335  } else {
4336  FF = BiddyInv(f);
4337  GG = g;
4338  HH = biddyOne; /* g */
4339  }
4340  } else {
4341  FF = f;
4342  GG = biddyOne;
4343  HH = g;
4344  }
4345  } else {
4346  if (BiddyGetMark(g)) {
4347  if (BiddyGetMark(f)) {
4348  NN = TRUE;
4349  FF = BiddyInv(g);
4350  GG = BiddyInv(f);
4351  HH = biddyZero; /* BiddyInv(g) */
4352  } else {
4353  FF = BiddyInv(g);
4354  GG = f;
4355  HH = biddyOne; /* g */
4356  }
4357  } else {
4358  FF = g;
4359  GG = biddyOne;
4360  HH = f;
4361  }
4362  }
4363  }
4364 
4365  else {
4366 
4367  /* THIS IS NOT ITE CACHE! */
4368 
4369  if (((uintptr_t) f) > ((uintptr_t) g)) {
4370  FF = biddyZero;
4371  GG = f;
4372  HH = g;
4373  } else {
4374  FF = biddyZero;
4375  GG = g;
4376  HH = f;
4377  }
4378 
4379  }
4380 
4381  /* IF RESULT IS NOT IN THE CACHE TABLE... */
4382  cindex = 0;
4383  if (!findOp3Cache(biddyOPCache,FF,GG,HH,&r,&cindex))
4384  {
4385 
4386  if ((biddyManagerType == BIDDYTYPEOBDDC) || (biddyManagerType == BIDDYTYPEOBDD)) {
4387 
4388  /* LOOKING FOR THE SMALLEST TOP VARIABLE */
4389  /* CONSTANT VARIABLE MUST HAVE MAX ORDER */
4390  topF = BiddyV(f);
4391  topG = BiddyV(g);
4392  v = BiddyIsSmaller(biddyOrderingTable,topF,topG) ? topF : topG;
4393 
4394  /* DETERMINING PARAMETERS FOR RECURSIVE CALLS */
4395  /* COMPLEMENTED EDGES MUST BE TRANSFERED */
4396  if (topF == v) {
4397  Fneg_v = BiddyInvCond(BiddyE(f),BiddyGetMark(f));
4398  Fv = BiddyInvCond(BiddyT(f),BiddyGetMark(f));
4399  } else {
4400  Fneg_v = Fv = f;
4401  }
4402 
4403  if (topG == v) {
4404  Gneg_v = BiddyInvCond(BiddyE(g),BiddyGetMark(g));
4405  Gv = BiddyInvCond(BiddyT(g),BiddyGetMark(g));
4406  } else {
4407  Gneg_v = Gv = g;
4408  }
4409 
4410  rtag = v;
4411 
4412  }
4413 
4414 #ifndef COMPACT
4415  else if ((biddyManagerType == BIDDYTYPEZBDDC) || (biddyManagerType == BIDDYTYPEZBDD)) {
4416 
4417  /* LOOKING FOR THE SMALLEST TOP VARIABLE */
4418  /* CONSTANT VARIABLE MUST HAVE MAX ORDER */
4419  topF = BiddyV(f);
4420  topG = BiddyV(g);
4421  v = BiddyIsSmaller(biddyOrderingTable,topF,topG) ? topF : topG;
4422 
4423  /* DETERMINING PARAMETERS FOR RECURSIVE CALLS */
4424  /* COMPLEMENTED EDGES MUST BE TRANSFERED */
4425  if (topF == v) {
4426  Fneg_v = BiddyInvCond(BiddyE(f),BiddyGetMark(f));
4427  Fv = BiddyT(f);
4428  } else {
4429  Fneg_v = f;
4430  Fv = biddyZero;
4431  }
4432  if (topG == v) {
4433  Gneg_v = BiddyInvCond(BiddyE(g),BiddyGetMark(g));
4434  Gv = BiddyT(g);
4435  } else {
4436  Gneg_v = g;
4437  Gv = biddyZero;
4438  }
4439 
4440  rtag = v;
4441 
4442  }
4443 
4444  else if (biddyManagerType == BIDDYTYPETZBDD) {
4445 
4446  /* VARIANT 1 */
4447  /*
4448  tagF = BiddyGetTag(f);
4449  tagG = BiddyGetTag(g);
4450  if (tagF == tagG) {
4451  / * THE SAME TAG * /
4452  topF = BiddyV(f);
4453  topG = BiddyV(g);
4454  v = BiddyIsSmaller(biddyOrderingTable,topF,topG) ? topF : topG;
4455  rtag = tagF;
4456  w = v;
4457  if (topF == v) {
4458  Fneg_v = BiddyE(f);
4459  Fv = BiddyT(f);
4460  } else {
4461  Fneg_v = f;
4462  BiddySetTag(Fneg_v,v);
4463  Fneg_v = BiddyManagedIncTag(MNG,Fneg_v);
4464  Fv = biddyZero;
4465  }
4466  if (topG == v) {
4467  Gneg_v = BiddyE(g);
4468  Gv = BiddyT(g);
4469  } else {
4470  Gneg_v = g;
4471  BiddySetTag(Gneg_v,v);
4472  Gneg_v = BiddyManagedIncTag(MNG,Gneg_v);
4473  Gv = biddyZero;
4474  }
4475  } else {
4476  / * DIFFERENT TAG * /
4477  rtag = BiddyIsSmaller(biddyOrderingTable,tagF,tagG) ? tagF : tagG;
4478  w = rtag;
4479  if (tagF == rtag) {
4480  if (BiddyV(f) == rtag) {
4481  / * TAG AND TOP VARIABLE ARE EQUAL * /
4482  Fneg_v = BiddyE(f);
4483  Fv = BiddyT(f);
4484  } else {
4485  / * TAG AND TOP VARIABLE ARE NOT EQUAL * /
4486  Fneg_v = f;
4487  BiddySetTag(Fneg_v,rtag);
4488  Fneg_v = BiddyManagedIncTag(MNG,Fneg_v);
4489  Fv = biddyZero;
4490  }
4491  Gneg_v = Gv = g;
4492  } else {
4493  if (BiddyV(g) == rtag) {
4494  / * TAG AND TOP VARIABLE ARE EQUAL * /
4495  Gneg_v = BiddyE(g);
4496  Gv = BiddyT(g);
4497  } else {
4498  / * TAG AND TOP VARIABLE ARE NOT EQUAL * /
4499  Gneg_v = g;
4500  BiddySetTag(Gneg_v,rtag);
4501  Gneg_v = BiddyManagedIncTag(MNG,Gneg_v);
4502  Gv = biddyZero;
4503  }
4504  Fneg_v = Fv = f;
4505  }
4506  }
4507  */
4508 
4509  /* VARIANT 2 */
4510 
4511  tagF = BiddyGetTag(f);
4512  tagG = BiddyGetTag(g);
4513  topF = BiddyV(f);
4514  topG = BiddyV(g);
4515  rtag = BiddyIsSmaller(biddyOrderingTable,tagF,tagG) ? tagF : tagG;
4516  v = BiddyIsSmaller(biddyOrderingTable,topF,topG) ? topF : topG;
4517  if (tagF != tagG) v = rtag;
4518  if (tagF == rtag) {
4519  if (topF == v) {
4520  Fneg_v = BiddyE(f);
4521  Fv = BiddyT(f);
4522  } else {
4523  Fneg_v = f;
4524  BiddySetTag(Fneg_v,v);
4525  Fneg_v = BiddyManagedIncTag(MNG,Fneg_v);
4526  Fv = biddyZero;
4527  }
4528  } else {
4529  Fneg_v = Fv = f;
4530  }
4531  if (tagG == rtag) {
4532  if (topG == v) {
4533  Gneg_v = BiddyE(g);
4534  Gv = BiddyT(g);
4535  } else {
4536  Gneg_v = g;
4537  BiddySetTag(Gneg_v,v);
4538  Gneg_v = BiddyManagedIncTag(MNG,Gneg_v);
4539  Gv = biddyZero;
4540  }
4541  } else {
4542  Gneg_v = Gv = g;
4543  }
4544 
4545 
4546  }
4547 #endif
4548 
4549  /* RECURSIVE CALLS */
4550  /* returning biddyOne in a recursive call is wrong for ZBDD and ZBDDC, */
4551  /* because top variable of the result may be lower (topmore) than top variables of the arguments */
4552  /* (i.e. because the result depends on domain) */
4553  if (Fneg_v == biddyZero) {
4554  E = Gneg_v;
4555  } else if (Gneg_v == biddyZero) {
4556  E = Fneg_v;
4557  } else if (Fneg_v == biddyOne) {
4558  /* FOR ZBDD AND ZBDDC THIS LINE IS NOT REACHABLE IN RECURSIVE CALLS */
4559  E = biddyOne;
4560  } else if (Gneg_v == biddyOne) {
4561  /* FOR ZBDD AND ZBDDC THIS LINE IS NOT REACHABLE IN RECURSIVE CALLS */
4562  E = biddyOne;
4563  } else {
4564  E = BiddyManagedOr(MNG,Fneg_v,Gneg_v);
4565  }
4566  if (Fv == biddyZero) {
4567  T = Gv;
4568  } else if (Gv == biddyZero) {
4569  T = Fv;
4570  } else if (Fv == biddyOne) {
4571  /* FOR ZBDD AND ZBDDC THIS LINE IS NOT REACHABLE IN RECURSIVE CALLS */
4572  T = biddyOne;
4573  } else if (Gv == biddyOne) {
4574  /* FOR ZBDD AND ZBDDC THIS LINE IS NOT REACHABLE IN RECURSIVE CALLS */
4575  T = biddyOne;
4576  } else {
4577  T = BiddyManagedOr(MNG,Fv,Gv);
4578  }
4579 
4580  r = BiddyManagedTaggedFoaNode(MNG,v,E,T,rtag,TRUE);
4581  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
4582 
4583  if (NN) {
4584  addOp3Cache(biddyOPCache,FF,GG,HH,BiddyInv(r),cindex);
4585  } else {
4586  addOp3Cache(biddyOPCache,FF,GG,HH,r,cindex);
4587  }
4588 
4589  } else {
4590 
4591  if (NN) {
4592  BiddyInvertMark(r);
4593  }
4594 
4595  /* IF THE RESULT IS FROM CACHE TABLE, REFRESH IT! */
4596  BiddyRefresh(r);
4597 
4598  }
4599 
4600  return r;
4601 }
4602 
4603 /***************************************************************************/
4612 Biddy_Edge
4613 BiddyManagedNand(const Biddy_Manager MNG, const Biddy_Edge f,
4614  const Biddy_Edge g)
4615 {
4616  Biddy_Edge r;
4617 
4618  assert( MNG != NULL );
4619  assert( f != NULL );
4620  assert( g != NULL );
4621 
4622  /* IMPLEMENTED FOR OBDDC, ONLY */
4623  assert( biddyManagerType == BIDDYTYPEOBDDC );
4624 
4625  r = biddyNull;
4626 
4627  if (biddyManagerType == BIDDYTYPEOBDDC) {
4628  r = BiddyInv(BiddyManagedAnd(MNG,f,g));
4629  }
4630 
4631  return r;
4632 }
4633 
4634 /***************************************************************************/
4643 Biddy_Edge
4644 BiddyManagedNor(const Biddy_Manager MNG, const Biddy_Edge f,
4645  const Biddy_Edge g)
4646 {
4647  Biddy_Edge r;
4648 
4649  assert( MNG != NULL );
4650  assert( f != NULL );
4651  assert( g != NULL );
4652 
4653  /* IMPLEMENTED FOR OBDDC, ONLY */
4654  assert( biddyManagerType == BIDDYTYPEOBDDC );
4655 
4656  r = biddyNull;
4657 
4658  if (biddyManagerType == BIDDYTYPEOBDDC) {
4659  r = BiddyManagedAnd(MNG,BiddyInv(f),BiddyInv(g));
4660  }
4661 
4662  return r;
4663 }
4664 
4665 /***************************************************************************/
4674 Biddy_Edge
4675 BiddyManagedXor(const Biddy_Manager MNG, const Biddy_Edge f,
4676  const Biddy_Edge g)
4677 {
4678  Biddy_Edge r, T, E, Fv, Gv, Fneg_v, Gneg_v;
4679  Biddy_Edge FF, GG, HH;
4680  Biddy_Boolean NN;
4681  Biddy_Variable v,rtag;
4682  unsigned int cindex;
4683 
4684  static Biddy_Variable topF; /* CAN BE STATIC, WHAT IS BETTER? */
4685  static Biddy_Variable topG; /* CAN BE STATIC, WHAT IS BETTER? */
4686 
4687 #ifndef COMPACT
4688  static Biddy_Variable tagF; /* CAN BE STATIC, WHAT IS BETTER? */
4689  static Biddy_Variable tagG; /* CAN BE STATIC, WHAT IS BETTER? */
4690 #endif
4691 
4692  assert( MNG != NULL );
4693  assert( f != NULL );
4694  assert( g != NULL );
4695 
4696  /* IMPLEMENTED FOR OBDD, OBDDC, ZBDD, ZBDDC, AND TZBDD */
4697  assert(
4698  (biddyManagerType == BIDDYTYPEOBDD) ||
4699  (biddyManagerType == BIDDYTYPEOBDDC) ||
4700  (biddyManagerType == BIDDYTYPEZBDD) ||
4701  (biddyManagerType == BIDDYTYPEZBDDC) ||
4702  (biddyManagerType == BIDDYTYPETZBDD)
4703  );
4704 
4705 #ifdef BIDDYEXTENDEDSTATS_YES
4706  biddyNodeTable.xorrecursive++;
4707 #endif
4708 
4709  /* LOOKING FOR SIMPLE CASE */
4710  /* returning biddyOne in a recursive call is wrong for ZBDD and ZBDDC, */
4711  /* because top variable of the result may be lower (topmore) than top variables of the arguments */
4712  /* (i.e. because the result depends on domain) */
4713 
4714  if (f == biddyZero) {
4715  BiddyRefresh(g); /* return non-obsolete node even if the parameter is an obsolete node */
4716  return g;
4717  } else if (g == biddyZero) {
4718  BiddyRefresh(f); /* return non-obsolete node even if the parameter is an obsolete node */
4719  return f;
4720  } else if (f == biddyOne) {
4721  /* FOR ZBDD AND ZBDDC THIS LINE IS NOT REACHABLE IN RECURSIVE CALLS */
4722  return BiddyManagedNot(MNG,g);
4723  } else if (g == biddyOne) {
4724  /* FOR ZBDD AND ZBDDC THIS LINE IS NOT REACHABLE IN RECURSIVE CALLS */
4725  return BiddyManagedNot(MNG,f);
4726  } else if (f == g) {
4727  return biddyZero;
4728  }
4729 
4730  if (biddyManagerType == BIDDYTYPEOBDDC) {
4731  if (BiddyIsEqvPointer(f,g)) {
4732  return biddyOne;
4733  }
4734  }
4735 
4736  /* THIS IS NOT A SIMPLE CASE */
4737 
4738  FF = GG = HH = biddyNull;
4739  NN = FALSE;
4740  Fneg_v = Fv = biddyNull;
4741  Gneg_v = Gv = biddyNull;
4742  rtag = 0;
4743  v = 0;
4744 
4745  /* NORMALIZATION OF COMPLEMENTED EDGES */
4746  /* FF, GG, and HH ARE USED FOR CACHE LOOKUP, ONLY */
4747  /* FF AND GG SHOULD NOT BE COMPLEMENTED */
4748  /* ((uintptr_t) f) SHOULD BE GREATER THAN ((uintptr_t) g) */
4749 
4750  if (biddyManagerType == BIDDYTYPEOBDDC) {
4751 
4752  if (((uintptr_t) f) > ((uintptr_t) g)) {
4753  if (BiddyGetMark(f)) {
4754  if (BiddyGetMark(g)) {
4755  FF = BiddyInv(f);
4756  GG = BiddyInv(g); /* h */
4757  HH = g;
4758  } else {
4759  NN = TRUE;
4760  FF = BiddyInv(f);
4761  GG = g;
4762  HH = BiddyInv(g); /* h */
4763  }
4764  } else {
4765  if (BiddyGetMark(g)) {
4766  NN = TRUE;
4767  FF = f;
4768  GG = BiddyInv(g); /* h */
4769  HH = g;
4770  } else {
4771  FF = f;
4772  GG = g;
4773  HH = BiddyInv(g); /* h */
4774  }
4775  }
4776  } else {
4777  if (BiddyGetMark(g)) {
4778  if (BiddyGetMark(f)) {
4779  FF = BiddyInv(g);
4780  GG = BiddyInv(f); /* h */
4781  HH = f;
4782  } else {
4783  NN = TRUE;
4784  FF = BiddyInv(g);
4785  GG = f;
4786  HH = BiddyInv(f); /* h */
4787  }
4788  } else {
4789  if (BiddyGetMark(f)) {
4790  NN = TRUE;
4791  FF = g;
4792  GG = BiddyInv(f); /* h */
4793  HH = f;
4794  } else {
4795  FF = g;
4796  GG = f;
4797  HH = BiddyInv(f); /* h */
4798  }
4799  }
4800  }
4801 
4802  }
4803 
4804  else {
4805 
4806  /* THIS IS NOT ITE CACHE! */
4807 
4808  if (((uintptr_t) f) > ((uintptr_t) g)) {
4809  FF = f;
4810  GG = biddyZero;
4811  HH = g;
4812  } else {
4813  FF = g;
4814  GG = biddyZero;
4815  HH = f;
4816  }
4817 
4818  }
4819 
4820  /* IF RESULT IS NOT IN THE CACHE TABLE... */
4821  cindex = 0;
4822  if (!findOp3Cache(biddyOPCache,FF,GG,HH,&r,&cindex))
4823  {
4824 
4825  if ((biddyManagerType == BIDDYTYPEOBDDC) || (biddyManagerType == BIDDYTYPEOBDD)) {
4826 
4827  /* LOOKING FOR THE SMALLEST TOP VARIABLE */
4828  /* CONSTANT VARIABLE MUST HAVE MAX ORDER */
4829  topF = BiddyV(f);
4830  topG = BiddyV(g);
4831  v = BiddyIsSmaller(biddyOrderingTable,topF,topG) ? topF : topG;
4832 
4833  /* DETERMINING PARAMETERS FOR RECURSIVE CALLS */
4834  /* COMPLEMENTED EDGES MUST BE TRANSFERED */
4835  if (topF == v) {
4836  Fneg_v = BiddyInvCond(BiddyE(f),BiddyGetMark(f));
4837  Fv = BiddyInvCond(BiddyT(f),BiddyGetMark(f));
4838  } else {
4839  Fneg_v = Fv = f;
4840  }
4841  if (topG == v) {
4842  Gneg_v = BiddyInvCond(BiddyE(g),BiddyGetMark(g));
4843  Gv = BiddyInvCond(BiddyT(g),BiddyGetMark(g));
4844  } else {
4845  Gneg_v = Gv = g;
4846  }
4847 
4848  rtag = v;
4849 
4850  }
4851 
4852 #ifndef COMPACT
4853  else if ((biddyManagerType == BIDDYTYPEZBDDC) || (biddyManagerType == BIDDYTYPEZBDD)) {
4854 
4855  /* LOOKING FOR THE SMALLEST TOP VARIABLE */
4856  /* CONSTANT VARIABLE MUST HAVE MAX ORDER */
4857  topF = BiddyV(f);
4858  topG = BiddyV(g);
4859  v = BiddyIsSmaller(biddyOrderingTable,topF,topG) ? topF : topG;
4860 
4861  /* DETERMINING PARAMETERS FOR RECURSIVE CALLS */
4862  /* COMPLEMENTED EDGES MUST BE TRANSFERED */
4863  if (topF == v) {
4864  Fneg_v = BiddyInvCond(BiddyE(f),BiddyGetMark(f));
4865  Fv = BiddyT(f);
4866  } else {
4867  Fneg_v = f;
4868  Fv = biddyZero;
4869  }
4870  if (topG == v) {
4871  Gneg_v = BiddyInvCond(BiddyE(g),BiddyGetMark(g));
4872  Gv = BiddyT(g);
4873  } else {
4874  Gneg_v = g;
4875  Gv = biddyZero;
4876  }
4877 
4878  rtag = v;
4879 
4880  }
4881 
4882  else if (biddyManagerType == BIDDYTYPETZBDD) {
4883 
4884  /* VARIANT 1 */
4885  /*
4886  tagF = BiddyGetTag(f);
4887  tagG = BiddyGetTag(g);
4888  if (tagF == tagG) {
4889  / * THE SAME TAG * /
4890  topF = BiddyV(f);
4891  topG = BiddyV(g);
4892  v = BiddyIsSmaller(biddyOrderingTable,topF,topG) ? topF : topG;
4893  rtag = tagF;
4894  w = v;
4895  if (topF == v) {
4896  Fneg_v = BiddyE(f);
4897  Fv = BiddyT(f);
4898  } else {
4899  Fneg_v = f;
4900  BiddySetTag(Fneg_v,v);
4901  Fneg_v = BiddyManagedIncTag(MNG,Fneg_v);
4902  Fv = biddyZero;
4903  }
4904  if (topG == v) {
4905  Gneg_v = BiddyE(g);
4906  Gv = BiddyT(g);
4907  } else {
4908  Gneg_v = g;
4909  BiddySetTag(Gneg_v,v);
4910  Gneg_v = BiddyManagedIncTag(MNG,Gneg_v);
4911  Gv = biddyZero;
4912  }
4913  } else {
4914  / * DIFFERENT TAG * /
4915  rtag = BiddyIsSmaller(biddyOrderingTable,tagF,tagG) ? tagF : tagG;
4916  w = rtag;
4917  if (tagF == rtag) {
4918  if (BiddyV(f) == rtag) {
4919  / * TAG AND TOP VARIABLE ARE EQUAL * /
4920  Fneg_v = BiddyE(f);
4921  Fv = BiddyT(f);
4922  } else {
4923  / * TAG AND TOP VARIABLE ARE NOT EQUAL * /
4924  Fneg_v = f;
4925  BiddySetTag(Fneg_v,rtag);
4926  Fneg_v = BiddyManagedIncTag(MNG,Fneg_v);
4927  Fv = biddyZero;
4928  }
4929  Gneg_v = Gv = g;
4930  } else {
4931  if (BiddyV(g) == rtag) {
4932  / * TAG AND TOP VARIABLE ARE EQUAL * /
4933  Gneg_v = BiddyE(g);
4934  Gv = BiddyT(g);
4935  } else {
4936  / * TAG AND TOP VARIABLE ARE NOT EQUAL * /
4937  Gneg_v = g;
4938  BiddySetTag(Gneg_v,rtag);
4939  Gneg_v = BiddyManagedIncTag(MNG,Gneg_v);
4940  Gv = biddyZero;
4941  }
4942  Fneg_v = Fv = f;
4943  }
4944  }
4945  */
4946 
4947  /* VARIANT 2 */
4948 
4949  tagF = BiddyGetTag(f);
4950  tagG = BiddyGetTag(g);
4951  topF = BiddyV(f);
4952  topG = BiddyV(g);
4953  rtag = BiddyIsSmaller(biddyOrderingTable,tagF,tagG) ? tagF : tagG;
4954  v = BiddyIsSmaller(biddyOrderingTable,topF,topG) ? topF : topG;
4955  if (tagF != tagG) v = rtag;
4956  if (tagF == rtag) {
4957  if (topF == v) {
4958  Fneg_v = BiddyE(f);
4959  Fv = BiddyT(f);
4960  } else {
4961  Fneg_v = f;
4962  BiddySetTag(Fneg_v,v);
4963  Fneg_v = BiddyManagedIncTag(MNG,Fneg_v);
4964  Fv = biddyZero;
4965  }
4966  } else {
4967  Fneg_v = Fv = f;
4968  }
4969  if (tagG == rtag) {
4970  if (topG == v) {
4971  Gneg_v = BiddyE(g);
4972  Gv = BiddyT(g);
4973  } else {
4974  Gneg_v = g;
4975  BiddySetTag(Gneg_v,v);
4976  Gneg_v = BiddyManagedIncTag(MNG,Gneg_v);
4977  Gv = biddyZero;
4978  }
4979  } else {
4980  Gneg_v = Gv = g;
4981  }
4982 
4983 
4984  }
4985 #endif
4986 
4987  /* RECURSIVE CALLS */
4988  /* returning biddyOne in a recursive call is wrong for ZBDD and ZBDDC, */
4989  /* because top variable of the result may be lower (topmore) than top variables of the arguments */
4990  /* (i.e. because the result depends on domain) */
4991  if (Fneg_v == biddyZero) {
4992  E = Gneg_v;
4993  } else if (Gneg_v == biddyZero) {
4994  E = Fneg_v;
4995  } else if (Fneg_v == biddyOne) {
4996  /* FOR ZBDD AND ZBDDC THIS LINE IS NOT REACHABLE IN RECURSIVE CALLS */
4997  E = BiddyManagedNot(MNG,Gneg_v);
4998  } else if (Gneg_v == biddyOne) {
4999  /* FOR ZBDD AND ZBDDC THIS LINE IS NOT REACHABLE IN RECURSIVE CALLS */
5000  E = BiddyManagedNot(MNG,Fneg_v);
5001  } else if (Fneg_v == Gneg_v) {
5002  E = biddyZero;
5003  } else {
5004  E = BiddyManagedXor(MNG,Fneg_v,Gneg_v);
5005  }
5006  if (Fv == biddyZero) {
5007  T = Gv;
5008  } else if (Gv == biddyZero) {
5009  T = Fv;
5010  } else if (Fv == biddyOne) {
5011  /* FOR ZBDD AND ZBDDC THIS LINE IS NOT REACHABLE IN RECURSIVE CALLS */
5012  T = BiddyManagedNot(MNG,Gv);
5013  } else if (Gv == biddyOne) {
5014  /* FOR ZBDD AND ZBDDC THIS LINE IS NOT REACHABLE IN RECURSIVE CALLS */
5015  T = BiddyManagedNot(MNG,Fv);
5016  } else if (Fv == Gv) {
5017  T = biddyZero;
5018  } else {
5019  T = BiddyManagedXor(MNG,Fv,Gv);
5020  }
5021 
5022  r = BiddyManagedTaggedFoaNode(MNG,v,E,T,rtag,TRUE);
5023  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
5024 
5025  if (NN) {
5026  addOp3Cache(biddyOPCache,FF,GG,HH,BiddyInv(r),cindex);
5027  } else {
5028  addOp3Cache(biddyOPCache,FF,GG,HH,r,cindex);
5029  }
5030 
5031  } else {
5032 
5033  if (NN) {
5034  BiddyInvertMark(r);
5035  }
5036 
5037  /* IF THE RESULT IS FROM CACHE TABLE, REFRESH IT! */
5038  BiddyRefresh(r);
5039 
5040  }
5041 
5042  return r;
5043 }
5044 
5045 /***************************************************************************/
5054 Biddy_Edge
5055 BiddyManagedXnor(const Biddy_Manager MNG, const Biddy_Edge f,
5056  const Biddy_Edge g)
5057 {
5058  Biddy_Edge r;
5059 
5060  assert( MNG != NULL );
5061  assert( f != NULL );
5062  assert( g != NULL );
5063 
5064  r = biddyNull;
5065 
5066  /* IMPLEMENTED FOR OBDDC, ONLY */
5067  assert( biddyManagerType == BIDDYTYPEOBDDC );
5068 
5069  if (biddyManagerType == BIDDYTYPEOBDDC) {
5070  r = BiddyInv(BiddyManagedXor(MNG,f,g));
5071  }
5072 
5073  return r;
5074 }
5075 
5076 /***************************************************************************/
5085 Biddy_Edge
5086 BiddyManagedLeq(const Biddy_Manager MNG, const Biddy_Edge f, const Biddy_Edge g)
5087 {
5088  Biddy_Edge r, T, E, Fv, Gv, Fneg_v, Gneg_v;
5089  Biddy_Edge FF, GG, HH;
5090  Biddy_Variable v,rtag;
5091  unsigned int cindex;
5092 
5093  static Biddy_Variable topF; /* CAN BE STATIC, WHAT IS BETTER? */
5094  static Biddy_Variable topG; /* CAN BE STATIC, WHAT IS BETTER? */
5095 
5096 #ifndef COMPACT
5097  static Biddy_Variable tagF; /* CAN BE STATIC, WHAT IS BETTER? */
5098  static Biddy_Variable tagG; /* CAN BE STATIC, WHAT IS BETTER? */
5099 #endif
5100 
5101  assert( MNG != NULL );
5102  assert( f != NULL );
5103  assert( g != NULL );
5104 
5105  r = biddyNull;
5106 
5107  /* IMPLEMENTED FOR OBDD, OBDDC, ZBDD, ZBDDC, AND TZBDDC */
5108  assert(
5109  (biddyManagerType == BIDDYTYPEOBDD) ||
5110  (biddyManagerType == BIDDYTYPEOBDDC) ||
5111  (biddyManagerType == BIDDYTYPEZBDD) ||
5112  (biddyManagerType == BIDDYTYPEZBDDC) ||
5113  (biddyManagerType == BIDDYTYPETZBDD)
5114  );
5115 
5116  if (biddyManagerType == BIDDYTYPEOBDDC) {
5117 
5118  /* FOR OBDDC, PROCEED BY CALCULATING NOT-AND */
5119 
5120  r = BiddyInv(BiddyManagedAnd(MNG,f,BiddyInv(g)));
5121  return r;
5122 
5123  }
5124 
5125 #ifndef COMPACT
5126  if ((biddyManagerType == BIDDYTYPEZBDDC) || (biddyManagerType == BIDDYTYPEZBDD)) {
5127 
5128  /* FOR ZBDD AND ZBDDC, PROCEED BY CALCULATING ITE */
5129  /* THIS IS NOT DIRECT IMPLEMENTATION (AS FOR OBDD AND TZBDD), */
5130  /* BUT IT IS NOT SIGNIFICANTLY SLOWER */
5131 
5132  r = BiddyManagedITE(MNG,f,g,biddyOne);
5133  return r;
5134 
5135  }
5136 #endif
5137 
5138  /* LOOKING FOR SIMPLE CASE */
5139  /* returning biddyOne in a RECURSIVE call is wrong for ZBDD and ZBDDC */
5140  /* using Not in a RECURSIVE call is wrong for ZBDD and ZBDDC */
5141  /* because top variable of biddyOne/result may be lower (topmore) than top variables of the arguments */
5142  /* (i.e. because biddyOne/result depends on domain) */
5143 
5144  /* ZBDD AND ZBDDC ARE ALREADY CALCULATED */
5145  if (f == biddyZero) {
5146  return biddyOne;
5147  } else if (g == biddyZero) {
5148  return BiddyManagedNot(MNG,f);
5149  } else if (f == biddyOne) {
5150  BiddyRefresh(g); /* return non-obsolete node even if the parameter is an obsolete node */
5151  return g;
5152  } else if (g == biddyOne) {
5153  return biddyOne;
5154  } else if (f == g) {
5155  return biddyOne;
5156  }
5157 
5158 #ifndef COMPACT
5159  if (biddyManagerType == BIDDYTYPETZBDD) {
5160  if (BiddyR(f) == BiddyR(g)) {
5161  if (BiddyIsSmaller(biddyOrderingTable,BiddyGetTag(f),BiddyGetTag(g))) {
5162  return biddyOne;
5163  }
5164  }
5165  }
5166 #endif
5167 
5168  /* THIS IS NOT A SIMPLE CASE */
5169 
5170  FF = GG = HH = biddyNull;
5171  Fneg_v = Fv = biddyNull;
5172  Gneg_v = Gv = biddyNull;
5173  rtag = 0;
5174  v = 0;
5175 
5176  if (biddyManagerType == BIDDYTYPEOBDDC) {
5177  /* ALREADY CALCULATED */
5178  }
5179 
5180 #ifndef COMPACT
5181  else if ((biddyManagerType == BIDDYTYPEZBDDC) || (biddyManagerType == BIDDYTYPEZBDD)) {
5182  /* ALREADY CALCULATED */
5183  }
5184 #endif
5185 
5186  else {
5187 
5188 #ifdef BIDDYEXTENDEDSTATS_YES
5189  biddyNodeTable.andorrecursive++;
5190 #endif
5191 
5192  /* FF, GG, and HH ARE USED FOR CACHE LOOKUP, ONLY */
5193  /* THIS IS NOT ITE CACHE! */
5194 
5195  FF = f;
5196  GG = f;
5197  HH = g;
5198 
5199  }
5200 
5201  /* IF RESULT IS NOT IN THE CACHE TABLE... */
5202  cindex = 0;
5203  if (!findOp3Cache(biddyOPCache,FF,GG,HH,&r,&cindex))
5204  {
5205 
5206  if (biddyManagerType == BIDDYTYPEOBDD) {
5207 
5208  /* LOOKING FOR THE SMALLEST TOP VARIABLE */
5209  /* CONSTANT VARIABLE MUST HAVE MAX ORDER */
5210  topF = BiddyV(f);
5211  topG = BiddyV(g);
5212  v = BiddyIsSmaller(biddyOrderingTable,topF,topG) ? topF : topG;
5213 
5214  /* DETERMINING PARAMETERS FOR RECURSIVE CALLS */
5215  /* COMPLEMENTED EDGES MUST BE TRANSFERED */
5216  if (topF == v) {
5217  Fneg_v = BiddyE(f);
5218  Fv = BiddyT(f);
5219  } else {
5220  Fneg_v = Fv = f;
5221  }
5222 
5223  if (topG == v) {
5224  Gneg_v = BiddyE(g);
5225  Gv = BiddyT(g);
5226  } else {
5227  Gneg_v = Gv = g;
5228  }
5229 
5230  rtag = v;
5231 
5232  }
5233 
5234  else if (biddyManagerType == BIDDYTYPEOBDDC) {
5235  /* ALREADY CALCULATED */
5236  }
5237 
5238 #ifndef COMPACT
5239  else if ((biddyManagerType == BIDDYTYPEZBDDC) || (biddyManagerType == BIDDYTYPEZBDD)) {
5240  /* ALREADY CALCULATED */
5241  }
5242 
5243  else if (biddyManagerType == BIDDYTYPETZBDD) {
5244 
5245  /* LOOKING FOR THE SMALLEST TAG AND SMALLEST TOP VARIABLE */
5246  /* CONSTANT VARIABLE MUST HAVE MAX ORDER */
5247  tagF = BiddyGetTag(f);
5248  tagG = BiddyGetTag(g);
5249  topF = BiddyV(f);
5250  topG = BiddyV(g);
5251  rtag = BiddyIsSmaller(biddyOrderingTable,tagF,tagG) ? tagF : tagG;
5252  v = BiddyIsSmaller(biddyOrderingTable,topF,topG) ? topF : topG;
5253 
5254  if (tagF != tagG) v = rtag;
5255  if (tagF == rtag) {
5256  if (topF == v) {
5257  Fneg_v = BiddyE(f);
5258  Fv = BiddyT(f);
5259  } else {
5260  Fneg_v = f;
5261  BiddySetTag(Fneg_v,v);
5262  Fneg_v = BiddyManagedIncTag(MNG,Fneg_v);
5263  Fv = biddyZero;
5264  }
5265  } else {
5266  Fneg_v = Fv = f;
5267  }
5268  if (tagG == rtag) {
5269  if (topG == v) {
5270  Gneg_v = BiddyE(g);
5271  Gv = BiddyT(g);
5272  } else {
5273  Gneg_v = g;
5274  BiddySetTag(Gneg_v,v);
5275  Gneg_v = BiddyManagedIncTag(MNG,Gneg_v);
5276  Gv = biddyZero;
5277  }
5278  } else {
5279  Gneg_v = Gv = g;
5280  }
5281 
5282  }
5283 #endif
5284 
5285  /* RECURSIVE CALLS */
5286  /* returning biddyOne in a RECURSIVE call is wrong for ZBDD and ZBDDC */
5287  /* using Not in a RECURSIVE call is wrong for ZBDD and ZBDDC */
5288  /* because top variable of biddyOne/result may be lower (topmore) than top variables of the arguments */
5289  /* (i.e. because biddyOne/result depends on domain) */
5290 
5291  /* ZBDD AND ZBDDC ARE ALREADY CALCULATED */
5292  if (Fneg_v == biddyZero) {
5293  E = biddyOne;
5294  } else if (Gneg_v == biddyZero) {
5295  E = BiddyManagedNot(MNG,Fneg_v);
5296  } else if (Fneg_v == biddyOne) {
5297  E = Gneg_v;
5298  } else if (Gneg_v == biddyOne) {
5299  E = biddyOne;
5300  } else if (Fneg_v == Gneg_v) {
5301  E = biddyOne;
5302  } else {
5303  E = BiddyManagedLeq(MNG,Fneg_v,Gneg_v);
5304  }
5305  if (Fv == biddyZero) {
5306  T = biddyOne;
5307  } else if (Gv == biddyZero) {
5308  T = BiddyManagedNot(MNG,Fv);
5309  } else if (Fv == biddyOne) {
5310  T = Gv;
5311  } else if (Gv == biddyOne) {
5312  T = biddyOne;
5313  } else if (Fv == Gv) {
5314  T = biddyOne;
5315  } else {
5316  T = BiddyManagedLeq(MNG,Fv,Gv);
5317  }
5318 
5319  r = BiddyManagedTaggedFoaNode(MNG,v,E,T,rtag,TRUE);
5320  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
5321 
5322  addOp3Cache(biddyOPCache,FF,GG,HH,r,cindex);
5323 
5324  } else {
5325 
5326  /* IF THE RESULT IS FROM CACHE TABLE, REFRESH IT! */
5327  BiddyRefresh(r);
5328 
5329  }
5330 
5331  return r;
5332 }
5333 
5334 /***************************************************************************/
5343 Biddy_Edge
5344 BiddyManagedGt(const Biddy_Manager MNG, const Biddy_Edge f, const Biddy_Edge g)
5345 {
5346  Biddy_Edge r, T, E, Fv, Gv, Fneg_v, Gneg_v;
5347  Biddy_Edge FF, GG, HH;
5348  Biddy_Variable v,rtag;
5349  unsigned int cindex;
5350 
5351  static Biddy_Variable topF; /* CAN BE STATIC, WHAT IS BETTER? */
5352  static Biddy_Variable topG; /* CAN BE STATIC, WHAT IS BETTER? */
5353 
5354 #ifndef COMPACT
5355  static Biddy_Variable tagF; /* CAN BE STATIC, WHAT IS BETTER? */
5356  static Biddy_Variable tagG; /* CAN BE STATIC, WHAT IS BETTER? */
5357 #endif
5358 
5359  assert( MNG != NULL );
5360  assert( f != NULL );
5361  assert( g != NULL );
5362 
5363  r = biddyNull;
5364 
5365  /* IMPLEMENTED FOR OBDD, OBDDC, ZBDD, ZBDDC, AND TZBDDC */
5366  assert(
5367  (biddyManagerType == BIDDYTYPEOBDD) ||
5368  (biddyManagerType == BIDDYTYPEOBDDC) ||
5369  (biddyManagerType == BIDDYTYPEZBDD) ||
5370  (biddyManagerType == BIDDYTYPEZBDDC) ||
5371  (biddyManagerType == BIDDYTYPETZBDD)
5372  );
5373 
5374  if (biddyManagerType == BIDDYTYPEOBDDC) {
5375 
5376  /* FOR OBDDC, PROCEED BY CALCULATING NOT-AND */
5377 
5378  r = BiddyManagedAnd(MNG,f,BiddyInv(g));
5379  return r;
5380 
5381  }
5382 
5383  /* LOOKING FOR SIMPLE CASE */
5384  /* using BiddyManagedNot in a RECURSIVE call is wrong for ZBDD and ZBDDC */
5385  /* because top variable of the result may be lower (topmore) than top variables of the arguments */
5386  /* (i.e. because the result depends on domain) */
5387 
5388  if (f == biddyZero) {
5389  return biddyZero;
5390  } else if (g == biddyZero) {
5391  BiddyRefresh(f); /* return non-obsolete node even if the parameter is an obsolete node */
5392  return f;
5393  } else if (f == biddyOne) {
5394  /* FOR ZBDD AND ZBDDC THIS LINE IS NOT REACHABLE IN RECURSIVE CALLS */
5395  return BiddyManagedNot(MNG,g);
5396  } else if (g == biddyOne) {
5397  return biddyZero;
5398  } else if (f == g) {
5399  return biddyZero;
5400  }
5401 
5402 #ifndef COMPACT
5403  if (biddyManagerType == BIDDYTYPETZBDD) {
5404  if (BiddyR(f) == BiddyR(g)) {
5405  if (BiddyIsSmaller(biddyOrderingTable,BiddyGetTag(f),BiddyGetTag(g))) {
5406  return biddyZero;
5407  }
5408  }
5409  }
5410 #endif
5411 
5412  /* THIS IS NOT A SIMPLE CASE */
5413 
5414  FF = GG = HH = biddyNull;
5415  Fneg_v = Fv = biddyNull;
5416  Gneg_v = Gv = biddyNull;
5417  rtag = 0;
5418  v = 0;
5419 
5420  if (biddyManagerType == BIDDYTYPEOBDDC) {
5421  /* ALREADY CALCULATED */
5422  }
5423 
5424  else {
5425 
5426 #ifdef BIDDYEXTENDEDSTATS_YES
5427  biddyNodeTable.andorrecursive++;
5428 #endif
5429 
5430  /* FF, GG, and HH ARE USED FOR CACHE LOOKUP, ONLY */
5431  /* THIS IS NOT ITE CACHE! */
5432 
5433  FF = f;
5434  GG = g;
5435  HH = g;
5436 
5437  }
5438 
5439  /* IF RESULT IS NOT IN THE CACHE TABLE... */
5440  cindex = 0;
5441  if ((((biddyManagerType == BIDDYTYPEZBDDC) || (biddyManagerType == BIDDYTYPEZBDD))
5442  && BiddyIsSmaller(biddyOrderingTable,BiddyV(g),BiddyV(f))
5443  ) || !findOp3Cache(biddyOPCache,FF,GG,HH,&r,&cindex))
5444  {
5445 
5446  if ((biddyManagerType == BIDDYTYPEOBDDC) || (biddyManagerType == BIDDYTYPEOBDD)) {
5447 
5448  /* FOR OBDDC THE RESULTS HAS BEEN ALREADY CALCULATED */
5449 
5450  /* LOOKING FOR THE SMALLEST TOP VARIABLE */
5451  /* CONSTANT VARIABLE MUST HAVE MAX ORDER */
5452  topF = BiddyV(f);
5453  topG = BiddyV(g);
5454  v = BiddyIsSmaller(biddyOrderingTable,topF,topG) ? topF : topG;
5455 
5456  /* DETERMINING PARAMETERS FOR RECURSIVE CALLS */
5457  if (topF == v) {
5458  Fneg_v = BiddyE(f);
5459  Fv = BiddyT(f);
5460  } else {
5461  Fneg_v = Fv = f;
5462  }
5463 
5464  if (topG == v) {
5465  Gneg_v = BiddyE(g);
5466  Gv = BiddyT(g);
5467  } else {
5468  Gneg_v = Gv = g;
5469  }
5470 
5471  rtag = v;
5472 
5473  }
5474 
5475 #ifndef COMPACT
5476  else if ((biddyManagerType == BIDDYTYPEZBDDC) || (biddyManagerType == BIDDYTYPEZBDD)) {
5477 
5478  /* LOOKING FOR THE SMALLEST TOP VARIABLE */
5479  /* CONSTANT VARIABLE MUST HAVE MAX ORDER */
5480  topF = BiddyV(f);
5481  topG = BiddyV(g);
5482  v = BiddyIsSmaller(biddyOrderingTable,topF,topG) ? topF : topG;
5483 
5484  /* THIS CALL IS NOT INTRODUCING NEW NODES */
5485  /* COMPLEMENTED EDGES MUST BE TRANSFERED */
5486  /* IT SEEMS THAT CACHING THIS RESULTS IS NOT A GOOD IDEA */
5487  if (topF != v) {
5488  r = BiddyManagedGt(MNG,f,BiddyInvCond(BiddyE(g),BiddyGetMark(g)));
5489  return r;
5490  }
5491 
5492  /* DETERMINING PARAMETERS FOR RECURSIVE CALLS */
5493  /* IT IS ALREADY KNOWN THAT topF == v */
5494  /* COMPLEMENTED EDGES MUST BE TRANSFERED */
5495  Fneg_v = BiddyInvCond(BiddyE(f),BiddyGetMark(f));
5496  Fv = BiddyT(f);
5497  if (topG == v) {
5498  Gneg_v = BiddyInvCond(BiddyE(g),BiddyGetMark(g));
5499  Gv = BiddyT(g);
5500  } else {
5501  Gneg_v = g;
5502  Gv = biddyZero;
5503  }
5504 
5505  rtag = v;
5506 
5507  }
5508 
5509  else if (biddyManagerType == BIDDYTYPETZBDD) {
5510 
5511  /* LOOKING FOR THE SMALLEST TAG AND SMALLEST TOP VARIABLE */
5512  /* CONSTANT VARIABLE MUST HAVE MAX ORDER */
5513  tagF = BiddyGetTag(f);
5514  tagG = BiddyGetTag(g);
5515  topF = BiddyV(f);
5516  topG = BiddyV(g);
5517  rtag = BiddyIsSmaller(biddyOrderingTable,tagF,tagG) ? tagF : tagG;
5518  v = BiddyIsSmaller(biddyOrderingTable,topF,topG) ? topF : topG;
5519 
5520  if (BiddyIsSmaller(biddyOrderingTable,tagG,tagF)) v = rtag;
5521 
5522  if (BiddyIsSmaller(biddyOrderingTable,v,tagF)) {
5523  Fneg_v = Fv = f;
5524  } else if (BiddyIsSmaller(biddyOrderingTable,v,topF)) {
5525  Fneg_v = f;
5526  BiddySetTag(Fneg_v,v);
5527  Fneg_v = BiddyManagedIncTag(MNG,Fneg_v);
5528  Fv = biddyZero;
5529  } else {
5530  /* HERE topF == v */
5531  /* TO DO: CHECK And FOR OPTIMIZATION */
5532  Fneg_v = BiddyE(f);
5533  Fv = BiddyT(f);
5534  }
5535  if (BiddyIsSmaller(biddyOrderingTable,v,tagG)) {
5536  Gneg_v = Gv = g;
5537  } else if (BiddyIsSmaller(biddyOrderingTable,v,topG)) {
5538  Gneg_v = g;
5539  BiddySetTag(Gneg_v,v);
5540  Gneg_v = BiddyManagedIncTag(MNG,Gneg_v);
5541  Gv = biddyZero;
5542  } else {
5543  /* HERE topG == v */
5544  /* TO DO: CHECK And FOR OPTIMIZATION */
5545  Gneg_v = BiddyE(g);
5546  Gv = BiddyT(g);
5547  }
5548 
5549  }
5550 #endif
5551 
5552  /* RECURSIVE CALLS */
5553  /* using BiddyManagedNot in a recursive call is wrong for ZBDD and ZBDDC, */
5554  /* because top variable of the result may be lower (topmore) than top variables of the arguments */
5555  /* (i.e. because the result depends on domain) */
5556 
5557  if (Fneg_v == biddyZero) {
5558  E = biddyZero;
5559  } else if (Gneg_v == biddyZero) {
5560  E = Fneg_v;
5561  } else if (Fneg_v == biddyOne) {
5562  /* FOR ZBDD AND ZBDDC THIS LINE IS NOT REACHABLE IN RECURSIVE CALLS */
5563  E = BiddyManagedNot(MNG,Gneg_v);
5564  } else if (Gneg_v == biddyOne) {
5565  E = biddyZero;
5566  } else if (Fneg_v == Gneg_v) {
5567  E = biddyZero;
5568  } else {
5569  E = BiddyManagedGt(MNG,Fneg_v,Gneg_v);
5570  }
5571  if (Fv == biddyZero) {
5572  T = biddyZero;
5573  } else if (Gv == biddyZero) {
5574  T = Fv;
5575  } else if (Fv == biddyOne) {
5576  /* FOR ZBDD AND ZBDDC THIS LINE IS NOT REACHABLE IN RECURSIVE CALLS */
5577  T = BiddyManagedNot(MNG,Gv);
5578  } else if (Gv == biddyOne) {
5579  T = biddyZero;
5580  } else if (Fv == Gv) {
5581  T = biddyZero;
5582  } else {
5583  T = BiddyManagedGt(MNG,Fv,Gv);
5584  }
5585 
5586  r = BiddyManagedTaggedFoaNode(MNG,v,E,T,rtag,TRUE);
5587  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
5588 
5589  addOp3Cache(biddyOPCache,FF,GG,HH,r,cindex);
5590 
5591  } else {
5592 
5593  /* IF THE RESULT IS FROM CACHE TABLE, REFRESH IT! */
5594  BiddyRefresh(r);
5595 
5596  }
5597 
5598  return r;
5599 }
5600 
5601 /***************************************************************************/
5610 Biddy_Edge
5611 BiddyManagedRestrict(Biddy_Manager MNG, Biddy_Edge f, Biddy_Variable v,
5612  Biddy_Boolean value)
5613 {
5614  Biddy_Edge e, t, r;
5615  Biddy_Variable fv;
5616  Biddy_Edge FF, GG, HH;
5617  unsigned int cindex;
5618 
5619 #ifndef COMPACT
5620  Biddy_Variable tag;
5621 #endif
5622 
5623  assert( MNG != NULL );
5624  assert( f != NULL );
5625  assert( v != 0);
5626 
5627  /* IMPLEMENTED FOR OBDD, OBDDC, ZBDD, ZBDDC, AND TZBDD */
5628  assert(
5629  (biddyManagerType == BIDDYTYPEOBDD) ||
5630  (biddyManagerType == BIDDYTYPEOBDDC) ||
5631  (biddyManagerType == BIDDYTYPEZBDD) ||
5632  (biddyManagerType == BIDDYTYPEZBDDC) ||
5633  (biddyManagerType == BIDDYTYPETZBDD)
5634  );
5635 
5636  r = biddyNull;
5637 
5638  if (f == biddyZero) return biddyZero;
5639 
5640  FF = f;
5641  GG = value?biddyZero:biddyOne;
5642  HH = biddyNull;
5643 
5644  if ((biddyManagerType == BIDDYTYPEOBDDC) || (biddyManagerType == BIDDYTYPEOBDD)) {
5645  HH = biddyVariableTable.table[v].variable;
5646  }
5647 #ifndef COMPACT
5648  else if ((biddyManagerType == BIDDYTYPEZBDDC) || (biddyManagerType == BIDDYTYPEZBDD)) {
5649  HH = biddyVariableTable.table[v].element;
5650  }
5651  else if (biddyManagerType == BIDDYTYPETZBDD) {
5652  HH = biddyVariableTable.table[v].variable;
5653  }
5654 #endif
5655 
5656  /* IF RESULT IS NOT IN THE CACHE TABLE... */
5657  /* Result is stored in cache only if recursive calls are needed */
5658  /* I am not sure if this is a good strategy! */
5659  cindex = 0;
5660  if (!findOp3Cache(biddyRCCache,FF,GG,HH,&r,&cindex))
5661  {
5662 
5663  if ((biddyManagerType == BIDDYTYPEOBDDC) || (biddyManagerType == BIDDYTYPEOBDD)) {
5664  if ((fv=BiddyV(f)) == v) {
5665  if (value) {
5666  r = BiddyInvCond(BiddyT(f),BiddyGetMark(f));
5667  BiddyRefresh(r); /* subnode may be marked as an obsolete node! */
5668  } else {
5669  r = BiddyInvCond(BiddyE(f),BiddyGetMark(f));
5670  BiddyRefresh(r); /* subnode may be marked as an obsolete node! */
5671  }
5672  }
5673  else if (BiddyIsSmaller(biddyOrderingTable,v,fv)) {
5674  r = f;
5675  BiddyRefresh(r); /* return non-obsolete node even if the parameter is an obsolete node */
5676  }
5677  else {
5678  e = BiddyManagedRestrict(MNG,BiddyE(f),v,value);
5679  t = BiddyManagedRestrict(MNG,BiddyT(f),v,value);
5680  r = BiddyInvCond(BiddyManagedTaggedFoaNode(MNG,fv,e,t,fv,TRUE),BiddyGetMark(f));
5681  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
5682  addOp3Cache(biddyRCCache,FF,GG,HH,r,cindex);
5683  }
5684  }
5685 
5686 #ifndef COMPACT
5687  else if ((biddyManagerType == BIDDYTYPEZBDDC) || (biddyManagerType == BIDDYTYPEZBDD)) {
5688  if ((fv=BiddyV(f)) == v) {
5689  if (value) {
5690  t = BiddyT(f);
5691  r = BiddyManagedTaggedFoaNode(MNG,v,t,t,v,TRUE);
5692  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
5693  } else {
5694  e = BiddyInvCond(BiddyE(f),BiddyGetMark(f));
5695  r = BiddyManagedTaggedFoaNode(MNG,v,e,e,v,TRUE);
5696  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
5697  }
5698  }
5699  else if (BiddyIsSmaller(biddyOrderingTable,v,fv)) {
5700  if (value) {
5701  r = biddyZero;
5702  } else {
5703  r = BiddyManagedTaggedFoaNode(MNG,v,f,f,v,TRUE);
5704  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
5705  }
5706  }
5707  else {
5708  e = BiddyManagedRestrict(MNG,BiddyInvCond(BiddyE(f),BiddyGetMark(f)),v,value);
5709  t = BiddyManagedRestrict(MNG,BiddyT(f),v,value);
5710  r = BiddyManagedTaggedFoaNode(MNG,fv,e,t,fv,TRUE);
5711  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
5712  addOp3Cache(biddyRCCache,FF,GG,HH,r,cindex);
5713  }
5714  }
5715 
5716  else if (biddyManagerType == BIDDYTYPETZBDD) {
5717  tag = BiddyGetTag(f);
5718  if (BiddyIsSmaller(biddyOrderingTable,v,tag)) {
5719  r = f;
5720  BiddyRefresh(r); /* return non-obsolete node even if the parameter is an obsolete node */
5721  } else {
5722  fv = BiddyV(f);
5723  if (v == fv) {
5724  if (v == tag) {
5725  if (value) {
5726  r = BiddyT(f);
5727  BiddyRefresh(r); /* subnode may be marked as an obsolete node! */
5728  } else {
5729  r = BiddyE(f);
5730  BiddyRefresh(r); /* subnode may be marked as an obsolete node! */
5731  }
5732  } else {
5733  if (value) {
5734  t = BiddyT(f);
5735  r = BiddyManagedTaggedFoaNode(MNG,v,t,t,tag,TRUE);
5736  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
5737  } else {
5738  e = BiddyE(f);
5739  r = BiddyManagedTaggedFoaNode(MNG,v,e,e,tag,TRUE);
5740  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
5741  }
5742  }
5743  } else if (BiddyIsSmaller(biddyOrderingTable,v,fv)) {
5744  if (value) {
5745  r = biddyZero;
5746  } else {
5747  if (v == tag) {
5748  r = BiddyManagedIncTag(MNG,f);
5749  } else {
5750  r = f;
5751  /* BiddyRefresh(r); */ /* f may be an obsolete node but this is not a problem here */
5752  BiddySetTag(r,v);
5753  r = BiddyManagedIncTag(MNG,r);
5754  r = BiddyManagedTaggedFoaNode(MNG,v,r,r,tag,TRUE);
5755  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
5756  }
5757  }
5758  } else {
5759  e = BiddyManagedRestrict(MNG,BiddyE(f),v,value);
5760  t = BiddyManagedRestrict(MNG,BiddyT(f),v,value);
5761  r = BiddyManagedTaggedFoaNode(MNG,fv,e,t,tag,TRUE);
5762  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
5763  addOp3Cache(biddyRCCache,FF,GG,HH,r,cindex);
5764  }
5765  }
5766  }
5767 #endif
5768 
5769  } else {
5770 
5771  /* IF THE RESULT IS FROM CACHE TABLE, REFRESH IT! */
5772  BiddyRefresh(r);
5773 
5774  }
5775 
5776  return r;
5777 }
5778 
5779 /***************************************************************************/
5788 Biddy_Edge
5789 BiddyManagedCompose(Biddy_Manager MNG, Biddy_Edge f, Biddy_Edge g,
5790  Biddy_Variable v)
5791 {
5792  Biddy_Edge e, t, r;
5793  Biddy_Variable fv;
5794  Biddy_Edge FF, GG, HH;
5795  unsigned int cindex;
5796 
5797 #ifndef COMPACT
5798  Biddy_Variable tag;
5799 #endif
5800 
5801  assert( MNG != NULL );
5802  assert( f != NULL );
5803  assert( g != NULL );
5804  assert( v != 0);
5805 
5806  /* IMPLEMENTED FOR OBDD, OBDDC, ZBDD, ZBDDC, AND TZBDD */
5807  assert(
5808  (biddyManagerType == BIDDYTYPEOBDD) ||
5809  (biddyManagerType == BIDDYTYPEOBDDC) ||
5810  (biddyManagerType == BIDDYTYPEZBDD) ||
5811  (biddyManagerType == BIDDYTYPEZBDDC) ||
5812  (biddyManagerType == BIDDYTYPETZBDD)
5813  );
5814 
5815  r = biddyNull;
5816 
5817  if (f == biddyZero) return biddyZero;
5818 
5819  FF = f;
5820  GG = g;
5821  HH = biddyNull;
5822 
5823  if ((biddyManagerType == BIDDYTYPEOBDDC) || (biddyManagerType == BIDDYTYPEOBDD)) {
5824  HH = biddyVariableTable.table[v].variable;
5825  }
5826 #ifndef COMPACT
5827  else if ((biddyManagerType == BIDDYTYPEZBDDC) || (biddyManagerType == BIDDYTYPEZBDD)) {
5828  HH = biddyVariableTable.table[v].element;
5829  }
5830  else if (biddyManagerType == BIDDYTYPETZBDD) {
5831  HH = biddyVariableTable.table[v].variable;
5832  }
5833 #endif
5834 
5835  /* IF RESULT IS NOT IN THE CACHE TABLE... */
5836  /* TO DO: CHECK ONLY IF IT IS POSSIBLE TO EXIST IN THE CACHE */
5837  cindex = 0;
5838  if (!findOp3Cache(biddyRCCache,FF,GG,HH,&r,&cindex))
5839  {
5840 
5841  if ((biddyManagerType == BIDDYTYPEOBDDC) || (biddyManagerType == BIDDYTYPEOBDD)) {
5842  if ((fv=BiddyV(f)) == v) {
5843  r = BiddyInvCond(BiddyManagedITE(MNG,g,BiddyT(f),BiddyE(f)),BiddyGetMark(f));
5844  }
5845  else if (BiddyIsSmaller(biddyOrderingTable,v,fv)) {
5846  r = f;
5847  BiddyRefresh(r); /* return non-obsolete node even if the parameter is an obsolete node */
5848  }
5849  else {
5850  e = BiddyManagedCompose(MNG,BiddyE(f),g,v);
5851  t = BiddyManagedCompose(MNG,BiddyT(f),g,v);
5852  /* VARIANT A: USE TRUE FOR THE FIRST CONDITION */
5853  /* VARIANT B: USE FALSE FOR THE FIRST CONDITION */
5854  if (TRUE && BiddyIsSmaller(biddyOrderingTable,fv,BiddyV(e)) && BiddyIsSmaller(biddyOrderingTable,fv,BiddyV(t))) {
5855  r = BiddyInvCond(BiddyManagedTaggedFoaNode(MNG,fv,e,t,fv,TRUE),BiddyGetMark(f));
5856  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
5857  } else {
5858  r = BiddyInvCond(BiddyManagedITE(MNG,biddyVariableTable.table[fv].variable,t,e),BiddyGetMark(f));
5859  }
5860  addOp3Cache(biddyRCCache,FF,GG,HH,r,cindex);
5861  }
5862  }
5863 
5864 #ifndef COMPACT
5865  else if ((biddyManagerType == BIDDYTYPEZBDDC) || (biddyManagerType == BIDDYTYPEZBDD)) {
5866  /* TO DO: Biddy_Replace USE DIFFERENT APPROACH */
5867  /* TO DO: check if that approach is applicable and more efficient */
5868  if ((fv=BiddyV(f)) == v) {
5869  e = BiddyInvCond(BiddyE(f),BiddyGetMark(f));
5870  e = BiddyManagedTaggedFoaNode(MNG,v,e,e,v,TRUE);
5871  BiddyRefresh(e); /* FoaNode returns an obsolete node! */
5872  t = BiddyT(f);
5873  t = BiddyManagedTaggedFoaNode(MNG,v,t,t,v,TRUE);
5874  BiddyRefresh(t); /* FoaNode returns an obsolete node! */
5875  r = BiddyManagedITE(MNG,g,t,e);
5876  addOp3Cache(biddyRCCache,FF,GG,HH,r,cindex);
5877  }
5878  else if (BiddyIsSmaller(biddyOrderingTable,v,fv)) {
5879  r = BiddyManagedTaggedFoaNode(MNG,v,f,f,v,TRUE);
5880  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
5881  r = BiddyManagedITE(MNG,g,biddyZero,r);
5882  addOp3Cache(biddyRCCache,FF,GG,HH,r,cindex);
5883  }
5884  else {
5885  e = BiddyManagedCompose(MNG,BiddyInvCond(BiddyE(f),BiddyGetMark(f)),g,v);
5886  t = BiddyManagedCompose(MNG,BiddyT(f),BiddyManagedChange(MNG,g,fv),v);
5887  t = BiddyManagedChange(MNG,t,fv);
5888  r = BiddyManagedXor(MNG,e,t);
5889  addOp3Cache(biddyRCCache,FF,GG,HH,r,cindex);
5890  }
5891  }
5892 
5893  else if (biddyManagerType == BIDDYTYPETZBDD) {
5894  /* TO DO: Biddy_Replace USE DIFFERENT APPROACH */
5895  /* TO DO: check if that approach is applicable and more efficient */
5896  tag = BiddyGetTag(f);
5897  if (BiddyIsSmaller(biddyOrderingTable,v,tag)) {
5898  r = f;
5899  BiddyRefresh(r); /* return non-obsolete node even if the parameter is an obsolete node */
5900  } else {
5901  if ((fv=BiddyV(f)) == v) {
5902  /* VARIANT 1 */
5903 
5904  if (v == tag) {
5905  e = BiddyE(f);
5906  t = BiddyT(f);
5907  } else {
5908  e = BiddyManagedTaggedFoaNode(MNG,v,BiddyE(f),BiddyE(f),tag,TRUE);
5909  BiddyRefresh(e); /* FoaNode returns an obsolete node! */
5910  t = BiddyManagedTaggedFoaNode(MNG,v,BiddyT(f),BiddyT(f),tag,TRUE);
5911  BiddyRefresh(t); /* FoaNode returns an obsolete node! */
5912  }
5913  r = BiddyManagedITE(MNG,g,t,e);
5914 
5915  /* VARIANT 2 - THIS COULD BE BETTER FOR SOME EXAMPLES */
5916  /*
5917  r = BiddyManagedTaggedFoaNode(MNG,v,biddyOne,biddyOne,tag,TRUE);
5918  BiddyRefresh(r);
5919  e = BiddyE(f);
5920  t = BiddyT(f);
5921  r = BiddyManagedAnd(MNG,r,BiddyManagedITE(MNG,g,t,e));
5922  */
5923  addOp3Cache(biddyRCCache,FF,GG,HH,r,cindex);
5924  }
5925  else if (BiddyIsSmaller(biddyOrderingTable,v,fv)) {
5926  r = BiddyManagedRestrict(MNG,f,v,FALSE);
5927  r = BiddyManagedITE(MNG,g,biddyZero,r);
5928  addOp3Cache(biddyRCCache,FF,GG,HH,r,cindex);
5929  } else {
5930  /* VARIANT 1 */
5931 
5932  r = BiddyManagedTaggedFoaNode(MNG,fv,biddyOne,biddyOne,tag,TRUE);
5933  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
5934  e = BiddyManagedCompose(MNG,BiddyE(f),g,v);
5935  t = BiddyManagedCompose(MNG,BiddyT(f),g,v);
5936  r = BiddyManagedAnd(MNG,r,BiddyManagedITE(MNG,biddyVariableTable.table[fv].variable,t,e));
5937 
5938  /* VARIANT 2 - THIS SEEMS TO BE SLOWER */
5939  /*
5940  e = BiddyManagedTaggedFoaNode(MNG,fv,biddyOne,biddyZero,tag,TRUE);
5941  BiddyRefresh(e);
5942  t = BiddyManagedTaggedFoaNode(MNG,fv,biddyZero,biddyOne,tag,TRUE);
5943  BiddyRefresh(t);
5944  e = BiddyManagedAnd(MNG,e,BiddyManagedCompose(MNG,BiddyE(f),g,v));
5945  t = BiddyManagedAnd(MNG,t,BiddyManagedCompose(MNG,BiddyT(f),g,v));
5946  r = BiddyManagedXor(MNG,e,t);
5947  */
5948  addOp3Cache(biddyRCCache,FF,GG,HH,r,cindex);
5949  }
5950  }
5951  }
5952 #endif
5953 
5954  } else {
5955 
5956  /* IF THE RESULT IS FROM CACHE TABLE, FRESH IT! */
5957  BiddyRefresh(r);
5958 
5959  }
5960 
5961  return r;
5962 }
5963 
5964 /***************************************************************************/
5973 Biddy_Edge
5974 BiddyManagedE(Biddy_Manager MNG, Biddy_Edge f, Biddy_Variable v)
5975 {
5976  Biddy_Edge h;
5977  Biddy_Edge e, t, r;
5978  Biddy_Variable fv;
5979  unsigned int cindex;
5980 
5981 #ifndef COMPACT
5982  Biddy_Variable tag;
5983 #endif
5984 
5985  assert( MNG != NULL );
5986  assert( f != NULL );
5987  assert( v != 0);
5988 
5989  /* IMPLEMENTED FOR OBDD, OBDDC, ZBDD, ZBDDC, AND TZBDD */
5990  assert(
5991  (biddyManagerType == BIDDYTYPEOBDD) ||
5992  (biddyManagerType == BIDDYTYPEOBDDC) ||
5993  (biddyManagerType == BIDDYTYPEZBDD) ||
5994  (biddyManagerType == BIDDYTYPEZBDDC) ||
5995  (biddyManagerType == BIDDYTYPETZBDD)
5996  );
5997 
5998  fv = 0;
5999  r = biddyNull;
6000 
6001 #ifndef COMPACT
6002  tag = 0;
6003 #endif
6004 
6005  /* LOOKING FOR SIMPLE CASE */
6006  if (f == biddyZero) return biddyZero;
6007 
6008  h = biddyNull;
6009 
6010  /* h MUST BE COMPATIBLE WITH CUBE */
6011  if ((biddyManagerType == BIDDYTYPEOBDDC) || (biddyManagerType == BIDDYTYPEOBDD)) {
6012  fv = BiddyV(f);
6013  if (BiddyIsSmaller(biddyOrderingTable,v,fv)) {
6014  BiddyRefresh(f); /* return non-obsolete node even if the parameter is an obsolete node */
6015  return f;
6016  }
6017  h = biddyVariableTable.table[v].variable;
6018  }
6019 #ifndef COMPACT
6020  else if ((biddyManagerType == BIDDYTYPEZBDDC) || (biddyManagerType == BIDDYTYPEZBDD)) {
6021  h = biddyVariableTable.table[v].element;
6022  }
6023  else if (biddyManagerType == BIDDYTYPETZBDD) {
6024  tag = BiddyGetTag(f);
6025  if (BiddyIsSmaller(biddyOrderingTable,v,tag)) {
6026  BiddyRefresh(f); /* return non-obsolete node even if the parameter is an obsolete node */
6027  return f;
6028  }
6029  h = biddyVariableTable.table[v].variable;
6030  }
6031 #endif
6032 
6033  /* IF RESULT IS NOT IN THE CACHE TABLE... */
6034  cindex = 0;
6035  if ((((uintptr_t) f) > ((uintptr_t) biddyOne)) ?
6036  !findOp3Cache(biddyEACache,biddyOne,f,h,&r,&cindex) :
6037  !findOp3Cache(biddyEACache,f,biddyOne,h,&r,&cindex))
6038  {
6039 
6040  if ((biddyManagerType == BIDDYTYPEOBDDC) || (biddyManagerType == BIDDYTYPEOBDD)) {
6041  if (fv == v) {
6042  r = BiddyManagedOr(MNG,
6043  BiddyInvCond(BiddyE(f),BiddyGetMark(f)),
6044  BiddyInvCond(BiddyT(f),BiddyGetMark(f)));
6045  }
6046  else {
6047  e = BiddyManagedE(MNG,BiddyInvCond(BiddyE(f),BiddyGetMark(f)),v);
6048  t = BiddyManagedE(MNG,BiddyInvCond(BiddyT(f),BiddyGetMark(f)),v);
6049  r = BiddyManagedTaggedFoaNode(MNG,fv,e,t,fv,TRUE);
6050  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
6051  }
6052  }
6053 
6054 #ifndef COMPACT
6055  else if ((biddyManagerType == BIDDYTYPEZBDDC) || (biddyManagerType == BIDDYTYPEZBDD)) {
6056  if ((fv=BiddyV(f)) == v) {
6057  r = BiddyManagedOr(MNG,
6058  BiddyInvCond(BiddyE(f),BiddyGetMark(f)),
6059  BiddyT(f));
6060  r = BiddyManagedTaggedFoaNode(MNG,v,r,r,v,TRUE);
6061  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
6062  }
6063  else if (BiddyIsSmaller(biddyOrderingTable,v,fv)) {
6064  r = BiddyManagedTaggedFoaNode(MNG,v,f,f,v,TRUE);
6065  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
6066  }
6067  else {
6068  e = BiddyManagedE(MNG,BiddyInvCond(BiddyE(f),BiddyGetMark(f)),v);
6069  t = BiddyManagedE(MNG,BiddyT(f),v);
6070  r = BiddyManagedTaggedFoaNode(MNG,fv,e,t,fv,TRUE);
6071  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
6072  }
6073  }
6074 
6075  else if (biddyManagerType == BIDDYTYPETZBDD) {
6076  if ((fv=BiddyV(f)) == v) {
6077  r = BiddyManagedOr(MNG,BiddyE(f),BiddyT(f));
6078  if (v != tag) {
6079  r = BiddyManagedTaggedFoaNode(MNG,v,r,r,tag,TRUE);
6080  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
6081  }
6082  } else if (BiddyIsSmaller(biddyOrderingTable,v,fv)) {
6083  if (v == tag) {
6084  r = BiddyManagedIncTag(MNG,f);
6085  } else {
6086  r = f;
6087  /* BiddyRefresh(r); */ /* f may be an obsolete node but this is not a problem here */
6088  BiddySetTag(r,v);
6089  r = BiddyManagedIncTag(MNG,r);
6090  r = BiddyManagedTaggedFoaNode(MNG,v,r,r,tag,TRUE);
6091  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
6092  }
6093  } else {
6094  e = BiddyManagedE(MNG,BiddyE(f),v);
6095  t = BiddyManagedE(MNG,BiddyT(f),v);
6096  r = BiddyManagedTaggedFoaNode(MNG,fv,e,t,tag,TRUE);
6097  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
6098  }
6099  }
6100 #endif
6101 
6102  /* CACHE FOR Ex(v)(f*1), f*1 <=> 1*f */
6103  if (((uintptr_t) f) > ((uintptr_t) biddyOne)) {
6104  addOp3Cache(biddyEACache,biddyOne,f,h,r,cindex);
6105  } else {
6106  addOp3Cache(biddyEACache,f,biddyOne,h,r,cindex);
6107  }
6108 
6109  } else {
6110 
6111  /* IF THE RESULT IS FROM CACHE TABLE, REFRESH IT! */
6112  BiddyRefresh(r);
6113 
6114  }
6115 
6116  return r;
6117 }
6118 
6119 /***************************************************************************/
6128 Biddy_Edge
6129 BiddyManagedA(Biddy_Manager MNG, Biddy_Edge f, Biddy_Variable v)
6130 {
6131  Biddy_Edge r;
6132 
6133  assert( MNG != NULL );
6134  assert( f != NULL );
6135  assert( v != 0);
6136 
6137  /* IMPLEMENTED FOR OBDDC, ONLY */
6138  assert( biddyManagerType == BIDDYTYPEOBDDC );
6139 
6140  /* LOOKING FOR SIMPLE CASE */
6141  if (BiddyIsTerminal(f)) return f;
6142 
6143  /* PROCEED BY CALCULATING NOT (EX v NOT f) */
6144  r = BiddyInv(BiddyManagedE(MNG,BiddyInv(f),v));
6145 
6146  return r;
6147 }
6148 
6149 /***************************************************************************/
6158 Biddy_Edge
6159 BiddyManagedExistAbstract(Biddy_Manager MNG, Biddy_Edge f, Biddy_Edge cube)
6160 {
6161  Biddy_Edge e, t, r;
6162  Biddy_Variable fv,cv;
6163  unsigned int cindex;
6164 
6165 #ifndef COMPACT
6166  Biddy_Variable tag;
6167 #endif
6168 
6169  assert( MNG != NULL );
6170  assert( f != NULL );
6171  assert( cube != NULL );
6172 
6173  /* IMPLEMENTED FOR OBDD, OBDDC, ZBDD, ZBDDC, AND TZBDD */
6174  assert(
6175  (biddyManagerType == BIDDYTYPEOBDD) ||
6176  (biddyManagerType == BIDDYTYPEOBDDC) ||
6177  (biddyManagerType == BIDDYTYPEZBDD) ||
6178  (biddyManagerType == BIDDYTYPEZBDDC) ||
6179  (biddyManagerType == BIDDYTYPETZBDD)
6180  );
6181 
6182  r = biddyNull;
6183 
6184  /* LOOKING FOR SIMPLE CASE */
6185  if (f == biddyZero) return biddyZero;
6186 
6187  /* IF RESULT IS NOT IN THE CACHE TABLE... */
6188  cindex = 0;
6189  if ((((uintptr_t) f) > ((uintptr_t) biddyOne)) ?
6190  !findOp3Cache(biddyEACache,biddyOne,f,cube,&r,&cindex) :
6191  !findOp3Cache(biddyEACache,f,biddyOne,cube,&r,&cindex))
6192  {
6193 
6194  if ((biddyManagerType == BIDDYTYPEOBDDC) || (biddyManagerType == BIDDYTYPEOBDD)) {
6195  fv = BiddyV(f);
6196  cv = BiddyV(cube);
6197  while (!BiddyIsTerminal(cube) && BiddyIsSmaller(biddyOrderingTable,cv,fv)) {
6198  cube = BiddyT(cube);
6199  cv = BiddyV(cube);
6200  }
6201  if (BiddyIsTerminal(cube)) {
6202  BiddyRefresh(f); /* return non-obsolete node even if the parameter is an obsolete node */
6203  return f;
6204  }
6205  if (cv == fv) {
6206  e = BiddyManagedExistAbstract(MNG,
6207  BiddyInvCond(BiddyE(f),BiddyGetMark(f)),BiddyT(cube));
6208  t = BiddyManagedExistAbstract(MNG,
6209  BiddyInvCond(BiddyT(f),BiddyGetMark(f)),BiddyT(cube));
6210  r = BiddyManagedOr(MNG,e,t);
6211  } else {
6212  e = BiddyManagedExistAbstract(MNG,
6213  BiddyInvCond(BiddyE(f),BiddyGetMark(f)),cube);
6214  t = BiddyManagedExistAbstract(MNG,
6215  BiddyInvCond(BiddyT(f),BiddyGetMark(f)),cube);
6216  r = BiddyManagedTaggedFoaNode(MNG,fv,e,t,fv,TRUE);
6217  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
6218  }
6219  }
6220 
6221 #ifndef COMPACT
6222  else if ((biddyManagerType == BIDDYTYPEZBDDC) || (biddyManagerType == BIDDYTYPEZBDD)) {
6223  if (BiddyIsTerminal(cube)) {
6224  BiddyRefresh(f); /* return non-obsolete node even if the parameter is an obsolete node */
6225  return f;
6226  }
6227  cv = BiddyV(cube);
6228  fv = BiddyV(f);
6229  if (BiddyIsSmaller(biddyOrderingTable,cv,fv)) {
6230  r = BiddyManagedExistAbstract(MNG,f,BiddyT(cube));
6231  r = BiddyManagedTaggedFoaNode(MNG,cv,r,r,cv,TRUE); /* REMOVE THIS LINE TO GET ElementAbstract */
6232  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
6233  }
6234  else if (cv == fv) {
6235  e = BiddyManagedExistAbstract(MNG,
6236  BiddyInvCond(BiddyE(f),BiddyGetMark(f)),BiddyT(cube));
6237  t = BiddyManagedExistAbstract(MNG,BiddyT(f),BiddyT(cube));
6238  r = BiddyManagedOr(MNG,e,t);
6239  r = BiddyManagedTaggedFoaNode(MNG,cv,r,r,cv,TRUE); /* REMOVE THIS LINE TO GET ElementAbstract */
6240  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
6241  } else {
6242  e = BiddyManagedExistAbstract(MNG,
6243  BiddyInvCond(BiddyE(f),BiddyGetMark(f)),cube);
6244  t = BiddyManagedExistAbstract(MNG,BiddyT(f),cube);
6245  r = BiddyManagedTaggedFoaNode(MNG,fv,e,t,fv,TRUE);
6246  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
6247  }
6248  }
6249 
6250  else if (biddyManagerType == BIDDYTYPETZBDD) {
6251  tag = BiddyGetTag(f);
6252  cv = BiddyV(cube);
6253  while (!BiddyIsTerminal(cube) && BiddyIsSmaller(biddyOrderingTable,cv,tag)) {
6254  cube = BiddyT(cube);
6255  cv = BiddyV(cube);
6256  }
6257  if (BiddyIsTerminal(cube)) {
6258  BiddyRefresh(f); /* return non-obsolete node even if the parameter is an obsolete node */
6259  return f;
6260  }
6261  fv = BiddyV(f);
6262 
6263  /* VARIANT 1 */
6264  /*
6265  if (cv == tag) {
6266  if (tag == fv) {
6267  e = BiddyManagedExistAbstract(MNG,BiddyE(f),BiddyT(cube));
6268  t = BiddyManagedExistAbstract(MNG,BiddyT(f),BiddyT(cube));
6269  r = BiddyManagedOr(MNG,e,t);
6270  } else {
6271  r = BiddyManagedIncTag(MNG,f);
6272  r = BiddyManagedExistAbstract(MNG,r,BiddyT(cube));
6273  }
6274  } else if (BiddyIsSmaller(biddyOrderingTable,cv,fv)) {
6275  r = f;
6276  / * BiddyRefresh(r); * / / * return non-obsolete node even if the parameter is an obsolete node * /
6277  BiddySetTag(r,cv);
6278  r = BiddyManagedIncTag(MNG,r);
6279  r = BiddyManagedExistAbstract(MNG,r,BiddyT(cube));
6280  r = BiddyManagedTaggedFoaNode(MNG,cv,r,r,tag,TRUE);
6281  BiddyRefresh(r); / * FoaNode returns an obsolete node! * /
6282  } else if (cv == fv) {
6283  e = BiddyManagedExistAbstract(MNG,BiddyE(f),BiddyT(cube));
6284  t = BiddyManagedExistAbstract(MNG,BiddyT(f),BiddyT(cube));
6285  r = BiddyManagedOr(MNG,e,t);
6286  r = BiddyManagedTaggedFoaNode(MNG,cv,r,r,tag,TRUE);
6287  BiddyRefresh(r); / * FoaNode returns an obsolete node! * /
6288  } else {
6289  e = BiddyManagedExistAbstract(MNG,BiddyE(f),cube);
6290  t = BiddyManagedExistAbstract(MNG,BiddyT(f),cube);
6291  r = BiddyManagedTaggedFoaNode(MNG,fv,e,t,tag,TRUE);
6292  BiddyRefresh(r); / * FoaNode returns an obsolete node! * /
6293  }
6294  */
6295 
6296  /* VARIANT 2 */
6297 
6298  if (cv == fv) {
6299  e = BiddyManagedExistAbstract(MNG,BiddyE(f),BiddyT(cube));
6300  t = BiddyManagedExistAbstract(MNG,BiddyT(f),BiddyT(cube));
6301  r = BiddyManagedOr(MNG,e,t);
6302  if (cv != tag) {
6303  r = BiddyManagedTaggedFoaNode(MNG,cv,r,r,tag,TRUE);
6304  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
6305  }
6306  } else if (BiddyIsSmaller(biddyOrderingTable,cv,fv)) {
6307  if (cv == tag) {
6308  r = BiddyManagedIncTag(MNG,f);
6309  r = BiddyManagedExistAbstract(MNG,r,BiddyT(cube));
6310  } else {
6311  r = f;
6312  /* BiddyRefresh(r); */ /* f may be an obsolete node but this is not a problem here */
6313  BiddySetTag(r,cv);
6314  r = BiddyManagedIncTag(MNG,r);
6315  r = BiddyManagedExistAbstract(MNG,r,BiddyT(cube));
6316  r = BiddyManagedTaggedFoaNode(MNG,cv,r,r,tag,TRUE);
6317  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
6318  }
6319  } else {
6320  e = BiddyManagedExistAbstract(MNG,BiddyE(f),cube);
6321  t = BiddyManagedExistAbstract(MNG,BiddyT(f),cube);
6322  r = BiddyManagedTaggedFoaNode(MNG,fv,e,t,tag,TRUE);
6323  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
6324  }
6325 
6326 
6327  }
6328 #endif
6329 
6330  /* CACHE EVERYTHING */
6331  if (((uintptr_t) f) > ((uintptr_t) biddyOne)) {
6332  addOp3Cache(biddyEACache,biddyOne,f,cube,r,cindex);
6333  } else {
6334  addOp3Cache(biddyEACache,f,biddyOne,cube,r,cindex);
6335  }
6336 
6337  } else {
6338 
6339  /* IF THE RESULT IS FROM CACHE TABLE, REFRESH IT! */
6340  BiddyRefresh(r);
6341 
6342  }
6343 
6344  return r;
6345 }
6346 
6347 /***************************************************************************/
6356 Biddy_Edge
6357 BiddyManagedUnivAbstract(Biddy_Manager MNG, Biddy_Edge f, Biddy_Edge cube)
6358 {
6359  Biddy_Edge r;
6360 
6361  assert( MNG != NULL );
6362  assert( f != NULL );
6363  assert( cube != NULL );
6364 
6365  /* IMPLEMENTED FOR OBDDC, ONLY */
6366  assert( biddyManagerType == BIDDYTYPEOBDDC );
6367 
6368  /* LOOKING FOR SIMPLE CASE */
6369  if (BiddyIsTerminal(f)) return f;
6370 
6371  /* PROCEED BY CALCULATING NOT (EX cube NOT f) */
6372  r = BiddyInv(BiddyManagedExistAbstract(MNG,BiddyInv(f),cube));
6373 
6374  return r;
6375 }
6376 
6377 /***************************************************************************/
6386 Biddy_Edge
6387 BiddyManagedAndAbstract(Biddy_Manager MNG, Biddy_Edge f, Biddy_Edge g,
6388  Biddy_Edge cube)
6389 {
6390  Biddy_Edge f0,f1,g0,g1;
6391  Biddy_Edge e, t, r;
6392  Biddy_Variable fv,gv,minv,cv;
6393  unsigned int cindex;
6394 
6395 #ifndef COMPACT
6396  Biddy_Variable ftag,gtag,mintag;
6397  Biddy_Boolean cgt;
6398 #endif
6399 
6400  assert( MNG != NULL );
6401  assert( f != NULL );
6402  assert( g != NULL );
6403  assert( cube != NULL );
6404 
6405  /* IMPLEMENTED FOR OBDD, OBDDC, ZBDD, ZBDDC, AND TZBDDC */
6406  assert(
6407  (biddyManagerType == BIDDYTYPEOBDD) ||
6408  (biddyManagerType == BIDDYTYPEOBDDC) ||
6409  (biddyManagerType == BIDDYTYPEZBDD) ||
6410  (biddyManagerType == BIDDYTYPEZBDDC) ||
6411  (biddyManagerType == BIDDYTYPETZBDD)
6412  );
6413 
6414  r = biddyNull;
6415 
6416  /* LOOKING FOR SIMPLE CASE */
6417  if ((f == biddyZero) || (g == biddyZero)) {
6418  return biddyZero;
6419  } else if (BiddyIsTerminal(cube)) {
6420  return BiddyManagedAnd(MNG,f,g);
6421  } else if (f == biddyOne) {
6422  return BiddyManagedExistAbstract(MNG,g,cube);
6423  } else if (g == biddyOne) {
6424  return BiddyManagedExistAbstract(MNG,f,cube);
6425  } else if (f == g) {
6426  return BiddyManagedExistAbstract(MNG,f,cube);
6427  }
6428 
6429  if (biddyManagerType == BIDDYTYPEOBDDC) {
6430  if (BiddyIsEqvPointer(f,g)) {
6431  return biddyZero;
6432  }
6433  }
6434 
6435 #ifndef COMPACT
6436  else if (biddyManagerType == BIDDYTYPETZBDD) {
6437  if (BiddyR(f) == BiddyR(g)) {
6438  if (BiddyIsSmaller(biddyOrderingTable,BiddyGetTag(f),BiddyGetTag(g))) {
6439  return BiddyManagedExistAbstract(MNG,f,cube);
6440  } else {
6441  return BiddyManagedExistAbstract(MNG,g,cube);
6442  }
6443  }
6444  }
6445 #endif
6446 
6447  /* NORMALIZATION */
6448  if (((uintptr_t) f) > ((uintptr_t) g)) {
6449  exchangeEdges(&f,&g);
6450  }
6451 
6452  /* IF RESULT IS NOT IN THE CACHE TABLE... */
6453  cindex = 0;
6454  if (!findOp3Cache(biddyEACache,f,g,cube,&r,&cindex))
6455  {
6456 
6457  if ((biddyManagerType == BIDDYTYPEOBDDC) || (biddyManagerType == BIDDYTYPEOBDD)) {
6458  fv = BiddyV(f);
6459  gv = BiddyV(g);
6460  if (BiddyIsSmaller(biddyOrderingTable,fv,gv)) {
6461  f0 = BiddyInvCond(BiddyE(f),BiddyGetMark(f));
6462  f1 = BiddyInvCond(BiddyT(f),BiddyGetMark(f));
6463  g0 = g;
6464  g1 = g;
6465  minv = fv;
6466  } else if (BiddyIsSmaller(biddyOrderingTable,gv,fv)) {
6467  f0 = f;
6468  f1 = f;
6469  g0 = BiddyInvCond(BiddyE(g),BiddyGetMark(g));
6470  g1 = BiddyInvCond(BiddyT(g),BiddyGetMark(g));
6471  minv = gv;
6472  } else {
6473  f0 = BiddyInvCond(BiddyE(f),BiddyGetMark(f));
6474  f1 = BiddyInvCond(BiddyT(f),BiddyGetMark(f));
6475  g0 = BiddyInvCond(BiddyE(g),BiddyGetMark(g));
6476  g1 = BiddyInvCond(BiddyT(g),BiddyGetMark(g));
6477  minv = fv;
6478  }
6479  cv = BiddyV(cube);
6480  while (BiddyIsSmaller(biddyOrderingTable,cv,minv)) {
6481  cube = BiddyT(cube);
6482  cv = BiddyV(cube);
6483  }
6484  /* if (!cv) return BiddyManagedAnd(MNG,f,g); */ /* unnecessary */
6485  if (minv == cv) {
6486  /* Tricky optimizations are from: */
6487  /* B. Yang et al. A Performance Study of BDD-Based Model Checking. 1998. */
6488  /* http://fmv.jku.at/papers/YangEtAl-FMCAD98.pdf */
6489  e = BiddyManagedAndAbstract(MNG,f0,g0,BiddyT(cube));
6490  if (e == biddyOne) return biddyOne;
6491  if ((e == f1) || (e == g1)) {
6492  r = e;
6493  return r; /* I AM NOT SURE IF THIS SHOULD BE CACHED */
6494  } else {
6495  if (e == BiddyInv(f1)) f1 = biddyOne; /* this is useful only for OBDDC, but not wrong for OBDD */
6496  if (e == BiddyInv(g1)) g1 = biddyOne; /* this is useful only for OBDDC, but not wrong for OBDD */
6497  t = BiddyManagedAndAbstract(MNG,f1,g1,BiddyT(cube));
6498  r = BiddyManagedOr(MNG,e,t);
6499  }
6500  } else {
6501  e = BiddyManagedAndAbstract(MNG,f0,g0,cube);
6502  t = BiddyManagedAndAbstract(MNG,f1,g1,cube);
6503  r = BiddyManagedTaggedFoaNode(MNG,minv,e,t,minv,TRUE);
6504  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
6505  }
6506  }
6507 
6508 #ifndef COMPACT
6509  else if ((biddyManagerType == BIDDYTYPEZBDDC) || (biddyManagerType == BIDDYTYPEZBDD)) {
6510  fv = BiddyV(f);
6511  gv = BiddyV(g);
6512  minv = BiddyIsSmaller(biddyOrderingTable,fv,gv) ? fv : gv;
6513  if (fv != gv) {
6514  if (fv == minv) {
6515  if (BiddyGetMark(f)) {
6516  r = BiddyManagedAndAbstract(MNG,BiddyInv(BiddyE(f)),g,cube);
6517  /* return r; */ /* WE ARE CASHING THIS */
6518  } else {
6519  r = BiddyManagedAndAbstract(MNG,BiddyE(f),g,cube);
6520  /* return r; */ /* WE ARE CASHING THIS */
6521  }
6522  } else {
6523  if (BiddyGetMark(g)) {
6524  r = BiddyManagedAndAbstract(MNG,f,BiddyInv(BiddyE(g)),cube);
6525  /* return r; */ /* WE ARE CASHING THIS */
6526  } else {
6527  r = BiddyManagedAndAbstract(MNG,f,BiddyE(g),cube);
6528  /* return r; */ /* WE ARE CASHING THIS */
6529  }
6530  }
6531  } else {
6532  cv = BiddyV(cube);
6533  if (BiddyIsSmaller(biddyOrderingTable,cv,minv)) {
6534  r = BiddyManagedAndAbstract(MNG,f,g,BiddyT(cube));
6535  r = BiddyManagedTaggedFoaNode(MNG,cv,r,r,cv,TRUE);
6536  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
6537  }
6538  else if (cv == minv) {
6539  f0 = BiddyInvCond(BiddyE(f),BiddyGetMark(f));
6540  f1 = BiddyT(f);
6541  g0 = BiddyInvCond(BiddyE(g),BiddyGetMark(g));
6542  g1 = BiddyT(g);
6543  e = BiddyManagedAndAbstract(MNG,f0,g0,BiddyT(cube));
6544  t = BiddyManagedAndAbstract(MNG,f1,g1,BiddyT(cube));
6545  r = BiddyManagedOr(MNG,e,t);
6546  r = BiddyManagedTaggedFoaNode(MNG,cv,r,r,cv,TRUE);
6547  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
6548  } else {
6549  f0 = BiddyInvCond(BiddyE(f),BiddyGetMark(f));
6550  f1 = BiddyT(f);
6551  g0 = BiddyInvCond(BiddyE(g),BiddyGetMark(g));
6552  g1 = BiddyT(g);
6553  e = BiddyManagedAndAbstract(MNG,f0,g0,cube);
6554  t = BiddyManagedAndAbstract(MNG,f1,g1,cube);
6555  r = BiddyManagedTaggedFoaNode(MNG,minv,e,t,minv,TRUE);
6556  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
6557  }
6558  }
6559  }
6560 
6561  else if (biddyManagerType == BIDDYTYPETZBDD) {
6562  ftag = BiddyGetTag(f);
6563  gtag = BiddyGetTag(g);
6564  mintag = BiddyIsSmaller(biddyOrderingTable,ftag,gtag) ? ftag : gtag;
6565  cv = BiddyV(cube);
6566  while (BiddyIsSmaller(biddyOrderingTable,cv,mintag)) {
6567  cube = BiddyT(cube);
6568  cv = BiddyV(cube);
6569  }
6570  /* if (!cv) return BiddyManagedAnd(MNG,f,g); */ /* unnecessary */
6571 
6572  /* VARIANT 1 */
6573  /*
6574  fv = BiddyV(f);
6575  gv = BiddyV(g);
6576  minv = BiddyIsSmaller(biddyOrderingTable,fv,gv) ? fv : gv;
6577  if (BiddyIsSmaller(biddyOrderingTable,fv,gtag)) {
6578  f0 = BiddyE(f);
6579  f1 = BiddyT(f);
6580  g0 = g1 = g;
6581  } else if (BiddyIsSmaller(biddyOrderingTable,gv,ftag)) {
6582  f0 = f1 = f;
6583  g0 = BiddyE(g);
6584  g1 = BiddyT(g);
6585  } else {
6586  if (minv == fv) {
6587  f0 = BiddyE(f);
6588  f1 = BiddyT(f);
6589  } else {
6590  f0 = f;
6591  BiddySetTag(f0,minv);
6592  f0 = BiddyManagedIncTag(MNG,f0);
6593  f1 = biddyZero;
6594  }
6595  if (minv == gv) {
6596  g0 = BiddyE(g);
6597  g1 = BiddyT(g);
6598  } else {
6599  g0 = g;
6600  BiddySetTag(g0,minv);
6601  g0 = BiddyManagedIncTag(MNG,g0);
6602  g1 = biddyZero;
6603  }
6604  }
6605  if (BiddyIsSmaller(biddyOrderingTable,minv,cv)) {
6606  e = BiddyManagedAndAbstract(MNG,f0,g0,cube);
6607  t = BiddyManagedAndAbstract(MNG,f1,g1,cube);
6608  } else {
6609  e = BiddyManagedAndAbstract(MNG,f0,g0,BiddyT(cube));
6610  t = BiddyManagedAndAbstract(MNG,f1,g1,BiddyT(cube));
6611  }
6612  if (cv == mintag) {
6613  if (minv == mintag) {
6614  r = BiddyManagedOr(MNG,e,t);
6615  } else {
6616  r = BiddyManagedTaggedFoaNode(MNG,minv,e,t,mintag,TRUE);
6617  BiddyRefresh(r); / * FoaNode returns an obsolete node! * /
6618  if (r != biddyZero) r = BiddyManagedIncTag(MNG,r);
6619  }
6620  } else if (BiddyIsSmaller(biddyOrderingTable,cv,minv)) {
6621  r = BiddyManagedTaggedFoaNode(MNG,minv,e,t,cv,TRUE);
6622  BiddyRefresh(r); / * FoaNode returns an obsolete node! * /
6623  r = BiddyManagedIncTag(MNG,r);
6624  r = BiddyManagedTaggedFoaNode(MNG,cv,r,r,mintag,TRUE);
6625  BiddyRefresh(r); / * FoaNode returns an obsolete node! * /
6626  } else if (cv == minv) {
6627  r = BiddyManagedOr(MNG,e,t);
6628  r = BiddyManagedTaggedFoaNode(MNG,cv,r,r,mintag,TRUE);
6629  BiddyRefresh(r); / * FoaNode returns an obsolete node! * /
6630  } else {
6631  r = BiddyManagedTaggedFoaNode(MNG,minv,e,t,mintag,TRUE);
6632  BiddyRefresh(r); / * FoaNode returns an obsolete node! * /
6633  }
6634  */
6635 
6636  /* VARIANT 2 */
6637  fv = BiddyV(f);
6638  gv = BiddyV(g);
6639  minv = BiddyIsSmaller(biddyOrderingTable,fv,gv) ? fv : gv;
6640  if (BiddyIsSmaller(biddyOrderingTable,minv,ftag)) {
6641  f0 = f1 = f;
6642  } else if (minv == fv) {
6643  f0 = BiddyE(f);
6644  f1 = BiddyT(f);
6645  } else {
6646  f0 = f;
6647  BiddySetTag(f0,minv);
6648  f0 = BiddyManagedIncTag(MNG,f0);
6649  f1 = biddyZero;
6650  }
6651  if (BiddyIsSmaller(biddyOrderingTable,minv,gtag)) {
6652  g0 = g1 = g;
6653  } else if (minv == gv) {
6654  g0 = BiddyE(g);
6655  g1 = BiddyT(g);
6656  } else {
6657  g0 = g;
6658  BiddySetTag(g0,minv);
6659  g0 = BiddyManagedIncTag(MNG,g0);
6660  g1 = biddyZero;
6661  }
6662  cgt = BiddyIsSmaller(biddyOrderingTable,minv,cv);
6663  if (f0 == biddyZero) {
6664  e = biddyZero;
6665  } else if (g0 == biddyZero) {
6666  e = biddyZero;
6667  } else {
6668  e = BiddyManagedAndAbstract(MNG,f0,g0,cgt?cube:BiddyT(cube));
6669  }
6670  if (f1 == biddyZero) {
6671  t = biddyZero;
6672  } else if (g1 == biddyZero) {
6673  t = biddyZero;
6674  } else {
6675  t = BiddyManagedAndAbstract(MNG,f1,g1,cgt?cube:BiddyT(cube));
6676  }
6677 
6678  /* VARIANT 2A */
6679  /*
6680  if (cv == mintag) {
6681  if (minv == mintag) {
6682  r = BiddyManagedOr(MNG,e,t);
6683  } else {
6684  r = BiddyManagedTaggedFoaNode(MNG,minv,e,t,mintag,TRUE);
6685  BiddyRefresh(r); / * FoaNode returns an obsolete node! * /
6686  if (r != biddyZero) r = BiddyManagedIncTag(MNG,r);
6687  }
6688  } else if (BiddyIsSmaller(biddyOrderingTable,cv,minv)) {
6689  r = BiddyManagedTaggedFoaNode(MNG,minv,e,t,cv,TRUE);
6690  BiddyRefresh(r); / * FoaNode returns an obsolete node! * /
6691  if (r != biddyZero) r = BiddyManagedIncTag(MNG,r);
6692  r = BiddyManagedTaggedFoaNode(MNG,cv,r,r,mintag,TRUE);
6693  BiddyRefresh(r); / * FoaNode returns an obsolete node! * /
6694  } else if (cv == minv) {
6695  r = BiddyManagedOr(MNG,e,t);
6696  r = BiddyManagedTaggedFoaNode(MNG,cv,r,r,mintag,TRUE);
6697  BiddyRefresh(r); / * FoaNode returns an obsolete node! * /
6698  } else {
6699  r = BiddyManagedTaggedFoaNode(MNG,minv,e,t,mintag,TRUE);
6700  BiddyRefresh(r); / * FoaNode returns an obsolete node! * /
6701  }
6702  */
6703 
6704  /* VARIANT 2B */
6705  if (BiddyIsSmaller(biddyOrderingTable,cv,minv)) {
6706  r = BiddyManagedTaggedFoaNode(MNG,minv,e,t,cv,TRUE);
6707  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
6708  if (r != biddyZero) r = BiddyManagedIncTag(MNG,r);
6709  if (cv != mintag) {
6710  r = BiddyManagedTaggedFoaNode(MNG,cv,r,r,mintag,TRUE);
6711  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
6712  }
6713  } else if (cv == minv) {
6714  r = BiddyManagedOr(MNG,e,t);
6715  if (cv != mintag) {
6716  r = BiddyManagedTaggedFoaNode(MNG,cv,r,r,mintag,TRUE);
6717  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
6718  }
6719  } else {
6720  r = BiddyManagedTaggedFoaNode(MNG,minv,e,t,mintag,TRUE);
6721  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
6722  }
6723 
6724  }
6725 #endif
6726 
6727  /* CACHE EVERYTHING */
6728  addOp3Cache(biddyEACache,f,g,cube,r,cindex);
6729 
6730  } else {
6731 
6732  /* IF THE RESULT IS FROM CACHE TABLE, REFRESH IT! */
6733  BiddyRefresh(r);
6734 
6735  }
6736 
6737  return r;
6738 }
6739 
6740 /***************************************************************************/
6749 Biddy_Edge
6750 BiddyManagedConstrain(Biddy_Manager MNG, Biddy_Edge f, Biddy_Edge c)
6751 {
6752  Biddy_Edge f0,f1,c0,c1;
6753  Biddy_Edge e, t, r;
6754  Biddy_Variable fv,cv,minv;
6755 
6756  assert( MNG != NULL );
6757  assert( f != NULL );
6758  assert( c != NULL );
6759 
6760  /* IMPLEMENTED FOR OBDD AND OBDDC */
6761  assert(
6762  (biddyManagerType == BIDDYTYPEOBDD) ||
6763  (biddyManagerType == BIDDYTYPEOBDDC)
6764  );
6765 
6766  r = biddyNull;
6767 
6768  /* LOOKING FOR SIMPLE CASE */
6769  if (c == biddyZero) {
6770  return biddyZero;
6771  } else if (c == biddyOne) {
6772  BiddyRefresh(f); /* return non-obsolete node even if the parameter is an obsolete node */
6773  return f;
6774  } else if (BiddyIsTerminal(f)) {
6775  return f;
6776  }
6777 
6778  fv = BiddyV(f);
6779  cv = BiddyV(c);
6780 
6781  if (BiddyIsSmaller(biddyOrderingTable,fv,cv)) {
6782  f0 = BiddyInvCond(BiddyE(f),BiddyGetMark(f));
6783  f1 = BiddyInvCond(BiddyT(f),BiddyGetMark(f));
6784  c0 = c;
6785  c1 = c;
6786  minv = fv;
6787  } else if (BiddyIsSmaller(biddyOrderingTable,cv,fv)) {
6788  f0 = f;
6789  f1 = f;
6790  c0 = BiddyInvCond(BiddyE(c),BiddyGetMark(c));
6791  c1 = BiddyInvCond(BiddyT(c),BiddyGetMark(c));
6792  minv = cv;
6793  } else {
6794  f0 = BiddyInvCond(BiddyE(f),BiddyGetMark(f));
6795  f1 = BiddyInvCond(BiddyT(f),BiddyGetMark(f));
6796  c0 = BiddyInvCond(BiddyE(c),BiddyGetMark(c));
6797  c1 = BiddyInvCond(BiddyT(c),BiddyGetMark(c));
6798  minv = cv;
6799  }
6800 
6801  if (c0 == biddyZero) return BiddyManagedConstrain(MNG,f1,c1);
6802  if (c1 == biddyZero) return BiddyManagedConstrain(MNG,f0,c0);
6803 
6804  e = BiddyManagedConstrain(MNG,f0,c0);
6805  t = BiddyManagedConstrain(MNG,f1,c1);
6806  r = BiddyManagedITE(MNG,biddyVariableTable.table[minv].variable,t,e);
6807 
6808  return r;
6809 }
6810 
6811 /***************************************************************************/
6820 Biddy_Edge
6821 BiddyManagedSimplify(Biddy_Manager MNG, Biddy_Edge f, Biddy_Edge c)
6822 {
6823  Biddy_Edge f0,f1,c0,c1;
6824  Biddy_Edge e, t, r;
6825  Biddy_Variable fv,cv,minv;
6826 
6827  assert( MNG != NULL );
6828  assert( f != NULL );
6829  assert( c != NULL );
6830 
6831  /* IMPLEMENTED FOR OBDD AND OBDDC */
6832  assert(
6833  (biddyManagerType == BIDDYTYPEOBDD) ||
6834  (biddyManagerType == BIDDYTYPEOBDDC)
6835  );
6836 
6837  r = biddyNull;
6838 
6839  /* LOOKING FOR SIMPLE CASE */
6840  if (c == biddyZero) return biddyNull;
6841  if (c == biddyOne) {
6842  BiddyRefresh(f); /* return non-obsolete node even if the parameter is an obsolete node */
6843  return f;
6844  } else if (BiddyIsTerminal(f)) {
6845  return f;
6846  }
6847 
6848  /* THIS IS FROM 20-CS-626-001 */
6849  /* http://gauss.ececs.uc.edu/Courses/c626/lectures/BDD/bdd-desc.pdf */
6850  if (f == c) return biddyOne;
6851  if (biddyManagerType == BIDDYTYPEOBDDC) {
6852  if (BiddyIsEqvPointer(f,c)) {
6853  return biddyZero;
6854  }
6855  }
6856 
6857  fv = BiddyV(f);
6858  cv = BiddyV(c);
6859 
6860  /* SPECIAL CASE: f/~a == f/a */
6861  if (BiddyIsSmaller(biddyOrderingTable,cv,fv)) {
6862  return BiddyManagedSimplify(MNG,f,BiddyManagedE(MNG,c,cv));
6863  }
6864 
6865  if (BiddyIsSmaller(biddyOrderingTable,fv,cv)) {
6866  f0 = BiddyInvCond(BiddyE(f),BiddyGetMark(f));
6867  f1 = BiddyInvCond(BiddyT(f),BiddyGetMark(f));
6868  c0 = c;
6869  c1 = c;
6870  minv = fv;
6871  } else {
6872  f0 = BiddyInvCond(BiddyE(f),BiddyGetMark(f));
6873  f1 = BiddyInvCond(BiddyT(f),BiddyGetMark(f));
6874  c0 = BiddyInvCond(BiddyE(c),BiddyGetMark(c));
6875  c1 = BiddyInvCond(BiddyT(c),BiddyGetMark(c));
6876  minv = cv;
6877  }
6878 
6879  if (c0 == biddyZero) return BiddyManagedSimplify(MNG,f1,c1);
6880  if (c1 == biddyZero) return BiddyManagedSimplify(MNG,f0,c0);
6881 
6882  e = BiddyManagedSimplify(MNG,f0,c0);
6883  t = BiddyManagedSimplify(MNG,f1,c1);
6884  r = BiddyManagedITE(MNG,biddyVariableTable.table[minv].variable,t,e);
6885 
6886  return r;
6887 }
6888 
6889 /***************************************************************************/
6898 Biddy_Edge
6899 BiddyManagedSupport(Biddy_Manager MNG, Biddy_Edge f)
6900 {
6901  Biddy_Variable v;
6902  unsigned int n;
6903  Biddy_Edge s;
6904 
6905  assert( MNG != NULL );
6906 
6907  /* IMPLEMENTED FOR OBDD, OBDDC, ZBDDC, and TZBDD */
6908  assert(
6909  (biddyManagerType == BIDDYTYPEOBDD) ||
6910  (biddyManagerType == BIDDYTYPEOBDDC) ||
6911  (biddyManagerType == BIDDYTYPEZBDD) ||
6912  (biddyManagerType == BIDDYTYPEZBDDC) ||
6913  (biddyManagerType == BIDDYTYPETZBDD)
6914  );
6915 
6916  if (BiddyIsNull(f)) return biddyNull;
6917  if (BiddyIsTerminal(f)) return biddyZero;
6918 
6919  /* MAKE VARIABLES UNSELECTED */
6920  /*
6921  for (v=1;v<biddyVariableTable.num;v++) {
6922  biddyVariableTable.table[v].selected = FALSE;
6923  }
6924  */
6925 
6926  if ((biddyManagerType == BIDDYTYPEOBDDC) || (biddyManagerType == BIDDYTYPEOBDD)) {
6927  n = 1; /* NUMBER OF NODES NOT NEEDED, BUT NODES ARE COUNTED BY BiddyNodeVarNumber */
6928  BiddyManagedSelectNode(MNG,biddyTerminal); /* for OBDDs, this is needed for BiddyNodeVarNumber */
6929  BiddyNodeVarNumber(MNG,f,&n); /* DEPENDENT VARIABLES ARE MARKED, all nodes are selected */
6930  BiddyManagedDeselectAll(MNG);
6931  }
6932 #ifndef COMPACT
6933  else if ((biddyManagerType == BIDDYTYPEZBDDC) || (biddyManagerType == BIDDYTYPEZBDD)) {
6934  BiddyCreateLocalInfo(MNG,f); /* FOR ZBDDs, localinfo IS USED BY BiddyNodeVarNumber */
6935  n = 1; /* NUMBER OF NODES NOT NEEDED, BUT NODES ARE COUNTED BY BiddyNodeVarNumber */
6936  BiddyNodeVarNumber(MNG,f,&n); /* DEPENDENT VARIABLES ARE MARKED, selects all except terminal node */
6937  BiddyDeleteLocalInfo(MNG,f); /* FOR ZBDDs, localinfo IS USED BY BiddyNodeVarNumber */
6938  }
6939  else if (biddyManagerType == BIDDYTYPETZBDD) {
6940  n = 1; /* NUMBER OF NODES NOT NEEDED, BUT NODES ARE COUNTED BY BiddyNodeVarNumber */
6941  BiddyManagedSelectNode(MNG,biddyTerminal); /* for TZBDDs, this is needed for BiddyNodeVarNumber */
6942  BiddyNodeVarNumber(MNG,f,&n); /* DEPENDENT VARIABLES ARE MARKED, all nodes are selected */
6943  BiddyManagedDeselectAll(MNG);
6944  }
6945 #endif
6946 
6947  s = biddyNull;
6948  if ((biddyManagerType == BIDDYTYPEOBDDC) || (biddyManagerType == BIDDYTYPEOBDD)) {
6949  s = biddyOne;
6950  for (v=1;v<biddyVariableTable.num;v++) {
6951  if (biddyVariableTable.table[v].selected == TRUE) {
6952  s = BiddyManagedAnd(MNG,s,biddyVariableTable.table[v].variable);
6953  biddyVariableTable.table[v].selected = FALSE;
6954  }
6955  }
6956  }
6957 #ifndef COMPACT
6958  else if ((biddyManagerType == BIDDYTYPEZBDDC) || (biddyManagerType == BIDDYTYPEZBDD)) {
6959  s = biddyTerminal; /* this is base set */
6960  for (v=1;v<biddyVariableTable.num;v++) {
6961  /* variables above the top variable (which are always all dependent) are not selected, yet */
6962  if (BiddyIsSmaller(biddyOrderingTable,v,BiddyV(f))) biddyVariableTable.table[v].selected = TRUE;
6963  if (biddyVariableTable.table[v].selected == TRUE)
6964  {
6965  s = BiddyManagedChange(MNG,s,v);
6966  biddyVariableTable.table[v].selected = FALSE;
6967  }
6968  }
6969  }
6970  else if (biddyManagerType == BIDDYTYPETZBDD) {
6971  s = biddyOne;
6972  for (v=1;v<biddyVariableTable.num;v++) {
6973  if (biddyVariableTable.table[v].selected == TRUE) {
6974  s = BiddyManagedAnd(MNG,s,biddyVariableTable.table[v].variable);
6975  biddyVariableTable.table[v].selected = FALSE;
6976  }
6977  }
6978  /* variables above the top variable which are equal or greater than the top tag are also dependent */
6979  v = BiddyGetTag(f);
6980  while (BiddyIsSmaller(biddyOrderingTable,v,BiddyV(f))) {
6981  s = BiddyManagedAnd(MNG,s,biddyVariableTable.table[v].variable);
6982  v = biddyVariableTable.table[v].next;
6983  }
6984  }
6985 #endif
6986 
6987  return s;
6988 }
6989 
6990 /***************************************************************************/
6999 Biddy_Edge
7000 BiddyManagedReplaceByKeyword(Biddy_Manager MNG, Biddy_Edge f,
7001  Biddy_String keyword)
7002 {
7003  Biddy_Edge r;
7004  unsigned int key;
7005  Biddy_Boolean OK;
7006  int cc;
7007  const Biddy_Boolean disableCache = FALSE;
7008 
7009  assert( MNG != NULL );
7010 
7011  /* IMPLEMENTED FOR OBDD, OBDDC, and TZBDD */
7012  assert(
7013  (biddyManagerType == BIDDYTYPEOBDD) ||
7014  (biddyManagerType == BIDDYTYPEOBDDC) ||
7015  (biddyManagerType == BIDDYTYPETZBDD)
7016  );
7017 
7018  if (f == biddyZero) return biddyZero;
7019  if (f == biddyOne) return biddyOne;
7020 
7021  r = biddyNull;
7022 
7023  /* find keyword in keywordList */
7024 
7025  /* VARIANT A: LINEAR SEARCH */
7026  key = 0;
7027  if (!disableCache && keyword) {
7028  OK = FALSE;
7029  if (biddyReplaceCache.keywordList) {
7030  for (key = 0; !OK && (key < biddyReplaceCache.keywordNum); key++) {
7031  cc = strcmp(keyword,biddyReplaceCache.keywordList[key]);
7032  if (cc == 0) {
7033  OK = TRUE;
7034  break;
7035  }
7036  if (cc < 0) break;
7037  }
7038  }
7039  }
7040 
7041  /* TO DO: BINARY SEARCH */
7042  /* NOT IMPORTANT BECAUSE NUMBER OF KEYWORDS IS VERY SMALL IN THE PRACTICE */
7043 
7044  if (disableCache || !keyword) {
7045  /* keyword not given */
7046  key = ++biddyReplaceCache.keyNum;
7047  } else {
7048  /* keyword given but not found - it will be added */
7049  if (!OK) {
7050  Biddy_String *tmp1;
7051  unsigned int *tmp2;
7052 
7053  biddyReplaceCache.keywordNum++;
7054  if (!(tmp1 = (Biddy_String *)
7055  realloc(biddyReplaceCache.keywordList,biddyReplaceCache.keywordNum*sizeof(Biddy_String))))
7056  {
7057  fprintf(stderr,"BiddyManagedReplaceByKeyword: Out of memoy!\n");
7058  exit(1);
7059  }
7060  biddyReplaceCache.keywordList = tmp1;
7061  if (!(tmp2 = (unsigned int *)
7062  realloc(biddyReplaceCache.keyList,biddyReplaceCache.keywordNum*sizeof(unsigned int))))
7063  {
7064  fprintf(stderr,"BiddyManagedReplaceByKeyword: Out of memoy!\n");
7065  exit(1);
7066  }
7067  biddyReplaceCache.keyList = tmp2;
7068 
7069  memmove(&biddyReplaceCache.keywordList[key+1],&biddyReplaceCache.keywordList[key],(biddyReplaceCache.keywordNum-key-1)*sizeof(Biddy_String));
7070  memmove(&biddyReplaceCache.keyList[key+1],&biddyReplaceCache.keyList[key],(biddyReplaceCache.keywordNum-key-1)*sizeof(unsigned int));
7071  /*
7072  for (i = biddyReplaceCache.keywordNum-1; i > key; i--) {
7073  biddyReplaceCache.keywordList[i] = biddyReplaceCache.keywordList[i-1];
7074  biddyReplaceCache.keyList[i] = biddyReplaceCache.keyList[i-1];
7075  }
7076  */
7077 
7078  biddyReplaceCache.keywordList[key] = strdup(keyword);
7079  biddyReplaceCache.keyList[key] = ++biddyReplaceCache.keyNum;
7080  }
7081  key = biddyReplaceCache.keyList[key];
7082  }
7083 
7084  /* DEBUGGING */
7085  /*
7086  fprintf(stderr,"ReplaceByKeyword: keyword = %s, key = %u\n",keyword,key);
7087  */
7088 
7089  if (biddyManagerType == BIDDYTYPEOBDD) {
7090  if (!disableCache && !key) BiddyReplaceGarbageDeleteAll(MNG); /* purge Replace cache */
7091  r = replaceByKeyword(MNG,f,0,key);
7092  } else if (biddyManagerType == BIDDYTYPEOBDDC) {
7093  if (!disableCache && !key) BiddyReplaceGarbageDeleteAll(MNG); /* purge Replace cache */
7094  r = replaceByKeyword(MNG,f,0,key);
7095  }
7096 #ifndef COMPACT
7097  else if (biddyManagerType == BIDDYTYPEZBDD) {
7098  /* NOT COMPLETELY IMPLEMENTED, YET */
7099  /*
7100  if (!disableCache && !key) BiddyReplaceGarbageDeleteAll(MNG); / * purge Replace cache * /
7101  r = replaceByKeyword(MNG,f,BiddyManagedGetLowestVariable(MNG),key);
7102  */
7103  } else if (biddyManagerType == BIDDYTYPEZBDDC) {
7104  /* NOT COMPLETELY IMPLEMENTED, YET */
7105  /*
7106  if (!disableCache && !key) BiddyReplaceGarbageDeleteAll(MNG); / * purge Replace cache * /
7107  r = replaceByKeyword(MNG,f,BiddyManagedGetLowestVariable(MNG),key);
7108  */
7109  } else if (biddyManagerType == BIDDYTYPETZBDD) {
7110  if (!disableCache && !key) BiddyReplaceGarbageDeleteAll(MNG); /* purge Replace cache */
7111  r = replaceByKeyword(MNG,f,0,key);
7112  }
7113 #endif
7114 
7115  return r;
7116 }
7117 
7118 /***************************************************************************/
7127 Biddy_Edge
7128 BiddyManagedChange(Biddy_Manager MNG, Biddy_Edge f, Biddy_Variable v)
7129 {
7130  Biddy_Edge e,t,r;
7131  Biddy_Variable fv;
7132  Biddy_Edge FF, GG, HH;
7133  unsigned int cindex;
7134 
7135 #ifndef COMPACT
7136  Biddy_Variable tag;
7137 #endif
7138 
7139  assert( MNG != NULL );
7140  assert( f != NULL );
7141  assert( v != 0);
7142 
7143  /* IMPLEMENTED FOR OBDD, OBDDC, ZBDD, ZBDDC, AND TZBDD */
7144  assert(
7145  (biddyManagerType == BIDDYTYPEOBDD) ||
7146  (biddyManagerType == BIDDYTYPEOBDDC) ||
7147  (biddyManagerType == BIDDYTYPEZBDD) ||
7148  (biddyManagerType == BIDDYTYPEZBDDC) ||
7149  (biddyManagerType == BIDDYTYPETZBDD)
7150  );
7151 
7152  if (f == biddyZero) return biddyZero;
7153 
7154  r = biddyNull;
7155 
7156  FF = f;
7157  GG = biddyNull;
7158  HH = biddyNull;
7159 
7160  if ((biddyManagerType == BIDDYTYPEOBDDC) || (biddyManagerType == BIDDYTYPEOBDD)) {
7161  HH = biddyVariableTable.table[v].variable;
7162  }
7163 #ifndef COMPACT
7164  else if ((biddyManagerType == BIDDYTYPEZBDDC) || (biddyManagerType == BIDDYTYPEZBDD)) {
7165  HH = biddyVariableTable.table[v].element;
7166  }
7167  else if (biddyManagerType == BIDDYTYPETZBDD) {
7168  HH = biddyVariableTable.table[v].variable;
7169  }
7170 #endif
7171 
7172  /* IF RESULT IS NOT IN THE CACHE TABLE... */
7173  /* TO DO: CHECK ONLY IF IT IS POSSIBLE TO EXIST IN THE CACHE */
7174  cindex = 0;
7175  if (!findOp3Cache(biddyRCCache,FF,GG,HH,&r,&cindex))
7176  {
7177 
7178  if ((biddyManagerType == BIDDYTYPEOBDDC) || (biddyManagerType == BIDDYTYPEOBDD)) {
7179  fv = BiddyV(f);
7180  if (v == fv) {
7181  e = BiddyInvCond(BiddyT(f),BiddyGetMark(f));
7182  t = BiddyInvCond(BiddyE(f),BiddyGetMark(f));
7183  r = BiddyManagedTaggedFoaNode(MNG,v,e,t,v,TRUE);
7184  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
7185  } else if (BiddyIsSmaller(biddyOrderingTable,v,fv)) {
7186  r = f;
7187  BiddyRefresh(r); /* return non-obsolete node even if the parameter is an obsolete node */
7188  } else {
7189  e = BiddyManagedChange(MNG,BiddyInvCond(BiddyE(f),BiddyGetMark(f)),v);
7190  t = BiddyManagedChange(MNG,BiddyInvCond(BiddyT(f),BiddyGetMark(f)),v);
7191  r = BiddyManagedTaggedFoaNode(MNG,fv,e,t,fv,TRUE);
7192  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
7193  addOp3Cache(biddyRCCache,FF,GG,HH,r,cindex);
7194  }
7195  }
7196 
7197 #ifndef COMPACT
7198  else if ((biddyManagerType == BIDDYTYPEZBDDC) || (biddyManagerType == BIDDYTYPEZBDD)) {
7199  fv = BiddyV(f);
7200  if (v == fv) {
7201  e = BiddyT(f);
7202  t = BiddyInvCond(BiddyE(f),BiddyGetMark(f));
7203  r = BiddyManagedTaggedFoaNode(MNG,v,e,t,v,TRUE);
7204  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
7205  } else if (BiddyIsSmaller(biddyOrderingTable,v,fv)) {
7206  r = BiddyManagedTaggedFoaNode(MNG,v,biddyZero,f,v,TRUE);
7207  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
7208  } else {
7209  e = BiddyManagedChange(MNG,BiddyInvCond(BiddyE(f),BiddyGetMark(f)),v);
7210  t = BiddyManagedChange(MNG,BiddyT(f),v);
7211  r = BiddyManagedTaggedFoaNode(MNG,fv,e,t,fv,TRUE);
7212  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
7213  addOp3Cache(biddyRCCache,FF,GG,HH,r,cindex);
7214  }
7215  }
7216 
7217  else if (biddyManagerType == BIDDYTYPETZBDD) {
7218  tag = BiddyGetTag(f);
7219  if (BiddyIsSmaller(biddyOrderingTable,v,tag)) {
7220  r = f;
7221  BiddyRefresh(r); /* return non-obsolete node even if the parameter is an obsolete node */
7222  } else {
7223  fv = BiddyV(f);
7224  if (v == fv) {
7225  e = BiddyT(f);
7226  t = BiddyE(f);
7227  r = BiddyManagedTaggedFoaNode(MNG,v,e,t,tag,TRUE);
7228  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
7229  } else if (BiddyIsSmaller(biddyOrderingTable,v,fv)) {
7230  r = f;
7231  /* BiddyRefresh(r); */ /* f may be an obsolete node but this is not a problem here */
7232  BiddySetTag(r,v);
7233  r = BiddyManagedIncTag(MNG,r);
7234  r = BiddyManagedTaggedFoaNode(MNG,v,biddyZero,r,tag,TRUE);
7235  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
7236  } else {
7237  e = BiddyManagedChange(MNG,BiddyE(f),v);
7238  t = BiddyManagedChange(MNG,BiddyT(f),v);
7239  r = BiddyManagedTaggedFoaNode(MNG,fv,e,t,tag,TRUE);
7240  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
7241  addOp3Cache(biddyRCCache,FF,GG,HH,r,cindex);
7242  }
7243  }
7244  }
7245 #endif
7246 
7247  } else {
7248 
7249  /* IF THE RESULT IS FROM CACHE TABLE, REFRESH IT! */
7250  BiddyRefresh(r);
7251 
7252  }
7253 
7254  return r;
7255 }
7256 
7257 /***************************************************************************/
7266 Biddy_Edge
7267 BiddyManagedVarSubset(Biddy_Manager MNG, Biddy_Edge f, Biddy_Variable v,
7268  Biddy_Boolean value)
7269 {
7270  Biddy_Edge h;
7271  Biddy_Edge e, t, r;
7272  Biddy_Variable fv;
7273  Biddy_Edge FF, GG, HH;
7274  unsigned int cindex;
7275 
7276 #ifndef COMPACT
7277  Biddy_Variable tag,ntag;
7278 #endif
7279 
7280  assert( MNG != NULL );
7281  assert( f != NULL );
7282  assert( v != 0);
7283 
7284  /* IMPLEMENTED FOR OBDD, OBDDC, ZBDD, ZBDDC, AND TZBDD */
7285  assert(
7286  (biddyManagerType == BIDDYTYPEOBDD) ||
7287  (biddyManagerType == BIDDYTYPEOBDDC) ||
7288  (biddyManagerType == BIDDYTYPEZBDD) ||
7289  (biddyManagerType == BIDDYTYPEZBDDC) ||
7290  (biddyManagerType == BIDDYTYPETZBDD)
7291  );
7292 
7293  if (f == biddyZero) return biddyZero;
7294 
7295  r = biddyNull;
7296 
7297  FF = biddyNull;
7298  GG = biddyNull;
7299  HH = biddyNull;
7300  h = biddyNull;
7301 
7302  if ((biddyManagerType == BIDDYTYPEOBDDC) || (biddyManagerType == BIDDYTYPEOBDD)) {
7303  h = biddyVariableTable.table[v].variable;
7304  }
7305 #ifndef COMPACT
7306  else if ((biddyManagerType == BIDDYTYPEZBDDC) || (biddyManagerType == BIDDYTYPEZBDD)) {
7307  h = biddyVariableTable.table[v].element;
7308  }
7309  else if (biddyManagerType == BIDDYTYPETZBDD) {
7310  h = biddyVariableTable.table[v].variable;
7311  }
7312 #endif
7313 
7314  if (!value) {
7315  h = BiddyManagedNot(MNG,h);
7316  }
7317 
7318  /* TO DO: CACHE TABLE FOR OBDDC COULD BE OPTIMIZED BY USING COMPLEMENTED EDGES */
7319  if (biddyManagerType == BIDDYTYPEOBDDC) {
7320  if (((uintptr_t) f) > ((uintptr_t) h)) {
7321  FF = f;
7322  GG = h;
7323  HH = biddyZero;
7324  } else {
7325  FF = h;
7326  GG = f;
7327  HH = biddyZero;
7328  }
7329  }
7330  else {
7331  if (((uintptr_t) f) > ((uintptr_t) h)) {
7332  FF = f;
7333  GG = h;
7334  HH = biddyZero;
7335  } else {
7336  FF = h;
7337  GG = f;
7338  HH = biddyZero;
7339  }
7340  }
7341 
7342  /* IF RESULT IS NOT IN THE CACHE TABLE... */
7343  /* TO DO: CHECK ONLY IF IT IS POSSIBLE TO EXIST IN THE CACHE */
7344  cindex = 0;
7345  if (!findOp3Cache(biddyOPCache,FF,GG,HH,&r,&cindex))
7346  {
7347  if ((biddyManagerType == BIDDYTYPEOBDDC) || (biddyManagerType == BIDDYTYPEOBDD)) {
7348  if ((fv=BiddyV(f)) == v) {
7349  if (value) {
7350  r = BiddyManagedTaggedFoaNode(MNG,v,biddyZero,BiddyInvCond(BiddyT(f),BiddyGetMark(f)),v,TRUE);
7351  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
7352  } else {
7353  r = BiddyManagedTaggedFoaNode(MNG,v,BiddyInvCond(BiddyE(f),BiddyGetMark(f)),biddyZero,v,TRUE);
7354  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
7355  }
7356  }
7357  else if (BiddyIsSmaller(biddyOrderingTable,v,fv)) {
7358  if (value) {
7359  r = BiddyManagedTaggedFoaNode(MNG,v,biddyZero,f,v,TRUE);
7360  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
7361  } else {
7362  r = BiddyManagedTaggedFoaNode(MNG,v,f,biddyZero,v,TRUE);
7363  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
7364  }
7365  } else {
7366  e = BiddyManagedVarSubset(MNG,BiddyInvCond(BiddyE(f),BiddyGetMark(f)),v,value);
7367  t = BiddyManagedVarSubset(MNG,BiddyInvCond(BiddyT(f),BiddyGetMark(f)),v,value);
7368  r = BiddyManagedTaggedFoaNode(MNG,fv,e,t,fv,TRUE);
7369  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
7370  addOp3Cache(biddyOPCache,FF,GG,HH,r,cindex);
7371  }
7372  }
7373 
7374 #ifndef COMPACT
7375  else if ((biddyManagerType == BIDDYTYPEZBDDC) || (biddyManagerType == BIDDYTYPEZBDD)) {
7376  if ((fv=BiddyV(f)) == v) {
7377  if (value) {
7378  r = BiddyManagedTaggedFoaNode(MNG,v,biddyZero,BiddyT(f),v,TRUE);
7379  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
7380  } else {
7381  r = BiddyInvCond(BiddyE(f),BiddyGetMark(f));
7382  BiddyRefresh(r); /* subnode may be marked as an obsolete node! */
7383  }
7384  }
7385  else if (BiddyIsSmaller(biddyOrderingTable,v,fv)) {
7386  if (value) {
7387  r = biddyZero;
7388  } else {
7389  r = f;
7390  BiddyRefresh(r); /* return non-obsolete node even if the parameter is an obsolete node */
7391  }
7392  } else {
7393  e = BiddyManagedVarSubset(MNG,BiddyInvCond(BiddyE(f),BiddyGetMark(f)),v,value);
7394  t = BiddyManagedVarSubset(MNG,BiddyT(f),v,value);
7395  r = BiddyManagedTaggedFoaNode(MNG,fv,e,t,fv,TRUE);
7396  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
7397  addOp3Cache(biddyOPCache,FF,GG,HH,r,cindex);
7398  }
7399  }
7400 
7401  else if (biddyManagerType == BIDDYTYPETZBDD) {
7402  tag = BiddyGetTag(f);
7403  if (BiddyIsSmaller(biddyOrderingTable,v,tag)) {
7404  if (value) {
7405  r = BiddyManagedTaggedFoaNode(MNG,v,biddyZero,f,v,TRUE);
7406  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
7407  } else {
7408  ntag = biddyVariableTable.table[v].next;
7409  if (tag == ntag) {
7410  r = f;
7411  BiddyRefresh(r); /* return non-obsolete node even if the parameter is an obsolete node */
7412  BiddySetTag(r,v);
7413  } else {
7414  r = BiddyManagedTaggedFoaNode(MNG,ntag,f,f,v,TRUE);
7415  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
7416  }
7417  }
7418  } else {
7419  fv = BiddyV(f);
7420  if (v == fv) {
7421  if (value) {
7422  r = BiddyManagedTaggedFoaNode(MNG,v,biddyZero,BiddyT(f),tag,TRUE);
7423  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
7424  } else {
7425  ntag = biddyVariableTable.table[v].next;
7426  e = BiddyE(f);
7427  if (ntag == BiddyGetTag(e)) {
7428  r = e;
7429  BiddyRefresh(r); /* subnode may be marked as an obsolete node! */
7430  if (r != biddyZero) {
7431  BiddySetTag(r,tag);
7432  }
7433  } else {
7434  r = BiddyManagedTaggedFoaNode(MNG,ntag,e,e,tag,TRUE);
7435  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
7436  }
7437  }
7438  } else if (BiddyIsSmaller(biddyOrderingTable,v,fv)) {
7439  if (value) {
7440  r = biddyZero;
7441  } else {
7442  r = f;
7443  BiddyRefresh(r); /* return non-obsolete node even if the parameter is an obsolete node */
7444  }
7445  } else {
7446  e = BiddyManagedVarSubset(MNG,BiddyE(f),v,value);
7447  t = BiddyManagedVarSubset(MNG,BiddyT(f),v,value);
7448  r = BiddyManagedTaggedFoaNode(MNG,fv,e,t,tag,TRUE);
7449  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
7450  addOp3Cache(biddyOPCache,FF,GG,HH,r,cindex);
7451  }
7452  }
7453  }
7454 #endif
7455 
7456  } else {
7457 
7458  /* IF THE RESULT IS FROM CACHE TABLE, REFRESH IT! */
7459  BiddyRefresh(r);
7460 
7461  }
7462 
7463  return r;
7464 }
7465 
7466 /***************************************************************************/
7475 Biddy_Edge
7476 BiddyManagedElementAbstract(Biddy_Manager MNG, Biddy_Edge f, Biddy_Variable v)
7477 {
7478  Biddy_Edge h;
7479  Biddy_Edge r;
7480  unsigned int cindex;
7481  Biddy_Edge e, t;
7482  Biddy_Variable fv;
7483 
7484 #ifndef COMPACT
7485  Biddy_Variable tag;
7486 #endif
7487 
7488  assert( MNG != NULL );
7489  assert( f != NULL );
7490  assert( v != 0);
7491 
7492  /* IMPLEMENTED FOR OBDD, OBDDC, ZBDD, ZBDDC, AND TZBDD */
7493  assert(
7494  (biddyManagerType == BIDDYTYPEOBDD) ||
7495  (biddyManagerType == BIDDYTYPEOBDDC) ||
7496  (biddyManagerType == BIDDYTYPEZBDD) ||
7497  (biddyManagerType == BIDDYTYPEZBDDC) ||
7498  (biddyManagerType == BIDDYTYPETZBDD)
7499  );
7500 
7501  r = biddyNull;
7502 
7503  /* LOOKING FOR SIMPLE CASE */
7504  if (f == biddyZero) return biddyZero;
7505 
7506  h = biddyNull;
7507 
7508 #ifndef COMPACT
7509  fv = tag = 0;
7510 #endif
7511 
7512  /* h MUST BE COMPATIBLE WITH CUBE */
7513  if ((biddyManagerType == BIDDYTYPEOBDDC) || (biddyManagerType == BIDDYTYPEOBDD)) {
7514  h = biddyVariableTable.table[v].variable;
7515  }
7516 #ifndef COMPACT
7517  else if ((biddyManagerType == BIDDYTYPEZBDDC) || (biddyManagerType == BIDDYTYPEZBDD)) {
7518  fv = BiddyV(f);
7519  if (BiddyIsSmaller(biddyOrderingTable,v,fv)) {
7520  BiddyRefresh(f); /* return non-obsolete node even if the parameter is an obsolete node */
7521  return f;
7522  }
7523  h = biddyVariableTable.table[v].element;
7524  }
7525  else if (biddyManagerType == BIDDYTYPETZBDD) {
7526  fv = BiddyV(f);
7527  tag = BiddyGetTag(f);
7528  if (BiddyIsSmaller(biddyOrderingTable,v,fv) && !BiddyIsSmaller(biddyOrderingTable,v,tag)) {
7529  BiddyRefresh(f); /* return non-obsolete node even if the parameter is an obsolete node */
7530  return f;
7531  }
7532  h = biddyVariableTable.table[v].variable;
7533  }
7534 #endif
7535 
7536  /* IF RESULT IS NOT IN THE CACHE TABLE... */
7537  cindex = 0;
7538  if (!findOp3Cache(biddyEACache,f,biddyZero,h,&r,&cindex))
7539  {
7540 
7541  if ((biddyManagerType == BIDDYTYPEOBDDC) || (biddyManagerType == BIDDYTYPEOBDD)) {
7542  if ((fv=BiddyV(f)) == v) {
7543  r = BiddyManagedOr(MNG,
7544  BiddyInvCond(BiddyE(f),BiddyGetMark(f)),
7545  BiddyInvCond(BiddyT(f),BiddyGetMark(f)));
7546  r = BiddyManagedTaggedFoaNode(MNG,v,r,biddyZero,v,TRUE);
7547  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
7548  }
7549  else if (BiddyIsSmaller(biddyOrderingTable,v,fv)) {
7550  r = BiddyManagedTaggedFoaNode(MNG,v,f,biddyZero,v,TRUE);
7551  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
7552  }
7553  else {
7554  e = BiddyManagedElementAbstract(MNG,BiddyInvCond(BiddyE(f),BiddyGetMark(f)),v);
7555  t = BiddyManagedElementAbstract(MNG,BiddyInvCond(BiddyT(f),BiddyGetMark(f)),v);
7556  r = BiddyManagedTaggedFoaNode(MNG,fv,e,t,fv,TRUE);
7557  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
7558  }
7559  }
7560 
7561 #ifndef COMPACT
7562  else if ((biddyManagerType == BIDDYTYPEZBDDC) || (biddyManagerType == BIDDYTYPEZBDD)) {
7563  if (fv == v) {
7564  r = BiddyManagedOr(MNG,
7565  BiddyInvCond(BiddyE(f),BiddyGetMark(f)),
7566  BiddyT(f));
7567  }
7568  else {
7569  e = BiddyManagedElementAbstract(MNG,BiddyInvCond(BiddyE(f),BiddyGetMark(f)),v);
7570  t = BiddyManagedElementAbstract(MNG,BiddyT(f),v);
7571  r = BiddyManagedTaggedFoaNode(MNG,fv,e,t,fv,TRUE);
7572  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
7573  }
7574  }
7575 
7576  else if (biddyManagerType == BIDDYTYPETZBDD) {
7577 
7578  if (fv == v) {
7579  r = BiddyManagedOr(MNG,BiddyE(f),BiddyT(f));
7580  v = BiddyManagedGetNextVariable(MNG,v);
7581  if (v == BiddyGetTag(r)) {
7582  BiddySetTag(r,tag);
7583  } else {
7584  r = BiddyManagedTaggedFoaNode(MNG,v,r,r,tag,TRUE);
7585  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
7586  }
7587  } else if (BiddyIsSmaller(biddyOrderingTable,v,fv)) {
7588  /* the case !BiddyIsSmaller(biddyOrderingTable,v,tag) is already solved */
7589  r = BiddyManagedTaggedFoaNode(MNG,v,f,biddyZero,v,TRUE);
7590  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
7591  } else {
7592  e = BiddyManagedElementAbstract(MNG,BiddyE(f),v);
7593  t = BiddyManagedElementAbstract(MNG,BiddyT(f),v);
7594  r = BiddyManagedTaggedFoaNode(MNG,fv,e,t,tag,TRUE);
7595  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
7596  }
7597  }
7598 #endif
7599 
7600  addOp3Cache(biddyEACache,f,biddyZero,h,r,cindex);
7601 
7602  } else {
7603 
7604  /* IF THE RESULT IS FROM CACHE TABLE, REFRESH IT! */
7605  BiddyRefresh(r);
7606 
7607  }
7608 
7609  return r;
7610 }
7611 
7612 /***************************************************************************/
7621 Biddy_Edge
7622 BiddyManagedProduct(Biddy_Manager MNG, Biddy_Edge f, Biddy_Edge g)
7623 {
7624  Biddy_Edge e, t, r, Fv, Gv, Fneg_v, Gneg_v;
7625  Biddy_Variable v, topF, topG;
7626  Biddy_Edge FF, GG, HH;
7627  unsigned int cindex;
7628 
7629 #ifndef COMPACT
7630  Biddy_Variable tagF, tagG, rtag;
7631 #endif
7632 
7633  assert( MNG != NULL );
7634  assert( f != NULL );
7635  assert( g != NULL );
7636 
7637  /* IMPLEMENTED FOR OBDD, OBDDC, ZBDD, ZBDDC, AND TZBDD */
7638  assert(
7639  (biddyManagerType == BIDDYTYPEOBDD) ||
7640  (biddyManagerType == BIDDYTYPEOBDDC) ||
7641  (biddyManagerType == BIDDYTYPEZBDD) ||
7642  (biddyManagerType == BIDDYTYPEZBDDC) ||
7643  (biddyManagerType == BIDDYTYPETZBDD)
7644  );
7645 
7646  /* DEBUGGING */
7647  /*
7648  tagF = BiddyGetTag(f);
7649  tagG = BiddyGetTag(g);
7650  topF = BiddyV(f);
7651  topG = BiddyV(g);
7652  printf("\n");
7653  if (f == biddyZero) printf("Product: F = 0\n");
7654  if (g == biddyZero) printf("Product: G = 0\n");
7655  printf("Product: tagF = %u (%s)\n",tagF,BiddyManagedGetVariableName(MNG,tagF));
7656  printf("Product: topF = %u (%s)\n",topF,BiddyManagedGetVariableName(MNG,topF));
7657  printf("Product: tagG = %u (%s)\n",tagG,BiddyManagedGetVariableName(MNG,tagG));
7658  printf("Product: topG = %u (%s)\n",topG,BiddyManagedGetVariableName(MNG,topG));
7659  */
7660 
7661  if (f == biddyZero) return biddyZero;
7662  if (g == biddyZero) return biddyZero;
7663 
7664  topF = topG = 0;
7665 
7666 #ifndef COMPACT
7667  tagF = tagG = 0;
7668 #endif
7669 
7670  if ((biddyManagerType == BIDDYTYPEOBDDC) || (biddyManagerType == BIDDYTYPEOBDD)) {
7671  if ((f == biddyOne) && (g == biddyOne)) return biddyOne;
7672  /* if ((f == biddyOne) && (g includes empty combination)) return biddyOne; */
7673  }
7674 #ifndef COMPACT
7675  else if ((biddyManagerType == BIDDYTYPEZBDDC) || (biddyManagerType == BIDDYTYPEZBDD)) {
7676  if (f == biddyTerminal) {
7677  BiddyRefresh(g); /* return non-obsolete node even if the parameter is an obsolete node */
7678  return g;
7679  }
7680  if (g == biddyTerminal) {
7681  BiddyRefresh(f); /* return non-obsolete node even if the parameter is an obsolete node */
7682  return f;
7683  }
7684  }
7685  else if (biddyManagerType == BIDDYTYPETZBDD) {
7686  tagF = BiddyGetTag(f);
7687  tagG = BiddyGetTag(g);
7688  topF = BiddyV(f);
7689  topG = BiddyV(g);
7690  if ((topF == 0) && (!BiddyIsSmaller(biddyOrderingTable,tagG,tagF))) {
7691  BiddyRefresh(g); /* return non-obsolete node even if the parameter is an obsolete node */
7692  return g;
7693  }
7694  if ((topG == 0) && (!BiddyIsSmaller(biddyOrderingTable,tagF,tagG))) {
7695  BiddyRefresh(f); /* return non-obsolete node even if the parameter is an obsolete node */
7696  return f;
7697  }
7698  }
7699 #endif
7700 
7701  r = biddyNull;
7702 
7703  if (((uintptr_t) f) > ((uintptr_t) g)) {
7704  FF = g;
7705  GG = f;
7706  } else {
7707  FF = f;
7708  GG = g;
7709  }
7710  HH = biddyZero;
7711 
7712  /* IF RESULT IS NOT IN THE CACHE TABLE... */
7713  cindex = 0;
7714  if (!findOp3Cache(biddyRCCache,FF,GG,HH,&r,&cindex))
7715  {
7716 
7717  if ((biddyManagerType == BIDDYTYPEOBDDC) || (biddyManagerType == BIDDYTYPEOBDD)) {
7718 
7719  /* LOOKING FOR THE SMALLEST TOP VARIABLE */
7720  /* CONSTANT VARIABLE MUST HAVE MAX ORDER */
7721  topF = BiddyV(f);
7722  topG = BiddyV(g);
7723  v = BiddyIsSmaller(biddyOrderingTable,topF,topG) ? topF : topG;
7724 
7725  /* DETERMINING PARAMETERS FOR RECURSIVE CALLS */
7726  /* COMPLEMENTED EDGES MUST BE TRANSFERED */
7727  if (topF == v) {
7728  Fneg_v = BiddyInvCond(BiddyE(f),BiddyGetMark(f));
7729  Fv = BiddyInvCond(BiddyT(f),BiddyGetMark(f));
7730  } else {
7731  Fneg_v = Fv = f;
7732  }
7733  if (topG == v) {
7734  Gneg_v = BiddyInvCond(BiddyE(g),BiddyGetMark(g));
7735  Gv = BiddyInvCond(BiddyT(g),BiddyGetMark(g));
7736  } else {
7737  Gneg_v = Gv = g;
7738  }
7739 
7740  if (topF == topG) {
7741  e = BiddyManagedProduct(MNG,Fneg_v,Gneg_v);
7742  t = BiddyManagedProduct(MNG,Fv,Gv);
7743  t = BiddyManagedOr(MNG,t,BiddyManagedProduct(MNG,Fneg_v,Gv));
7744  t = BiddyManagedOr(MNG,t,BiddyManagedProduct(MNG,Fv,Gneg_v));
7745  } else {
7746  e = BiddyManagedProduct(MNG,Fneg_v,Gneg_v);
7747  t = BiddyManagedOr(MNG,e,BiddyManagedProduct(MNG,Fv,Gv)); /* e=Product(Fneg_v,G) or e=Product(F,Gneg_v) */
7748  }
7749  r = BiddyManagedTaggedFoaNode(MNG,v,e,t,v,TRUE);
7750  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
7751  addOp3Cache(biddyRCCache,FF,GG,HH,r,cindex);
7752 
7753  }
7754 
7755 #ifndef COMPACT
7756  else if ((biddyManagerType == BIDDYTYPEZBDDC) || (biddyManagerType == BIDDYTYPEZBDD)) {
7757 
7758  /* LOOKING FOR THE SMALLEST TOP VARIABLE */
7759  /* CONSTANT VARIABLE MUST HAVE MAX ORDER */
7760  topF = BiddyV(f);
7761  topG = BiddyV(g);
7762  v = BiddyIsSmaller(biddyOrderingTable,topF,topG) ? topF : topG;
7763 
7764  /* DETERMINING PARAMETERS FOR RECURSIVE CALLS */
7765  /* COMPLEMENTED EDGES MUST BE TRANSFERED */
7766  if (topF == v) {
7767  Fneg_v = BiddyInvCond(BiddyE(f),BiddyGetMark(f));
7768  Fv = BiddyT(f);
7769  } else {
7770  Fv = Fneg_v = f;
7771  }
7772  if (topG == v) {
7773  Gneg_v = BiddyInvCond(BiddyE(g),BiddyGetMark(g));
7774  Gv = BiddyT(g);
7775  } else {
7776  Gv = Gneg_v = g;
7777  }
7778 
7779  if (topF == topG) {
7780  e = BiddyManagedProduct(MNG,Fneg_v,Gneg_v);
7781  t = BiddyManagedProduct(MNG,Fv,Gv);
7782  t = BiddyManagedOr(MNG,t,BiddyManagedProduct(MNG,Fneg_v,Gv));
7783  t = BiddyManagedOr(MNG,t,BiddyManagedProduct(MNG,Fv,Gneg_v));
7784  } else {
7785  e = BiddyManagedProduct(MNG,Fneg_v,Gneg_v);
7786  t = BiddyManagedProduct(MNG,Fv,Gv);
7787  }
7788  r = BiddyManagedTaggedFoaNode(MNG,v,e,t,v,TRUE);
7789  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
7790  addOp3Cache(biddyRCCache,FF,GG,HH,r,cindex);
7791 
7792  }
7793 
7794  else if (biddyManagerType == BIDDYTYPETZBDD) {
7795 
7796  /* LOOKING FOR THE SMALLEST TAG AND SMALLEST TOP VARIABLE */
7797  /* CONSTANT VARIABLE MUST HAVE MAX ORDER */
7798  /* tagF = BiddyGetTag(f); */ /* already set */
7799  /* tagG = BiddyGetTag(g); */ /* already set */
7800  /* topF = BiddyV(f); */ /* already set */
7801  /* topG = BiddyV(g); */ /* already set */
7802  v = BiddyIsSmaller(biddyOrderingTable,topF,topG) ? topF : topG;
7803  rtag = BiddyIsSmaller(biddyOrderingTable,tagF,tagG) ? tagG : tagF; /* max tag! */
7804  if (BiddyIsSmaller(biddyOrderingTable,v,rtag)) rtag = v;
7805 
7806  /*
7807  printf("Product: rtag = %u (%s)\n",rtag,BiddyManagedGetVariableName(MNG,rtag));
7808  printf("Product: v = %u (%s)\n",v,BiddyManagedGetVariableName(MNG,v));
7809  */
7810 
7811  if (BiddyIsSmaller(biddyOrderingTable,v,tagF)) {
7812  Fneg_v = Fv = f;
7813  } else if (v == topF) {
7814  Fneg_v = BiddyE(f);
7815  Fv = BiddyT(f);
7816  } else {
7817  Fneg_v = f;
7818  BiddySetTag(Fneg_v,v);
7819  Fneg_v = BiddyManagedIncTag(MNG,Fneg_v);
7820  Fv = biddyZero;
7821  }
7822  if (BiddyIsSmaller(biddyOrderingTable,v,tagG)) {
7823  Gneg_v = Gv = g;
7824  } else if (v == topG) {
7825  Gneg_v = BiddyE(g);
7826  Gv = BiddyT(g);
7827  } else {
7828  Gneg_v = g;
7829  BiddySetTag(Gneg_v,v);
7830  Gneg_v = BiddyManagedIncTag(MNG,Gneg_v);
7831  Gv = biddyZero;
7832  }
7833 
7834  /*
7835  printf("Product: Fneg_v = %u (%s)\n",BiddyV(Fneg_v),BiddyManagedGetVariableName(MNG,BiddyV(Fneg_v)));
7836  printf("Product: Fv = %u (%s)\n",BiddyV(Fv),BiddyManagedGetVariableName(MNG,BiddyV(Fv)));
7837  printf("Product: Gneg_v = %u (%s)\n",BiddyV(Gneg_v),BiddyManagedGetVariableName(MNG,BiddyV(Gneg_v)));
7838  printf("Product: Gv = %u (%s)\n",BiddyV(Gv),BiddyManagedGetVariableName(MNG,BiddyV(Gv)));
7839  */
7840 
7841  e = BiddyManagedProduct(MNG,Fneg_v,Gneg_v);
7842  t = BiddyManagedProduct(MNG,Fv,Gv);
7843  t = BiddyManagedOr(MNG,t,BiddyManagedProduct(MNG,Fneg_v,Gv));
7844  t = BiddyManagedOr(MNG,t,BiddyManagedProduct(MNG,Fv,Gneg_v));
7845 
7846  r = BiddyManagedTaggedFoaNode(MNG,v,e,t,rtag,TRUE);
7847  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
7848  addOp3Cache(biddyRCCache,FF,GG,HH,r,cindex);
7849 
7850  }
7851 #endif
7852 
7853  } else {
7854 
7855  /* IF THE RESULT IS FROM CACHE TABLE, REFRESH IT! */
7856  BiddyRefresh(r);
7857 
7858  }
7859 
7860  return r;
7861 }
7862 
7863 /***************************************************************************/
7872 Biddy_Edge
7873 BiddyManagedSelectiveProduct(Biddy_Manager MNG, Biddy_Edge f, Biddy_Edge g, Biddy_Edge pncube)
7874 {
7875  Biddy_Edge e, t, r, Fv, Gv, Fneg_v, Gneg_v, nextcube;
7876  Biddy_Variable v, topF, topG;
7877  Biddy_Edge FF, GG, HH;
7878  unsigned int cindex;
7879 
7880 #ifndef COMPACT
7881  Biddy_Variable tagF, tagG, rtag;
7882 #endif
7883 
7884  assert( MNG != NULL );
7885  assert( f != NULL );
7886  assert( g != NULL );
7887  assert( pncube != NULL );
7888 
7889  assert( (f == biddyZero) ||
7890  (g == biddyZero) ||
7891  ((f == biddyTerminal) && (g == biddyTerminal)) ||
7892  (pncube != biddyZero)
7893  );
7894 
7895  /* IMPLEMENTED FOR OBDD, OBDDC, ZBDD, ZBDDC, AND TZBDD */
7896  assert(
7897  (biddyManagerType == BIDDYTYPEOBDD) ||
7898  (biddyManagerType == BIDDYTYPEOBDDC) ||
7899  (biddyManagerType == BIDDYTYPEZBDD) ||
7900  (biddyManagerType == BIDDYTYPEZBDDC) ||
7901  (biddyManagerType == BIDDYTYPETZBDD)
7902  );
7903 
7904  /* DEBUGGING TZBDD */
7905  /*
7906  if (biddyManagerType == BIDDYTYPETZBDD) {
7907  tagF = BiddyGetTag(f);
7908  tagG = BiddyGetTag(g);
7909  topF = BiddyV(f);
7910  topG = BiddyV(g);
7911  printf("\n");
7912  if (f == biddyZero) printf("SelectiveProduct: F = 0\n");
7913  else if (g == biddyZero) printf("SelectiveProduct: G = 0\n");
7914  else {
7915  printf("SelectiveProduct: tagCube = %u (%s)\n",BiddyGetTag(pncube),BiddyManagedGetVariableName(MNG,BiddyGetTag(pncube)));
7916  printf("SelectiveProduct: cube = %u (%s)\n",BiddyV(pncube),BiddyManagedGetVariableName(MNG,BiddyV(pncube)));
7917  printf("SelectiveProduct: tagF = %u (%s)\n",tagF,BiddyManagedGetVariableName(MNG,tagF));
7918  printf("SelectiveProduct: topF = %u (%s)\n",topF,BiddyManagedGetVariableName(MNG,topF));
7919  printf("SelectiveProduct: tagG = %u (%s)\n",tagG,BiddyManagedGetVariableName(MNG,tagG));
7920  printf("SelectiveProduct: topG = %u (%s)\n",topG,BiddyManagedGetVariableName(MNG,topG));
7921  }
7922  }
7923  */
7924 
7925  if (f == biddyZero) return biddyZero;
7926  if (g == biddyZero) return biddyZero;
7927 
7928  v = 0;
7929  topF = topG = 0;
7930 
7931 #ifndef COMPACT
7932  tagF = tagG = rtag = 0;
7933 #endif
7934 
7935  if ((biddyManagerType == BIDDYTYPEOBDDC) || (biddyManagerType == BIDDYTYPEOBDD)) {
7936  if ((f == biddyOne) && (g == biddyOne)) return biddyOne;
7937  topF = BiddyV(f);
7938  topG = BiddyV(g);
7939  while (BiddyIsSmaller(biddyOrderingTable,BiddyV(pncube),topF)) {
7940  r = BiddyInvCond(BiddyT(pncube),BiddyGetMark(pncube)); /* r is used here as a tmp variable */
7941  if (r != biddyZero) {
7942  pncube = r;
7943  } else {
7944  pncube = BiddyInvCond(BiddyE(pncube),BiddyGetMark(pncube));
7945  }
7946  }
7947  }
7948 #ifndef COMPACT
7949  else if ((biddyManagerType == BIDDYTYPEZBDDC) || (biddyManagerType == BIDDYTYPEZBDD)) {
7950  if (g == biddyTerminal) {
7951  BiddyRefresh(f); /* return non-obsolete node even if the parameter is an obsolete node */
7952  return f;
7953  }
7954  topF = BiddyV(f);
7955  topG = BiddyV(g);
7956  while (BiddyIsSmaller(biddyOrderingTable,BiddyV(pncube),topG)) pncube = BiddyT(pncube);
7957  }
7958  else if (biddyManagerType == BIDDYTYPETZBDD) {
7959  tagF = BiddyGetTag(f);
7960  tagG = BiddyGetTag(g);
7961  topF = BiddyV(f);
7962  topG = BiddyV(g);
7963  if ((topF == 0) && (topG == 0)) {
7964  if (BiddyIsSmaller(biddyOrderingTable,tagF,tagG)) {
7965  while (BiddyIsSmaller(biddyOrderingTable,BiddyV(pncube),tagF)) pncube = BiddyT(pncube);
7966  while (BiddyIsSmaller(biddyOrderingTable,BiddyV(pncube),tagG) && (BiddyE(pncube) != biddyZero)) pncube = BiddyT(pncube);
7967  if (BiddyIsSmaller(biddyOrderingTable,BiddyV(pncube),tagG)) { /* smallest positive >= tagF is smaller as tagG */
7968  if (BiddyManagedGetNextVariable(MNG,BiddyV(pncube)) == tagG) { /* smallest positive is previous of tagG */
7969  BiddySetTag(g,BiddyV(pncube));
7970  return g;
7971  } else {
7972  rtag = BiddyV(pncube);
7973  v = BiddyManagedGetNextVariable(MNG,rtag);
7974  pncube = BiddyT(pncube);
7975  /* THIS PART IS OPTIONAL - WE PREFER TO USE IT ALTHOUGH NO REAL DIFFERENCE IS OBSERVED */
7976 
7977  if (v == BiddyV(pncube)) nextcube = BiddyT(pncube); else nextcube = pncube;
7978  BiddySetTag(f,BiddyManagedGetNextVariable(MNG,v));
7979  r = BiddyManagedSelectiveProduct(MNG,f,g,nextcube);
7980  if ((v == BiddyV(pncube)) && (BiddyE(pncube) == biddyZero)) { // v in positive set
7981  r = BiddyManagedTaggedFoaNode(MNG,v,r,biddyZero,rtag,TRUE);
7982  } else {
7983  r = BiddyManagedTaggedFoaNode(MNG,v,r,r,rtag,TRUE);
7984  }
7985  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
7986  return r;
7987 
7988  }
7989  } else {
7990  BiddyRefresh(g); /* return non-obsolete node even if the parameter is an obsolete node */
7991  return g;
7992  }
7993  } else {
7994  BiddyRefresh(f); /* return non-obsolete node even if the parameter is an obsolete node */
7995  return f;
7996  }
7997  } else if ((topG == 0) && !BiddyIsSmaller(biddyOrderingTable,tagF,tagG)) {
7998  BiddyRefresh(f); /* return non-obsolete node even if the parameter is an obsolete node */
7999  return f;
8000  } else {
8001  v = BiddyIsSmaller(biddyOrderingTable,topF,topG) ? topF : topG;
8002  rtag = BiddyIsSmaller(biddyOrderingTable,tagF,tagG) ? tagG : tagF; /* max tag! */
8003  while (BiddyIsSmaller(biddyOrderingTable,BiddyV(pncube),tagF)) pncube = BiddyT(pncube);
8004  if (BiddyIsSmaller(biddyOrderingTable,tagF,tagG) && (BiddyV(pncube) == tagF) && (BiddyE(pncube) == biddyZero)) {
8005  rtag = tagF;
8006  if ((tagF != topF) && BiddyIsSmaller(biddyOrderingTable,BiddyManagedGetNextVariable(MNG,tagF),tagG)) {
8007  v = BiddyManagedGetNextVariable(MNG,tagF);
8008  }
8009  }
8010  if (BiddyIsSmaller(biddyOrderingTable,v,rtag)) rtag = v;
8011  while (BiddyIsSmaller(biddyOrderingTable,BiddyV(pncube),v)) pncube = BiddyT(pncube);
8012  }
8013  }
8014 #endif
8015 
8016  r = biddyNull;
8017 
8018  FF = f;
8019  GG = g;
8020  HH = pncube;
8021 
8022  /* IF RESULT IS NOT IN THE CACHE TABLE... */
8023  cindex = 0;
8024  if (!findOp3Cache(biddyRCCache,FF,GG,HH,&r,&cindex))
8025  {
8026 
8027  if ((biddyManagerType == BIDDYTYPEOBDDC) || (biddyManagerType == BIDDYTYPEOBDD)) {
8028 
8029  /* LOOKING FOR THE SMALLEST TOP VARIABLE */
8030  /* CONSTANT VARIABLE MUST HAVE MAX ORDER */
8031  v = BiddyIsSmaller(biddyOrderingTable,topF,topG) ? topF : topG;
8032 
8033  /* DETERMINING PARAMETERS FOR RECURSIVE CALLS */
8034  /* COMPLEMENTED EDGES MUST BE TRANSFERED */
8035  if (topF == v) {
8036  Fneg_v = BiddyInvCond(BiddyE(f),BiddyGetMark(f));
8037  Fv = BiddyInvCond(BiddyT(f),BiddyGetMark(f));
8038  } else {
8039  Fneg_v = Fv = f;
8040  }
8041  if (topG == v) {
8042  Gneg_v = BiddyInvCond(BiddyE(g),BiddyGetMark(g));
8043  Gv = BiddyInvCond(BiddyT(g),BiddyGetMark(g));
8044  } else {
8045  Gneg_v = Gv = g;
8046  }
8047 
8048  if (v == BiddyV(pncube)) {
8049  r = BiddyInvCond(BiddyT(pncube),BiddyGetMark(pncube)); /* r is used here as a tmp variable */
8050  if (r != biddyZero) {
8051  nextcube = r;
8052  } else {
8053  nextcube = BiddyInvCond(BiddyE(pncube),BiddyGetMark(pncube));
8054  }
8055  } else {
8056  nextcube = pncube;
8057  }
8058  if (topF == topG) {
8059  e = BiddyManagedSelectiveProduct(MNG,Fneg_v,Gneg_v,nextcube);
8060  if (((v == BiddyV(pncube)) && (BiddyInvCond(BiddyE(pncube),BiddyGetMark(pncube)) == biddyZero))) { /* v in positive set */
8061  t = BiddyManagedSelectiveProduct(MNG,Fv,Gv,nextcube);
8062  t = BiddyManagedOr(MNG,t,BiddyManagedSelectiveProduct(MNG,Fv,Gneg_v,nextcube));
8063  } else if (((v == BiddyV(pncube)) && (BiddyInvCond(BiddyE(pncube),BiddyGetMark(pncube)) != biddyZero))) { /* v in negative set */
8064  t = BiddyManagedSelectiveProduct(MNG,Fneg_v,Gv,nextcube);
8065  t = BiddyManagedOr(MNG,t,BiddyManagedSelectiveProduct(MNG,Fv,Gneg_v,nextcube));
8066  } else {
8067  t = BiddyManagedSelectiveProduct(MNG,Fv,Gv,nextcube);
8068  t = BiddyManagedOr(MNG,t,BiddyManagedSelectiveProduct(MNG,Fneg_v,Gv,nextcube));
8069  t = BiddyManagedOr(MNG,t,BiddyManagedSelectiveProduct(MNG,Fv,Gneg_v,nextcube));
8070  }
8071  } else {
8072  e = BiddyManagedSelectiveProduct(MNG,Fneg_v,Gneg_v,nextcube);
8073  if ((topF == v) && (v == BiddyV(pncube)) && (BiddyInvCond(BiddyE(pncube),BiddyGetMark(pncube)) == biddyZero)) {
8074  /* topF < topG (because topF == v) and v in positive set */
8075  t = BiddyManagedSelectiveProduct(MNG,Fv,Gv,nextcube);
8076  } else {
8077  /* all other cases, checking if v is in positive set is not needed */
8078  t = BiddyManagedOr(MNG,e,BiddyManagedSelectiveProduct(MNG,Fv,Gv,nextcube));
8079  }
8080  }
8081  r = BiddyManagedTaggedFoaNode(MNG,v,e,t,v,TRUE);
8082  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
8083  addOp3Cache(biddyRCCache,FF,GG,HH,r,cindex);
8084 
8085  }
8086 
8087 #ifndef COMPACT
8088  else if ((biddyManagerType == BIDDYTYPEZBDDC) || (biddyManagerType == BIDDYTYPEZBDD)) {
8089 
8090  /* LOOKING FOR THE SMALLEST TOP VARIABLE */
8091  /* CONSTANT VARIABLE MUST HAVE MAX ORDER */
8092  v = BiddyIsSmaller(biddyOrderingTable,topF,topG) ? topF : topG;
8093 
8094  /* DETERMINING PARAMETERS FOR RECURSIVE CALLS */
8095  /* COMPLEMENTED EDGES MUST BE TRANSFERED */
8096  if (topF == v) {
8097  Fneg_v = BiddyInvCond(BiddyE(f),BiddyGetMark(f));
8098  Fv = BiddyT(f);
8099  } else {
8100  Fv = Fneg_v = f;
8101  }
8102  if (topG == v) {
8103  Gneg_v = BiddyInvCond(BiddyE(g),BiddyGetMark(g));
8104  Gv = BiddyT(g);
8105  } else {
8106  Gv = Gneg_v = g;
8107  }
8108 
8109  if (v == BiddyV(pncube)) nextcube = BiddyT(pncube); else nextcube = pncube;
8110  if (topF == topG) {
8111  e = BiddyManagedSelectiveProduct(MNG,Fneg_v,Gneg_v,nextcube);
8112  if (((v == BiddyV(pncube)) && (BiddyInvCond(BiddyE(pncube),BiddyGetMark(pncube)) == biddyZero))) { /* v in positive set */
8113  t = BiddyManagedSelectiveProduct(MNG,Fv,Gv,nextcube);
8114  t = BiddyManagedOr(MNG,t,BiddyManagedSelectiveProduct(MNG,Fv,Gneg_v,nextcube));
8115  } else if (((v == BiddyV(pncube)) && (BiddyInvCond(BiddyE(pncube),BiddyGetMark(pncube)) != biddyZero))) { /* v in negative set */
8116  t = BiddyManagedSelectiveProduct(MNG,Fneg_v,Gv,nextcube);
8117  t = BiddyManagedOr(MNG,t,BiddyManagedSelectiveProduct(MNG,Fv,Gneg_v,nextcube));
8118  } else {
8119  t = BiddyManagedSelectiveProduct(MNG,Fv,Gv,nextcube);
8120  t = BiddyManagedOr(MNG,t,BiddyManagedSelectiveProduct(MNG,Fneg_v,Gv,nextcube));
8121  t = BiddyManagedOr(MNG,t,BiddyManagedSelectiveProduct(MNG,Fv,Gneg_v,nextcube));
8122  }
8123  } else {
8124  e = BiddyManagedSelectiveProduct(MNG,Fneg_v,Gneg_v,nextcube);
8125  if ((topG == v) && (v == BiddyV(pncube)) && (BiddyInvCond(BiddyE(pncube),BiddyGetMark(pncube)) == biddyZero)) {
8126  /* topG < topF (because topG == v) and v in positive set */
8127  t = BiddyManagedGetEmptySet(MNG);
8128  } else {
8129  /* all other cases, checking if v is in positive set is not needed */
8130  t = BiddyManagedSelectiveProduct(MNG,Fv,Gv,nextcube);
8131  }
8132  }
8133  r = BiddyManagedTaggedFoaNode(MNG,v,e,t,v,TRUE);
8134  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
8135  addOp3Cache(biddyRCCache,FF,GG,HH,r,cindex);
8136 
8137  }
8138 
8139  else if (biddyManagerType == BIDDYTYPETZBDD) {
8140 
8141  /* LOOKING FOR THE SMALLEST TAG AND SMALLEST TOP VARIABLE */
8142  /* CONSTANT VARIABLE MUST HAVE MAX ORDER */
8143  /* topF = BiddyV(f); */ /* already set */
8144  /* topG = BiddyV(g); */ /* already set */
8145  /* tagF = BiddyGetTag(f); */ /* already set */
8146  /* tagG = BiddyGetTag(g); */ /* already set */
8147  /* v */ /* already set */
8148  /* rtag */ /* already set */
8149 
8150  if (BiddyIsSmaller(biddyOrderingTable,v,tagF)) {
8151  Fneg_v = Fv = f;
8152  } else if (v == topF) {
8153  Fneg_v = BiddyE(f);
8154  Fv = BiddyT(f);
8155  } else {
8156  Fneg_v = f;
8157  BiddySetTag(Fneg_v,v);
8158  Fneg_v = BiddyManagedIncTag(MNG,Fneg_v);
8159  Fv = biddyZero;
8160  }
8161  if (BiddyIsSmaller(biddyOrderingTable,v,tagG)) {
8162  Gneg_v = Gv = g;
8163  } else if (v == topG) {
8164  Gneg_v = BiddyE(g);
8165  Gv = BiddyT(g);
8166  } else {
8167  Gneg_v = g;
8168  BiddySetTag(Gneg_v,v);
8169  Gneg_v = BiddyManagedIncTag(MNG,Gneg_v);
8170  Gv = biddyZero;
8171  }
8172 
8173  if (v == BiddyV(pncube)) nextcube = BiddyT(pncube); else nextcube = pncube;
8174  e = BiddyManagedSelectiveProduct(MNG,Fneg_v,Gneg_v,nextcube);
8175  if ((v == BiddyV(pncube)) && (BiddyE(pncube) == biddyZero)) { // v in positive set
8176  /* printf("\nPOSITIVE"); */
8177  t = BiddyManagedSelectiveProduct(MNG,Fv,Gv,nextcube);
8178  t = BiddyManagedOr(MNG,t,BiddyManagedSelectiveProduct(MNG,Fv,Gneg_v,nextcube));
8179  } else if ((v != BiddyV(pncube)) && !BiddyIsSmaller(biddyOrderingTable,v,BiddyGetTag(pncube))) { // v in negative set
8180  /* printf("\nNEGATIVE"); */
8181  t = BiddyManagedSelectiveProduct(MNG,Fneg_v,Gv,nextcube);
8182  t = BiddyManagedOr(MNG,t,BiddyManagedSelectiveProduct(MNG,Fv,Gneg_v,nextcube));
8183  } else {
8184  /* printf("\nNEUTRAL"); */
8185  t = BiddyManagedSelectiveProduct(MNG,Fv,Gv,nextcube);
8186  t = BiddyManagedOr(MNG,t,BiddyManagedSelectiveProduct(MNG,Fneg_v,Gv,nextcube));
8187  t = BiddyManagedOr(MNG,t,BiddyManagedSelectiveProduct(MNG,Fv,Gneg_v,nextcube));
8188  }
8189 
8190  r = BiddyManagedTaggedFoaNode(MNG,v,e,t,rtag,TRUE);
8191  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
8192  addOp3Cache(biddyRCCache,FF,GG,HH,r,cindex);
8193  }
8194 #endif
8195 
8196  } else {
8197 
8198  /* IF THE RESULT IS FROM CACHE TABLE, REFRESH IT! */
8199  BiddyRefresh(r);
8200 
8201  }
8202 
8203  /* DEBUGGING */
8204  /*
8205  printf("SelectiveProduct: RESULT = %u (%s)\n",BiddyV(r),BiddyManagedGetVariableName(MNG,BiddyV(r)));
8206  */
8207 
8208  return r;
8209 }
8210 
8211 /***************************************************************************/
8220 Biddy_Edge
8221 BiddyManagedSupset(Biddy_Manager MNG, Biddy_Edge f, Biddy_Edge g)
8222 {
8223  Biddy_Edge e, t, r, Fv, Gv, Fneg_v, Gneg_v;
8224  Biddy_Variable v, topF, topG;
8225  Biddy_Edge FF, GG, HH;
8226  unsigned int cindex;
8227 
8228 #ifndef COMPACT
8229  Biddy_Variable tagF, tagG, rtag;
8230 #endif
8231 
8232  assert( MNG != NULL );
8233  assert( f != NULL );
8234  assert( g != NULL );
8235 
8236  /* IMPLEMENTED FOR OBDD, OBDDC, ZBDD, ZBDDC, AND TZBDD */
8237  assert(
8238  (biddyManagerType == BIDDYTYPEOBDD) ||
8239  (biddyManagerType == BIDDYTYPEOBDDC) ||
8240  (biddyManagerType == BIDDYTYPEZBDD) ||
8241  (biddyManagerType == BIDDYTYPEZBDDC) ||
8242  (biddyManagerType == BIDDYTYPETZBDD)
8243  );
8244 
8245  if (f == biddyZero) return biddyZero;
8246  if (g == biddyZero) return biddyZero;
8247  if (f == g) {
8248  BiddyRefresh(f); /* return non-obsolete node even if the parameter is an obsolete node */
8249  return f;
8250  }
8251 
8252 #ifndef COMPACT
8253  tagF = tagG = topF = topG = 0; /* to make compiler happy */
8254  if (biddyManagerType == BIDDYTYPETZBDD) {
8255  tagF = BiddyGetTag(f);
8256  tagG = BiddyGetTag(g);
8257  topF = BiddyV(f);
8258  topG = BiddyV(g);
8259  if ((topF == 0) && ((topG == 0))) {
8260  BiddyRefresh(f); /* return non-obsolete node even if the parameter is an obsolete node */
8261  return f;
8262  }
8263  }
8264 #endif
8265 
8266  r = biddyNull;
8267 
8268  FF = biddyNull;
8269  GG = f;
8270  HH = g;
8271 
8272  /* IF RESULT IS NOT IN THE CACHE TABLE... */
8273  cindex = 0;
8274  if (!findOp3Cache(biddyRCCache,FF,GG,HH,&r,&cindex))
8275  {
8276 
8277  if ((biddyManagerType == BIDDYTYPEOBDDC) || (biddyManagerType == BIDDYTYPEOBDD)) {
8278 
8279  /* LOOKING FOR THE SMALLEST TOP VARIABLE */
8280  /* CONSTANT VARIABLE MUST HAVE MAX ORDER */
8281  topF = BiddyV(f);
8282  topG = BiddyV(g);
8283  v = BiddyIsSmaller(biddyOrderingTable,topF,topG) ? topF : topG;
8284 
8285  /* DETERMINING PARAMETERS FOR RECURSIVE CALLS */
8286  /* COMPLEMENTED EDGES MUST BE TRANSFERED */
8287  if (topF == v) {
8288  Fneg_v = BiddyInvCond(BiddyE(f),BiddyGetMark(f));
8289  Fv = BiddyInvCond(BiddyT(f),BiddyGetMark(f));
8290  } else {
8291  Fneg_v = Fv = f;
8292  }
8293  if (topG == v) {
8294  Gneg_v = BiddyInvCond(BiddyE(g),BiddyGetMark(g));
8295  Gv = BiddyInvCond(BiddyT(g),BiddyGetMark(g));
8296  } else {
8297  Gneg_v = Gv = g;
8298  }
8299 
8300  e = BiddyManagedSupset(MNG,Fneg_v,Gneg_v);
8301  t = BiddyManagedSupset(MNG,Fv,Gv);
8302  if (v == topG) {
8303  t = BiddyManagedOr(MNG,t,BiddyManagedSupset(MNG,Fv,Gneg_v));
8304  }
8305 
8306  r = BiddyManagedTaggedFoaNode(MNG,v,e,t,v,TRUE);
8307  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
8308  addOp3Cache(biddyRCCache,FF,GG,HH,r,cindex);
8309 
8310  }
8311 
8312 #ifndef COMPACT
8313  else if ((biddyManagerType == BIDDYTYPEZBDDC) || (biddyManagerType == BIDDYTYPEZBDD)) {
8314 
8315  /* LOOKING FOR THE SMALLEST TOP VARIABLE */
8316  /* CONSTANT VARIABLE MUST HAVE MAX ORDER */
8317  topF = BiddyV(f);
8318  topG = BiddyV(g);
8319  v = BiddyIsSmaller(biddyOrderingTable,topF,topG) ? topF : topG;
8320 
8321  /* DETERMINING PARAMETERS FOR RECURSIVE CALLS */
8322  /* COMPLEMENTED EDGES MUST BE TRANSFERED */
8323  if (topF == v) {
8324  Fneg_v = BiddyInvCond(BiddyE(f),BiddyGetMark(f));
8325  Fv = BiddyT(f);
8326  } else {
8327  Fneg_v = Fv = f;
8328  }
8329  if (topG == v) {
8330  Gneg_v = BiddyInvCond(BiddyE(g),BiddyGetMark(g));
8331  Gv = BiddyT(g);
8332  } else {
8333  Gneg_v = Gv = g;
8334  }
8335 
8336  if (topF == topG) {
8337  e = BiddyManagedSupset(MNG,Fneg_v,Gneg_v);
8338  t = BiddyManagedSupset(MNG,Fv,Gv);
8339  t = BiddyManagedOr(MNG,t,BiddyManagedSupset(MNG,Fv,Gneg_v));
8340  } else if (v == topF) {
8341  e = BiddyManagedSupset(MNG,Fneg_v,Gneg_v);
8342  t = BiddyManagedSupset(MNG,Fv,Gv);
8343  } else {
8344  e = BiddyManagedSupset(MNG,Fneg_v,Gneg_v);
8345  t = biddyZero;
8346  }
8347 
8348  r = BiddyManagedTaggedFoaNode(MNG,v,e,t,v,TRUE);
8349  BiddyRefresh(r); /* FoaNode returns an obsolete node! */
8350  addOp3Cache(biddyRCCache,FF,GG,HH,r,cindex);
8351 
8352  }
8353 
8354  else if (biddyManagerType == BIDDYTYPETZBDD) {
8355 
8356  /* LOOKING FOR THE SMALLEST TAG AND SMALLEST TOP VARIABLE */
8357  /* CONSTANT VARIABLE MUST HAVE MAX ORDER */
8358  /* tagF = BiddyGetTag(f); */ /* already set */
8359  /* tagG = BiddyGetTag(g); */ /* already set */
8360  /* topF = BiddyV(f); */ /* already set */
8361  /* topG = BiddyV(g); */ /* already set */
8362  rtag = BiddyIsSmaller(biddyOrderingTable,tagF,topG) ? tagF : topG; /* min(tagF,topG) */
8363  v = BiddyIsSmaller(biddyOrderingTable,topF,topG) ? topF : topG; /* min(topF,topG) */
8364 
8365  if (BiddyIsSmaller(biddyOrderingTable,topG,tagF)) {
8366  Fneg_v = Fv = f;
8367  Gneg_v = BiddyE(g);
8368  Gv = BiddyT(g);