Text Book: Introduction to Turbo prolog
-Carl Townsend

Course: Artificial Intelligence and Expert System Md. Shamim Akhter Assistant Professor
Department of Computer Science American International University-Bangladesh

On a mainframe computer or micro computer.and relations between them.Chapter 1 What is Prolog? Prolog was taken from the phrase “Programming in logic”. Chapter 2 Starting of Turbo Prolog You have a compressed file named Turbo_prolog in web. Please download this file and unzipped it.S computer market. The name should be the same. Click on any one exe dos version or windows version and you will see the following screen in the monitor. tree-based data structuring and automatic backtracking. Open the directory and find the exe file named PROLOG. This includes applications in expert systems. During those years Prolog and LISP both were very slow in execution and consumed large amounts of memory. A short history of Prolog During the 1970s Prolog became popular in Europe for AI application. than X must be closer than Z. Prolog remained a relatively minor computer language. Application for prolog Prolog is useful for almost any application that requires formal reasoning. including pattern matching. Prolog is especially well suited for problems that involve objects-in particular. users needed considerable programming expertise to use Prolog or LISP program. However. the Japanese announced they would leapfrog over the current technology with new hardware and software by the 1990s. in the United States. It is also easy to state a more general rule: if object X is closer o the observer than object Y. The picture suddenly changed in1981 at the First International Conference on Fifth Generation Systems in Tokyo. As a result of this Japanese initiative. The Japanese were having great difficulty competing with the rapidly growing U. They often are easier to use. cost less than earlier versions and faster. a programming language centered on a small set of basic mechanisms. LISP was considered a more powerful programming language for these applications. Roussel at the University of Marseilles in France. natural language processing. and Y is closer than Z. Prolog. you will now find that Prolog often is the best language for nay application that involves formal or symbolic reasoning. . It was developed in 1972 by Alain Colmerauer and P. to express spatial relationships between objects. For example. developers around the world took a new interest in Prolog. So now you have a directory call Turbo_Prolog. In addition. Researchers of United States preferred the LISP language for AI applications. Forming a new and aggressive national technology plan. The computer language for the new systems would be Prolog. Today’s versions of Prolog have features and power that far exceed those of a few years ago. robotics and gaming & simulations. structure objects. such as the blue sphere is behind the green one. through it was more difficult to learn and use than Prolog.

Click F5 to get 4 windows in your screen. Message and Trace) clearly then type Alt+S. click on the Window size. then the following screen will be seen. left-right key. Dialog. Thereafter. If you did not find 4 windows (Editor. . Then make changes the size of any window by moving the up-down.

Your program will execute and give the following result True Goal: Your Work. 2. likes (frank.person2) clauses likes (frank. Write the following codes into the Editor Window /*Simple test Program */ predicates likes(symbol. Page 14-28. (Write query) 1. ruth) Important topics need to understand 1. 4. Domain types. Chapter 3 How to run a Prolog program 1. Save this program (Alt+F to go to file Menu Option and then select “write to” options to save in a specific file name (please give the file name “prog1. Predicates.pro b. Change the program as following /*Simple test Program */ domains person1. . Goto Edit in menubar and press Enter 3. sue) 2. Facts Domains. likes(Harold.The Six Options: Details of each Option will be given in Chapter 2. person2=symbol predicates likes (person1.pro”).ruth). 4. likes(frank. Goto the Run Menubar Option and press Enter 6.symbol) clauses likes(frank. sue). (You are now in a Dialog window where you have Goal: ) Write your query there. After typing the query press enter 8. Clauses Adding Comments Using Trace Procedure a. 5. F10 to get all windows in screen 2. let you are going to type likes (Harold. ruth) 7. Open program prog1.sue). 3.

ruth). inkey(Char). keypressed predicates 8. likes(_. Unification and Rules of Unification (page 63) 4.ruth) 2. Definitions of Rules and working procedure Page 58: program write and run 2. hasan) Hints: you need to specify the predicates name and define arguments father. inside the Trace window and Editor Window …Where the cursor in Editor Window is and what is written inside the Trace Window. Goal: age(X) f. age. (Write query) 1. Now again Save and Run this program with any one goal f. Chapter 4 1. writef. hasan) h. Write a program that will answer the question about your family Let your name is hasan a. give the following commends beside Goal: 1. readchar.hasan)) e. brother.pro (run will all goals) d. readint. Using Windows . Goal: age(father(_._) Your Work. mother. “clearwindow” commend .Try to understand… g. sister Also specify the clauses as the same name of predicates.hasan) b. Bound and Free Variables b. To traverse the program in each step Press F10 to proceed step by step. Compound facts 3. readreal predicates 7. Goal: father(_. write. Anonymous Variables After Trace procedure successfully executed.hasan) c. not predicate and its uses and problems (page 65) 5. readln. Goal: brother(_. Goal: sister(X.. Variables a._) g. After successfully running write the following commend any place above domain section Trace e.likes (Harold. c. 5. Save the program at any name and do the same activities that you have done with prog1. Watch carefully. Goal: brother(X. likes (frank. writedevice predicates 6. Goal: mother(_. Goal: age(hasan) d.

For all X. 6. Predicates after the recursive call are invoked during unwinding. X is a parent of Y if Y is an offspring of X. Now modify the login program as like program on page 99. 3. 3. just as in any other invocation. Page 100. 1. X is the mother of Y if X is a parent of Y and X is a female. 87. Chapter 5 The concept of Recursion program practice and trace page 93 (both). Y and Z. Your Work: Write program that will satisfy the following relations 1. Write a program that will invoke an input (an integer) and find out the factorial of that number recursively. the recursive procedure should do its work on the way down. Rules of Recursion a. Run program on (page 79) 10. b. b. Write a program that will invoke two inputs and find out the first seven (7) Fibonacci numbers from their Fibonacci series. find out the difference and why this differences are occurring. Run program on (page 85. program practice and trace on page 95 (using repeat). Find out the difference of program on page 93 and program on page 95 ( by forcely stop you may need to use Ctrl+Break ).9. Y is an offspring of X if X is a parent of Y. 2. c. . the variables in the copy are bound through the process of unification. 2. 4. X is a grandparent of Z if X is a parent of Y and Y is a parent of Z. fail predicate 11. Variable binding in a rule or fact applies only to the current layer. look the difference. c. Concept of Unwinding a. In most applications. For all X and Y. b. 88). Predicates before recursive call are invoked during winding down. Recursion involves two phases: “winding down” and “unwinding”. When a copy of the rule or fact in invoked. For all X and Y. 5. Modify your previous program as program in page 98.Carefully watch the difference. A program must include some method of terminating the recursion loop. 7. Exercise: a. For all X and Y. 4.

Sign up to vote on this title
UsefulNot useful