Tuesday, October 13, 2009

Final Project Prolog

This the final project prolog. We will show about all possible combination of a set. Okay, let's begin..

Step 1

Make a set. In here, We call it "himpunan s" and "himpunan h". The member of "himpunan s" are Fahrireza, Izzat, Chandra, and Catur. And the member of "himpunan h" are Probolinggo, Nganjuk, Surabaya, and Sidoarjo. Make the set in notepad by typing :
himpunans(fahrireza).
himpunans(izzat).
himpunans(chandra).
himpunans(catur).
himpunanh(probolinggo).
himpunanh(nganjuk).
himpunanh(surabaya).
himpunanh(sidoarjo).

note : In Prolog, the letters must be typed in Lower Case and Without Space. Also must type dot "." or stop mark in the last declaration.

See this image :
















(Click the image if you can't see well)


Step 2

Save with format prolog. In our computer, Extension Prolog is ".pro". So We save it with extension ".pro". Prolog can be ".pro" or ".pl" extension. We name the file with "prolog".

note : Must save in My Documents\Prolog\

See this image :
















(Click the image if you can't see well)


Step 3

Open the Prolog and open the file. Command in prolog to open the file is consult. The sintax is consult('file.pro').

note : Remember to give stop mark or dot "." in last command and declaration.

See this image :
















(Click the image if you can't see well)


Step 4

If file is correct and prolog can open it, prolog will show if the file is compiled successfully. Now, to check the file really has been compiled with prolog, We can try it with type : himpunans(X). With this command prolog will show the member of himpunans.

See this image :
















(Click the image if you can't see well)

Step 5

Now, prolog show an output "X = fahrireza". In this output show that X possible or can be replace with fahrireza. If you feel fahrireza who are not you find, you can type ";". Prolog will show another possibility. If you type ";" rapidly, if the last possibility, prolog will show output "No". Because prolog conclude that the member what you want is nothing.

See this image :










































































(Click the image if you can't see well)


Step 6

Okay let's check the possibility can prolog show if We want to know how many possibility combination of "himpunans" and "himpunanh". Command in prolog to check it is : himpunans(X),himpunanh(Y).

It mean that prolog must show how many possibility of "himpunans" and "himpunanh" by make output the member of himpunans and himpunanh.

See this image :






























(Click the image if you can't see well)

The possibility is sixteen. So we can conclude that how many possibility can be calculate with "the count of himpunans multiply with the count of himpunanh". So if himpunans have 4 members and himpunanh also have 4 members, the possibility is 4 x 4 = 16.

0 comments:

Post a Comment

About This Blog

This Blog created to complete Discrete Math Assignment. This Blog contain all about discrete math subject especially Prolog programming. The member of team are Fahri Reza, Izzat, Chandra and Catur. We are from Discrete Math class A at Information System Department faculty of Information Technology INSTITUT TEKNOLOGI SEPULUH NOPEMBER (ITS) Surabaya. We hope all existing posts on this blog will be useful for all people. And thanks for visiting our Blog..

Followers

  © Blogger template PingooIgloo by Ourblogtemplates.com 2009 | The Permutation Team's Blog 2009

Back to TOP