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

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.

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

Reply via email to