1 / 7

Problem 1

Problem 1. The following two slides contain part of the definition of a data base of English word forms using the lex/4 predicate. With this data base as part of your program, answer questions 1.1 and 1.2. lex—1. lex(love, love, n, sing). lex(love, love, v, base).

yen
Download Presentation

Problem 1

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Problem 1 The following two slides contain part of the definition of a data base of English word forms using the lex/4 predicate. With this data base as part of your program, answer questions 1.1 and 1.2.

  2. lex—1 lex(love, love, n, sing). lex(love, love, v, base). lex(loves, love, v, pres(sg, 3)). lex(loves, love, n, plur). lex(loving, love, v, pres_part). lex(loved, love, v, past). lex(grind, grind, v, base). lex(grinds, grind, v, pres(sg, 3)). lex(grinding, grind, v, pres_part). lex(ground, grind, v, past). lex(ground, ground, n, sing). lex(grounds, ground, n, plur). lex(see, see, v, base). lex(sees, see, v, pres(sg, 3)).

  3. lex—2 lex(seeing, see, v, pres_part). lex(saw, see, v, past_tense(_, _)). lex(seen, see, v, past_part). lex(hit, hit, v, short). lex(hits, hit, v, pres(sg, 3)). lex(hitting, hit, v, pres_part). lex(sheep, sheep, n, _). lex(X, X, v, base) :- lex(X, X, v, short). lex(X, X, v, past) :- lex(X, X, v, short). lex(X, X, v, inf) :- lex(X, X, v, base). lex(X, X, v, pres(sg, 1)) :- lex(X, X, v, base). lex(X, X, v, pres(sg, 3)) :- lex(X, X, v, base). lex(X, X, v, pres(pl, _)) :- lex(X, X, v, base).

  4. Question 1.1 Write a predicate ambiguous(X) that is true just in case X is a word that can be both a noun and a verb. It should allow you to do this: | ?- ambiguous(ground). yes | ?- ambiguous(see). no | ?- ambiguous(X). X=love yes | ?-

  5. Question 1.2 Notice that the verb “see” has a past_tense and a “past_part” form. The other verbs have only a “past” form, because there is no difference between their past-tense and past-participle forms. Write two new clauses which when applied to any verb with a “past” entry in the data base, will enable the past_tense and past_part forms to be found. They should make it possible to do at least this: | ?- lex(loved, love, v, past_tense). yes | ?- lex(loved, love, v, past_part). yes | ?-

  6. Problem 2 reverse([], []). reverse([H|T], Rev) :- reverse(T, RT), append(RT, [H], Rev). There is a much more efficient way of reversing a list than the one given in class. The trick is to use another predicate, with three arguments, to do the work, so that reverse itself is defined like this: reverse(A, B) :- rev (A, [], B). Write the two-clause definition of rev/3.

  7. Problem 3 Write a predicate delete(List1, Member, List2). which is true just in case List2 is the result of deleting Member from List1. The predicate should fail if Member is not a member of List1. | ?- delete([a,b,a,c,a,d,a,e], a, X). X = [b,a,c,a,d,a,e] ? ; X = [a,b,c,a,d,a,e] ? ; X = [a,b,a,c,d,a,e] ? ; X = [a,b,a,c,a,d,e] ? ; no | ?-

More Related