Selasa, 22 Desember 2009

Download Kode dan Laporan Simple Expert System for Identifying Human Desease

Link ini untuk mendownload expert system kelompok kami .
untuk rule pada notepad dan dalam format prolog

sedangkan untuk mengunduh file report Simple Expert System for identifying human desease silahkan klik disini

Sabtu, 19 Desember 2009

defining the disease using SWI-Prolog

This is my expert system by using prolog .
chek this out..
1 . first write this rule into notepad .

2. and then save it with name coba.pl
3. open SWI-Prolog then consult he file
4. after that write definisi(Penyakit,Virus,_,_,_). to list all of the disease and the virus .

5. to list Gejala we can write definisi(Penyakit,Virus,_,Gejala,_).

6. if you want to list all of the disease and alternatif , ou can write this definisi(Penyakit,Virus,Menyerang,Gejal,Solusi).

7. please don't forget to give (.) ont the end of command .

Sabtu, 05 Desember 2009

LOOP (Exercise 6)

hei . nice to see you again .
ok now we will do exercise 6 from book Logic Programing with Prolog .

Practical Exercise 6

(1) Define a predicate to output the values of the squares of the integers from N1 to N2 inclusive and test it with N1 = 6 and N2 = 12.
for answer number 1 its very easy . you should do it step by step .
ok, lets se the step .
1. first you must write a rules in notepad .

2. second you save it .pl
3. and then open the Prolog and and consult the file.
4. then you should write the instruction outsquare(7,10) . for this, you can write everything number that you like .
5.push enter .
6. so the result is :


(2) Define and test a predicate to read in a series of characters input by the user and output all of those before the first new line or ? character.

for number 2 , we should be careful .

lets do it together .
1. for step one , we must write a rules in notepad an then save .pl .

2. step two, open the prolog and consult the file .
3. then write instruction go. , push enter .
4. and then we can write everything you like, push enter again .
5. so, the result is :
6. but if you insert a character like '?' . it is only repeat word before character , but if you write again, it can't be repeat . it only once .
if you confuse , this is the example .


(3) Using the person clauses given in Section 6.3.1, find the professions of all those over 40.

this is the step to answer number 3.
1. first you must write a rule in notepad .
2. save it .pl
3. open the prolog and consult this file .
4. then write an instruction find. , and the result are is :finish . ^.^

LOOPS

Most conventional programming languages have a looping facility that enables a set of instructions to be executed repeatedly either a fixed number of times or until a given condition is met. Prolog has no looping facilities, similar effects can be obtained that enable a sequence of goals to be evaluated repeatedly. This can be done in a variety of ways, using backtracking, recursion, built-in predicates, or a combination of these.

1.1 Looping a Fixed Number of Times

No such facility loop in prolog, but a similar effect can be obtained using recursion.

Ex :

1. Make a new rule notepad.


2. then save .pl

3. and then open prolog consult that file and write an instruction ?- loop(6). And then push enter .

4. and the result is

Ex 2 :

1. make a rule in notepad.


2. then save .pl

3. and consult in prolog .

4. and then write a instruction output_values(4,10). And the result is :


1.2Looping Until a Condition Is Satisfied

No such facility a set of instructions to be executed repeatedly until a given condition is met available directly in Prolog, but a similar effect can be obtained in several ways.

1.2.1 Recursion

Ex1 :

1. Make a new rule in notepad.


2. The second save .pl

3. And then open in prolog and consult the file .

4. Write a instruction go. Then push enter , and then write the the answer (without spasi and don’t forget to give (.) ).

5. The result is :


Ex 2 :

1. Make a rule in notepad .


2. Second step is you must ave it .pl

3. And then open prolog , consult the file .

4. In prolog you must write an instruction get_answer(Myanswer).

5. The result is :


1.2.2 Using the ‘repeat’ predicate.

Another method that is often used is based on the built-in predicate repeat. The name of this predicate is really a misnomer. 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.

Ex1 :

1. First make a rule in notepad .


2. Second save it with format .pl

3. Then consult this file in prolog .

4. Write the instruction get_answer(Y). then push enter .

5. Show the evaluation will prompt the user to enter a term.

6. Answer it with yes or no, it can’t stop until you aswer Yes or No.


Ex 2 :

1. Make a rule in notepad then save .pl


2. Then make a new file with name myfile.txt


3. Open prolog and consult the file .

4. And then write an instruction readterms(‘myfile.txt’). please don’t forget to bring (.).

5. The result is :


1.3Backtracking with Failure

1.3.1 Searching the Prolog Database

Ex 1 :

1. Make a rule in notepad and save .pl

2. Then consult the file in prolog .

3. And then write alldogs. in prolog

4. And the result is :


5. But if in rule you write this


6. The result is :


The next program is designed to search a database containing clauses representing the name, age, place of residence and occupation of a number of people.

Ex 2 :

1. Make a rule in notepad and then save .pl


2. Second open the prolog and consult the file

3. Write allteachers. In prolog

4. And the result is .

1.3.2 Finding Multiple Solutions

Backtracking with failure can also be used to find all the ways of satisfying a goal.