How to create an expert system in visual prolog

Discussions related to Visual Prolog
Fadejimi
Posts: 2
Joined: 24 Dec 2014 8:12

How to create an expert system in visual prolog

Unread post by Fadejimi » 26 Dec 2014 9:32

I am a newbie in prolog and would like friends to help me with my project, I have successfully built a prolog program to get information from the user to diagonize tuberculosis but I do not know how to set the rules that should be followed to tell the user he or she has tuberculosis

Take for instance the user logs in his information such as Name, Age and then states how high his cough, weight loss etc. is.

I want to set the following rules to clarify that the user has typhoid
Rule 01: IF cough > 3 weeks = high and weight loss = high and fever = high and drenching night sweats = mild and loss of appetite = high and anaemia = mild and sputum AFB = high and mantoux = moderate THEN TB = very high.

Rule 02: IF cough > 3 weeks = moderate and weight loss = low and fever = low and drenching night sweats = low and loss of appetite = low and anaemia = low and sputum AFB = low and mantoux = low THEN TB = low.


Please how do i set this rules and can someone please link me to a tutorial and an example on it.

I would be very grateful thanks in advance
I want to learn <b>prolog<b>

Paul Cerkez
VIP Member
Posts: 202
Joined: 6 Mar 2000 0:01

Unread post by Paul Cerkez » 29 Dec 2014 13:06

off the top of my head, here is one way to do this: (not tested and may not be 100% syntactically correct)

Code: Select all

constants low =1. mild = 2. high = 3. moderate = 4.   Predicate tb_test(integer Weeks, integer WL, integer Fever, integer NS, integer LOA, integer Sputnum ...).   Clauses tb_test(Weeks, high, high, mild, high, ...) = veryHigh :-  % rule 1 Weeks >3. tb_test(Weeks, moderate, low, low, low, ...) = low :-  % rule 2 Weeks >3.
....


***********************
basically, set up a predicate with the number or arguments matching the number of conditions. In the case of Weeks, it is a duration so you can put that condition check in the body of the clause. The rest seem to be defined scalar values (high, moderate, low, etc.). Call the predicate from wherever you have collected all the conditions.

You would need to create a rule for each combination of conditions. This can be long and tedious and all rules are then 'hard coded.'

This approach will give you a deeper understanding of rules processing. Once you get a firm foundation under your belt, there are many ways this can be optimized and made more abstract (i.e., an abstract rule with no 'hard coded' conditions that still gives the same results).
AI Rules!
P.

Fadejimi
Posts: 2
Joined: 24 Dec 2014 8:12

Thanks

Unread post by Fadejimi » 1 Jan 2015 11:17

Thanks very much am so grateful, I av not been able to reply the message because of bad internet connections where I come from.

I downloaded the two books from this website. I am hoping if you could give me a link to a good book on how to create an expert system with visual prolog, cause am willing to learn.

Dont know much on functional programming although am quite good with object oriented programming would love to learn more.

Thanks and HAPPY NEW YEAR to you guys
I want to learn <b>prolog<b>

Post Reply