Over 10 Million Study Resources Now at Your Fingertips

Download as :
Rating : ⭐⭐⭐⭐⭐
Price : $10.99

Just use the asserta built-in predicate introduced section


ask(Q,A) :- write(Q), write('?'), read(A), nl.

diagnosis('fuse blown') :- ask('Does the device work at all',no),

ask(Are the lights in the house off',yes).

Input coding groups user answers into categories. An important case is questions with only yes or no answers; expert systems often to rely on them for simplicity. We can define two new predicates affirmative and negative, which say whether a word the user typed is a positive or a negative answer respectively:




Then we can define a predicate askif of one input argument. It will be just like ask except it will have only one argument, the question, and it will succeed if that question is answered affirmatively and fail if the question is answered negatively. We can also fix it so that if an answer is neither positive nor negative (in other words, it is unclear), we will complain and ask for another answer.

askif(Q) :- ask(Q,A), positive_answer(A).

which saves some parentheses.

Users may not always understand a question. We can let them type a ? instead of an answer, give them some explanatory text, and provide them another chance to answer:

where explain facts store explanatory text. Minor humanizing touches such as these can be immensely important to user satisfaction, while imposing little on the programmer.

Output coding

How It Works
Login account
Login Your Account
Add to cart
Add to Cart
Make payment
Document download
Download File
PageId: ELI357D233
Uploaded by :
Page 1 Preview
just use the asserta builtin predicate introduced
Sell Your Old Documents & Earn Wallet Balance