Determine a) what the knowledge base is looking for, b) Is the knowledge base correct (does it
Question:
Determine a) what the knowledge base is looking for, b) Is the knowledge base correct (does it return the right answer for every input query, and if there are improper/incorrect/missing elements, what are they?), and c) Give two queries that will return True and two that will return False, assuming each is possible (if it is impossible to get true or false, state why)
* a) What each Knowledge Base is looking for
* b) Is the Knowledge Base correct (i.e. will it always return the right answer for every query).
* A wrong answer could be returned from several different results.
* 1) Missing statements or rules
* 2) Improper statements or rules
* 3) Poor end conditions
* If there are errors inside the Knowledge Bases, what steps are needed to fix them?
* i.e. what changes or new rules would be added in?
* c) What are two (valid) queries that will return True from each Knowledge Base, and what are two
* queries that will return False from each. */
% KNOWLEDGE BASE 1
start(X) :- check1(X), check2(X).
check1([X|Y]) :- other(Y).
check1([]).
other([X|Y]) :- check1(Y).
check2([0|X]) :- check2(X).
check2([1|X]) :- step1(X).
step1([0|X]) :- check2(X).
step1([1|X]) :- step2(X).
step2([0|X]) :- step2(X).
step2([1|X]) :- step2(X).
step3([0|X]) :- step4(X).
step3([1|X]) :- step1(X).
step4([]).
step4([0|X]) :- check2(X).
step4([1|X]) :- step1(X).
% KNOWLEDGE BASE 2
victory(X,Y) :- X\=Y, phase1(X,Y), phase2(X), phase3(X,Y).
phase1(X,Y) :- attr(X), attr(Y).
attr(tim).
attr(joe).
attr(bill).
attr(jane).
attr(ashley).
attr(bob).
attr(phyllis).
attr(sara).
phase2(X,Y) :- work(X), work(Y).
work(tim).
work(ashley).
work(bob).
work(sara).
work(claire).
work(chris).
phase3(X,Y) :- learn(Y), learn(X).
learn(X) :- work(X), pass(X).
pass(claire).
pass(chris).
pass(tim).
pass(sara).
pass(bob).
pass(ashley).
Data Structures and Algorithm Analysis in Java
ISBN: 978-0132576277
3rd edition
Authors: Mark A. Weiss