Ejemplo n.º 1
0
def concatenation():
    A = NFA.of_set({"abc", "ABC"}).renum().visu()
    B = NFA.of_set({"012", "789"}).renum().visu()

    C = A + B
    C = C.visu()  # .renum().visu()

    D = NFA.concatenate(A, B, C).visu().renum().named("D").visu() \
        .rm_eps().visu().dfa().visu().mini().visu()

    # words of fixed length
    L = NFA.of_length(0, "abc").visu()
    L = NFA.of_length(2, "abc").visu()
    L = NFA.of_length(4, "01").visu()
    L = NFA.of_length(4, "01").setworder(tuple).visu()
Ejemplo n.º 2
0
def shuffles():
    Big = NFA.of_set({"aAbBcC", "aaaBBB"}, "two").visu()
    A = Big.proj("abc").visu().renum().visu()
    B = Big.proj("ABC").renum().visu()
    C = (A @ B).setnop(name="Shuffle")
    C.visu().dfa().visu().mini().visu()

    Bad = (C - Big).mini().visu()

    C.run("aABbcC")

    A = NFA.universal('abc').visu()
    B = NFA.of_word("abc").visu()
    C = (A - B).visu().mini().visu()

    # fun case where determinising is removing redundant loops.
    S = (A @ B).setnop(name="Shuffle").visu().dfa().visu()
    ##print(A[0], A[1], list(A[:10]))

    (A | B).visu().mini().visu()
    NFA.union(A, A, B, A).visu().dfa().visu().mini().visu()
Ejemplo n.º 3
0
def hard_minimisation():
    tab = False

    def fib(n):
        if n == 0: return "0"
        if n == 1: return "1"
        return fib(n - 1) + fib(n - 2)

    def FIB(n):
        return {fib(k) for k in range(n)}

    S = FIB(6)

    A = NFA.of_set(S).dfa().renum().visu().mini(table=tab).visu()

    # starts with final, need to ensure I, II and not II, I, prev bug.
    B = NFA.spec("""
    0
    0
    0 a 1 b 1
    1 b 0 a 1
    """).visu().mini(table=tab).visu()

    C = NFA.of_word("aaaa").complete().visu().mini(table=tab).visu()
Ejemplo n.º 4
0
def ofset():
    A = NFA.of_set({"a", "acb", "acccb", "bb"}).renum().visu().mini().visu()