% File: zoo.pl
% includes examples and interface predicates for the zoo domain

% adapted from data base obtained from the UCI Machine Learning Repository
% http://www1.ics.uci.edu/~mlearn/MLRepository.html
% Original creator: Richard Forsyth

% two classes; are they mammals (yes) or not (no)


classes([yes,no]).

data(aardvark,yes,[1,0,0,0,0,1,1,1,1,0,0,4,0,0]).
data(antelope,yes,[1,0,0,0,0,0,1,1,1,0,0,4,1,0]).
data(bass,no,[0,0,1,0,1,1,1,1,0,0,1,0,1,0]).
data(bear,yes,[1,0,0,0,0,1,1,1,1,0,0,4,0,0]).
data(boar,yes,[1,0,0,0,0,1,1,1,1,0,0,4,1,0]).
data(buffalo,yes,[1,0,0,0,0,0,1,1,1,0,0,4,1,0]).
data(calf,yes,[1,0,0,0,0,0,1,1,1,0,0,4,1,1]).
data(carp,no,[0,0,1,0,1,0,1,1,0,0,1,0,1,1]).
data(catfish,no,[0,0,1,0,1,1,1,1,0,0,1,0,1,0]).
data(cavy,yes,[1,0,0,1,0,0,1,1,1,0,0,4,0,1]).
data(cheetah,yes,[1,0,0,0,0,1,1,1,1,0,0,4,1,0]).
data(chicken,no,[0,1,1,1,0,0,0,1,1,0,0,2,1,1]).
data(chub,no,[0,0,1,0,1,1,1,1,0,0,1,0,1,0]).
data(clam,no,[0,0,1,0,0,1,0,0,0,0,0,0,0,0]).
data(crab,no,[0,0,1,0,1,1,0,0,0,0,0,4,0,0]).
data(crayfish,no,[0,0,1,0,1,1,0,0,0,0,0,6,0,0]).
data(crow,no,[0,1,1,1,0,1,0,1,1,0,0,2,1,0]).
data(deer,yes,[1,0,0,0,0,0,1,1,1,0,0,4,1,0]).
data(dogfish,no,[0,0,1,0,1,1,1,1,0,0,1,0,1,0]).
data(dolphin,yes,[0,0,0,0,1,1,1,1,1,0,1,0,1,0]).
data(dove,no,[0,1,1,1,0,0,0,1,1,0,0,2,1,1]).
data(duck,no,[0,1,1,1,1,0,0,1,1,0,0,2,1,0]).
data(elephant,yes,[1,0,0,0,0,0,1,1,1,0,0,4,1,0]).
data(flamingo,no,[0,1,1,1,0,0,0,1,1,0,0,2,1,0]).
data(flea,no,[0,0,1,0,0,0,0,0,1,0,0,6,0,0]).
data(frog,no,[0,0,1,0,1,1,1,1,1,0,0,4,0,0]).
data(venomousfrog,no,[0,0,1,0,1,1,1,1,1,1,0,4,0,0]).
data(fruitbat,yes,[1,0,0,1,0,0,1,1,1,0,0,2,1,0]).
data(giraffe,yes,[1,0,0,0,0,0,1,1,1,0,0,4,1,0]).
data(girl,yes,[1,0,0,0,0,1,1,1,1,0,0,2,0,1]).
data(gnat,no,[0,0,1,1,0,0,0,0,1,0,0,6,0,0]).
data(goat,yes,[1,0,0,0,0,0,1,1,1,0,0,4,1,1]).
data(gorilla,yes,[1,0,0,0,0,0,1,1,1,0,0,2,0,0]).
data(gull,no,[0,1,1,1,1,1,0,1,1,0,0,2,1,0]).
data(haddock,no,[0,0,1,0,1,0,1,1,0,0,1,0,1,0]).
data(hamster,yes,[1,0,0,0,0,0,1,1,1,0,0,4,1,1]).
data(hare,yes,[1,0,0,0,0,0,1,1,1,0,0,4,1,0]).
data(hawk,no,[0,1,1,1,0,1,0,1,1,0,0,2,1,0]).
data(herring,no,[0,0,1,0,1,1,1,1,0,0,1,0,1,0]).
data(honeybee,no,[1,0,1,1,0,0,0,0,1,1,0,6,0,1]).
data(housefly,no,[1,0,1,1,0,0,0,0,1,0,0,6,0,0]).
data(kiwi,no,[0,1,1,0,0,1,0,1,1,0,0,2,1,0]).
data(ladybird,no,[0,0,1,1,0,1,0,0,1,0,0,6,0,0]).
data(lark,no,[0,1,1,0,1,0,0,1,1,0,0,2,1,0]).
data(leopard,yes,[1,0,0,0,0,1,1,1,1,0,0,4,1,0]).
data(lion,yes,[1,0,0,0,0,1,1,1,1,0,0,4,1,0]).
data(lobster,no,[0,0,1,0,1,1,0,0,0,0,0,6,0,0]).
data(lynx,yes,[1,0,0,0,0,1,1,1,1,0,0,4,1,0]).
data(mink,yes,[1,0,0,0,1,1,1,1,1,0,0,4,1,0]).
data(mole,yes,[1,0,0,0,0,1,1,1,1,0,0,4,1,0]).
data(mongoose,yes,[1,0,0,0,0,1,1,1,1,0,0,4,1,0]).
data(moth,no,[1,0,1,1,0,0,0,0,1,0,0,6,0,0]).
data(newt,no,[0,0,1,0,1,1,1,1,1,0,0,4,1,0]).
data(octopus,no,[0,0,1,0,1,1,0,0,0,0,0,8,0,0]).
data(opossum,yes,[1,0,0,0,0,1,1,1,1,0,0,4,1,0]).
data(oryx,yes,[1,0,0,0,0,0,1,1,1,0,0,4,1,0]).
data(ostrich,no,[0,1,1,0,0,0,0,1,1,0,0,2,1,0]).
data(parakeet,no,[0,1,1,1,0,0,0,1,1,0,0,2,1,1]).
data(penguin,no,[0,1,1,0,1,1,0,1,1,0,0,2,1,0]).
data(pheasant,no,[0,1,1,1,0,0,0,1,1,0,0,2,1,0]).
data(pike,no,[0,0,1,0,1,1,1,1,0,0,1,0,1,0]).
data(piranha,no,[0,0,1,0,1,1,1,1,0,0,1,0,1,0]).
data(pitviper,no,[0,0,1,0,0,1,1,1,1,1,0,0,1,0]).
data(platypus,yes,[1,0,1,0,1,1,0,1,1,0,0,4,1,0]).
data(polecat,yes,[1,0,0,0,0,1,1,1,1,0,0,4,1,0]).
data(pony,yes,[1,0,0,0,0,0,1,1,1,0,0,4,1,1]).
data(porpoise,no,[0,0,0,0,1,1,1,1,1,0,1,0,1,0]).
data(puma,yes,[1,0,0,0,0,1,1,1,1,0,0,4,1,0]).
data(pussycat,yes,[1,0,0,0,0,1,1,1,1,0,0,4,1,1]).
data(raccoon,yes,[1,0,0,0,0,1,1,1,1,0,0,4,1,0]).
data(reindeer,yes,[1,0,0,0,0,0,1,1,1,0,0,4,1,1]).
data(rhea,no,[0,1,1,0,0,1,0,1,1,0,0,2,1,0]).
data(scorpion,no,[0,0,0,0,0,1,0,0,1,1,0,8,1,0]).
data(seahorse,no,[0,0,1,0,1,0,1,1,0,0,1,0,1,0]).
data(seal,yes,[1,0,0,0,1,1,1,1,1,0,1,0,0,0]).
data(sealion,yes,[1,0,0,0,1,1,1,1,1,0,1,2,1,0]).
data(seasnake,no,[0,0,0,0,1,1,1,1,0,1,0,0,1,0]).
data(seawasp,no,[0,0,1,0,1,1,0,0,0,1,0,0,0,0]).
data(skimmer,no,[0,1,1,1,1,1,0,1,1,0,0,2,1,0]).
data(skua,no,[0,1,1,1,1,1,0,1,1,0,0,2,1,0]).
data(slowworm,no,[0,0,1,0,0,1,1,1,1,0,0,0,1,0]).
data(slug,no,[0,0,1,0,0,0,0,0,1,0,0,0,0,0]).
data(sole,no,[0,0,1,0,1,0,1,1,0,0,1,0,1,0]).
data(sparrow,no,[0,1,1,1,0,0,0,1,1,0,0,2,1,0]).
data(squirrel,yes,[1,0,0,0,0,0,1,1,1,0,0,2,1,0]).
data(starfish,no,[0,0,1,0,1,1,0,0,0,0,0,5,0,0]).
data(stingray,no,[0,0,1,0,1,1,1,1,0,1,1,0,1,0]).
data(swan,no,[0,1,1,1,1,0,0,1,1,0,0,2,1,0]).
data(termite,no,[0,0,1,0,0,0,0,0,1,0,0,6,0,0]).
data(toad,no,[0,0,1,0,1,0,1,1,1,0,0,4,0,0]).
data(tortoise,no,[0,0,1,0,0,0,0,1,1,0,0,4,1,0]).
data(tuatara,no,[0,0,1,0,0,1,1,1,1,0,0,4,1,0]).
data(tuna,no,[0,0,1,0,1,1,1,1,0,0,1,0,1,0]).
data(vampire,yes,[1,0,0,1,0,0,1,1,1,0,0,2,1,0]).
data(vole,yes,[1,0,0,0,0,0,1,1,1,0,0,4,1,0]).
data(vulture,no,[0,1,1,1,0,1,0,1,1,0,0,2,1,0]).
data(wallaby,yes,[1,0,0,0,0,0,1,1,1,0,0,2,1,0]).
data(wasp,no,[1,0,1,1,0,0,0,0,1,1,0,6,0,0]).
data(wolf,yes,[1,0,0,0,0,1,1,1,1,0,0,4,1,0]).
data(worm,no,[0,0,1,0,0,0,0,0,1,0,0,0,0,0]).
data(wren,no,[0,1,1,1,0,0,0,1,1,0,0,2,1,0]).

%note list of attributes in reverse order
attributes([domestic,tail,legs,fins,venomous,breathes,backbone,toothed,predator,aquatic,airborne,eggs,feathers,hair]).

av(hair,[_99|_413],_99).
av(feathers,[_417,_99|_429],_99).
av(eggs,[_417,_433,_99|_445],_99).
av(airborne,[_433,_449,_465,_99|_477],_99).
av(aquatic,[_433,_449,_465,_481,_99|_493],_99).
av(predator,[_433,_449,_465,_481,_497,_99|_509],_99).
av(toothed,[_433,_449,_465,_481,_497,_513,_99|_525],_99).
av(backbone,[_433,_449,_465,_481,_497,_513,_529,_99|_541],_99).
av(breathes,[_433,_449,_465,_481,_497,_513,_529,_545,_99|_557],_99).
av(venomous,[_433,_449,_465,_481,_497,_513,_529,_545,_561,_99|_573],_99).
av(fins,[_433,_449,_465,_481,_497,_513,_529,_545,_561,_577,_99|_589],_99).
av(legs,[_433,_449,_465,_481,_497,_513,_529,_545,_561,_577,_593,_99|_6],_99).
av(tail,[_433,_449,_465,_481,_497,_513,_529,_545,_561,_577,_593,_609,_99|_621],_99).
av(domestic,[_433,_449,_465,_481,_497,_513,_529,_545,_561,_577,_593,_609,_25,_99|_637],_99).

attr_value(A,Ex,V) :-
   data(Ex,_,L),
   av(A,L,V).

% all binary valued except legs

values(legs,[0,2,4,5,6,8]):-!.
values(_,[0,1]).


class(Ex,C) :- data(Ex,C,_).

training_data([aardvark,boar,buffalo,calf,cavy,cheetah,chicken,chub,clam,crayfish,deer,dolphin,dove,flamingo,frog,venomousfrog,fruitbat,girl,gnat,goat,gull,haddock,hamster,hare,hawk,kiwi,lark,leopard,lion,lynx,mink,mole,moth,opossum,oryx,ostrich,parakeet,penguin,pike,platypus,pony,pussycat,raccoon,reindeer,rhea,scorpion,sealion,skimmer,slowworm,squirrel,stingray,swan,termite,tortoise,tuatara,tuna,vampire,wallaby,wolf,worm]).

test_data([antelope,carp,crab,dogfish,duck,flea,gorilla,honeybee,ladybird,mongoose,octopus,pitviper,porpoise,seahorse,seal,seasnake,sole,starfish,toad,wasp,wren,bass,catfish,crow,giraffe,herring,lobster,newt,piranha,polecat,puma,seawasp,slug,sparrow,vole,vulture,bear,elephant,pheasant,skua,housefly]).




