Różnice

Różnice między wybraną wersją a wersją aktualną.

Odnośnik do tego porównania

pl:prolog:pllib:animals_kb [2019/06/27 15:50] (aktualna)
Linia 1: Linia 1:
 +====== Animals kb ======
 +{{tag>​knowledge_base}}
 +===== Description =====
 +A simple knowledge base for identifying animals.
 +
 +
 +**Source**: ​ PROLOG programming for artificial intelligence,​ 3rd Edition, Harlow, 2001, ISBN 0-201-40375-7.
 +
 +===== Download =====
 +Program source code: {{animals_kb.pl}}
 +===== Listing =====
 +<code prolog>
 +% Figure 16.1  A simple knowledge base for identifying animals.
 +
 +% Adapted from Winston (1984). The relation '​askable'​ defines those things
 +
 +% that can be asked by user. The operators '::',​ if, then, '​and',​ '​or'​
 +
 +% are declared as in Figure 16.6.
 +
 +
 +
 +
 +
 +%     A small knowledge base for identifying animals
 +
 +
 +
 +:-  op( 100, xfx, [ has, gives, 'does not', eats, lays, isa]).
 +
 +
 +
 +:-  op( 100, xf, [ swims, flies]).
 +
 +:-  op( 200, xfy, [:, ::]).
 +
 +:-  op( 185, fx, if).
 +
 +:-  op( 190, xfx, then).
 +
 +:-  op( 180, xfy, or).
 +
 +:-  op( 160, xfy, and).
 +
 +
 +
 +
 +
 +rule1 ::   if
 +
 + Animal has hair
 +
 +    or
 +
 + Animal gives milk
 +
 + then
 +
 + Animal isa mammal.
 +
 +
 +
 +
 +
 +rule2 ::   if
 +
 + Animal has feathers
 +
 +    or
 +
 + Animal flies  and
 +
 + Animal lays eggs
 +
 + then
 +
 + Animal isa bird.
 +
 +
 +
 +rule3 ::  if
 +
 + Animal isa mammal ​ and
 +
 +              ( Animal eats meat
 +
 +                  or
 +
 + Animal has '​pointed teeth' and
 +
 + Animal has claws  and
 +
 + Animal has '​forward pointing eyes' )
 +
 + then
 +
 + Animal isa carnivore.
 +
 +
 +
 +rule4 ::  if
 +
 + Animal isa carnivore ​ and
 +
 + Animal has 'tawny color' ​ and
 +
 + Animal has 'dark spots'
 +
 +        then
 +
 + Animal isa cheetah.
 +
 +
 +
 +rule5 ::  if
 +
 + Animal isa carnivore ​ and
 +
 + Animal has 'tawny color' ​ and
 +
 + Animal has 'black stripes'​
 +
 + then
 +
 + Animal isa tiger.
 +
 +
 +
 +rule6 ::  if
 +
 + Animal isa bird  and
 +
 + Animal 'does not' fly  and
 +
 + Animal swims
 +
 + then
 +
 + Animal isa penguin.
 +
 +
 +
 +rule7 :: if
 +
 + Animal isa bird  and
 +
 + Animal isa 'good flyer'
 +
 + then
 +
 + Animal isa albatross.
 +
 +
 +
 +
 +
 +fact :: X isa animal ​  :-
 +
 +  member( X, [cheetah, tiger, penguin, albatross]).
 +
 +
 +
 +
 +
 +askable( _ gives _, '​Animal'​ gives '​What'​).
 +
 +
 +
 +askable( _ flies, '​Animal'​ flies).
 +
 +
 +
 +askable( _ lays eggs, '​Animal'​ lays eggs).
 +
 +
 +
 +askable( _ eats _, '​Animal'​ eats '​What'​).
 +
 +
 +
 +askable( _ has _, '​Animal'​ has '​Something'​).
 +
 +
 +
 +askable( _ 'does not' _, '​Animal'​ 'does not' fly).
 +
 +
 +
 +askable( _ swims, '​Animal'​ swims).
 +
 +
 +
 +askable( _ isa 'good flyer',​ '​Animal'​ isa 'good flyer'​).
 +
 +
 +
 +</​code>​
 +===== Comments =====
  
pl/prolog/pllib/animals_kb.txt · ostatnio zmienione: 2019/06/27 15:50 (edycja zewnętrzna)
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0