abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
compl.c File Reference
#include "espresso.h"

Go to the source code of this file.

Macros

#define USE_COMPL_LIFT   0
 
#define USE_COMPL_LIFT_ONSET   1
 
#define USE_COMPL_LIFT_ONSET_COMPLEX   2
 
#define NO_LIFTING   3
 

Functions

static bool compl_special_cases ()
 
static pcover compl_merge ()
 
static void compl_d1merge ()
 
static pcover compl_cube ()
 
static void compl_lift ()
 
static void compl_lift_onset ()
 
static void compl_lift_onset_complex ()
 
static bool simp_comp_special_cases ()
 
static bool simplify_special_cases ()
 
pcover complement (pcube *T)
 
static bool compl_special_cases (pcube *T, pcover *Tbar)
 
static pcover compl_merge (pcube *T1, pcover L, pcover R, pcube cl, pcube cr, int var, int lifting)
 
static void compl_lift (pcube *A1, pcube *B1, pcube bcube, int var)
 
static void compl_lift_onset (pcube *A1, pcover T, pcube bcube, int var)
 
static void compl_lift_onset_complex (pcube *A1, pcover T, int var)
 
static void compl_d1merge (pcube *L1, pcube *R1)
 
static pcover compl_cube (pcube p)
 
void simp_comp (pcube *T, pcover *Tnew, pcover *Tbar)
 
static bool simp_comp_special_cases (pcube *T, pcover *Tnew, pcover *Tbar)
 
pcover simplify (pcube *T)
 
static bool simplify_special_cases (pcube *T, pcover *Tnew)
 

Macro Definition Documentation

#define NO_LIFTING   3

Definition at line 35 of file compl.c.

#define USE_COMPL_LIFT   0

Definition at line 32 of file compl.c.

#define USE_COMPL_LIFT_ONSET   1

Definition at line 33 of file compl.c.

#define USE_COMPL_LIFT_ONSET_COMPLEX   2

Definition at line 34 of file compl.c.

Function Documentation

static pcover compl_cube ( )
static
static pcover compl_cube ( pcube  p)
static

Definition at line 400 of file compl.c.

402 {
403  register pcube diff=cube.temp[7], pdest, mask, full=cube.fullset;
404  int var;
405  pcover R;
406 
407  /* Allocate worst-case size cover (to avoid checking overflow) */
408  R = new_cover(cube.num_vars);
409 
410  /* Compute bit-wise complement of the cube */
411  INLINEset_diff(diff, full, p);
412 
413  for(var = 0; var < cube.num_vars; var++) {
414  mask = cube.var_mask[var];
415  /* If the bit-wise complement is not empty in var ... */
416  if (! setp_disjoint(diff, mask)) {
417  pdest = GETSET(R, R->count++);
418  INLINEset_merge(pdest, diff, full, mask);
419  }
420  }
421  return R;
422 }
#define INLINEset_diff(r, a, b)
Definition: espresso.h:208
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define pcover
Definition: espresso.h:264
int var(Lit p)
Definition: SolverTypes.h:62
bool setp_disjoint()
#define new_cover(i)
Definition: espresso.h:265
#define INLINEset_merge(r, a, b, mask)
Definition: espresso.h:225
#define GETSET(family, index)
Definition: espresso.h:161
#define pcube
Definition: espresso.h:261
static void compl_d1merge ( )
static
static void compl_d1merge ( pcube L1,
pcube R1 
)
static

Definition at line 376 of file compl.c.

378 {
379  register pcube pl, pr;
380 
381  /* Find equal cubes between the two cofactors */
382  for(pl = *L1, pr = *R1; (pl != NULL) && (pr != NULL); )
383  switch (d1_order(L1, R1)) {
384  case 1:
385  pr = *(++R1); break; /* advance right pointer */
386  case -1:
387  pl = *(++L1); break; /* advance left pointer */
388  case 0:
389  RESET(pr, ACTIVE);
390  INLINEset_or(pl, pl, pr);
391  pr = *(++R1);
392  default:
393  ;
394  }
395 }
#define RESET(set, flag)
Definition: espresso.h:123
#define INLINEset_or(r, a, b)
Definition: espresso.h:205
int d1_order()
#define ACTIVE
Definition: espresso.h:129
#define pcube
Definition: espresso.h:261
static void compl_lift ( )
static
static void compl_lift ( pcube A1,
pcube B1,
pcube  bcube,
int  var 
)
static

Definition at line 266 of file compl.c.

269 {
270  register pcube a, b, *B2, lift=cube.temp[4], liftor=cube.temp[5];
271  pcube mask = cube.var_mask[var];
272 
273  (void) set_and(liftor, bcube, mask);
274 
275  /* for each cube in the first array ... */
276  for(; (a = *A1++) != NULL; ) {
277  if (TESTP(a, ACTIVE)) {
278 
279  /* create a lift of this cube in the merging coord */
280  (void) set_merge(lift, bcube, a, mask);
281 
282  /* for each cube in the second array */
283  for(B2 = B1; (b = *B2++) != NULL; ) {
284  INLINEsetp_implies(lift, b, /* when_false => */ continue);
285  /* when_true => fall through to next statement */
286 
287  /* cube of A1 was contained by some cube of B1, so raise */
288  INLINEset_or(a, a, liftor);
289  break;
290  }
291  }
292  }
293 }
#define INLINEsetp_implies(a, b, when_false)
Definition: espresso.h:228
int var(Lit p)
Definition: SolverTypes.h:62
pset set_and()
#define INLINEset_or(r, a, b)
Definition: espresso.h:205
#define TESTP(set, flag)
Definition: espresso.h:124
#define ACTIVE
Definition: espresso.h:129
pset set_merge()
#define pcube
Definition: espresso.h:261
static void compl_lift_onset ( )
static
static void compl_lift_onset ( pcube A1,
pcover  T,
pcube  bcube,
int  var 
)
static

Definition at line 303 of file compl.c.

308 {
309  register pcube a, last, p, lift=cube.temp[4], mask=cube.var_mask[var];
310 
311  /* for each active cube from one branch of the complement */
312  for(; (a = *A1++) != NULL; ) {
313  if (TESTP(a, ACTIVE)) {
314 
315  /* create a lift of this cube in the merging coord */
316  INLINEset_and(lift, bcube, mask); /* isolate parts to raise */
317  INLINEset_or(lift, a, lift); /* raise these parts in a */
318 
319  /* for each cube in the ON-set, check for intersection */
320  foreach_set(T, last, p) {
321  if (cdist0(p, lift)) {
322  goto nolift;
323  }
324  }
325  INLINEset_copy(a, lift); /* save the raising */
326  SET(a, ACTIVE);
327 nolift : ;
328  }
329  }
330 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int var(Lit p)
Definition: SolverTypes.h:62
#define INLINEset_and(r, a, b)
Definition: espresso.h:202
#define SET(set, flag)
Definition: espresso.h:122
#define foreach_set(R, last, p)
Definition: espresso.h:135
#define INLINEset_or(r, a, b)
Definition: espresso.h:205
#define INLINEset_copy(r, a)
Definition: espresso.h:195
#define TESTP(set, flag)
Definition: espresso.h:124
#define ACTIVE
Definition: espresso.h:129
bool cdist0()
#define pcube
Definition: espresso.h:261
static void compl_lift_onset_complex ( )
static
static void compl_lift_onset_complex ( pcube A1,
pcover  T,
int  var 
)
static

Definition at line 338 of file compl.c.

342 {
343  register int dist;
344  register pcube last, p, a, xlower;
345 
346  /* for each cube in the complement */
347  xlower = new_cube();
348  for(; (a = *A1++) != NULL; ) {
349 
350  if (TESTP(a, ACTIVE)) {
351 
352  /* Find which parts of the splitting variable are forced low */
353  INLINEset_clear(xlower, cube.size);
354  foreach_set(T, last, p) {
355  if ((dist = cdist01(p, a)) < 2) {
356  if (dist == 0) {
357  fatal("compl: ON-set and OFF-set are not orthogonal");
358  } else {
359  (void) force_lower(xlower, p, a);
360  }
361  }
362  }
363 
364  (void) set_diff(xlower, cube.var_mask[var], xlower);
365  (void) set_or(a, a, xlower);
366  free_cube(xlower);
367  }
368  }
369 }
pset force_lower()
pset set_or()
int cdist01()
void fatal(char *s)
Definition: cvrmisc.c:140
#define new_cube()
Definition: espresso.h:262
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int var(Lit p)
Definition: SolverTypes.h:62
#define free_cube(r)
Definition: espresso.h:263
#define foreach_set(R, last, p)
Definition: espresso.h:135
pset set_diff()
#define TESTP(set, flag)
Definition: espresso.h:124
#define ACTIVE
Definition: espresso.h:129
#define pcube
Definition: espresso.h:261
#define INLINEset_clear(r, size)
Definition: espresso.h:197
static pcover compl_merge ( )
static
static pcover compl_merge ( pcube T1,
pcover  L,
pcover  R,
pcube  cl,
pcube  cr,
int  var,
int  lifting 
)
static

Definition at line 172 of file compl.c.

178 {
179  register pcube p, last, pt;
180  pcover T, Tbar;
181  pcube *L1, *R1;
182 
183  if (debug & COMPL) {
184  (void) printf("compl_merge: left %d, right %d\n", L->count, R->count);
185  (void) printf("%s (cl)\n%s (cr)\nLeft is\n", pc1(cl), pc2(cr));
186  cprint(L);
187  (void) printf("Right is\n");
188  cprint(R);
189  }
190 
191  /* Intersect each cube with the cofactored cube */
192  foreach_set(L, last, p) {
193  INLINEset_and(p, p, cl);
194  SET(p, ACTIVE);
195  }
196  foreach_set(R, last, p) {
197  INLINEset_and(p, p, cr);
198  SET(p, ACTIVE);
199  }
200 
201  /* Sort the arrays for a distance-1 merge */
202  (void) set_copy(cube.temp[0], cube.var_mask[var]);
203  qsort((char *) (L1 = sf_list(L)), L->count, sizeof(pset), (int (*)()) d1_order);
204  qsort((char *) (R1 = sf_list(R)), R->count, sizeof(pset), (int (*)()) d1_order);
205 
206  /* Perform distance-1 merge */
207  compl_d1merge(L1, R1);
208 
209  /* Perform lifting */
210  switch(lifting) {
212  T = cubeunlist(T1);
213  compl_lift_onset(L1, T, cr, var);
214  compl_lift_onset(R1, T, cl, var);
215  free_cover(T);
216  break;
218  T = cubeunlist(T1);
221  free_cover(T);
222  break;
223  case USE_COMPL_LIFT:
224  compl_lift(L1, R1, cr, var);
225  compl_lift(R1, L1, cl, var);
226  break;
227  case NO_LIFTING:
228  break;
229  default:
230  ;
231  }
232  FREE(L1);
233  FREE(R1);
234 
235  /* Re-create the merged cover */
236  Tbar = new_cover(L->count + R->count);
237  pt = Tbar->data;
238  foreach_set(L, last, p) {
239  INLINEset_copy(pt, p);
240  Tbar->count++;
241  pt += Tbar->wsize;
242  }
243  foreach_active_set(R, last, p) {
244  INLINEset_copy(pt, p);
245  Tbar->count++;
246  pt += Tbar->wsize;
247  }
248 
249  if (debug & COMPL) {
250  (void) printf("Result %d\n", Tbar->count);
251  if (verbose_debug)
252  cprint(Tbar);
253  }
254 
255  free_cover(L);
256  free_cover(R);
257  return Tbar;
258 }
pcover cubeunlist(pcube *A1)
Definition: cofactor.c:350
#define USE_COMPL_LIFT_ONSET_COMPLEX
Definition: compl.c:34
char * pc1(pcube c)
Definition: cvrout.c:379
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define free_cover(r)
Definition: espresso.h:266
#define pcover
Definition: espresso.h:264
pset set_copy()
int var(Lit p)
Definition: SolverTypes.h:62
#define INLINEset_and(r, a, b)
Definition: espresso.h:202
#define USE_COMPL_LIFT_ONSET
Definition: compl.c:33
void cprint(pcover T)
Definition: cvrout.c:424
char * pc2(pcube c)
Definition: cvrout.c:381
#define SET(set, flag)
Definition: espresso.h:122
#define foreach_set(R, last, p)
Definition: espresso.h:135
static void compl_d1merge()
#define USE_COMPL_LIFT
Definition: compl.c:32
unsigned int debug
Definition: globals.c:19
static void compl_lift_onset_complex()
static void compl_lift()
#define INLINEset_copy(r, a)
Definition: espresso.h:195
#define NO_LIFTING
Definition: compl.c:35
#define FREE(obj)
Definition: avl.h:31
#define new_cover(i)
Definition: espresso.h:265
unsigned int * pset
Definition: espresso.h:73
int d1_order()
#define foreach_active_set(R, last, p)
Definition: espresso.h:139
pset * sf_list(IN register pset_family A)
Definition: contain.c:351
bool verbose_debug
Definition: globals.c:20
#define ACTIVE
Definition: espresso.h:129
#define COMPL
Definition: espresso.h:351
#define pcube
Definition: espresso.h:261
static void compl_lift_onset()
static bool compl_special_cases ( )
static
static bool compl_special_cases ( pcube T,
pcover Tbar 
)
static

Definition at line 89 of file compl.c.

92 {
93  register pcube *T1, p, ceil, cof=T[0];
94  pcover A, ceil_compl;
95 
96  /* Check for no cubes in the cover */
97  if (T[2] == NULL) {
98  *Tbar = sf_addset(new_cover(1), cube.fullset);
99  free_cubelist(T);
100  return TRUE;
101  }
102 
103  /* Check for only a single cube in the cover */
104  if (T[3] == NULL) {
105  *Tbar = compl_cube(set_or(cof, cof, T[2]));
106  free_cubelist(T);
107  return TRUE;
108  }
109 
110  /* Check for a row of all 1's (implies complement is null) */
111  for(T1 = T+2; (p = *T1++) != NULL; ) {
112  if (full_row(p, cof)) {
113  *Tbar = new_cover(0);
114  free_cubelist(T);
115  return TRUE;
116  }
117  }
118 
119  /* Check for a column of all 0's which can be factored out */
120  ceil = set_save(cof);
121  for(T1 = T+2; (p = *T1++) != NULL; ) {
122  INLINEset_or(ceil, ceil, p);
123  }
124  if (! setp_equal(ceil, cube.fullset)) {
125  ceil_compl = compl_cube(ceil);
126  (void) set_or(cof, cof, set_diff(ceil, cube.fullset, ceil));
127  set_free(ceil);
128  *Tbar = sf_append(complement(T), ceil_compl);
129  return TRUE;
130  }
131  set_free(ceil);
132 
133  /* Collect column counts, determine unate variables, etc. */
134  massive_count(T);
135 
136  /* If single active variable not factored out above, then tautology ! */
137  if (cdata.vars_active == 1) {
138  *Tbar = new_cover(0);
139  free_cubelist(T);
140  return TRUE;
141 
142  /* Check for unate cover */
143  } else if (cdata.vars_unate == cdata.vars_active) {
144  A = map_cover_to_unate(T);
145  free_cubelist(T);
146  A = unate_compl(A);
147  *Tbar = map_unate_to_cover(A);
148  sf_free(A);
149  return TRUE;
150 
151  /* Not much we can do about it */
152  } else {
153  return MAYBE;
154  }
155 }
pset set_or()
static pcover compl_cube()
#define set_free(r)
Definition: espresso.h:167
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define pcover
Definition: espresso.h:264
#define set_save(r)
Definition: espresso.h:166
void sf_free()
pcover complement(pcube *T)
Definition: compl.c:49
#define INLINEset_or(r, a, b)
Definition: espresso.h:205
bool setp_equal()
pset_family sf_addset()
pset set_diff()
bool full_row()
pset_family unate_compl()
#define new_cover(i)
Definition: espresso.h:265
#define TRUE
Definition: cudd.h:88
pcover map_unate_to_cover()
#define free_cubelist(T)
Definition: espresso.h:267
#define MAYBE
Definition: espresso.h:257
pcover map_cover_to_unate()
pset_family sf_append()
#define pcube
Definition: espresso.h:261
void massive_count(IN pcube *T)
Definition: cofactor.c:131
pcover complement ( pcube T)

Definition at line 49 of file compl.c.

51 {
52  register pcube cl, cr;
53  register int best;
54  pcover Tbar, Tl, Tr;
55  int lifting;
56  static int compl_level = 0;
57 
58  if (debug & COMPL)
59  debug_print(T, "COMPLEMENT", compl_level++);
60 
61  if (compl_special_cases(T, &Tbar) == MAYBE) {
62 
63  /* Allocate space for the partition cubes */
64  cl = new_cube();
65  cr = new_cube();
66  best = binate_split_select(T, cl, cr, COMPL);
67 
68  /* Complement the left and right halves */
69  Tl = complement(scofactor(T, cl, best));
70  Tr = complement(scofactor(T, cr, best));
71 
72  if (Tr->count*Tl->count > (Tr->count+Tl->count)*CUBELISTSIZE(T)) {
73  lifting = USE_COMPL_LIFT_ONSET;
74  } else {
75  lifting = USE_COMPL_LIFT;
76  }
77  Tbar = compl_merge(T, Tl, Tr, cl, cr, best, lifting);
78 
79  free_cube(cl);
80  free_cube(cr);
81  free_cubelist(T);
82  }
83 
84  if (debug & COMPL)
85  debug1_print(Tbar, "exit COMPLEMENT", --compl_level);
86  return Tbar;
87 }
#define new_cube()
Definition: espresso.h:262
#define pcover
Definition: espresso.h:264
#define USE_COMPL_LIFT_ONSET
Definition: compl.c:33
#define free_cube(r)
Definition: espresso.h:263
pcover complement(pcube *T)
Definition: compl.c:49
#define CUBELISTSIZE(T)
Definition: espresso.h:329
#define USE_COMPL_LIFT
Definition: compl.c:32
unsigned int debug
Definition: globals.c:19
static pcover compl_merge()
int binate_split_select(IN pcube *T, IN register pcube cleft, IN register pcube cright, IN int debug_flag)
Definition: cofactor.c:258
pcube * scofactor(IN pcube *T, IN pcube c, IN int var)
Definition: cofactor.c:93
#define free_cubelist(T)
Definition: espresso.h:267
void debug_print(pcube *T, char *name, int level)
Definition: cvrout.c:385
#define MAYBE
Definition: espresso.h:257
void debug1_print(pcover T, char *name, int num)
Definition: cvrout.c:407
#define COMPL
Definition: espresso.h:351
static bool compl_special_cases()
#define pcube
Definition: espresso.h:261
void simp_comp ( pcube T,
pcover Tnew,
pcover Tbar 
)

Definition at line 425 of file compl.c.

429 {
430  register pcube cl, cr;
431  register int best;
432  pcover Tl, Tr, Tlbar, Trbar;
433  int lifting;
434  static int simplify_level = 0;
435 
436  if (debug & COMPL)
437  debug_print(T, "SIMPCOMP", simplify_level++);
438 
439  if (simp_comp_special_cases(T, Tnew, Tbar) == MAYBE) {
440 
441  /* Allocate space for the partition cubes */
442  cl = new_cube();
443  cr = new_cube();
444  best = binate_split_select(T, cl, cr, COMPL);
445 
446  /* Complement the left and right halves */
447  simp_comp(scofactor(T, cl, best), &Tl, &Tlbar);
448  simp_comp(scofactor(T, cr, best), &Tr, &Trbar);
449 
450  lifting = USE_COMPL_LIFT;
451  *Tnew = compl_merge(T, Tl, Tr, cl, cr, best, lifting);
452 
453  lifting = USE_COMPL_LIFT;
454  *Tbar = compl_merge(T, Tlbar, Trbar, cl, cr, best, lifting);
455 
456  /* All of this work for nothing ? Let's hope not ... */
457  if ((*Tnew)->count > CUBELISTSIZE(T)) {
458  sf_free(*Tnew);
459  *Tnew = cubeunlist(T);
460  }
461 
462  free_cube(cl);
463  free_cube(cr);
464  free_cubelist(T);
465  }
466 
467  if (debug & COMPL) {
468  debug1_print(*Tnew, "exit SIMPCOMP (new)", simplify_level);
469  debug1_print(*Tbar, "exit SIMPCOMP (compl)", simplify_level);
470  simplify_level--;
471  }
472 }
pcover cubeunlist(pcube *A1)
Definition: cofactor.c:350
#define new_cube()
Definition: espresso.h:262
#define pcover
Definition: espresso.h:264
void sf_free()
#define free_cube(r)
Definition: espresso.h:263
static bool simp_comp_special_cases()
#define CUBELISTSIZE(T)
Definition: espresso.h:329
#define USE_COMPL_LIFT
Definition: compl.c:32
unsigned int debug
Definition: globals.c:19
static pcover compl_merge()
void simp_comp(pcube *T, pcover *Tnew, pcover *Tbar)
Definition: compl.c:425
int binate_split_select(IN pcube *T, IN register pcube cleft, IN register pcube cright, IN int debug_flag)
Definition: cofactor.c:258
pcube * scofactor(IN pcube *T, IN pcube c, IN int var)
Definition: cofactor.c:93
#define free_cubelist(T)
Definition: espresso.h:267
void debug_print(pcube *T, char *name, int level)
Definition: cvrout.c:385
#define MAYBE
Definition: espresso.h:257
void debug1_print(pcover T, char *name, int num)
Definition: cvrout.c:407
#define COMPL
Definition: espresso.h:351
#define pcube
Definition: espresso.h:261
static bool simp_comp_special_cases ( )
static
static bool simp_comp_special_cases ( pcube T,
pcover Tnew,
pcover Tbar 
)
static

Definition at line 474 of file compl.c.

478 {
479  register pcube *T1, p, ceil, cof=T[0];
480  pcube last;
481  pcover A;
482 
483  /* Check for no cubes in the cover (function is empty) */
484  if (T[2] == NULL) {
485  *Tnew = new_cover(1);
486  *Tbar = sf_addset(new_cover(1), cube.fullset);
487  free_cubelist(T);
488  return TRUE;
489  }
490 
491  /* Check for only a single cube in the cover */
492  if (T[3] == NULL) {
493  (void) set_or(cof, cof, T[2]);
494  *Tnew = sf_addset(new_cover(1), cof);
495  *Tbar = compl_cube(cof);
496  free_cubelist(T);
497  return TRUE;
498  }
499 
500  /* Check for a row of all 1's (function is a tautology) */
501  for(T1 = T+2; (p = *T1++) != NULL; ) {
502  if (full_row(p, cof)) {
503  *Tnew = sf_addset(new_cover(1), cube.fullset);
504  *Tbar = new_cover(1);
505  free_cubelist(T);
506  return TRUE;
507  }
508  }
509 
510  /* Check for a column of all 0's which can be factored out */
511  ceil = set_save(cof);
512  for(T1 = T+2; (p = *T1++) != NULL; ) {
513  INLINEset_or(ceil, ceil, p);
514  }
515  if (! setp_equal(ceil, cube.fullset)) {
516  p = new_cube();
517  (void) set_diff(p, cube.fullset, ceil);
518  (void) set_or(cof, cof, p);
519  set_free(p);
520  simp_comp(T, Tnew, Tbar);
521 
522  /* Adjust the ON-set */
523  A = *Tnew;
524  foreach_set(A, last, p) {
525  INLINEset_and(p, p, ceil);
526  }
527 
528  /* Compute the new complement */
529  *Tbar = sf_append(*Tbar, compl_cube(ceil));
530  set_free(ceil);
531  return TRUE;
532  }
533  set_free(ceil);
534 
535  /* Collect column counts, determine unate variables, etc. */
536  massive_count(T);
537 
538  /* If single active variable not factored out above, then tautology ! */
539  if (cdata.vars_active == 1) {
540  *Tnew = sf_addset(new_cover(1), cube.fullset);
541  *Tbar = new_cover(1);
542  free_cubelist(T);
543  return TRUE;
544 
545  /* Check for unate cover */
546  } else if (cdata.vars_unate == cdata.vars_active) {
547  /* Make the cover minimum by single-cube containment */
548  A = cubeunlist(T);
549  *Tnew = sf_contain(A);
550 
551  /* Now form a minimum representation of the complement */
552  A = map_cover_to_unate(T);
553  A = unate_compl(A);
554  *Tbar = map_unate_to_cover(A);
555  sf_free(A);
556  free_cubelist(T);
557  return TRUE;
558 
559  /* Not much we can do about it */
560  } else {
561  return MAYBE;
562  }
563 }
pcover cubeunlist(pcube *A1)
Definition: cofactor.c:350
pset set_or()
static pcover compl_cube()
#define set_free(r)
Definition: espresso.h:167
#define new_cube()
Definition: espresso.h:262
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define pcover
Definition: espresso.h:264
#define set_save(r)
Definition: espresso.h:166
#define INLINEset_and(r, a, b)
Definition: espresso.h:202
void sf_free()
#define foreach_set(R, last, p)
Definition: espresso.h:135
#define INLINEset_or(r, a, b)
Definition: espresso.h:205
bool setp_equal()
ABC_NAMESPACE_IMPL_START pset_family sf_contain(INOUT pset_family A)
Definition: contain.c:37
pset_family sf_addset()
pset set_diff()
bool full_row()
pset_family unate_compl()
#define new_cover(i)
Definition: espresso.h:265
void simp_comp(pcube *T, pcover *Tnew, pcover *Tbar)
Definition: compl.c:425
#define TRUE
Definition: cudd.h:88
pcover map_unate_to_cover()
#define free_cubelist(T)
Definition: espresso.h:267
#define MAYBE
Definition: espresso.h:257
pcover map_cover_to_unate()
pset_family sf_append()
#define pcube
Definition: espresso.h:261
void massive_count(IN pcube *T)
Definition: cofactor.c:131
pcover simplify ( pcube T)

Definition at line 566 of file compl.c.

568 {
569  register pcube cl, cr;
570  register int best;
571  pcover Tbar, Tl, Tr;
572  int lifting;
573  static int simplify_level = 0;
574 
575  if (debug & COMPL) {
576  debug_print(T, "SIMPLIFY", simplify_level++);
577  }
578 
579  if (simplify_special_cases(T, &Tbar) == MAYBE) {
580 
581  /* Allocate space for the partition cubes */
582  cl = new_cube();
583  cr = new_cube();
584 
585  best = binate_split_select(T, cl, cr, COMPL);
586 
587  /* Complement the left and right halves */
588  Tl = simplify(scofactor(T, cl, best));
589  Tr = simplify(scofactor(T, cr, best));
590 
591  lifting = USE_COMPL_LIFT;
592  Tbar = compl_merge(T, Tl, Tr, cl, cr, best, lifting);
593 
594  /* All of this work for nothing ? Let's hope not ... */
595  if (Tbar->count > CUBELISTSIZE(T)) {
596  sf_free(Tbar);
597  Tbar = cubeunlist(T);
598  }
599 
600  free_cube(cl);
601  free_cube(cr);
602  free_cubelist(T);
603  }
604 
605  if (debug & COMPL) {
606  debug1_print(Tbar, "exit SIMPLIFY", --simplify_level);
607  }
608  return Tbar;
609 }
pcover cubeunlist(pcube *A1)
Definition: cofactor.c:350
#define new_cube()
Definition: espresso.h:262
#define pcover
Definition: espresso.h:264
static bool simplify_special_cases()
void sf_free()
#define free_cube(r)
Definition: espresso.h:263
#define CUBELISTSIZE(T)
Definition: espresso.h:329
#define USE_COMPL_LIFT
Definition: compl.c:32
unsigned int debug
Definition: globals.c:19
static pcover compl_merge()
int binate_split_select(IN pcube *T, IN register pcube cleft, IN register pcube cright, IN int debug_flag)
Definition: cofactor.c:258
pcube * scofactor(IN pcube *T, IN pcube c, IN int var)
Definition: cofactor.c:93
#define free_cubelist(T)
Definition: espresso.h:267
void debug_print(pcube *T, char *name, int level)
Definition: cvrout.c:385
#define MAYBE
Definition: espresso.h:257
pcover simplify(pcube *T)
Definition: compl.c:566
void debug1_print(pcover T, char *name, int num)
Definition: cvrout.c:407
#define COMPL
Definition: espresso.h:351
#define pcube
Definition: espresso.h:261
static bool simplify_special_cases ( )
static
static bool simplify_special_cases ( pcube T,
pcover Tnew 
)
static

Definition at line 611 of file compl.c.

614 {
615  register pcube *T1, p, ceil, cof=T[0];
616  pcube last;
617  pcover A;
618 
619  /* Check for no cubes in the cover */
620  if (T[2] == NULL) {
621  *Tnew = new_cover(0);
622  free_cubelist(T);
623  return TRUE;
624  }
625 
626  /* Check for only a single cube in the cover */
627  if (T[3] == NULL) {
628  *Tnew = sf_addset(new_cover(1), set_or(cof, cof, T[2]));
629  free_cubelist(T);
630  return TRUE;
631  }
632 
633  /* Check for a row of all 1's (implies function is a tautology) */
634  for(T1 = T+2; (p = *T1++) != NULL; ) {
635  if (full_row(p, cof)) {
636  *Tnew = sf_addset(new_cover(1), cube.fullset);
637  free_cubelist(T);
638  return TRUE;
639  }
640  }
641 
642  /* Check for a column of all 0's which can be factored out */
643  ceil = set_save(cof);
644  for(T1 = T+2; (p = *T1++) != NULL; ) {
645  INLINEset_or(ceil, ceil, p);
646  }
647  if (! setp_equal(ceil, cube.fullset)) {
648  p = new_cube();
649  (void) set_diff(p, cube.fullset, ceil);
650  (void) set_or(cof, cof, p);
651  free_cube(p);
652 
653  A = simplify(T);
654  foreach_set(A, last, p) {
655  INLINEset_and(p, p, ceil);
656  }
657  *Tnew = A;
658  set_free(ceil);
659  return TRUE;
660  }
661  set_free(ceil);
662 
663  /* Collect column counts, determine unate variables, etc. */
664  massive_count(T);
665 
666  /* If single active variable not factored out above, then tautology ! */
667  if (cdata.vars_active == 1) {
668  *Tnew = sf_addset(new_cover(1), cube.fullset);
669  free_cubelist(T);
670  return TRUE;
671 
672  /* Check for unate cover */
673  } else if (cdata.vars_unate == cdata.vars_active) {
674  A = cubeunlist(T);
675  *Tnew = sf_contain(A);
676  free_cubelist(T);
677  return TRUE;
678 
679  /* Not much we can do about it */
680  } else {
681  return MAYBE;
682  }
683 }
pcover cubeunlist(pcube *A1)
Definition: cofactor.c:350
pset set_or()
#define set_free(r)
Definition: espresso.h:167
#define new_cube()
Definition: espresso.h:262
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define pcover
Definition: espresso.h:264
#define set_save(r)
Definition: espresso.h:166
#define INLINEset_and(r, a, b)
Definition: espresso.h:202
#define free_cube(r)
Definition: espresso.h:263
#define foreach_set(R, last, p)
Definition: espresso.h:135
#define INLINEset_or(r, a, b)
Definition: espresso.h:205
bool setp_equal()
ABC_NAMESPACE_IMPL_START pset_family sf_contain(INOUT pset_family A)
Definition: contain.c:37
pset_family sf_addset()
pset set_diff()
bool full_row()
#define new_cover(i)
Definition: espresso.h:265
#define TRUE
Definition: cudd.h:88
#define free_cubelist(T)
Definition: espresso.h:267
#define MAYBE
Definition: espresso.h:257
pcover simplify(pcube *T)
Definition: compl.c:566
#define pcube
Definition: espresso.h:261
void massive_count(IN pcube *T)
Definition: cofactor.c:131