Fact, Rules, Predicate, and Variable in Prolog (Part 1)

Assalamualaikum….

Hey all of my friends….

Nw, we will learn about Facts, Rules, Predicate, and Variable in Prolog..

it's interesting right?? hehehehe no wories...

Excersice no. 1 :
Read more…
Given some facts and predicates like below :

We are supposed to find :

a) all the mammals

b) all the carnivores that are mammals

c) all the mammal with stripes

d) whether there is a reptile that has mane

> To find all the mammals this step :

  1. Open your Prolog, then create new file and write the facts and variable.
  2. File > Consult
  3. Write the rules ?-animal(mammal,Y,_,_).
  1. And then, the result will be like below :

>To find all the carnivores that are mammals :
  1. Still continue with the facts and rules before.
  2. Write this ?-animal(mammal,Y,carnivore,_).
  3. And then the result is :

>To find all the mammal with stripes :

  1. Still continue with the facts and rules in a).
  2. Write this ?-animal(mammal,Y,_,stripes).
  3. And then the result is :
>To find whether there is a reptile that has mane :
  1. Still continue with the facts and rules in a).
  2. Write this ?-animal(reptile,Y,_,mane).
  3. And then the result is no reptile that has mane.

That’s all for exercise number 1.
Now, continue with exersice number 2.
Read article Fact, Rules, Predicate, and Variable in Prolog (Part 2).
NO wories about math...
hohoho




  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • Twitter
  • RSS

0 Response to "Fact, Rules, Predicate, and Variable in Prolog (Part 1)"

Posting Komentar