The core of Geni--Inference Machine (5) dealing with why problem
1. Why issues are raised by customers from the browser
When the expert system works, it is necessary to ask the user questions and collect the factual basis of reasoning verification.
The user sometimes wants to know why the system asks such a question, asking the system to give an explanation. This is the so-called why problem.
Why question is the result of pressing the Web button "why".
2. Why function setting
Geni's first page Default.htm does not have a button "why". The process of setting it up is this:
From the predicate check in the previous section, the 3rd clause starts.
Check (RNO, history, [cno| REST]):-cond (cno,text,options),!, inpq (history,rno,cno,text,options).
At this time the cond is not the condition of verification, that there is no Yes (CNO) and No (CNO) The fact that, so, began to verify the sub-goal inpq.
INPQ (history,rno,cno,text,options)
INPQ (history,rno,cno,text,_):-Whymeet,!, gen_why (HISTORY,RNO,TEXT,CNO), endpage_why (), exit. Write ("\nis it true that:", TEXT, "\n<br>"),format (condstr, "cond_%", CNO),endpage (condstr) , Exit. INPQ (_history,_rno,cno,text,filename):-is_htmlfile (FILENAME),!, consult_htm (filename,htmltext), Gethtmlbody (htmltext,bodytext), write (BodyText),write ("\nis it true that:", TEXT, "\n<br>"), Format (CONDSTR, "cond_%", CNO),endpage (condstr),!,exit. Write ("\nis It true:", TEXT, " ", picture, "\ n"),format (condstr, "cond_%", CNO),endpage ( CONDSTR),!,exit.
INPQ's 1th clause, dealing with why issues, generates a dedicated web page. Here is an introduction.
INPQ 2nd, 3, 4 clauses, in common, have set up further questions and why function. The difference is that the method of displaying the page is different.
The why feature is actually set in the predicate endpage.
EndPage (CONDITION)
EndPage in front of the introduction, no longer repeated wordy. Just highlight its 2nd clause, set the why question.
Writef ("<input type=\" button\ "value=\" why\ "onclick=\" form.%s.value= ' why '; submit () \ ">\n", CONDITION),
The value of condition is cond_x,x is a number. Suppose x=15, form.cond_15.value= ' Why ' after the button "why".
This variable determines the whymeet into the fact base.
Whymeet into Fact Library
As already described in the previous section, cond_15=why this CGI data will be organized into parm ("cond_15", "why").
After goal assert_conditions verification, came to Assert_cond ("Cond_15", "why") of the verification:
Assert_cond (CNO, "yes"):-!, assert (yes (CNO)). Assert_cond (CNO, "no"):-!, assert (No (CNO)). Assert_cond (_cno, "why"):-!, assert (Whymeet). Assert_cond (_,_):-errorexit.
The 3rd clause, depositing whymeet into the fact base.
3. How to deal with the problem
The 1th clause of the predicate INPQ is responsible for dealing with the why problem.
INPQ (history,rno,cno,text,_):-Whymeet,!, gen_why (HISTORY,RNO,TEXT,CNO), endpage_why (), exit.
The fact that the user has pressed the button "why" in the browser whymeet the problem. Go down and see gen_why and endpage_why.
Gen_why (HISTORY,RNO,TEXT,CNO)
Gen_why (HISTORY,RNO,_TEXT,_CNO):-write ("why<br>\n"), Rule (RNO, Mygoal1, Mygoal2, _, _),!, Sub_cat (Mygoal1, MYGOAL2,LSTR), concat ("I try to show that:", lstr,lstr1), concat (LSTR1, "<br>\nby using rule number", Ls1), Str_int ( Str_num,rno), concat (Ls1,str_num,ans),concat (ans,lls1,ans1), Report(HISTORY,SNG),concat (Ans1, SNG,ANSW), write (ANSW), NL. Gen_why (_HISTORY,_RNO,_TEXT,_CNO):-errorexit.
Show_rule andreport, as well as endpage_why are built-in predicates that are used primarily to display the contents of a Web page and are no longer described. The rest of the built-in predicates, described in the previous sections, are no longer duplicated.
A little advice
Until after writing the bar (10), only to find the VIP directory examples there is a stand-alone version of the Geni.
Because there are no CGI processing problems such as HTML display, the program logic is much simpler and more suitable for studying.