Richard Grossman
unread,Jan 30, 2015, 11:02:32 PM1/30/15Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ZM, swi-p...@googlegroups.com
On 29/01/15 22:03 , ZM wrote:
> How can I implement following rules in prolog?
>
> No mammals lay eggs except for the platypus:
>
> ¬∃x(mammal (x) ∧ lay eggs(x) ∧ ¬platypus(x))
>
> Only Fish swim:
>
> ¬∃x (¬fish (x) ∧ Swim(x))
Here are some hints for this homework assignment. (Don't expect more
than general hints unless you show us your work so far and where you got
stuck.)
(1) Every Prolog rule Head :- Body is an implication that Body
implies head. So, use DeMorgan's rules to turn your problem rules into
implications.
(2) Your fish problem can be done with 1 implication; your mammals
problem may require several, depending on (3).
(3) Be clear what "implementing" means for this problem (which IMO is a
very poor one for an introductory Prolog programming class, and a pretty
poor one for an introductory first-order logic class). My _guess_ is
that it's something like if you enter an appropriate query then Prolog
will either bind variables appropriately, or fail.
For your fish problem:
?- swim(F).
should bind F to successive fish in the database; and
?- swim(Thing), \+ fish(Thing).
should fail.
But read the problem more carefully and/or check with your instructor to
see if that's the right interpretation.
--
---------------------------
| BBB b \ Barbara at LivingHistory stop co stop uk
| B B aa rrr b |
| BBB a a r bbb | ,008015L080180,022036,029037
| B B a a r b b | ,047045,L014114L4.
| BBB aa a r bbb |
-----------------------------