Esempio n. 1
0
 def parseProof(self, justified, findProof, discover, container,simultaneous):
     index = self.output.find("SPASS beiseite: ")
     resultStr = self.output[index:self.output.find("\n", index)]
     if self.errors != "":
         self.result = ("Error Found", [], [])
     elif resultStr.find("Ran out of time.") != -1:
         self.result = ("Time Up", [], [])
     elif resultStr.find("Completion found.") != -1:
         self.result = ("Completion Found", [], [])
     elif resultStr.find("Proof found.") != -1:
         self.result = ("Proof Found", [], [])
         if justified:
             index = self.output.find("Here is a proof with ")
             proofStr = self.output[self.output.find("\n", index):self.output.find("\nFormulae used in the proof",index)]
             if findProof:
                 emptyContainer=DCECContainer()
                 emptyContainer.namespace=container.namespace
                 self.proof=proofTree(proofStr,emptyContainer,simultaneous,self.symbolReverter)
             index = self.output.find("Formulae used in the proof : ") + len("Formulae used in the proof : ")
             proofStr = self.output[index:self.output.find("\n", index)]
             steps = proofStr.split(" ")
             for x in range(len(steps)-1,-1,-1):
                 if steps[x]=="CONJECTURE":
                     steps.pop(x)
                 elif steps[x]=="SORTING_RULE":
                     steps.pop(x)
                 elif steps[x].startswith("declaration"):
                     steps.pop(x)
             steps=Set(steps)
             for step in steps:
                 if step in self.axioms:
                     self.result[1].append(self.axioms[step])
                 else:
                     self.result[2].append(step)
     logic = self.output[self.output.find("Given clause:"):self.output.find("SPASS V 3.7")]
     logic = logic.split("\n")
     self.discoveries=DCECContainer()
     self.discoveries.namespace=container.namespace
     if discover:
         index = len(logic) - 1
         while index >= 0:
             if logic[index][-4:]=="-> .":
                 logic.pop(index)
             else:
                 logic[index]=logic[index][logic[index].find("]")+1:]
                 tmperarotya= toSNotation(logic[index],container.namespace.sorts,self.symbolReverter)
                 if tmperarotya!="":
                     self.discoveries.addStatement(toSNotation(logic[index],container.namespace.sorts,self.symbolReverter))
             index-=1
Esempio n. 2
0
 def parseProof(self, justified, findProof, discover, container,
                simultaneous):
     index = self.output.find("SPASS beiseite: ")
     resultStr = self.output[index:self.output.find("\n", index)]
     if self.errors != "":
         self.result = ("Error Found", [], [])
     elif resultStr.find("Ran out of time.") != -1:
         self.result = ("Time Up", [], [])
     elif resultStr.find("Completion found.") != -1:
         self.result = ("Completion Found", [], [])
     elif resultStr.find("Proof found.") != -1:
         self.result = ("Proof Found", [], [])
         if justified:
             index = self.output.find("Here is a proof with ")
             proofStr = self.output[
                 self.output.find("\n", index):self.output.
                 find("\nFormulae used in the proof", index)]
             if findProof:
                 emptyContainer = DCECContainer()
                 emptyContainer.namespace = container.namespace
                 self.proof = proofTree(proofStr, emptyContainer,
                                        simultaneous, self.symbolReverter)
             index = self.output.find(
                 "Formulae used in the proof : ") + len(
                     "Formulae used in the proof : ")
             proofStr = self.output[index:self.output.find("\n", index)]
             steps = proofStr.split(" ")
             for x in range(len(steps) - 1, -1, -1):
                 if steps[x] == "CONJECTURE":
                     steps.pop(x)
                 elif steps[x] == "SORTING_RULE":
                     steps.pop(x)
                 elif steps[x].startswith("declaration"):
                     steps.pop(x)
             steps = Set(steps)
             for step in steps:
                 if step in self.axioms:
                     self.result[1].append(self.axioms[step])
                 else:
                     self.result[2].append(step)
     logic = self.output[self.output.find("Given clause:"):self.output.
                         find("SPASS V 3.7")]
     logic = logic.split("\n")
     self.discoveries = DCECContainer()
     self.discoveries.namespace = container.namespace
     if discover:
         index = len(logic) - 1
         while index >= 0:
             if logic[index][-4:] == "-> .":
                 logic.pop(index)
             else:
                 logic[index] = logic[index][logic[index].find("]") + 1:]
                 tmperarotya = toSNotation(logic[index],
                                           container.namespace.sorts,
                                           self.symbolReverter)
                 if tmperarotya != "":
                     self.discoveries.addStatement(tmperarotya)
             index -= 1
Esempio n. 3
0
 def __init__(self,inputProof,container,isSimultaneous, symbolReverter):
     #inputProof is the raw spass proof output
     #container is an empty DCECContainer with the necessary namespace
     inputProof=inputProof.split("\n")
     #split the proof
     for x in range(0,len(inputProof)):
         idStart=inputProof[x].find("[")
         idEnd=inputProof[x].find("] ")+2
         #find the start and end of the premise ids
         if inputProof[x].rfind(":",0,idEnd) == inputProof[x].find(":",0,idEnd):
             premiseStart=idEnd-2
             #if there were no premises be prepared to have none
         else:
             premiseStart=inputProof[x].rfind(":",0,idEnd)+1
             #otherwise be prepared to cut off the rule
         inputProof[x]=[inputProof[x][:idStart],filter(None, inputProof[x][premiseStart:idEnd-2].split(",")),inputProof[x][idEnd:]]
         #set up a tuple with the first index the string for the line number
         #with the second index being the list of line numbers for premises
         #with the third index being the actual line
     
     for line in inputProof:
         if line[2][-4:]=='-> .':
             line[2]="(leads_to_conclusion "+toSNotation(line[2],container.namespace.sorts, symbolReverter)+")"
         else:
             line[2]=toSNotation(line[2],container.namespace.sorts,symbolReverter)
         if isSimultaneous:
             if line[2] in self.simultaneous:
                 line[2]=self.simultaneous[line[2]]
         else:
             if line[2] in self.nonSimultaneous:
                 line[2]=self.nonSimultaneous[line[2]]
     x=len(inputProof)-1
     while x>=0:
         if inputProof[x][1]==[] and inputProof[x][2]=='':
             inputProof.pop(x)
         else:
             for y in range(0,len(inputProof[x][1])):
                 inputProof[x][1][y]=inputProof[x][1][y].split(".")[0]
         x-=1
     idLookup=dict()
     for line in inputProof:
         idLookup[line[0]]=line[2]
     for line in inputProof:
         x=len(line[1])-1
         while x>=0:
             if not (line[1][x] in idLookup.keys()):
                 line[1].pop(x)
             x-=1
     usedLines=set()
     x=len(inputProof)-1
     while x>=0:
         y=len(inputProof[x][1])-1
         while y>=0:
             if idLookup[inputProof[x][1][y]]==inputProof[x][2]:
                 for z in inputProof:
                     if z[0]==inputProof[x][1][y]:
                         inputProof[x][1]+=z[1]
                         break
                 inputProof[x][1].pop(y)
                 y=len(inputProof[x][1])
             else:
                 usedLines.add(inputProof[x][1][y])
             y-=1
         x-=1
         inputProof[x][1]=list(set(inputProof[x][1]))
     usedLines.add(inputProof[-1][0])
     x=len(inputProof)-1
     while x>=0:
         if not inputProof[x][0] in usedLines:
             inputProof.pop(x)
         x-=1
     self.proofTree=dict()
     for line in inputProof:
         premises=[]
         for p in line[1]:
             premises.append(idLookup[p])
         self.proofTree[line[2]]=premises
     """