Ejemplo n.º 1
0
    def processClause(self):
        """
        Pick a clause from unprocessed and process it. If the empty
        clause is found, return it. Otherwise return None.
        """
        given_clause = self.unprocessed.extractFirst()
        given_clause = given_clause.freshVarCopy()
        print("#", given_clause)
        if given_clause.isEmpty():
            # We have found an explicit contradiction
            return given_clause

        new = []
        factors = computeAllFactors(given_clause)
        new.extend(factors)
        eresolvents = eresolution(given_clause)
        new.extend(eresolvents)
        resolvents = computeAllResolvents(given_clause, self.processed)
        new.extend(resolvents)
        modulated = computeAllParamodulates(given_clause, self.processed)
        new.extend(modulated)

        self.processed.addClause(given_clause)

        for c in new:
            self.unprocessed.addClause(c)
        return None
Ejemplo n.º 2
0
    def processClause(self):
        """
        Pick a clause from unprocessed and process it. If the empty
        clause is found, return it. Otherwise return None.
        """
        given_clause = self.unprocessed.extractBest()
        given_clause = given_clause.freshVarCopy()
        if not self.silent:
            print("#")
        if given_clause.isEmpty():
            # We have found an explicit contradiction
            return given_clause
        if self.params.delete_tautologies and \
           given_clause.isTautology():
            self.tautologies_deleted += 1
            return None
        if self.params.forward_subsumption and \
           forwardSubsumption(self.processed, given_clause):
            # If the given clause is subsumed by an already processed
            # clause, all releveant inferences will already have been
            # done with that more general clause. So we can discard
            # the given clause. We do keep count of how many clauses
            # we have dropped this way.
            self.forward_subsumed += 1
            return None

        if self.params.backward_subsumption:
            # If the given clause subsumes any of the already
            # processed clauses, it will "cover" for these less
            # general clauses in the future, so we can remove them
            # from the proof state. Again, we keep count of the number
            # of clauses dropped. This typically happens less often
            # than forward subsumption, because most heuristics prefer
            # smaller clauses, which tend to be more general (thus the
            # processed clauses are typically if not universally more
            # general than the new given clause).
            tmp = backwardSubsumption(given_clause, self.processed)
            self.backward_subsumed = self.backward_subsumed + tmp

        if (self.params.literal_selection):
            given_clause.selectInferenceLits(self.params.literal_selection)
        if not self.silent:
            print("#", given_clause)
        new = []
        factors = computeAllFactors(given_clause)
        new.extend(factors)
        resolvents = computeAllResolvents(given_clause, self.processed)
        new.extend(resolvents)
        self.proc_clause_count = self.proc_clause_count + 1
        self.factor_count = self.factor_count + len(factors)
        self.resolvent_count = self.resolvent_count + len(resolvents)

        self.processed.addClause(given_clause)

        for c in new:
            self.unprocessed.addClause(c)
        return None