Re: pilog in ersatz

2012-07-10 Thread Alexander Burger
Hi Christophe,

  Yes. This is an infinite recursion.
 ...
 So it seems it's not a syntax problem, but a conceptual one. I thought
 about @x and @y being the same person, but it shouldn't.
 Another hint?

I'm not a Prolog expert, but fact is that if the first three clauses

   (be bigger (me her))
   (be bigger (her son))
   (be bigger (son daughter))

don't find a match, the fourth one

   (be bigger (@x @y) (bigger @x @z) (bigger @z @y))

will always match and recurse infinitely.


I suspect this can be solved with a 'cut' (anybody out there who
knows?), but another solution would be to separate it into two
predicates:

   (be isbigger (me her))
   (be isbigger (her son))
   (be isbigger (son daughter))

   (be bigger (@x @y) (isbigger @x @y))
   (be bigger (@x @y) (isbigger @x @z) (isbigger @z @y))

This gives:

   : (? (bigger son daughter))
   - T

   : (? (bigger me @A))
@A=her   
@A=son
   - NIL

   : (? (bigger @A @B))
@A=me @B=her   
@A=her @B=son
@A=son @B=daughter
@A=me @B=son
@A=her @B=daughter
   - NIL

Cheers,
- Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: pilog in ersatz

2012-07-10 Thread Christophe Gragnic
On Mon, Jul 9, 2012 at 11:12 PM, Doug Snead semaphore_2...@yahoo.com wrote:

 Hmmm. Where do alix and sw originate?  I do not understand that.

Sorry for the confusion, I was doing my tests with real names in my
family but thought afterwards I should use names that could be
understood by anybody. My handmade-search-and-replace thing is not
very efficient. Someday I'll try to configure a vim hook for web
forms, or a vimesque mail client.

chri

-- 
Envoyé de ma messagerie électronique.
Merci de divulguer cette adresse mail au minimum (pour les envois en
groupe, utilisez la copie invisible).
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: pilog in ersatz

2012-07-10 Thread Alexander Burger
On Tue, Jul 10, 2012 at 09:56:26AM +0200, Alexander Burger wrote:
(be bigger (@x @y) (isbigger @x @z) (isbigger @z @y))

No, I think the last rule must be

(be bigger (@x @y) (isbigger @x @z) (bigger @z @y))

Cheers,
- Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: pilog in ersatz

2012-07-10 Thread Christophe Gragnic
On Tue, Jul 10, 2012 at 9:56 AM, Alexander Burger a...@software-lab.de wrote:

 don't find a match, the fourth one

(be bigger (@x @y) (bigger @x @z) (bigger @z @y))

 will always match and recurse infinitely.

Is it because it always match or because to know if it would succeed,
it must test itself? Hence the recursion, now I got it.

 I suspect this can be solved with a 'cut' (anybody out there who
 knows?)

I thought about the 'cut' before falling asleep, but I'm too weak at it.

 but another solution would be to separate it into two
 predicates:

(be isbigger (me her))
(be isbigger (her son))
(be isbigger (son daughter))

(be bigger (@x @y) (isbigger @x @y))
(be bigger (@x @y) (isbigger @x @z) (isbigger @z @y))

 This gives:

: (? (bigger son daughter))
- T

: (? (bigger me @A))
 @A=her
 @A=son
- NIL

: (? (bigger @A @B))
 @A=me @B=her
 @A=her @B=son
 @A=son @B=daughter
 @A=me @B=son
 @A=her @B=daughter
- NIL

It's a start, but it doesn't span enough: we can't prove «bigger me daughter».

- search search -

This it what is called a «transitive closure». Alex was right about
using two predicates. The first is the base one, the second is its
closure.

So Alex's rule:
(be bigger (@x @y) (isbigger @x @z) (isbigger @z @y))

should be:
(be bigger (@x @y) (isbigger @x @z) (bigger @z @y))

Tests left as an exercise !!!

Doug: Thanks for (trace). I thought about it but traced (?) instead.


chri
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: pilog in ersatz

2012-07-09 Thread Doug Snead
The pilog trace can be helpful in these situations.

: (be bigger (me her))
: (be bigger (her son))
: (be bigger (son daughter))
: (be bigger (@x @y) (bigger @x @z) (bigger @z @y))

List the assertions you want to trace before the clause to be proved, in this 
case bigger :

: (? bigger (bigger @x meily))

4 (bigger @x meily)
1 (bigger me her)
4 (bigger her meily)
2 (bigger her son)
4 (bigger son meily)
3 (bigger son daughter)
4 (bigger daughter meily)
4 (bigger daughter @y)
4 (bigger daughter @y)
4 (bigger daughter @y)
4 (bigger daughter @y)
4 (bigger daughter @y)
4 (bigger daughter @y)
4 (bigger daughter @y)
4 (bigger daughter @y)
4 (bigger daughter @y)
4 (bigger daughter @y)
4 (bigger daughter @y)
4 (bigger daughter @y)
4 (bigger daughter @y)
4 (bigger daughter @y)
...


So, it is infinitely recurring when trying to prove (bigger daughter @y).

The numbers in front of the pilog trace output lines correspond to the rule 
being proved at that stage. 

Hope that helps!

Cheers,

Doug




--- On Sun, 7/8/12, Christophe Gragnic christophegrag...@gmail.com wrote:

 From: Christophe Gragnic christophegrag...@gmail.com
 Subject: pilog in ersatz
 To: picolisp@software-lab.de
 Date: Sunday, July 8, 2012, 11:36 AM
 Hi all, I'm currently investigating
 Picolisp to teach prefix notation,
 and Pilog to teach first order logic.
 
 I have a problem with a set of instructions in ersatz:
 
 : (be bigger (me her))
 - bigger
 : (be bigger (her son))
 - bigger
 : (be bigger (son daughter))
 - bigger
 : (be bigger (@x @y) (bigger @x @z) (bigger @z @y))
 - bigger
 : bigger
 - NIL
 : (? (bigger @x meily))
  @x=alix
  @x=sw
 
 Then ersatz freezes, no prompt.
 Any idea?
 
 
 chri
 
 -- 
 Envoyé de ma messagerie électronique.
 Merci de divulguer cette adresse mail au minimum (pour les
 envois en
 groupe, utilisez la copie invisible).
 --
 UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: pilog in ersatz

2012-07-09 Thread Doug Snead
--- On Sun, 7/8/12, Christophe Gragnic christophegrag...@gmail.com wrote:
 : (be bigger (me her))
 - bigger
 : (be bigger (her son))
 - bigger
 : (be bigger (son daughter))
 - bigger
 : (be bigger (@x @y) (bigger @x @z) (bigger @z @y))
 - bigger
 : bigger
 - NIL
 : (? (bigger @x meily))
  @x=alix
  @x=sw

Hmmm. Where do alix and sw originate?  I do not understand that. 

(I was using full picolisp for my tracing before, I should have mentioned.) 

-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe