00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "espresso.h"
00011
00012
00013 find_equiv_outputs(PLA)
00014 pPLA PLA;
00015 {
00016 int i, j, ipart, jpart, some_equiv;
00017 pcover *R, *F;
00018
00019 some_equiv = FALSE;
00020
00021 makeup_labels(PLA);
00022
00023 F = ALLOC(pcover, cube.part_size[cube.output]);
00024 R = ALLOC(pcover, cube.part_size[cube.output]);
00025
00026 for(i = 0; i < cube.part_size[cube.output]; i++) {
00027 ipart = cube.first_part[cube.output] + i;
00028 R[i] = cof_output(PLA->R, ipart);
00029 F[i] = complement(cube1list(R[i]));
00030 }
00031
00032 for(i = 0; i < cube.part_size[cube.output]-1; i++) {
00033 for(j = i+1; j < cube.part_size[cube.output]; j++) {
00034 ipart = cube.first_part[cube.output] + i;
00035 jpart = cube.first_part[cube.output] + j;
00036
00037 if (check_equiv(F[i], F[j])) {
00038 (void) printf("# Outputs %d and %d (%s and %s) are equivalent\n",
00039 i, j, PLA->label[ipart], PLA->label[jpart]);
00040 some_equiv = TRUE;
00041 } else if (check_equiv(F[i], R[j])) {
00042 (void) printf("# Outputs %d and NOT %d (%s and %s) are equivalent\n",
00043 i, j, PLA->label[ipart], PLA->label[jpart]);
00044 some_equiv = TRUE;
00045 } else if (check_equiv(R[i], F[j])) {
00046 (void) printf("# Outputs NOT %d and %d (%s and %s) are equivalent\n",
00047 i, j, PLA->label[ipart], PLA->label[jpart]);
00048 some_equiv = TRUE;
00049 } else if (check_equiv(R[i], R[j])) {
00050 (void) printf("# Outputs NOT %d and NOT %d (%s and %s) are equivalent\n",
00051 i, j, PLA->label[ipart], PLA->label[jpart]);
00052 some_equiv = TRUE;
00053 }
00054 }
00055 }
00056
00057 if (! some_equiv) {
00058 (void) printf("# No outputs are equivalent\n");
00059 }
00060
00061 for(i = 0; i < cube.part_size[cube.output]; i++) {
00062 free_cover(F[i]);
00063 free_cover(R[i]);
00064 }
00065 FREE(F);
00066 FREE(R);
00067 }
00068
00069
00070
00071 int check_equiv(f1, f2)
00072 pcover f1, f2;
00073 {
00074 register pcube *f1list, *f2list;
00075 register pcube p, last;
00076
00077 f1list = cube1list(f1);
00078 foreach_set(f2, last, p) {
00079 if (! cube_is_covered(f1list, p)) {
00080 return FALSE;
00081 }
00082 }
00083 free_cubelist(f1list);
00084
00085 f2list = cube1list(f2);
00086 foreach_set(f1, last, p) {
00087 if (! cube_is_covered(f2list, p)) {
00088 return FALSE;
00089 }
00090 }
00091 free_cubelist(f2list);
00092
00093 return TRUE;
00094 }