Need help urgently!!!!

From: DonalMagennis (donal_magennis_at_hotmail-dot-com.no-spam.invalid)
Date: 03/01/05


Date: 1 Mar 2005 06:05:27 -0600

I can't get to grips with prolog at all and need help with these
problems. I know bits and pieces but just can't glue it all together
so to speak! Any help gratefull, cheers.

Write Prolog facts describing five fictitious employees and the
languages they speak e.g.
           languages(mary, [french, english]).
           languages(john, [english, german, french]).

   Write separate Prolog queries to find employees who:
           - speak both English and French
           - speak at least three languages
Write a Prolog predicate called all_languages to create a list of all
the languages spoken by two given employees. The list created should
be sorted in alphabetical order and contain no duplicates e.g.
       ?- all_languages(mary, john, L).
       L = [english, french, german]

Write Prolog facts in which five fictitious cars are described as
lists of attribute-value pairs e.g.
       details(car1, [owner, john, colour, blue, make, ford, type,
hatchback, doors, 3]).
       details(car2, [colour, red, make, volkswagen, type, saloon,
owner, sue]).
       Write a Prolog predicate called describe to output a
description of a given car with each attribute and its value on a
separate line e.g.
   ?- describe(car2).
colour = red
   make = volkswagen
   type = saloon
   owner = sue
       (Hint: describe should call another predicate that resembles
the writelist predicate from the lecture notes, and uses the [First,
Second | Rest] notation to access the elements of a list in pairs.)
       Your solution should include a commented listing of your Prolog
database and a single transcript of your describe predicate in use.

Write Prolog facts describing five fictitious A-level students and the
subjects they are studying e.g.
               subjects(mary, [maths, french, english]).
               subjects(john, [french, english, german, history]).
       Write a Prolog predicate called studies to find students who
study a given subject e.g.
               ?- studies(Who, english).
               Who = mary ;
               Who = john
       Use your studies predicate in another predicate called
all_students to create a list of all students who study a given
subject. The student names in the list should be in alphabetical
order e.g.
           ?- all_students(french, L).
           L = [andrew, john, mary]
        Your solution should include a commented listing of your
Prolog database and a single transcript of each predicate in use.

A simple grammar for a small subset of English is shown below.
   sentence --> noun phrase, verb phrase
   noun phrase --> determiner, adjective, noun
noun phrase --> determiner, noun
   verb phrase --> verb, noun_phrase
   verb phrase --> verb.
   determiner --> the
   noun --> woman
noun --> fly
noun --> spider
noun --> mouse
noun --> cat
noun --> dog
noun --> horse
verb --> swallows
adjective --> old

Implement the grammar in Prolog and write queries to find legal
sentences (not just completions of sentences) that:
           (a) contain less than 4 words
       (b) do not contain the word “woman”
       (c) start with the words “the old woman”
       (d) end with the words “swallows the fly”
       (e) contain the word “fly” more than once

 Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
    ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
                http://www.usenet.com



Relevant Pages

  • Re: Sublists question
    ... I believe that it is the cause of your stack overflows. ... I do not really get what the predicate means or does. ... > then translate into Prolog. ... What I intend to do in the 3 generate lists prdeicates is this: ...
    (comp.lang.prolog)
  • advice from a newbie
    ... I recently got my hands on Prolog. ... predicate and a database predicate in the last clause. ... I also have a brand new version of append - named app/3 for the same ... mixed lists and even lists whose elements are any ...
    (comp.lang.prolog)
  • Re: Ignore punctuation
    ... > recognise punctuation but not add it to the list. ... But nowadays, its not necessary to use this low-level predicate, "get0". ... depends on which brand of Prolog you are using. ... Many rules to deal with lists look like this: ...
    (comp.lang.prolog)
  • Re: This Logo program in Prolog?
    ... Term is the basic data structure of Prolog, ... easily use a compound term for building many of the other data ... including lists (lists are just compound terms ... only other language I've seen with such love for the list type is ...
    (comp.lang.prolog)
  • Re: This Logo program in Prolog?
    ... Term is the basic data structure of Prolog, ... easily use a compound term for building many of the other data ... including lists (lists are just compound terms ... only other language I've seen with such love for the list type is ...
    (comp.lang.prolog)