def caseAnd(first, second): """Build Linearfactors in case of &. This function is called when & is found Input: First and second location of & Output: Linearfactors""" myPhi = list(lf(first)) nyPsi = list(lf(second)) ofAndSet = set() for i in myPhi: for j in nyPsi: if (type(defSix(i[0], j[0])) != frozenset): if defSix(i[0], j[0]).getName() != 'ff': lAnd = lFormula("&") lAnd.setFirst(i[1]) lAnd.setSec(j[1]) solu = (defSix(i[0], j[0])) ofAndSet.add((solu, lAnd)) if (type(defSix(i[0], j[0])) == frozenset): lAnd = lFormula("&") lAnd.setFirst(i[1]) lAnd.setSec(j[1]) solu = (defSix(i[0], j[0])) ofAndSet.add((solu, lAnd)) return ofAndSet
def defSix(my, ny): """Check wheter calculation of linear factor is allowed. if there are contradictory parts or a part is ff then reject and return false(ff) Input: two ltl formulas Output: Union of both or false.""" if type(my) == tuple or type(ny) == tuple: if type(my) == tuple: my = list(my) if type(ny) == tuple: ny = list(ny) else: if type(my) != frozenset: my = {my} if type(ny) != frozenset: ny = {ny} total = list(my) + list(ny) doubleNeg = False for i in total: for j in total: if (i.getName() == j.getName() and i.getNeg() != j.getNeg()): doubleNeg = True if(list(my)[0].getName() == 'ff' or list(ny)[0].getName() == 'ff'): return lFormula('ff') elif(doubleNeg is True): return lFormula('ff') else: solution = set() for x in list(my): solution.add(x) for x in list(ny): solution.add(x) return frozenset(solution)
def isTrue(tt): '''Give back (tt, tt) if function called. Input: A tt string Output: Linear factor for tt => (tt, tt)''' tt = lFormula('tt') tt.setAtom() ttName = tt return (ttName, ttName)
def caseUntil(fromCase, untilCase): '''Generate linearfactors for the case that we are working on an 'U'. Input: in polish normalform - first and second subject of the U. Output: Second part of the linearfactor tuple.''' iterable = lf(fromCase) oneSet = set() while iterable: tup = iterable.pop() first = tup[0] second = tup[1] lAnd = lFormula("&") lUntil = lFormula("U") lUntil.setFirst(fromCase) lUntil.setSec(untilCase) lAnd.setFirst(second) lAnd.setSec(lUntil) oneSet.add((first, lAnd)) return oneSet
def literal(objects): '''Give back Linearfactors in case of literal. Input: an ltl-formula literal Output: (litera, tt)''' oneSet = set() # declaration of set, so that objectname istn't seperate oneSet.add(objects) oneSet = frozenset(oneSet) # set to frozenset, so that hashable tt = lFormula('tt') tt.setAtom() ttName = tt return (oneSet, ttName)
def release(firstCase, secondCase): '''Give back the linearfactors in case of 'R' Input: in polish normalform - first and second subject of the U. Output: Linearfactors for R x y ''' iterable = lf(secondCase) oneSet = set() while iterable: tup = iterable.pop() first = tup[0] second = tup[1] lAnd = lFormula("&") lRel = lFormula("R") lRel.setFirst(firstCase) lRel.setSec(secondCase) lAnd.setFirst(second) lAnd.setSec(lRel) oneSet.add((first, lAnd)) cA = caseAnd(firstCase, secondCase) oneSet = oneSet.union(cA) return oneSet
def caseNext(formular): ''' definition for case Next Input: formular is an object, so that information of pointFirst and pointSec is also presented. Output: (tt, def7(formula)) ''' oneSet = set() solution = set() tup = setBasedNorm(formular) oneSet = oneSet.union(tup) tt = lFormula('tt') ttName = tt while oneSet: i = oneSet.pop() solution.add((ttName, i)) return solution