def tFA_Intersection(fname3=IN_FNAME3, fname4=IN_FNAME4): fa = import_FA(fname3) print(f'Original FA 1: {fa.name}') print(fa) fb = import_FA(fname4) print(f'Original FA 2: {fb.name}') print(fb) fc = intersection(fa, fb) print('Intersection result') print(fc)
def tFA_Union(fname1=IN_FNAME1, fname2=IN_FNAME2): fa = import_FA(fname1) print(f'Original FA 1: {fa.name}') print(fa) fb = import_FA(fname2) print(f'Original FA 2: {fb.name}') print(fb) fc = union(fa, fb) print('Union result') print(fc)
def tFA_Determinization(fname=IN_FNAME): fa = import_FA(fname) print('Original NFA') print(fa) m = fa.determinize() print('Determinized FA') print(m)
def tFA_Minimization(fname=IN_FNAME): fa = import_FA(fname) print('Original FA') print(fa) m = fa.minimize() print('Minimized FA') print(m)
def tFA_Complete(fname1=IN_FNAME1): fa = import_FA(fname1) print('Original FA 1') print(fa) print('Complete result') print(fa.complete())
def tFA_Renaming_States(fname=IN_FNAME): fa = import_FA(fname) print(f'Original FA: {fa.name}') print(fa) rfa = fa.rename_states(100) print('Renamed FA') print(rfa)
def testFAtoRegularGrammarConversion(): fa = import_FA(faFileName) print("Automata to be converted ({}):".format(fa.name)) print(str(fa)) print("Converting to Regular Grammar...") fa = fa_to_rg(fa) print(str(fa))
def tFA_Recognition(fname1=IN_FNAME1): # starts and ends with same symbol dfa = import_FA(fname1) print(dfa) right_words = ['', 'a', 'b', 'aa', 'bb', 'aabbaba', 'bababab', 'bbbab'] xtest(dfa, right_words, True, msg='Correct words accepted.') wrong_words = ['ab', 'ba', 'abcba', 'c', 'ababbbab', 'bbabbabbabababa'] xtest(dfa, wrong_words, False, msg='Wrong words correctly not accepted.', start=len(right_words))