public boolean plResolution(KnowledgeBase kb,Sentence alpha){
  Set<Clause> clauses=setOfClausesInTheCNFRepresentationOfKBAndNotAlpha(kb,alpha);
  Set<Clause> newClauses=new LinkedHashSet<Clause>();
  do {
    List<Clause> clausesAsList=new ArrayList<Clause>(clauses);
    for (int i=0; i < clausesAsList.size() - 1; i++) {
      Clause ci=clausesAsList.get(i);
      for (int j=i + 1; j < clausesAsList.size(); j++) {
        Clause cj=clausesAsList.get(j);
        Set<Clause> resolvents=plResolve(ci,cj);
        if (resolvents.contains(Clause.EMPTY)) {
          return true;
        }
        newClauses.addAll(resolvents);
      }
    }
    if (clauses.containsAll(newClauses)) {
      return false;
    }
    clauses.addAll(newClauses);
  }
 while (true);
}

public boolean plResolution ( KnowledgeBase kb , Sentence alpha ) { Set < Clause > clauses = setOfClausesInTheCNFRepresentationOfKBAndNotAlpha ( kb , alpha ) ; Set < Clause > newClauses = new LinkedHashSet < Clause > ( ) ; do { List < Clause > clausesAsList = new ArrayList < Clause > ( clauses ) ; for ( int i = 0 ; i < clausesAsList . size ( ) - 1 ; i ++ ) { Clause ci = clausesAsList . get ( i ) ; for ( int j = i + 1 ; j < clausesAsList . size ( ) ; j ++ ) { Clause cj = clausesAsList . get ( j ) ; Set < Clause > resolvents = plResolve ( ci , cj ) ; if ( resolvents . contains ( Clause . EMPTY ) ) { return true ; } newClauses . addAll ( resolvents ) ; } } if ( clauses . containsAll ( newClauses ) ) { return false ; } clauses . addAll ( newClauses ) ; } while ( true ) ; }
pl - resolution ( kb , & alpha ; ) < br > a simple resolution algorithm for propositional logic .
