The task is to implement a very simple expert system in PROLOG. Facts are represented using a predicate fact(F) where F is a fact, e.g.: fact(bar_is_open). fact(money_left). As the expert system is limited to propositional logic, all rules are represented by rule(L1,L2) where L1 is a list of facts which must be true in order to draw the conlusions in the list L2. Examples of rules are: rule([bar_is_open, money_left],[buy_a_beer]). rule([buy_a_beer, still_thirsty],[drink_the_beer]). The knowledge base must include at least 5 rules and 5 facts and should describe a domain from real life. The inference engine should be able to do both forward and backward chaining. By forward chaining we here mean that the system should draw all the conclusions that are possible to draw, given the facts and rules in the knowledge base. By backward chaining we mean verifying a propositions from the facts and the rules in the knowledge base. If a fact is not in the knowledge base, the user should be able to ask whether the fact is true or not. Assuming that the rules and facts above have been loaded to the PROLOG system, the expert system should behave approximately in the following way: ?- verify(fact(buy_a_beer)). fact(bar_is_open) found in the KB fact(money_left) found in the KB fact(buy_a_beer) inferred from the KB yes ?- verify(fact(go_home)). no ?- forward. fact(buy_a_beer) added to the KB yes ?- verify(fact(drink_the_beer)). fact(buy_a_beer) found in the KB still_thirsty? yes. fact(drink_the_beer) inferred from the KB yes Note! verify should try to verify facts recursively, e.g., verify(fact(drink_the_beer)) should have answered yes also if it was performed before the forward command. Preparation Define a predicate alltrue(L) that checks whether all facts in the list L are true. Define a predicate addfacts(L) that adds the facts in the list L (that are are not already in the knowledge base) to the knowledge base.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement