Search: Lycos Tripod
  share this page Share This Page  report abuse Report Abuse  build a page Edit your Site  show site directory Browse Sites  hosted by tripod
  « Previous | Top 100 | Next » hosted by tripod

Turbo prolog programming

 

It is a trade-mark of Borland international Inc.

 

- The name ‘prolog’ is taken from ‘programming in logic’

 

- Originally developed in 1972 by

   Alain Colmerauer & P.Roussel,

   University of Marseiles,France.

Book Reference : Introduction to turbo prolog by Carl Townsend,BPB Publictions, ISBN 81-7029-104-6

Power of prolog :

 

- It is OO-language like LISP

 

- Use heuristic to solve problems

 

- Most efficient at formal reasoning

 

- Systems developed & maintained by Knowledge engineers

 

- Interactive & cyclic development

 

Features of Turbo Prolog

 

- Compilation is possible

 

- Std. predicates are available for many functions like string operations, random file access, cursor control, graphics, windowing & sound effects, like turbo pascal

 

- Functional interface to other languages - possible

 

- Declared variables for security

- integer, real arithmetic - possible

 

- An integrated editor for compilation, development and debugging- all very easy.

 

 

Starting Turbo prolog

 

c>PROLOG

 

Then the user-friendly editor appears as follows:-

 

Run      Compile      Edit     Options     Files   Setup    Quit

                     Editor

Line1   Col1   Indent  Insert Work.pro

 

 

 

 

 

 

----Dialog-----

--------Message---------

 

 

--------Trace----------

Use first letter of Option or select with -> or <-

 

 

Create a Sample program

 

1.Select Edit mode & enter program

2.                      Enter text or corrections as necessary

3.                      Save the program to disk

4.                      Compile the program

5.                      Execute the program

 

Edit operations : REFER BOOK

 

Similar to Turbo pascal

 

SAMPLE TEST PROGRAM

Run      Compile      Edit     Options     Files   Setup    Quit

                     Editor

Line1   Col1   Indent  Insert Work.pro

/* SAMPLE TEST PROGRAM */

predicates

     likes(symbol , symbol)

clauses

     likes(frank,sue).

     likes(Harold,ruth).

 

 

 

----Dialog-----

--------Message---------

 

 

--------Trace----------

F1:Help F3:Search F4:Subst F5:Copy F6:Move F7:del F8:ExtEdit F9:ExtCopy F10:End

 

Starting to execute the program

To compile and execute the

program exit the editor using Esc

or F10. Then select the Run option

from the main menu.

 

If NO errors, then see the prompt

in dialog box as follows:-

 

If error, turbo prolog will return

to the ditor.

 

Then compile again till ‘No error’

SAMPLE TEST PROGRAM

Run      Compile      Edit     Options     Files   Setup    Quit

                     Editor

Line1   Col1   Indent  Insert Work.pro

/* SAMPLE TEST PROGRAM */

predicates

     likes(symbol , symbol)

clauses

     likes(frank,sue).

     likes(Harold,ruth).

 

----Dialog-----

Goal :-

--------Message---------

 

 

--------Trace----------

F1:Help F3:Search F4:Subst F5:Copy F6:Move F7:del F8:ExtEdit F9:ExtCopy F10:End

Goal : likes(Harold,ruth)<-! (return key press )

Turbo Prolog will reply to you as

True

Goal :     ( wait for next goal )

Expressing Facts

(English to (Turbo)T. Prolog)

 

The right speaker is dead (English)

 

Is(right_speaker,dead). (T.prolog)

 

Fact                               Relation

 

has_a(bill, computer).    has_a

is_a(collie,dog).              is_a

likes(sue,chocolate).       Likes

 

 

Predicates (examples)

 

employee(bill)

eligible(mary)

marital_status(joyce,married)

 

For example, you can express the fact that mary is married and is eligible for employment as

 

eligible(mary) and marital-status(mary,married).

 

Facts expressed as prolog clauses

 

English: Bill is an employee.

Prolog: employee(Bill).

 

English: Bob is married to Mary.

Prolog: married_to(Bob,Mary).

 

English:The speaker is defective.

Prolog: defective_speaker.

 

English: Tom is a student.

Prolog: student(Tom).

Relationship of clauses, predicates, relations and objects.

Clauses

|

         |__________________|

     Facts                                Rules

   |________________|

Predicates                Periods(.)

|____________|

Relations      Arguments   

                           |

            |_______________|

         Objects               Variables

 

 

Example : Not for medical use !

 

domains

     disease,indication=symbol

predicates

     symptom(disease,indication)

clauses

       symptom(chicken_pox,high_fever). symptom(chicken_pox,chills). symptom(flu,chills). symptom(cold,mild_body_ache). symptom(flu,severe_body_ache). symptom(cold,runny_nose). symptom(flu,runny_nose). symptom(flu,moderate_cough).

Goal : symptom(cold,runny_nose) <-!

 

Response from prolog :

True

 

Goal : symptom(cold,headache) <-!

Response from prolog :

False

 

Using rules to solve the problems

 

Here another example to use

 

rules to solve the problems,

 

using hypothesis- concepts

 

Example : Medical Diagnostic System

 

domains

     disease,indication,name=symbol

predicates

     hypothesis(name,disease)

     symptom(disease,indication)

clauses

symptom(charlie,fever).    symptom(charlie,rash). symptom(charlie,headache). symptom(charlie,runny_nose).

Hypotheis(patient,measles):-

symptom(charlie,fever),    symptom(charlie,rash), symptom(charlie,headache), symptom(charlie,runny_nose),

symptom(charlie,cough).

Hypotheis(patient,german_measles):-

symptom(charlie,fever),    symptom(charlie,rash), symptom(charlie,headache), symptom(charlie,runny_nose).

Hypotheis(patient,flu):-

symptom(charlie,fever),    symptom(charlie,headache), symptom(charlie,body_ache), symptom(charlie,runny_nose),

symptom(charlie,cough).

Hypotheis(patient,mumps):-

symptom(charlie,fever),    symptom(charlie,swollen_glands).

 

Goal : hypothesis(patient,disease)

 

 

Prolog display as follows:-

 

Goal : hypothesis(patient,disease)

 

Patient=Charlie,disease=german_measles

 

-O-

 

For further advanced study continue as follows:-

 

Visual Prolog 6 On-line Tutorials

A series of tutorial articles that

will help you are as follows:-

New tutorials are added regularly.

Title

Last updated

Code Formatting

01-09-2003

 

Environment Overview

01-10-2002

 

Exceptions Handling

13-02-2004

Foreign Language Code

27-11-2003

 

Fundamental Prolog (Part 1)

13-01-2003

 

Fundamental Prolog (Part 2)

18-06-2003

 

Fundamental Visual Prolog

 

 

15-08-2003

 

Fundamental Visual Prolog - GUI

28-08-2003

 

Fundamental Visual Prolog - the Business Logical Layer

10-09-2003

 

Fundamental Visual Prolog - the Data Layer

22-12-2003

 

Introduction to Classes and Objects

04-11-2002

 

Memory Management

 

23-01-2003

 

Programming Pragmatics

13-03-2003

 

Visual Prolog for  Tyros

02-02-2004

 

Visual Prolog 6 for Visual Prolog 5 Users

04-11-2002

 

Writing CGI Applications in Visual Prolog 6

14-07-2003

 

 

-The End-