Ejemplo n.º 1
0
    def __makeStates2Letters(self, state, map): # state: tuple, map: dictionary
        "This method uses the transition relation to compute the mapping map.\
         For every state q reachable from 'state', map[q] is the list of\
         letters (i.e., a list of vectors, see MEMO) that Spoiler may choose\
         when he is in state q."
        if (map.has_key(state)):
            return

	if (type(state) == type("")):
	    if (state == 'tt'):
                map[state] = self.transitionRelation[state]['tt']
                if DEBUG:
                    print str(state) + " " + str(map[state])
	    elif (state == 'ff'):
		map[state] = []
		if DEBUG:
                    print str(state) + " " + str(map[state])
            else:
                self.__makeStates2Letters('tt', map)
                map[state] = self.transitionRelation[state]['tt']
                if DEBUG:
                    print str(state) + " " + str(map[state])
        elif (state[0] == '!'):
	    self.__makeStates2Letters('tt', map)
            map[state] = self.transitionRelation[state]['tt']
            if DEBUG:
                print str(state) + " " + str(map[state])
            
        elif (state[0] == 'X'):
            self.__makeStates2Letters(state[1], map)
            map[state] = [[0]*len(self.propSet)]
            if DEBUG:
                print str(state) + " " + str(map[state])
            
        elif (state[0] in ['|', 'U']):
            self.__makeStates2Letters(state[1], map)
            self.__makeStates2Letters(state[2], map)
            map[state] = Utilities.union(map[state[1]], map[state[2]])
            if DEBUG:
                print str(state) + " " + str(map[state])
            ## Die folgenden 4 Zeilen waren vorher auskommentiert.
            ## Ich habe sie wieder reingenommen, weil ich sie für
            ## makePowerSet brauche.
            if (state[0] == 'U'):
                #map[('|', state[2], ('&', state[1], ('X', state)))] =\
                #    map[state]
                self.__makeStates2Letters(('&', state[1], ('X', state)), map)
                                                      
        elif (state[0] == '&'):
            self.__makeStates2Letters(state[1], map)
            self.__makeStates2Letters(state[2], map)
            map[state] = Utilities.termAnd(map[state[1]], map[state[2]])
            if DEBUG:
                print str(state) + " " + str(map[state])

        elif(state[0] == 'V'):
            self.__makeStates2Letters(state[1], map)
            self.__makeStates2Letters(state[2], map)
            map[state] = Utilities.union(Utilities.termAnd(map[state[1]],\
                                                           map[state[2]]),\
                                         map[state[2]]) 
            if DEBUG:
                print str(state) + " " + str(map[state])
            ## Die folgenden beiden Zeilen waren vorher auskommentiert.
            ## Ich habe sie wieder reingenommen, weil ich sie für
            ## makePowerSet brauche.
            # map[('&', state[2], ('|', state[1], ('X', state)))] = map[state]
            self.__makeStates2Letters(('|', state[1], ('X', state)), map)
                
        elif (state[0] == 'G'):
            self.__makeStates2Letters(state[1], map)
            map[state] = map[state[1]]
            if DEBUG:
                print str(state) + " " + str(map[state])
            
        elif (state[0] == 'F'):
            self.__makeStates2Letters(state[1], map)
            map[state] = Utilities.union(map[state[1]], [[0]*len(self.propSet)])
            if DEBUG:
                print str(state) + " " + str(map[state])