Академический Документы
Профессиональный Документы
Культура Документы
w r i t e ( ’ I g u e s s t h a t you a r e s u f f e r i n g from : ’) ,
write ( Disease ) ,
nl ,
undo .
/∗ h y p o t h e s e s t o be t e s t e d ∗/
hypothesize ( malaria ) :− m a l a r i a , ! .
h y p o t h e s i z e ( dengue ) :− dengue , ! .
hypothesize ( tuberculosis ) :− t u b e r c u l o s i s , ! .
h y p o t h e s i z e ( unknown ) . /∗ no d i a g n o s i s ∗/
/∗ d i s e a s e i d e n t i f i c a t i o n r u l e s ∗/
m a l a r i a :− f e v e r ,
headache ,
muscle pain ,
chills ,
v e r i f y ( vomiting ) .
dengue :− fever ,
headache ,
muscle pain ,
verify ( skin rash ) ,
verify ( joint pain ).
t u b e r c u l o s i s :− f e v e r ,
chills ,
verify ( weight loss ) ,
v e r i f y ( weakness ) ,
v e r i f y ( bad cough ) .
/∗ c l a s s i f i c a t i o n r u l e s ∗/
fever :− v e r i f y ( h i g h f e v e r ) , ! .
fever :− v e r i f y ( f e v e r w i t h c h i l l s ) .
headache :− v e r i f y ( h e a d a c h e i n t h e m o r n i n g ) , ! .
headache :− v e r i f y ( v o m i t i n g ) ,
verify ( shaking chills ).
:− dynamic y e s / 1 , no / 1 .
/∗ How t o v e r i f y something ∗/
v e r i f y ( S ) :−
( yes (S)
−>
true ;
( no ( S )
−>
fail ;
ask ( S ) ) ) .
/∗ undo a l l y e s /no a s s e r t i o n s ∗/
undo :− r e t r a c t ( y e s ( ) ) , f a i l .
undo :− r e t r a c t ( no ( ) ) , f a i l .
undo .
Enter the prolog environment and execute our Expert System.
prolog medex.pl
?− d i a g n o s e .
Does t h e p a t i e n t have t h e f o l l o w i n g symptoms : h i g h f e v e r ? y .
?− d i a g n o s e .
Does t h e p a t i e n t have t h e f o l l o w i n g symptoms : h i g h f e v e r ? y .
I g u e s s t h a t you a r e s u f f e r i n g from : t u b e r c u l o s i s
true .