Re: [SWIPL] Existential and universal quantifier implementation

286 views
Skip to first unread message

Richard Grossman

unread,
Jan 30, 2015, 11:02:32 PM1/30/15
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 |
-----------------------------

norbert...@gmail.com

unread,
Jan 31, 2015, 7:31:55 AM1/31/15
to swi-p...@googlegroups.com, majid....@gmail.com, r...@ihug.co.nz


On Saturday, 31 January 2015 05:02:32 UTC+1, Richard Grossman wrote:
...

(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.
...

Two comments:

a) To get an implication you also need the replacement rule "material implication" (https://en.wikipedia.org/wiki/Material_implication_(rule_of_inference)).

b) All variables of a Prolog clause are implicitly universally quantified before the clause. 

ZM

unread,
Feb 13, 2015, 7:22:13 AM2/13/15
to majid....@gmail.com, r...@ihug.co.nz
So could you please tell me what't the problem with the following interpretation:

norbert...@gmail.com

unread,
Feb 14, 2015, 7:19:01 AM2/14/15
to swi-p...@googlegroups.com, majid....@gmail.com, r...@ihug.co.nz


On Friday, 13 February 2015 13:22:13 UTC+1, ZM wrote:
So could you please tell me what't the problem with the following interpretation:

  No mammals lay eggs except for the platypus: 
 
 ¬∃x(mammal (x) ∧ lay eggs(x) ∧ ¬platypus(x)) 

 Only Fish swim: 
 
 ¬∃x (¬fish (x) ∧ Swim(x)) 

If I recall correctly, you are supposed to express this in Prolog (see for instance http://www.learnprolognow.org).
Reply all
Reply to author
Forward
0 new messages