Renaming FormulaLTL -> Formula_rsLTL

This commit is contained in:
Artur Meski
2017-02-26 22:27:49 +01:00
parent d065dbac83
commit bae7611606

View File

@@ -1,6 +1,6 @@
from enum import Enum from enum import Enum
LTL_form_type = Enum('LTL_form_type', 'bag l_and l_or l_not globally next until release') rsLTL_form_type = Enum('rsLTL_form_type', 'bag l_and l_or l_not globally next until release')
BagDesc_oper = Enum('BagDesc_oper', 'entity l_and l_or l_not lt le eq ge gt') BagDesc_oper = Enum('BagDesc_oper', 'entity l_and l_or l_not lt le eq ge gt')
class BagDescription(object): class BagDescription(object):
@@ -69,51 +69,51 @@ class FormulaLTL(object):
self.bag_descr = bag self.bag_descr = bag
def __repr__(self): def __repr__(self):
if self.f_type == LTL_form_type.bag: if self.f_type == rsLTL_form_type.bag:
return repr(self.bag_descr) return repr(self.bag_descr)
if self.f_type == LTL_form_type.l_not: if self.f_type == rsLTL_form_type.l_not:
return "~( " + repr(self.left_operand) + " )" return "~( " + repr(self.left_operand) + " )"
if self.f_type == LTL_form_type.globally: if self.f_type == rsLTL_form_type.globally:
return "G( " + repr(self.left_operand) + " )" return "G( " + repr(self.left_operand) + " )"
if self.f_type == LTL_form_type.next: if self.f_type == rsLTL_form_type.next:
return "X( " + repr(self.left_operand) + " )" return "X( " + repr(self.left_operand) + " )"
if self.f_type == LTL_form_type.l_and: if self.f_type == rsLTL_form_type.l_and:
return "( " + repr(self.left_operand) + " & " + repr(self.right_operand) + " )" return "( " + repr(self.left_operand) + " & " + repr(self.right_operand) + " )"
if self.f_type == LTL_form_type.l_or: if self.f_type == rsLTL_form_type.l_or:
return "( " + repr(self.left_operand) + " | " + repr(self.right_operand) + " )" return "( " + repr(self.left_operand) + " | " + repr(self.right_operand) + " )"
if self.f_type == LTL_form_type.until: if self.f_type == rsLTL_form_type.until:
return "( " + repr(self.left_operand) + " U " + repr(self.right_operand) + " )" return "( " + repr(self.left_operand) + " U " + repr(self.right_operand) + " )"
if self.f_type == LTL_form_type.release: if self.f_type == rsLTL_form_type.release:
return "( " + repr(self.left_operand) + " R " + repr(self.right_operand) + " )" return "( " + repr(self.left_operand) + " R " + repr(self.right_operand) + " )"
@classmethod @classmethod
def f_bag(cls, bag_descr): def f_bag(cls, bag_descr):
return cls(LTL_form_type.bag, bag = bag_descr) return cls(rsLTL_form_type.bag, bag = bag_descr)
@classmethod @classmethod
def f_X(cls, arg): def f_X(cls, arg):
return cls(LTL_form_type.next, L_oper = arg) return cls(rsLTL_form_type.next, L_oper = arg)
@classmethod @classmethod
def f_G(cls, arg): def f_G(cls, arg):
return cls(LTL_form_type.globally, L_oper = arg) return cls(rsLTL_form_type.globally, L_oper = arg)
@classmethod @classmethod
def f_U(cls, arg_L, arg_R): def f_U(cls, arg_L, arg_R):
return cls(LTL_form_type.until, L_oper = arg_L, R_oper = arg_R) return cls(rsLTL_form_type.until, L_oper = arg_L, R_oper = arg_R)
@classmethod @classmethod
def f_R(cls, arg_L, arg_R): def f_R(cls, arg_L, arg_R):
return cls(LTL_form_type.release, L_oper = arg_L, R_oper = arg_R) return cls(rsLTL_form_type.release, L_oper = arg_L, R_oper = arg_R)
def __and__(self, other): def __and__(self, other):
return FormulaLTL(LTL_form_type.l_and, L_oper = self, R_oper = other) return FormulaLTL(rsLTL_form_type.l_and, L_oper = self, R_oper = other)
def __or__(self, other): def __or__(self, other):
return FormulaLTL(LTL_form_type.l_or, L_oper = self, R_oper = other) return FormulaLTL(rsLTL_form_type.l_or, L_oper = self, R_oper = other)
def __invert__(self): def __invert__(self):
return FormulaLTL(LTL_form_type.l_not, L_oper = self) return FormulaLTL(rsLTL_form_type.l_not, L_oper = self)
x = ~( FormulaLTL.f_X( FormulaLTL.f_bag( ~((BagDescription.f_entity("ent1") == 3) | (BagDescription.f_entity("ent2") < 3)) ) ) ) & FormulaLTL.f_X( FormulaLTL.f_bag( ~((BagDescription.f_entity("ent3") == 1) ) ) ) x = ~( FormulaLTL.f_X( FormulaLTL.f_bag( ~((BagDescription.f_entity("ent1") == 3) | (BagDescription.f_entity("ent2") < 3)) ) ) ) & FormulaLTL.f_X( FormulaLTL.f_bag( ~((BagDescription.f_entity("ent3") == 1) ) ) )