1.8 Exercises

  1. In the lecture, we represented haha1 in Prolog as follows:

    initial(1).
    final(4).
    arc(1,2,h).
    arc(2,3,a).
    arc(3,4,!).
    arc(3,2,h).

    But we could also have represented it like this:

    initial(1).
    final(4).
    arc(1,2,h).
    arc(2,3,a).
    arc(3,2,h).
    arc(3,4,!).

    Does it make any difference which way we represent it?

  2. Here's the code for recognize1 given in the lecture:

    recognize1(Node,[]) :-
        final(Node).
    recognize1(Node_1,String) :-
        arc(Node_1,Node_2,Label),
        traverse1(Label,String,NewString),
        recognize1(Node_2,NewString).

    Suppose we changed it to this:

    recognize1(Node,[]) :-
        final(Node),!.
    recognize1(Node_1,String) :-
        arc(Node_1,Node_2,Label),
        traverse1(Label,String,NewString),!,
        recognize1(Node_2,NewString).

    What effect would this change have? What sort of FSAs would not be affected by the change?

  3. Write FSAs that generate the following languages:

    •  a^m b^n, where m>3, n>2

    •  a^m c^l b^n, where m>1, l=2, n\ge 3


Patrick Blackburn and Kristina Striegnitz
Version 1.2.4 (20020829)