Selasa, 22 Desember 2009

Final Project Expert System

So, our final project expert system has done.

We often find students of senior high school feel confuse about university’s majors that they will take. According to our survey, 3 of 5 students of senior high school in the third grade still don’t decide what kind of major that they will choose. It is because they are lack of information about kind of majors, what subject that they will learn in those majors, and which universities that provide those majors. From that problem, we make a simple expert system by using prolog that helps them identifying the subject that they will learn if they choose a certain major. And more information in which universities that provide the majors.

Here is the link of our report:

http://www.4shared.com/file/179094754/a1e42b66/Report_FP_matdis_Irine_Rizqi_B.html

Source code:

http://www.4shared.com/file/179101122/f2d925c0/aaaaaaaaaaaaaa.html

Senin, 14 Desember 2009

Testing

Development of our simple EXPERT SYSTEM
1. Firstly, we made a notepad that contain of the facts, or we can say it as characteristic of each major. We still develop it in a simple way. We divided the characteristic into 3 parts (major in senior high school, faculty, major in university). Then we save it in .pl type.




















2. Then we opened SWI Prolog and consult the notepad. We entered an example instruction like this: jurusan(ipa,_,A). Press enter, and ';' for the next result. It will show the possibility of major if we choose IPA as favourite subject.

our next development will show another characteristic to specify the suitable major ^_^

Selasa, 08 Desember 2009

Summary for chapter 6

Introduction

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.

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.

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.

Recursion
The first example below 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.

go:-loop(start). /* start is a dummy value used to get
the looping process started.*/
loop(end).
loop(X):-X\=end,write('Type end to end'),read(Word),
write('Input was '),write(Word),nl,loop(Word).

?- go.
Type end to end: university.
Input was university
Type end to end: of.
Input was of
Type end to end: portsmouth.
Input was portsmouth
Type end to end: end
Input was end
Yes

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'.

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.

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.

Looping Exercise Page 97

(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.

pertama kita buat perintah seperti di bwah ini di notepad, kemudian disimpan dengan tipe .pl












kemudian kita mengetikkan perintah outsquare(6,12). Lalu tekan enter








(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.
pertama-tama buat rule seperti notepade berikut. Kemudian save dengan tipe .pl








Kemudian dari swi prolog consult rule tadi. Lalu kita masukkan perintah go.









(3) Using the person clauses given in Section 6.3.1, find the professions of all
those over 40.
pertama-tama buat rule seperti berikut, dan simpan dengan tipe .pl

lalu dari swi prolog kita consult file tadi. kemudian kita ketikkan perintah find.

Rabu, 25 November 2009

Input and Output in ProLog

TUTORIAL 4
INPUT AND OUTPUT

Outputting Terms
The write/1 predicate takes a single argument, which must be a valid Prolog term. Evaluating the predicate causes the term to be written to the current output stream, which by default is the user's screen. Evaluating a nl goal causes a new line to be output to the current output stream.

Examples
?- write(26),nl.
26
yes
?- write('a string of characters'),nl.
a string of characters
yes
?- write([a,b,c,d,[x,y,z]]),nl.
[a,b,c,d,[x,y,z]]
yes
?- write(mypred(a,b,c)),nl.
mypred(a,b,c)
yes
?- write('Example of use of nl'),nl,nl,write('end of example'),nl.
Example of use of nl
end of example
yes

Note that atoms that have to be quoted on input (e.g. 'Paul', 'hello world') are not quoted when output using write. If it is important to output the quotes, the writeq/1 predicate can be used. It is identical to write/1 except that atoms that need quotes for input are output between quotes (other atoms are not).

?- writeq('a string of characters'),nl.
'a string of characters'
yes
?-writeq(dog),nl.
dog
yes
?- writeq('dog'),nl.
dog
yes


Inputting Terms
The built-in predicate read/1 is provided to input terms. It takes a single argument, which must be a variable. Evaluating it causes the next term to be read from the current input stream, which by default is the user's keyboard. In the input stream, the term must be followed by a dot ('.') and at least onewhite space character, such as space or newline. The dot and white space characters are read in but are not considered part of the term. Note that for input from the keyboard (only) a prompt character such as a colon will usually be displayed to indicate that user input is required. It may be necessaryto press the 'return' key before Prolog will accept the input. Both of these do not apply to input from files.When a read goal is evaluated, the input term is unified with the argument variable. If the variable is unbound (which is usually the case) it is bound to the input value.
?- read(X).
: jim.
X = jim
?- read(X).
: 26.
X = 26
?- read(X).
: mypred(a,b,c).
X = mypred(a,b,c)
?- read(Z).
: [a,b,mypred(p,q,r),[z,y,x]].
Z = [a,b,mypred(p,q,r),[z,y,x]]
?- read(Y).
: 'a string of characters'.
Y = 'a string of characters'

If the argument variable is already bound (which for most users is far more likely to occur by mistake than by design), the goal succeeds if and only if the input term is identical to the previously bound value.

?- X=fred,read(X).
: jim.
no
?- X=fred,read(X).
: fred.
X = fred

Input and Output Using CharactersAlthough input and output of terms is straightforward, the use of quotes and full stops can be cumbersome and is not always suitable. For example, it would be tedious to define a predicate (using read) which would read a series of characters from the keyboard and count the number of vowels. A much better approach for problems of this kind is to input a character at a time. To do this it is first necessary to know about the ASCII value of a character.All printing characters and many non-printing characters (such as space and tab) have a corresponding ASCII (American Standard Code for Information Interchange) value, which is an integer from 0 to 255.

Outputting Characters
Characters are output using the built-in predicate put/1. The predicate takes a single argument, which must be a number from 0 to 255 or an expression that evaluates to an integer in that range.Evaluating a put goal causes a single character to be output to the current output stream. This is the character corresponding to the numerical value (ASCII value) of its argument, for example
?- put(97),nl.
a
yes
?- put(122),nl.
z
yes
?- put(64),nl.
@
yes

Inputting Characters
Two built-in predicates are provided to input a single character: get0/1 and get/1.The get0 predicate takes a single argument, which must be a variable. Evaluating aget0 goal causes a character to be read from the current input stream. The variableis then unified with the ASCII value of this character.Note that for input from the keyboard (only) a prompt character such as a colonwill usually be displayed to indicate that user input is required. It may be necessaryto press the 'return' key before Prolog will accept the input. Both of these alsoapply to the get predicate described below but do not apply to input from files.Assuming the argument variable is unbound (which will usually be the case), itis bound to the ASCII value of the input character.
?- get0(N).
: a
N = 97
?- get0(N).
: Z
N = 90
74 Logic Programming With Prolog
?- get0(M).
: )M = 41

If the argument variable is already bound, the goal succeeds if and only if it has a numerical value that is equal to the ASCII value of the input character.
?- get0(X).
: a
X = 97
?- M is 41,get0(M).
: )
M = 41
?- M=dog,get0(M).
: )
no
?- M=41.001,get0(M).
: )
no

The get predicate takes a single argument, which must be a variable. Evaluatinga get goal causes the next non-white-space character (i.e. character with an ASCIIvalue less than or equal to 32) to be read from the current input stream. Thevariable is then unified with the ASCII value of this character in the same way asfor get0.
?- get(X).
: Z
X = 90
?- get(M).
: Z
M = 90

Selasa, 24 November 2009

Expert System Design

Our simple design of expert system is:
"What is your suitable major?"

Background
We often find some student that feel confuse to decide what major they will take for their next study. Sometimes they fell hesitate to ask their teacher, or some other case just like leak of information, and difficult to get information about Universities. So because of that we want to help them

Explanation
This expert system is made for senior high school student to determine what kind of major that suitable for them. We make a question about their interest, favourite subject, their dream/idea. etc. And then, after they answer the multiple choice, we show the suitable major based o our characteristic that we have determine it before.

Benefit
The benefit is to help senior high school student in order not to take wrong major. We don't want they take wrong major that not suitable for their dream. They can explore their ability if they like the major itself.

Kamis, 12 November 2009

Blog kami

1. Irine Dwi Kenestie http://irindisini.blogspot.com/
2. Rizqi Prifsanti http://kucinglewat.blogspot.com/
3. Bunga Fadhila http://bungaitusaya.blogspot.com/

Summary : Operator and Arithmetic in Prolog

1. Operator
Binary predicate (predikat dengan dua argumen) dapat diubah menjadi bentuk infix operator. Contoh :
Standar : makan (kucing,tikus)
infix operator : kucing makan tikus
Unary predikat (predikat dengan satu argumen) dapat diubah menjadi bentuk prefix operator atau postfix operator. Contoh :
Standar : lucu (anjing)
prefix operator : lucu anjing
postfix operator: anjing lucu
2. Aritmatika
Dengan Prolog kita dapat melakukan penghitungan aritmatika.
a. Operator Aritmatika
X+Y (penjumlahan)
X-Y (pengurangan)
X*Y (perkalian)
X/Y (pembagian)
X//Y the ‘integer quotient’ of X and Y (the result is truncated to the nearest integer between it and zero)
X^Y (pangkat)
-X (negatif)
abs(X) (nilai absolut)
sin(X) (sinus)
cos(X) (cosinus)
max(X,Y)(nilai terbesar)
sqrt(X) (akar)
b. Pengutamaan Operator Dalam Ekspresi Aritmatika
Prolog menggunakan algoritma aljabar biasa dalam pengopersian aritmatika. Contohnya A+B*C-D. Di dalam ajabar C dan D dikalikan lebih dahulu lalu ditambah dengan A lalu dikurangi dengan D. DI prolog juga demikian. Untuk pengecualian, kita tinggal menggunakan kurung. Contoh : (A+B)*(C+D).
c. Operator Relasi
Operator seperti =, !=, >,>=, <, =<, dapat digunakan di Prolog.
3. Operator Pembanding
Berikut merupakan daftar dari equality operators yang digunakan dalam prolog beserta fungsi dari masing-masing operator.
Arithmetic Expression Equality =:=
Arithmetic Expression Inequality =\=
Terms Identical ==
Terms Not Identical \==
Terms Identical With Unification =
Non-Unification Between Two Terms \=
4. Operator Logika
a. Operator Not
Operator not dapat ditempatkan sebelum predikat untuk memberikan negasi. Predikat yang dinegasikan bernilai benar jika predikat yang asli salah dan bernilai salah jika predikat yang asli benar. Contoh penggunaan operator not :
dog(fido).
?- not dog(fido).
no
?- dog(fred).
no
?- not dog(fred).
yes
b. Operator Disjungsi
Operator disjungsi (;) digunakan sebagai operator ‘atau’. Contoh :
?- 6<3;7 is 5+2.
yes
?- 6*6=:=36;10=8+3.
yes

Fact, Rules, Predicate, and Variable

(1) Type the following program into a file and load it into Prolog.
/* Animals Database */animal(mammal,tiger,carnivore,stripes).animal(mammal,hyena,carnivore,ugly).animal(mammal,lion,carnivore,mane).animal(mammal,zebra,herbivore,stripes).animal(bird,eagle,carnivore,large).animal(bird,sparrow,scavenger,small).animal(reptile,snake,carnivore,long).animal(reptile,lizard,scavenger,small).
Devise and test goals to find (a) all the mammals, (b) all the carnivores that are mammals, (c) all the mammals with stripes, (d) whether there is a reptile that has a mane.

1. Pertama-tama buatlah new file di SWIProlog. Buat database seperti ini










2. untuk mengerjakan soal (a) all the mammals ketik ?- animal(mammal,X,_,_). kemudian tekan enter dan ; untuk hasil selanjutnya







3. untuk mengerjakan soal (b) all the carnivores that are mammals, ketik ?- animal(mammal,Y,carnivore,_). kemudian tekan enter dan ; untuk hasil selanjutnya









4. untuk mengerjakan soal (c) all the mammals with stripes, ketik ?- animal(mammal,Z,_,stripes).kemudian tekan enter dan ; untuk hasil selanjutnya








5. untuk mengerjakan soal (d) whether there is a reptile that has a mane, ketik ?- animal(reptile,R,_,mane). kemudian tekan enter dan ; untuk hasil selanjutnya . Jawabannya adalah No, karena tidak ada reptile yang mempunyai mane di dalam database.













(2) Type the following program into a file
/* Dating Agency Database */person(bill,male).person(george,male).person(alfred,male).person(carol,female).person(margaret,female).person(jane,female).
Extend the program with a rule that defines a predicate couple with two arguments, the first being the name of a man and the second the name of a woman.Load your revised program into Prolog and test it.
1. Buat database seperti berikut ini










2. Lalu masukkan perintah seperti berikut

?- pasangan(X,Y), lalu tekan enter dan ; untuk hasil selanjutnya

Kamis, 22 Oktober 2009

RULE BASED EXPERT SYSTEM

Expert System atau Sistem pakar adalah suatu program komputer yang memperlihatkan derajat keahlian dalam pemecahan masalah di bidang tertentu sebanding dengan seorang pakar (Ignizio, 1991). Keahlian sistem pakar dalam memecahkan suatu masalah diperoleh dengan cara merepresentasikan pengetahuan seorang atau beberapa orang pakar dalam format tertentu dan menyimpannya dalam basis pengetahuan. Sistem pakar berbasis kaidah (rule-based expert system) adalah sistem pakar yang menggunakan kaidah (rules) untuk merepresentasikan pengetahuan di dalam basis pengetahuannya.Mesin inferensi (inference engine) merupakan bagian yang bertindak sebagai pencari solusi dari suatu permasalahan berdasar pada kaidah-kaidah yang ada dalam basis pengetahuan sistem pakar. Selama proses inferensi, mesin inferensi memeriksa status dari basis pengetahuan dan memori kerja (working memory) untuk menentukan fakta apa saja yang diketahui dan untuk menambahkan fakta baru yang dihasilkan ke dalam memori kerja tersebut. Fakta-fakta yang merupakan hasil dari proses inferensi disimpan dalam memori kerja.

Rule Based Expert System
> Representasi Pengetahuan dengan Rules (aturan) sering disebut juga dengan Sistem Produksi
> Suatu Rule Terdiri dari 2 bagian, yaitu:
> Antacedent, yaitu bagian yang mengekspresikan situasi atau premis (Pernyataan berawalan IF)
> Konsekuen, yaitu bagian yang menyatakan suatu tindakan tertentu atau konklusi yang diterapkan jika situasi atau premis bernilai benar (Pernyataan berawalan THEN).
Misalnya:
IF lalulintas pagi ini macet
THEN saya naik sepeda motor saja

Selasa, 13 Oktober 2009

Tutorial

About Us



Hey there, here is our second posting.. In this posting we wanna write something about ourselves, just like description, but more specific.Our member consist of three girls, that we are live in the same street, same house, but not in the same room.




1. Irine Dwi Kenestie




All of you can call me irin, i was born in Gresik, February, 25th 1992 . My hobby is listening to music and watching a movie. My favourite food is meatball and my favourite drink is chocolate milk. I am graduate from 1st kebomas senior high school, and then i enter ITS because it's my dream to get my future be better. In this university i found my best friend who all of them, there are in this blog. I can be hummoris but i can keep silent too, because i'm a moody person. This is about me, who not a perfect person.




2. Rizqi Prifsanti





My name is Rizqi, but since I was in elementary school, my friends started to call me Rici until now. I was born in Jember, on 2nd August 1991. My senior high school is SMA 1 Jember. Now I am in ITS Surabaya, Information System department. There are a lot of new friends and experince that I found here. I hope I can make all of my dreams come true. My hobby are browsing the internet and watching movie with friends. Martabak and chicken noodle are some of my favourite of food. I love ice cream too. In this life I have some inspiration, they are my parents, Five Minutes, and The Titans. They are so kind to me :) hahaha. I have a lot of best friends too, that can make me both laugh and cry, I'm happy with them.




3. Bunga Fadhila


Hey there, my name is bunga fadhila, you just can call me Bunga. I was born in Jember, my lovely city, on 7th September 1991. My senior high school is SMA 1 Jember, the same school with Rici. After I graduate from SMA 1 Jember, I tried snmptn and I'm accepted in ITS, Information System departement. Here I learn how to handle everything by myself, not depend on my parents. I will always try to make them proud of me. I like listening to music and reading classic novel. My favourite food is Mayashi nut and my favourite drink is Ultra Milk Strawberry. In my friends opinion, I want everything what I do become perfect. They also said I'm so principal. I hope it will give advantages for my work in the future and get the best.

Kamis, 01 Oktober 2009

First Posting

Assalamualaikum wr. wb.
We are three girls from Information System ITS. Our group is consist of Irine Dwi Kenestie (5209100001), Rizqi Prifsanti (5209100084), and Bunga Fadhila (5209100105). This blog is one of our assignment from our lecturer, Mr. Ahmad Mukhlason as our final project for this semester.

We named this blog with Discmania Seventy Eight. What is the meaning? Discmania itself stand for Discrete Mathematic and Its Application. And how about the seventy eight? You can consider it as our basecamp. In there we live together and share about everything, such as our lecture, campus activity, and other kind of gossip.

Okay, that's it. We think our first posting in this blog is enough. We hope from this learning, we can get both knowledge and improvement for our Discrete Mathematic lecture. Amiiin.

Thank you for your attention.
Wassalamualaikum wr. wb.