Link to home
Start Free TrialLog in
Avatar of finalstud
finalstud

asked on

artificial intelligence-expert systems

i need a clips/pascal program to implement a expert system.expert system can be of less complexity
Avatar of Manuel Lopez-Michelone
Manuel Lopez-Michelone
Flag of Mexico image

You can find lots of expert system's (ES) code in most of the books about the topic. In any case, the idea behind an ES is to recreate human expertise, most of the time using cause-effects rules. This is called rule based ES and is the most common way to implement them.

You can write your own ES in any language, but prolog is a very good option, because it uses Robinsson algorith to find out an answer to a question in a simple rule bases expert system. I suggest to find more info in Bratko book or even in an old but a great book, Programming in Prolog, by Clocksin & Mellish (Springer-Verlag).

There are many implementation of Prolog, some commercial, some shareware and some others just freeware. Just search at www.google.com. The ES code is written for turbo prolog (now visual prolog, there is a free version for Windows users). Hope this helps...

best wishes
Manuel Lopez (lopem)


/*      Program: Dog Expert        */
/* Purpose: To show the working of */
/* an expert system. It is a pro-  */
/* duction rule-based system.      */
/*                                 */
/* Remarks: This is a dog classi-  */
/* cation expert system. It uses a */
/* set of production rules for the */
/* purpose of inferring.           */

domains

database

   xpositive(symbol,symbol)
   xnegative(symbol,symbol)


predicates

   do_expert_job
   do_consulting
   ask(symbol,symbol)
   dog_is(symbol)
   it_is(symbol)
   positive(symbol,symbol)
   negative(symbol,symbol)
   remember(symbol,symbol,symbol)
   clear_facts

goal

   do_expert_job.


clauses

/*  User Interface System (UIS) */

do_expert_job :-
     makewindow(1,7,7,"An Expert System",1,16,22,58),
     nl, write(" ************************************"),
     nl, write("    Welcome to a Dog Expert System"),
     nl, write("                                 "),
     nl, write(" This is a dog identification system"),
     nl, write(" Please, respond by typing in 'yes'"),
     nl, write(" or 'no'.            Thank you.    "),
     nl,nl,
     do_consulting,
     write("Press space bar..."), nl,
     readchar(_),
     clearwindow,
     exit.

do_consulting :-
     dog_is(X), !,
     nl, write(" Your dog may be a(n) ",X,"."),
     clear_facts.

do_consulting :-
     nl, write("Sorry, unable to determine the dog."),nl,
     clear_facts.

ask(X,Y) :-
     write("   Question :- ",X," it, ",Y," ? "),
     readln(Reply),
     remember(X,Y,Reply).


/* Inference Engine (INE) */

positive(X,Y) :-
     xpositive(X,Y),!.

positive(X,Y) :-
     not(negative(X,Y)),!,
     ask(X,Y).

negative(X,Y) :-
     xnegative(X,Y),!.

remember(X,Y,yes) :-
     asserta(xpositive(X,Y)).

remember(X,Y,no) :-
     asserta(xnegative(X,Y)),
     fail.

clear_facts :-
     retract(xpositive(_,_)),
     fail.

clear_facts :-
     retract(xnegative(_,_)),
     fail.


/* Production Rules */


dog_is("English Bulldog") :-
     it_is("short-haired dog"),
     positive(has,"height under 22 inches"),
     positive(has,"low-set tail"),
     positive(has,"good natured personality"),!.

dog_is("Beagle") :-
     it_is("short-haired dog"),
     positive(has,"height under 22 inches"),
     positive(has,"long ears"),
     positive(has,"good natured personality"),!.

dog_is("Great Dane") :-
     it_is("short-haired dog"),
     positive(has,"low-set tail"),
     positive(has,"longer ears"),
     positive(has,"good natured personality"),
     positive(has,"weight over 100 lb"),!.

dog_is("American Foxhound") :-
     it_is("short-haired dog"),
     positive(has,"height under 30 inches"),
     positive(has,"longer ears"),
     positive(has,"good natured personality"),!.
     
dog_is("Cocker Spaniel") :-
     it_is("long-haired dog"),
     positive(has,"height under 22 inches"),
     positive(has,"low-set tail"),
     positive(has,"longer ears"),
     positive(has,"good natured personality"),!.

dog_is("Irish Setter") :-
     it_is("long-haired dog"),
     positive(has,"height under 30 inches"),
     positive(has,"low-set tail"),
     positive(has,"good natured personality"),!.

dog_is("Collie") :-
     it_is("long-haired dog"),
     positive(has,"height under 30 inches"),
     positive(has,"low-set tail"),
     positive(has,"good natured personality"),!.

dog_is("St. Bernard") :-
     it_is("long-haired dog"),
     positive(has,"low-set tail"),
     positive(has,"good natured personality"),
     positive(has,"weight over 100 lb"),!.
     
it_is("short-haired dog") :-
     positive(has,"short-haired"),!.
     
it_is("long-haired dog") :-          
     positive(has,"long-haired"),!.
Avatar of finalstud
finalstud

ASKER

as iam new to expert systems,i need some simple expert systems concept to implement.i knw vb/java/c/c++.try to get me some code in this language
Hi, finalstud,

I dont do any expert system in c/java because you have to implement all the logic that prolog gives for free. In any case, probably this link can give the code in java you can dig in.

http://public.research.mimesweeper.com/RDF/RDFExpert/Intro.html

best regards,
Manuel Lopez (lopem)


No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
 - PAQ'd and pts removed
Please leave any comments here within the
next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

Nic;o)
ASKER CERTIFIED SOLUTION
Avatar of Netminder
Netminder

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial