/** new * gives the count of clauses that each literal solves uniequely and the clauses that are not satifiable by the literal * @param c the clause * @parm I the interpretation * @parm f the fourmla that contains the arrays of occus * @return TRUE if it is satisfied uniquely, FALSE if not uniquely satiscfied. */ void countSatLiterals(Formula f ,Interpretation I) { for (int i = 1; i <= f.nbVariables ; ++i) { clauseLink* head ,* headOpp; int count=0, index; if (getValueLiteral(I,i)) { head=f.literalOccurrences[literalIdx(i)]; headOpp=f.literalOccurrences[oppositeLiteralIdx(i)]; index=i; } else { head=f.literalOccurrences[oppositeLiteralIdx(i)]; headOpp=f.literalOccurrences[literalIdx(i)]; index= (-1*i); } while(head!=NULL) { if (isUniquelySat(*head->clause,I,index)) { count++; } head=head->next; } f.countUniq.datas[i]=count; //printf("for literal %d the count of sat is %d\n",i,count); count=0; while(headOpp!=NULL) { if (isFalsifiedClause(*headOpp->clause,I)) { count++; } headOpp=headOpp->next; } f.countUnSat.datas[i]=count; //printf("for literal %d the count of unsat is %d\n",i,count); } }
node * getOccurrences(Formula f, Literal l) { /*vecInt * occ=(vecInt *)malloc(sizeof(vecInt)); createEmptyVec(f.nbVariables,occ); for (int i = 0; i <f.nbClauses ; i++) { for(int j=0;j<f.clauses[i].size;j++) if(f.clauses[i].datas[j]==l)addLast(occ,i); } return occ;*/ /*int v=getVariable(l); if(l>0) return &f.literalOccurrences[2*(v-1)]; if(l<0) return &f.literalOccurrences[2*(v-1)+1];*/ return f.literalOccurrences[literalIdx(l)]; }