00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "espresso.h"
00014
00015
00016
00017
00018
00019 bool verify(F, Fold, Dold)
00020 pcover F, Fold, Dold;
00021 {
00022 pcube p, last, *FD;
00023 bool verify_error = FALSE;
00024
00025
00026 FD = cube2list(Fold, Dold);
00027 foreach_set(F, last, p)
00028 if (! cube_is_covered(FD, p)) {
00029 printf("some minterm in F is not covered by Fold u Dold\n");
00030 verify_error = TRUE;
00031 if (verbose_debug) printf("%s\n", pc1(p)); else break;
00032 }
00033 free_cubelist(FD);
00034
00035
00036 FD = cube2list(F, Dold);
00037 foreach_set(Fold, last, p)
00038 if (! cube_is_covered(FD, p)) {
00039 printf("some minterm in Fold is not covered by F u Dold\n");
00040 verify_error = TRUE;
00041 if (verbose_debug) printf("%s\n", pc1(p)); else break;
00042 }
00043 free_cubelist(FD);
00044
00045 return verify_error;
00046 }
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 bool PLA_verify(PLA1, PLA2)
00058 pPLA PLA1, PLA2;
00059 {
00060
00061
00062
00063 if (PLA1->label != NULL && PLA1->label[0] != NULL &&
00064 PLA2->label != NULL && PLA2->label[0] != NULL) {
00065 PLA_permute(PLA1, PLA2);
00066 } else {
00067 (void) fprintf(stderr, "Warning: cannot permute columns without names\n");
00068 return TRUE;
00069 }
00070
00071 if (PLA1->F->sf_size != PLA2->F->sf_size) {
00072 (void) fprintf(stderr, "PLA_verify: PLA's are not the same size\n");
00073 return TRUE;
00074 }
00075
00076 return verify(PLA2->F, PLA1->F, PLA1->D);
00077 }
00078
00079
00080
00081
00082
00083
00084
00085
00086 PLA_permute(PLA1, PLA2)
00087 pPLA PLA1, PLA2;
00088 {
00089 register int i, j, *permute, npermute;
00090 register char *labi;
00091 char **label;
00092
00093
00094
00095
00096 npermute = 0;
00097 permute = ALLOC(int, PLA2->F->sf_size);
00098 for(i = 0; i < PLA2->F->sf_size; i++) {
00099 labi = PLA2->label[i];
00100 for(j = 0; j < PLA1->F->sf_size; j++) {
00101 if (strcmp(labi, PLA1->label[j]) == 0) {
00102 permute[npermute++] = j;
00103 break;
00104 }
00105 }
00106 }
00107
00108
00109 if (PLA1->F != NULL) {
00110 PLA1->F = sf_permute(PLA1->F, permute, npermute);
00111 }
00112 if (PLA1->R != NULL) {
00113 PLA1->R = sf_permute(PLA1->R, permute, npermute);
00114 }
00115 if (PLA1->D != NULL) {
00116 PLA1->D = sf_permute(PLA1->D, permute, npermute);
00117 }
00118
00119
00120 label = ALLOC(char *, cube.size);
00121 for(i = 0; i < npermute; i++) {
00122 label[i] = PLA1->label[permute[i]];
00123 }
00124 for(i = npermute; i < cube.size; i++) {
00125 label[i] = NULL;
00126 }
00127 FREE(PLA1->label);
00128 PLA1->label = label;
00129
00130 FREE(permute);
00131 }
00132
00133
00134
00135
00136
00137
00138
00139 bool check_consistency(PLA)
00140 pPLA PLA;
00141 {
00142 bool verify_error = FALSE;
00143 pcover T;
00144
00145 T = cv_intersect(PLA->F, PLA->D);
00146 if (T->count == 0)
00147 printf("ON-SET and DC-SET are disjoint\n");
00148 else {
00149 printf("Some minterm(s) belong to both the ON-SET and DC-SET !\n");
00150 if (verbose_debug)
00151 cprint(T);
00152 verify_error = TRUE;
00153 }
00154 (void) fflush(stdout);
00155 free_cover(T);
00156
00157 T = cv_intersect(PLA->F, PLA->R);
00158 if (T->count == 0)
00159 printf("ON-SET and OFF-SET are disjoint\n");
00160 else {
00161 printf("Some minterm(s) belong to both the ON-SET and OFF-SET !\n");
00162 if (verbose_debug)
00163 cprint(T);
00164 verify_error = TRUE;
00165 }
00166 (void) fflush(stdout);
00167 free_cover(T);
00168
00169 T = cv_intersect(PLA->D, PLA->R);
00170 if (T->count == 0)
00171 printf("DC-SET and OFF-SET are disjoint\n");
00172 else {
00173 printf("Some minterm(s) belong to both the OFF-SET and DC-SET !\n");
00174 if (verbose_debug)
00175 cprint(T);
00176 verify_error = TRUE;
00177 }
00178 (void) fflush(stdout);
00179 free_cover(T);
00180
00181 if (tautology(cube3list(PLA->F, PLA->D, PLA->R)))
00182 printf("Union of ON-SET, OFF-SET and DC-SET is the universe\n");
00183 else {
00184 T = complement(cube3list(PLA->F, PLA->D, PLA->R));
00185 printf("There are minterms left unspecified !\n");
00186 if (verbose_debug)
00187 cprint(T);
00188 verify_error = TRUE;
00189 free_cover(T);
00190 }
00191 (void) fflush(stdout);
00192 return verify_error;
00193 }