Senin, 21 Desember 2009

Simple Expert System

now, we make a simple expert system to make easier our mother to find the recipe to make some food.

like usually, the first time, you must open your prolog and creat new .pl.

and then make the program in your notepade.











after make the rule, lets consult in your prolog:

and let's start the prolog program, write find(name of food) .


that is our prolog program can help our mother to find more easier recipes...
^ ^

Selasa, 15 Desember 2009

Simple Expert System

We make simple expert system to make someone more easier to find something what he want. Example, if someone want to buy a motorcycle, he/she can find what type of motorcycle he/she want with us this prolog program.
For more distinct you can see like this below:

 
 and if you want to fine a perusahaan san the tahun production of the motorcycle you can write " find(yamaha,2006)." and the result is:



that is our Simple Expert System,,,can help someone to find something more easier.

Senin, 07 Desember 2009

Input and Output in Prolog

Exercise 6

1.
write like this in your notepad with name output value.pl

and than consule in your prolog then write 'output_values(6,12).' and enter.



2.
write like this in your notepad with name or.pl

open your prolog and consult with or.pl, then write go.  in your prolog and th eresult like this below:

 3.
 write like this in your notepad with name person.pl







and then consult on prolog, and write 'see.'. And the result is

done.

Input and Output in Prolog

Summery for Chapter 6

6.1 Looping a Fixed Number of Times

     Many programming languages provide 'for loops' which enable a set of instructions to be executed a fixed number of times. No such facility is available in Prolog (directly), but a similar effect can be obtained using recursion.
 
6.2 Looping Until a Condition Is Satisfied

     Many languages have an 'until loop' which enables a set of instructions to be executed repeatedly until a given condition is met. Again, no such facility is available directly in Prolog, but a similar effect can be obtained in several ways.

     6.2.1 Recursion
              Shows the use of recursion to read terms entered by the user from the keyboard and output them to  the screen, until end is encountered. 
 
     6.2.2 Using the 'repeat' Predicate
              Although it can often be used to great effect, recursion is not always the easiest way to provide the types of looping required in Prolog programs. Another method that is often used is based on the built-in predicate repeat.
              The goal repeat does not repeat anything; it merely succeeds whenever it is called. The great value of repeat is that it also succeeds (as many times as necessary) on backtracking. The effect of this, as for any other goal succeeding, is to change the order of evaluating goals from 'right to left' (i.e. backtracking) back to 'left-to-right'. This can be used to create a looping effect.
 
6.3 Backtracking with Failure

     As the name implies, the predicate fail always fails, whether on 'standard' evaluation left-to-right or on backtracking. Advantage can be taken of this, combined with Prolog's automatic backtracking, to search through the database to find all the clauses with a specified property.

     6.3.1 Searching the Prolog Database
              Supposing the database contains clauses

     6.3.2 Finding Multiple Solutions
              Backtracking with failure can also be used to find all the ways of satisfying a goal. Suppose that a predicate findroute(Town1,Town2,Route) finds a route Route between two towns Town1 and Town2. The details of this predicate are irrelevant here. It may be assumed that Town1 and Town2 are atoms and that Route is a list.