/*Complied with g++. *this program is primarily used for testing individual DNF with more than 6 variables to see if there is any counterexample to the conjecture described in the thesis * */ # include # include # include # include # include #define Nvar 6 //the number of variables in a DNF #define Nterm 64 //the max number of terms in a 6 vars DNF void nrerror(char error_text[]) /*Numerical Recipes standard error handler*/ { int i; printf("\n\n"); fprintf(stderr,"Numerical Recipes run-time error...\n"); fprintf(stderr,"%s\n",error_text); fprintf(stderr,"...now exiting to system...\n"); exit(1); } int **imatrix(int nrl,int nrh,int ncl,int nch) /*Allocates a float matrix with range [nrl..nrh][ncl..nch]*/ { int i; int **m; m = new(int *[nrh-nrl+1]); if(!m)nrerror("Allocation failure 1 in matrix()"); m-=nrl; for(i=nrl;i<=nrh;i++){ m[i] = new(int [nch-ncl+1]); if(!m[i]) nrerror("Allocation failure 2 in matrix"); m[i] -= ncl; } return(m); } void free_imatrix(int **m,int nrl,int nrh,int ncl,int nch) /*Frees a matrix allocated by matrix()*/ { int i; for(i=nrh;i>=nrl;i--) delete [] (m[i]+ncl); delete [] (m+nrl); } int influence_cal(int **m,int tm,int n) /* the array vlist stores the list of variables as well as its inf, * sorted from the max inf to min inf */ { //to calculate the inf using the naive method, which defines the inf as a ratio of the numb of changed f(v)|v:0->1, //with the total 2^n numbers. And here the inf is defined without normalized by 2^n since one only cares the relative inf int dnf[Nterm],v[n]; int i,j,k,l; int fv,tv; //either 0 or 1 int tmp, indxf; int max=0, mindex; int vinf[n]; for(i=0;i>j)&1)? 1:0 ; //calculate the DNF function value for each i fv=0; for(k=1;k<=tm;k++) { tv=1; //initialize the term value for(l=1;l<=n;l++) { if(m[k][l]&1) //variable exsits tv&=v[l-1]; } fv|=tv; if(fv&1) break; //if DNF is already 1, calculation is done } dnf[i]=fv; } //cal the inf for each varible for(j=0;j>j)&1))//if the var_j is 0 { tmp=dnf[i]; indxf=(i|(1<leaf[i]) { min=leaf[i]; //get the min leaves //cout << "i is "< \n"); exit(0); } //allocating and initializing a DNF matrix DNF=imatrix(1,Nterm,1,Nvar); for(i=1;i<=Nterm;i++) { for(j=1;j<=Nvar;j++) { DNF[i][j]=0; } } int tn=1; //to keep track of the actual terms in a DNF //the following reads a DNF function from a file and stores in a matrix ifstream fin; fin.open(argc[1],ifstream::in); int vn; fin.get(c); while(c!='\n') { fin>>vn; DNF[tn][vn]=1; fin.get(c); if(c=='+') { tn++; fin.get(c); } } fin.close(); //finishing reading the file /* * debug the output * of the input reading */ cout<<" the input file has "<