Love-tester. Please help! 
Author Message
 Love-tester. Please help!

Here's a little program:

CLAUSES
  likes(symbol)        - nondeterm(i)

PREDICATES
  likes(James, Shawna).
  likes(James, Angela).
  likes(Shawna, James).
  likes(Angela, Juan).
  likes(Juan, Angela).

OK, how I can do a program, which looks for solution to who loves each
other.
In common language it's that:
  "If James likes Angela and Angela likes James, and James doesn't like any
other than Angela, and
  Angela doesn't like any other than James."   (There aren't any solution in
this program for this rule)

How I write it to prolog-language? (I use Visual Prolog)

And please correct my mistakes at grammar (Prolog & English:).

Regards,
Jake



Mon, 16 Jun 2003 05:21:02 GMT  
 Love-tester. Please help!
Oh, sorry. My lamer-message is maybe rubbish-mail for this kind of news
group.
So, is there any lamer-prolog-news-groups?:)

Regards,
Jake



Mon, 16 Jun 2003 05:24:54 GMT  
 Love-tester. Please help!

Quote:

> Here's a little program:

> CLAUSES
>   likes(symbol)        - nondeterm(i)

[...]

Quote:
> How I write it to prolog-language? (I use Visual Prolog)

Eewwwww!  Ack ack ack!  That looks like Turbo Prolog, of all hideous
and unearthly things.  Why would any other product continue the
enforcement of such declarations?

I'm going to go cry now.

--
vsync
http://quadium.net/ - last updated Thu Dec 28 02:24:19 PST 2000
(cons (cons (car (cons 'c 'r)) (cdr (cons 'a 'o))) ; Orjner
      (cons (cons (car (cons 'n 'c)) (cdr (cons nil 's))) nil))



Tue, 17 Jun 2003 03:07:54 GMT  
 Love-tester. Please help!



Quote:

> > Here's a little program:

> > CLAUSES
> >   likes(symbol)        - nondeterm(i)

> [...]

> > How I write it to prolog-language? (I use Visual Prolog)

> Eewwwww!  Ack ack ack!  That looks like Turbo Prolog, of all hideous
> and unearthly things.  Why would any other product continue the
> enforcement of such declarations?

> I'm going to go cry now.

> --
> vsync

Don't cry, only correct my mistakes.
I know that right way to declare is:
nondeterm likes(symbol)
is it?

I said that CORRECT my mistakes, don't CRY about my mistakes, you wheenie.

Jake



Tue, 17 Jun 2003 16:37:35 GMT  
 Love-tester. Please help!
OK, I corrected my mistakes and I a new program.
But this isn't working. What else I have to do?
Or what's the other way to do that?
Here is my corrected source:

PREDICATES
  nondeterm likes(symbol, symbol)
  nondeterm loves(symbol, symbol)

CLAUSES
  likes(james, shawna).
  likes(james, angela).
  likes(shawna, james).
  likes(angela, juan).
  likes(juan, angela).

  loves(X, Y):-
    likes(X,Y),
    likes(Y,X),
    likes(X,Z),
    not(likes(X,Z)),
    Z<>Y,
    likes(Y,Z),
    not(likes(Y,Z)),
    Z<>X,
    fail.

GOAL
  loves(anglea, juan).

That isn't working. It says: No. Right answer is -of course- Yes,
or is it?

ps. Can I do my own news-group? There ain't any prolog news-groups
in finnish. How can I do that?

Thanks in advance.
Regards,
Jarkko K?hk?nen

Http://www.jarkkokahkonen.com



Tue, 17 Jun 2003 16:52:56 GMT  
 Love-tester. Please help!


Quote:
> OK, I corrected my mistakes and I a new program.
> But this isn't working. What else I have to do?
> Or what's the other way to do that?
> Here is my corrected source:
>   loves(X, Y):-
>     likes(X,Y),
>     likes(Y,X),
>     likes(X,Z),
>     not(likes(X,Z)),
>     Z<>Y,
>     likes(Y,Z),
>     not(likes(Y,Z)),
>     Z<>X,
>     fail.

Why would it succeed?
You are asking it to prove likes(X,Z) and not(likes(X,Z)) at the same time!
You could use findall/3 but I suspect that's overkill and inefficent on a
larger KB.
I'm not sure though, it would fail quickly, hmmm...
OTOH, it does make loves/2 very short.

Geoff



Tue, 17 Jun 2003 23:30:37 GMT  
 Love-tester. Please help!


Quote:
>  loves(X, Y):-
>    likes(X,Y),
>    likes(Y,X),
ok so far
>    likes(X,Z),

I thought X was not supposed to like anyone else?
Quote:
>    not(likes(X,Z)),

This contradicts the previous goal, so is sure to fail

Quote:
>    Z<>Y,
>    likes(Y,Z),
>    not(likes(Y,Z)),
>    Z<>X,
>    fail.

This clause is guaranteed to fail, even without the 'fail' at the end.

Your Prolog is ok, but your logical thought is poor.

You need to code "James doesn't like any other than Angela".  What you
have coded is "James likes, and does not like, someone other than
Angela".

Nick
--



Wed, 18 Jun 2003 07:19:28 GMT  
 Love-tester. Please help!

Quote:

> Here's a little program:

> CLAUSES
>   likes(symbol)        - nondeterm(i)

> PREDICATES
>   likes(James, Shawna).
>   likes(James, Angela).
>   likes(Shawna, James).
>   likes(Angela, Juan).
>   likes(Juan, Angela).

> OK, how I can do a program, which looks for solution to who loves each
> other.
> In common language it's that:
>   "If James likes Angela and Angela likes James, and James doesn't like any
> other than Angela, and
>   Angela doesn't like any other than James."   (There aren't any solution in
> this program for this rule)

> How I write it to prolog-language? (I use Visual Prolog)

> And please correct my mistakes at grammar (Prolog & English:).

> Regards,
> Jake

Here is a simpler solution :
 Make a list of all people James loves.  Second, test if this list contains
only one person.  Do the same for Angela.
You build the list using "bagof".

Ex:
  bagof(X,likes(james,X),List)
This will unify the variable "List" to [shawna,angela].

Notes :
1) "bagof" will fail instead of returning an empty list in case there are no
matches.
2) In prolog, if the first letter is capitalized, the language will interpret
this as a variable.

Good luck
E Levac



Sun, 22 Jun 2003 00:59:38 GMT  
 Love-tester. Please help!


Quote:
> Here's a little program:

> CLAUSES
>   likes(symbol)        - nondeterm(i)

> PREDICATES
>   likes(James, Shawna).
>   likes(James, Angela).
>   likes(Shawna, James).
>   likes(Angela, Juan).
>   likes(Juan, Angela).

> OK, how I can do a program, which looks for solution to who loves each
> other.
> In common language it's that:
>   "If James likes Angela and Angela likes James, and James doesn't like
any
> other than Angela, and
>   Angela doesn't like any other than James."   (There aren't any solution
in
> this program for this rule)

> How I write it to prolog-language? (I use Visual Prolog)

> And please correct my mistakes at grammar (Prolog & English:).

> Regards,
> Jake

loves( X, Y ) :-
    % They like each other.
        likes( X, Y ),
        likes( Y, X ),
    % X doesn't like anyone else.
        not  likes_two_people( X, Y ),
    % Y doesn't like anyone else.
        not  likes_two_people( Y, X ).

% X likes 2 or more people.
likes_two_people( X, Y ) :-
    likes( X, Y ),
    likes( X, Y1 ),
    Y1 /== Y.        % Y1 and Y are different.

You can test "likes_two_people" on its own,
e.g.

?- likes_two_people( 'James', Y ).
Y = Shawna
Yes
?- likes_two_people( 'Angela', Y ).
No

?-

Then test "loves".

There are not many people who use this prolog newsgroup.
There would be very few people who would use a Finnish prolog newsgroup.

--
Martin Sondergaard,
London.



Fri, 27 Jun 2003 02:06:03 GMT  
 
 [ 14 post ] 

 Relevant Pages 

1. please, please, please, please, help

2. will someone please, please, please, please HELP me?!!

3. MF Visual Object COBOL - Love it, hate it, love it

4. VSE 3.1 Repository Problem: Please help (please please?)

5. PLEASE PLEASE PLEASE HELP !!!!!!!!!!!!

6. please,please please do help us

7. help please-----please help about array in DLL

8. NTTools - would like beta testers please.

9. tester - please ignore

10. GCalPro users/beta testers - Please read (Cross-posted)

11. HELP !..PLEASE,PLEASe,PLEAse,PLEase,PLease,Please,please.....

12. SMALLTALK APP TESTER $$$$ SMALLTALK APP. TESTER

 

 
Powered by phpBB® Forum Software