Representing Uncertainty

33 views
Skip to first unread message

Chris

unread,
Dec 12, 2009, 2:55:20 PM12/12/09
to PyKE
How would you represent uncertainty with Pyke? For example, using the
family relations knowledge base, how would you represent "Bruce is the
son of either Thomas or Mike"?

Would you append a certainty value to each fact?
e.g.
son_of(bruce, thomas, 0.5)
son_of(bruce, mike, 0.5)

If so, how would you modify the rules to aggregate certainties from
multiple matching facts, to generate certainties of implied facts like
grandson_of(bruce, thomas_father)?

Also, is it possible to nest facts, to make this representation more
compact?
e.g.
son_of(bruce, or(thomas,mike))

Regards,
Chris

Bruce Frederiksen

unread,
Dec 13, 2009, 8:04:11 PM12/13/09
to py...@googlegroups.com
Pyke, like Prolog, does not provide built-in support for certainty factors.

You can associate certainty values with facts as you show for son_of.  Then you can combine certainty factors in rules, such as:

grandson_of
  foreach
    son_of($son, $father, $certainty1)
    son_of($father, $grandfather, $certainty2)
    $final_certainty = combine($certainty1, $certainty2)
  assert
    grandson_of($son, $grandfather, $final_certainty)

where "combine" is a Python function that combines certainty values in the way that makes sense for your application.

To answer your question about nesting facts.  You can not nest facts directly as shown because a "fact" is not a standard Python object.  But you can nest tuples.  It is easy to rewrite facts as tuples, so rather than:

son_of(bruce, or(thomas, mike))

you can say:

son_of(bruce, (or, thomas, mike))

These could be combined for grandson_of as follows:

grandson_of
    foreach
        son_of($child, (or, *$fathers))
        python grandfathers = []
        forall
            $father in $fathers
            son_of($father, (or, *$grandfathers))
            python grandfathers.extend($grandfathers)
        $grandfathers = tuple(grandfathers)
    assert
        grandson_of($child, (or, *$grandfathers))

So, while there are fewer facts this way, the rules are more complicated.

Also, if you use separate son_of facts for each father, then Pyke can index the facts by father and very quickly find the sons of any given father.  But using tuples of fathers, Pyke would have to search all of the son_of facts to find which ones include any given father in this tuple.

So it is generally better to represent individual facts separately, even though that means more facts.


--

You received this message because you are subscribed to the Google Groups "PyKE" group.
To post to this group, send email to py...@googlegroups.com.
To unsubscribe from this group, send email to pyke+uns...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pyke?hl=en.



Reply all
Reply to author
Forward
0 new messages