Article View: comp.lang.prolog
Article #14Re: Turbo Prolog Help
From: Doug Palmer
Date: Wed, 28 Oct 1992 03:08
Date: Wed, 28 Oct 1992 03:08
48 lines
2034 bytes
2034 bytes
mcovingt@aisun3.ai.uga.edu (Michael Covington) writes: >In article <Bwr5A0.2Kr@sunfish.usd.edu> btoben@crappie.usd.edu (B. Toben) writes: >> drives(mike,X) :- X <> "camaro". >> >>I get an error if I state a goal like drives(mike,Z) because >>Turbo Prolog says it has nothing to compare against "camaro". I understand >>why I get the error, but my question is, is there a way around it, using that >>general logic? >No. You must first instantiate X to a value before you can perform the not- >equal test. Otherwise, when you state the goal "drives(mike,Z)" you are >saying "Give me everything in the universe that is not a Camaro"! Well, this does suggest one solution: drives(mike,X) :- car(X), X <> camaro. car(camaro). car(falcon). car(sigma). .... Note that this makes the drives predicate more correct, as well, since it will fail for queries like ?- drives(mike, teddybear) - which, presumably, you don't want to happen. Now, a question to any typing mavens out there: It seems to me that if you have a typed predicate, such as drive(person_type, car_type) where the types are regular types it should be possible to re-write any clause of the form drive(X, Y) :- Body. to be drive(X, Y) :- person_type(X), car_type(Y), Body. where person_type(X) and car_type(Y) are the declarative deifnitions of the regular types, written in Prolog. This should kick any problems with an uninstantiated negation in the head and remove any implicit moding caused by a negation? Comments? - Dug
Technical Details
Message-ID:
<9230214.10957@mulga.cs.mu.OZ.AU>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!darwin.sura.net!sgiblab!munnari.oz.au!cs.mu.OZ.AU!dfpReferences:
<Bwr5A0.2Kr@sunfish.usd.edu> <1992Oct27.023025.410@athena.cs.uga.edu>Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.prolog Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!darwin.sura.net!sgiblab!munnari.oz.au!cs.mu.OZ.AU!dfp From: dfp@cs.mu.OZ.AU (Doug Palmer) Subject: Re: Turbo Prolog Help Message-ID: <9230214.10957@mulga.cs.mu.OZ.AU> Organization: Computer Science, University of Melbourne, Australia References: <Bwr5A0.2Kr@sunfish.usd.edu> <1992Oct27.023025.410@athena.cs.uga.edu> Date: Wed, 28 Oct 1992 03:08:38 GMT Lines: 48