def __init__(self, literal, name): self.literal = literal self.name = name self.isVerified = False self.reqOf = [] self.resOf = [] logger.debug(f"{self} initialized.")
def __init__(self, name, variables:list, requirements:list, results:list, verify=None): self.name = name self.variables = variables self.requirements = requirements self.results = results self.verify = verify # custom verifier function logger.debug(f"{self} initialized.")
def visitStat(self, ctx): statName = ctx.NAME().getText() statLiteral = ctx.STATEMENT().getText() logger.debug(f"Visited statement: {statName}.") if statName in self.statDict.keys(): logger.warning(f"Redefined {statName}.") s = Statement(statLiteral, statName) self.statDict[statName] = s return s
def visitImpr(self, ctx): filename = ctx.lib.text logger.debug(f"Importing {filename}.") fs = FileStream(filename) lex = characteristicaLexer(fs) tokenst = CommonTokenStream(lex) parser = characteristicaParser(tokenst) tree = parser.prog() self.visit(tree)
def verify_tc(tc): if tc.verify(): for res in tc.callRes: for newTc in res.reqOf: if are_reqs_verified(newTc): verify_tc(newTc) logger.debug(f"{tc} is verified") else: logger.warning(f"Cannot verify tactic call: {tc}")
def __init__(self, tactic, callVars, callReqs, callRes): self.tactic = tactic self.callVars = callVars self.callReqs = callReqs for req in callReqs: req.reqOf += [self] self.callRes = callRes for res in callRes: res.resOf += [self] self.isVerified = False logger.debug(f"{self} initialized.")
def verify(self): logger.debug(f"{self} is being verified.") if self.tactic.verify: logger.debug(f"{self} is using custom verifier: {self.tactic.verifier.__name__}.") self.isVerified = self.tactic.verify(self) else: true_or_not = True for screq, sreq in zip(self.callReqs, self.tactic.requirements): creq = screq.literal req = sreq.literal for cvar, var in zip(self.callVars, self.tactic.variables): creq = creq.replace(cvar, var) true_or_not = true_or_not and (creq == req) self.isVerified = true_or_not for res in self.callRes: res.isVerified = self.isVerified logger.debug(f"{self}'s verification status is {self.isVerified}.") return self.isVerified
def visitAxiom(self, ctx): axName = ctx.NAME().getText() logger.debug(f"Visited axiom: {axName}") self.statDict[axName].isVerified = True return self.statDict[axName]
def are_reqs_verified(tc): true_or_not = True for req in tc.callReqs: true_or_not = true_or_not and req.isVerified logger.debug(f"Requirements of {tc} are verified {true_or_not}.") return true_or_not