def and_fml(path): if len(path) == 1: return PLTLFormula([path[0], None, None]) left = PLTLFormula([path[0], None, None]) return PLTLFormula(['&', left, and_fml(path[1:])])
def constants(self, varName): const = str(varName[0]) if (const == "S_TRUE"): const = "TRUE" elif (const == "S_FALSE"): const = "FALSE" return PLTLFormula([const, None, None])
def dict_var(self, f, vars_dict): if f is None: return None if (f._isLeaf()): if f.label == 'TRUE' or f.label == 'FALSE': var_name = f.label else: var_name = vars_dict[f.label] f = PLTLFormula([var_name, None, None]) return f left = self.dict_var(f.left, vars_dict) right = self.dict_var(f.right, vars_dict) return PLTLFormula([f.label, left, right])
def truthTable(self, formula): nodes = list(set(formula.getAllNodes())) self.truthAssignmentTable = {node: [None for _ in range(self.traceLength)] for node in nodes} for i in range(self.vars): fml = PLTLFormula([self.literals[i], None, None]) self.truthAssignmentTable[fml] = [bool(measurement[i]) for measurement in self.traceVector]
def or_fml(path): if len(path) == 1: return and_fml(path[0]) left = and_fml(path[0]) right = or_fml(path[1:]) return PLTLFormula(['|', left, right])
def or_fml(path): # print('PATH:', path) if len(path) == 1: return and_fml(path[0]) left = and_fml(path[0]) right = or_fml(path[1:]) return PLTLFormula(['|', left, right])
def m2f(self, size , model): def truth_value(depth, variables): for v in variables: vflag = model[variables[v]] if(v[0] == depth and vflag.is_true()): # logging.debug('%s := %s'%(str(v[0]), str(vflag))) return v[1] #Can filter SAT variables? label = truth_value(size, self.x) # print('label', label) # print('Depth', depth) if(label in self.Constants): if label == 'Top': label = 'TRUE' else: label = 'FALSE' f = PLTLFormula([label, None, None]) # print('Formula', f) return f if(label in self.AP): f = PLTLFormula([str(label), None, None]) # print('Formula', f) return f elif(label in self.unaryOp): left = truth_value(size, self.l) f = PLTLFormula([label, self.m2f(left, model)]) # print('Formula',f) return f elif(label in self.binaryOp): left = truth_value(size, self.l) right = truth_value(size, self.r) f = PLTLFormula([label, self.m2f(left, model), self.m2f(right, model)]) # print('Formula',f) return f
def variable(self, cname): var = cname[0] return PLTLFormula([var, None, None])
def formula(self, formulaArgs): return PLTLFormula(formulaArgs)
def variable(self, number): var = 'p' + number[0] return PLTLFormula([var, None, None])
def variable(self, varName): return PLTLFormula([str(varName[0]), None, None])
def variable(self, cname): var = cname[0] if var in self.var_dict: return self.var_dict[var] return PLTLFormula([var, None, None])