Example #1
0
 def __init__(self, clauses=[]):
     """
     Create the two indices and call the superclass initializer. 
     """
     self.res_index = ResolutionIndex()
     self.sub_index = SubsumptionIndex()
     ClauseSet.__init__(self, clauses)
Example #2
0
class IndexedClauseSet(ClauseSet):
    """
    This is a normal clause set, augmented by indices that speeds up
    the finding of resolution and subsumption partners.
    """
    def __init__(self, clauses=[]):
        """
        Create the two indices and call the superclass initializer. 
        """
        self.res_index = ResolutionIndex()
        self.sub_index = SubsumptionIndex()
        ClauseSet.__init__(self, clauses)

    def addClause(self, clause):
        """
        Add the clause to the indices, then use the  superclass
        function to add it to the actual set.
        """
        self.res_index.insertClause(clause)
        self.sub_index.insertClause(clause)
        ClauseSet.addClause(self, clause)

    def extractClause(self, clause):
        """
        Remove the clause from the indices, then use the  superclass
        function to remove it to the actual set.
        """
        self.res_index.removeClause(clause)
        self.sub_index.removeClause(clause)
        return ClauseSet.extractClause(self, clause)

    def getResolutionLiterals(self, lit):
        """
        Overwrite the original function with one based on indexing. 
        """
        return self.res_index.getResolutionLiterals(lit)

    def getSubsumingCandidates(self, queryclause):
        """
        Overwrite the original function with one based on indexing. 
        """
        return self.sub_index.getSubsumingCandidates(queryclause)

    def getSubsumedCandidates(self, queryclause):
        """
        Overwrite the original function with one based on indexing. 
        """
        return self.sub_index.getSubsumedCandidates(queryclause)