Example #1
0
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:])])
Example #2
0
 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])
Example #3
0
    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])
Example #4
0
 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]
Example #5
0
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])
Example #6
0
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])
Example #7
0
    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
Example #8
0
 def variable(self, cname):
     var = cname[0]
     return PLTLFormula([var, None, None])
Example #9
0
 def formula(self, formulaArgs):
     return PLTLFormula(formulaArgs)
Example #10
0
 def variable(self, number):
     var = 'p' + number[0]
     return PLTLFormula([var, None, None])
Example #11
0
 def variable(self, varName):
     return PLTLFormula([str(varName[0]), None, None])
Example #12
0
 def variable(self, cname):
     var = cname[0]
     if var in self.var_dict:
         return self.var_dict[var]
     return PLTLFormula([var, None, None])