7 Ask-the-user

The ask-the-user facility exists for yes/no questions as well as for functional properties. The subgoals have to be ground before being asked of the user. This may be fixed in future implementations.

To to make an atom askable, you can issue the command:

ailog:askable atom.

Whenever a ground instance of the atom is attempted to be proved, the user is asked if it is true. The system may ask:

Is g true?

The user can reply with one of:

if g is known to be true. The system will not ask this instance again.
if g is known to be false. The system will not ask this instance again.
if g is unknown. In this case any applicable clauses for g can be used.
to fail the subgoal (but not record an answer). This is only used to test you axiomatization.
to see why the system was asking this question. This then enters the why interaction described in Section 6.4.
to return to the ailog prompt.
to get a menu of available answers.

Note the assumption that AILog makes about the interaction between asking the user about g and using clauses for g. It assumes that if the user knows whether g is true, the user's answer should be used. Any rules for g are used only if the user doesn't know whether g is true or not.

Example. The following gives the example of the electrical example with askables (see [Poole, Mackworth, and Goebel (1998)], page 214):
ailog: load 'ailog_code/ch07/elect_askable.pl'.
Ailog theory ailog_code/ch07/elect_askable.pl loaded.
ailog: ask lit(L).
Is up(s2) true? [yes,no,unknown,why,help]: yes.
Is up(s1) true? [yes,no,unknown,why,help]: no.
Is down(s2) true? [yes,no,unknown,why,help]: no.
Is up(s3) true? [yes,no,unknown,why,help]: yes.
Answer: lit(l2).
  [ok,more,how,help]: ok.

If f is functional (i.e., if there can only be one value for f), you can use the special syntax f=V to mean that f has value V. Then when you issue the command:

ailog:askable $f=V$.

Then a goal of the form f=X will ask the user for the value of f once, and remember the value. For example:

ailog: askable age(P)=V.
ailog: tell young(P) <- age(P)=A & A<13.
ailog: ask young(sally) & young(bruce).
What is the value of age(sally)? [value,unknown,why,help]: 3.
What is the value of age(bruce)? [value,unknown,why,help]: 87.
No. young(sally) & young(bruce) doesn't follow from the knowledge base.
 Runtime since last report: 0.0 secs.
ailog: ask young(al) & young(sally).
What is the value of age(al)? [value,unknown,why,help]: 10.
Answer: young(al) & young(sally).
 Runtime since last report: 0.0 secs.
  [ok,more,how,help]: how.
   yes <-
      1: young(al)
      2: young(sally)
   How? [Number,up,retry,ok,prompt,help]: 1.
   young(al) <-
      1: age(al)=10
      2: 10<13
   How? [Number,up,retry,ok,prompt,help]: 1.
   You told me age(al)=10 is true.