Ejemplo n.º 1
0
#!/usr/bin/env python3
from nfa import NFA

#####################################
NFA.clear()

# NFA.NOVISU = True


def ann(f):
    """Test procedures announce themselves"""
    def g(*p, **kw):
        print(f.__name__, "-" * 30)
        NFA.visutext(f.__name__)
        f(*p, **kw)

    return g


@ann
def interro201819():
    A = NFA.spec("""
    0
    5
    
    0 a 1 c 2
    1 b 1 a 3
    2 b 2 a 4
    3 c 3 a 5 a 2
    4 c 3 a 5 a 1
    """,
#!/usr/bin/env python3
from nfa import NFA

NFA.clear()         # clean visu.pdf on each run
# NFA.NOVISU=True   # check that all runs without generating PDFs

A = NFA.spec("""
0
2
0 a 1 a 2
1 a 0 b 2 
""",name="A").visu()

A.run("aaab")

B = NFA.spec("""
0
0
0 c 1 a 0
1 c 0""", name="B").visu()

NFA.visutext("DETERMINISATION")

A.visu().dfa().visu(doublearrows=True)

NFA.visutext("PRODUCTS")
from itertools import product
A.visu(); B.visu()

(A & B).visu().dfa().visu().mini().visu()