First the prolog:
mother_child(trude, sally). father_child(tom, sally). father_child(tom, erica). father_child(mike, tom). sibling(X, Y) :- parent_child(Z, X), parent_child(Z, Y). parent_child(X, Y) :- father_child(X, Y). parent_child(X, Y) :- mother_child(X, Y).This results in the following query being evaluated as true:
?- sibling(sally, erica). YesNow in BKO:
|context> => |context: prolog example> mother |sally> => |trude> child |trude> = > |sally> father |sally> => |tom> child |tom> => |sally> father |erica> => |tom> child |tom> +=> |erica> father |tom> => |mike> child |mike> => |tom> parent |*> #=> mother |_self> + father |_self> sibling |*> #=> child parent |_self> -- this being the BKO equivalent of: sibling(X, Y) :- parent_child(Z, X), parent_child(Z, Y) sibling-of |*> #=> clean drop (child parent |_self> + -|_self>)now put it to use:
sa: sibling |sally> |sally> + |erica> sa: sibling |erica> |sally> + |erica> sa: sibling-of |sally> |erica> sa: sibling-of |erica> |sally>Finally, we can ask the question: "is X a sibling of Sally?"
sa: is-a-sibling-of-sally |*> #=> do-you-know mbr(|_self>, sibling-of|sally>) sa: is-a-sibling-of-sally |erica> |yes> sa: is-a-sibling-of-sally |george> |no>And I guess that is enough.
Update: perhaps we should tweak our operator names to a little closer to English and NLP?
mother-of |sally> => |trude> child-of |trude> = > |sally> father-of |sally> => |tom> child-of |tom> => |sally> father-of |erica> => |tom> child-of |tom> +=> |erica> father-of |tom> => |mike> child-of |mike> => |tom> parents-of |*> #=> mother-of |_self> + father-of |_self> siblings-of |*> #=> clean drop (child-of parents-of |_self> + -|_self>)
No comments:
Post a Comment