[mercury-users] more Mercury homework: "Mercuryfy" some simple Prolog

Raphael Collet rco at missioncriticalit.com
Fri Sep 24 17:07:11 AEST 2010


Dear Jean-Marc,

On 09/23/2010 04:30 PM, Jean-Marc Vanel wrote:
> Hi
>
> I'm in the middle of translating into Mercury some simple Prolog from
> the book "the Art Of Prolog" , namely Program 2.1:  Defining family
> relationships :
>
>          uncle(Uncle,Person) :-
>                  brother(Uncle,Parent), parent(Parent,Person).
>
> And, again, I do not find much help in the documentation.
>
> First , I put this is interface :
> :- type person.
>
> But, then, what to put in the implementation, which would the equivalent
> of an empty class in Java ?
>
>
> A 2nd problem is with pure database predicates (primitives), like
> brother. I put this :
> :- pred brother( person, person) is multi .
> :- mode brother( in, out ) is multi .
> :- mode brother( out, in ) is multi .

Beware of the determinism, 'multi' imposes a restriction on the 
predicate's definition: it says that every person has at least a 
brother.  I suppose that 'nondet' is more appropriate here.

> But the compiler is not happy :
> Error: no clauses for predicate `brother'/2.
>
> Let's suppose that brother/2 is provided by external facts .
>
> --
> Jean-Marc Vanel
> Consulting, services, training,
> Rule-based programming, Semantic Web
> http://jmvanel.free.fr/
> EulerGUI, a turntable GUI for Semantic Web + rules, XML, UML, eCore,
> Java bytecode
> +33 (0)6 89 16 29 52 -- +33 (0)1 39 55 58 16
> ( we rarely listen to voice messages, please send a mail instead )

Regards,

Raphael Collet
Mission Critical IT
http://www.missioncriticalit.com
--------------------------------------------------------------------------
mercury-users mailing list
Post messages to:       mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions:          mercury-users-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the users mailing list