🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #549

general PROLOG questions

#549
From: Cs211s65
Date: Wed, 06 Dec 1989 07:28
77 lines
3317 bytes
Hello.
  I am currently learning how to use PROLOG for my logic class. It
is an assignment showing the relationship between logic and PROLOG 
language. Please help or give me any relevant information. Few 
questions:
        1)   I need to know how to write a set of PROLOG rules
             that represent the rules of some organizational   
             system such as: the conditions for passing a 
             course in college or for determining eligibility
             for a post graduate grant.

       2)    Using a definitions of the listsize predicate for   
             guidence, a definition for a rule that will return
             the nth element of a given list. For example:    
             nth([a,short,list],2,Nth) should return Nth = short.

       3)    To write a set of PROLOG rules to determine if a given
             list of integers is in ascending order.

       4)    In the following  program:

           /* data */
          line(carlisle, newcastle, 62).
          line(newcastle, middlesbrough, 48).
          line(newcastle, darlington, 36).
          line(darlingtone, middlesbrough, 15).
          line(darlington, northallerton, 14).
          line(northallerton, york, 30).
          line(york, leeds, 25).
          line(leeds, manchester, 43).
          line(manchester, liverpool, 31).
          line(liverpool, preston, 28).
          line(manchester, preston, 31).
          line(preston, lancaster, 21).
          line(leeds, lancaster, 70).
          line(leeds, carlisle, 113).
          line(lancaster, carlisle, 69).

         with two rules:
         link (A,B,D) :-      link(A,B,D) :-
            line(A,B,D).         line(B,A,D).

        and with the of what is the route from A to B and the total distance?
        for example:
   
           | ?- route(manchester,newcastle,Route,Distance).

        is given below:

           route (S,F,R,D) :-
             route 1(S,F,[S],R,D).

           route (S,F,,[],D) :-
             link (S,F,D).

           route 1(S,F,S2,[S1|R],D) :-
            link(S,S1,D1),
            not (member(S1,S2))
            route 1(S1,F,[S1|S2],R,D2)
            D is (D1 + D2).

        then the distances are accumalated in D.

        the question is how to write an enchanced route finding program
        that finds alternative routes and establishes which is the 
        shortest.

       Please send any comments and suggestions to the questions quickly
       as I am currently working on a thesis on the relationship between
       PROLOG and Predicate logic and do not have enough time to become
       an expert in the language. Please, any help is GREATLY appreciated.
       Thank you very much.
                                     Thank you,
                                     Anthony Bush.
       Email me!
       bush@uhccux.bitnet
       thanks.
Technical Details
Message-ID: <5631@uhccux.uhcc.hawaii.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!mailrus!ames!uhccux!cs211s65

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!mailrus!ames!uhccux!cs211s65
From: cs211s65@uhccux.uhcc.hawaii.edu (Cs211s65)
Newsgroups: comp.lang.prolog,sci.philosophy.tech,sci.logic,misc.misc
Subject: general PROLOG questions
Keywords: new user..
Message-ID: <5631@uhccux.uhcc.hawaii.edu>
Date: 6 Dec 89 07:28:34 GMT
Organization: University of Hawaii
Lines: 77