def checkConsistency( inputDocument, entailedDocument=None, requiredDatatypes=[], # dt not impl forbiddenDatatypes=[], maxSeconds=5, axiomTags=(), inputFileName=None, outputFileName=None): """An OWL consistency checker takes a document as input, and returns one word being Consistent, Inconsistent, or Unknown. An OWL consistency checker SHOULD report network errors occurring during the computation of the imports closure. -- from http://www.w3.org/TR/owl-test/#conformance Search for an inconsistency & see what we find! ... Meanwhile, if we also have an "entailedDocument", add its negation; Inconsistent==Entailed, etc. """ for dt in requiredDatatypes: # if not supported, ... but they are ALL not supported right now! raise UnsupportedDatatype, dt kb = LX.kb.KB() kb.firstOrder = True # use rdf(s,p,o) instead of p(s,o) try: kb.load(inputDocument) if entailedDocument: kb2 = LX.kb.KB() kb2.firstOrder = True # use rdf(s,p,o) instead of p(s,o) kb2.load(entailedDocument) #print "Adding negated:", kb2 kb.add(LX.logic.NOT(kb2.asFormula())) #print "Giving us:", kb # possible huge performance gains by using subset of axioms (when that's not cheating) # possible huge performance gains by puting kb [or just kb2 if present] into SOS #kb.gather(prefixMap) try: LX.engine.otter.run( kb, includes=[axiomFile % tag for tag in axiomTags], maxSeconds=maxSeconds, inputFileName=inputFileName, outputFileName=outputFileName) return "Inconsistent" except LX.engine.otter.SOSEmpty: return "Consistent" except LX.engine.otter.TimeoutBeforeAnyProof: return "Unknown" except LX.kb.UnsupportedDatatype, e: raise UnsupportedDatatype, e
def checkConsistency(inputDocument, entailedDocument=None, requiredDatatypes=[], # dt not impl forbiddenDatatypes=[], maxSeconds=5, axiomTags=(), inputFileName=None, outputFileName=None): """An OWL consistency checker takes a document as input, and returns one word being Consistent, Inconsistent, or Unknown. An OWL consistency checker SHOULD report network errors occurring during the computation of the imports closure. -- from http://www.w3.org/TR/owl-test/#conformance Search for an inconsistency & see what we find! ... Meanwhile, if we also have an "entailedDocument", add its negation; Inconsistent==Entailed, etc. """ for dt in requiredDatatypes: # if not supported, ... but they are ALL not supported right now! raise UnsupportedDatatype, dt kb = LX.kb.KB() kb.firstOrder = True # use rdf(s,p,o) instead of p(s,o) try: kb.load(inputDocument) if entailedDocument: kb2 = LX.kb.KB() kb2.firstOrder = True # use rdf(s,p,o) instead of p(s,o) kb2.load(entailedDocument) #print "Adding negated:", kb2 kb.add(LX.logic.NOT(kb2.asFormula())) #print "Giving us:", kb # possible huge performance gains by using subset of axioms (when that's not cheating) # possible huge performance gains by puting kb [or just kb2 if present] into SOS #kb.gather(prefixMap) try: LX.engine.otter.run(kb, includes=[axiomFile % tag for tag in axiomTags], maxSeconds=maxSeconds, inputFileName=inputFileName, outputFileName=outputFileName) return "Inconsistent" except LX.engine.otter.SOSEmpty: return "Consistent" except LX.engine.otter.TimeoutBeforeAnyProof: return "Unknown" except LX.kb.UnsupportedDatatype, e: raise UnsupportedDatatype, e
def p_axiom(t): '''axiom : LPAREN tagList BODY sentence RPAREN''' #print "Adding formula %s\n" % t[4] kb.add(t[4])
def p_formulaList_more(t): '''formulaList : formulaList formula PERIOD''' #print "Adding formula %s\n" % t[2] kb.add(t[2])