Kamis, 12 November 2009

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.