Next: Example: Forward- and Backward-Chaining Up: Example: FramesAccess Paths, Previous: Facts Tell the Story

## Questions: Checking for Understanding

We test whether a human has understood a story by asking questions, first to check on retention of explicitly stated facts, then for the ability to draw reasonable conclusions.

• We return attention to the John Alden story from whatever else we were doing, by explicitly making its context frame, ja-story, the current context.

```  (tell '((:clear-slot *context* current)
(current *context* ja-story))
:comment "In the John Alden story ...")```
• This question follows the access path from context, to speaker, to wife, to age. Her name is only retrieved for nicely presenting the output.

```  (ask '((:the ?me (speaker (current *context*) ?me))
(:the ?w (wife ?me ?w))
(age ?w ?a ?units)
(name ?w ?n))
:collect '(?n is ?a ?units old)
:comment "How old is my wife?")```

The :collect keyword provides restructured output.

```QUERYING:  How old is my wife?

Input preds:          (:the ?me (speaker (current *context*) ?me))
(:the ?w (wife ?me ?w)) (age ?w ?a ?units) (name ?w ?n)

Result:
Bindings:            ?n     --- "priscilla"
?units   --- years
?a     --- 23
?w     --- frame1-wife "priscilla"
?me    --- frame1 "john alden"
?\$x20  --- ja-story

=> (("Priscilla" IS 23 YEARS OLD))```
• This question checks that obvious inferences were made from the given information, by retrieving Priscilla's husband and then his name.

```  (ask '((husband Priscilla ?h)
(:eval (pp-frame '?h))
(name ?h ?n))
:comment "Who is Priscilla's husband?"
:collect '?n)```

The special :eval form applies the lisp function pp-frame to the frame bound to the variable ?h, to display it on the terminal. Then the name is returned.

```QUERYING:  Who is Priscilla's husband?

Input preds:          (husband priscilla ?h) (:eval (pp-frame (quote ?h)))
(name ?h ?n)

Frame1:
Isa:        things objects physical-objects people
Name:       "john alden"
Age:        (25 years)
Wife:       frame1-wife
Gender:     male
Spouse:     frame1-wife

Result:
Bindings:            ?n     --- "john alden"
?h     --- frame1 "john alden"

=> ("John Alden")```
• This question has more than one answer, so both are returned.

```  (ask '((name (friend Priscilla) ?name))
:comment "What is Priscilla's friend's name ?"
:collect '?name)```

Here we collect two names into a list.

```QUERYING:  What is Priscilla's friend's name ?

Input pred:           (name (friend priscilla) ?name)

Result (1 of 2):
Bindings:            ?name  --- "cotton mather"
?\$x21  --- |cotton mather|

Result (2 of 2):
Bindings:            ?name  --- "miles standish"
?\$x21  --- |miles standish|

=> ("Miles Standish" "Cotton Mather")```

Micheal S. Hewett
Tue Oct 29 10:54:13 CST 1996