def read_word(fa: Automata, word: str, state=-1): for letter in word: if letter not in fa.symboles: return False if word == "" and state == -1: for init in fa.initialStates: if fa.has_finalStates(init): return True return False elif state == -1: for init in fa.initialStates: if not read_word(fa, word, init): continue else: return read_word(fa, word, init) elif word is "": if fa.has_finalStates(state): return True else: return False else: if word[0] not in fa.states[state]: return False else: nextState = fa.states[state][word[0]] print(nextState) if nextState is []: if fa.has_finalStates(state): return True else: return False else: for newstate in nextState: if not read_word(fa, word[1:], newstate): continue else: return read_word(fa, word[1:], newstate)
def minimization(fa: Automata): if not is_complete(fa): print("c pa possible") else: groupeList = [] groupeList.append([]) for final in fa.finalStates: groupeList[0].append(final) groupeList.append([]) for state in fa.states: if not fa.has_finalStates(state): groupeList[1].append(state) print(groupeList) temp = [] while (temp != groupeList): tempGroupe = [] print(tempGroupe) temp = groupeList