def combine_s_a_f(self, enfa): ls = len(self.state) # combine states self.state += [i + ls for i in enfa.state] enfa.init_state += ls enfa.final_state = [i + ls for i in enfa.final_state] # combine alphabet self.alphabet += enfa.alphabet self.alphabet = FA.sls(self.alphabet) # combine t_func temp_t_func_list = [] for (k, v) in enfa.t_func_list.items(): temp_t_func_list.append(((k[0] + ls, k[1] + ls), v)) self.t_func_list = dict(list(self.t_func_list.items()) + temp_t_func_list)
def add_alphabet(self, inp): self.alphabet.append(inp) self.alphabet = FA.sls(self.alphabet)