On Fri, Nov 01, 2002 at 07:54:01AM +1100, Damian Conway wrote:
> Austin Hastings wrote:
>> traits = any ( ... )
>> requirements = .. & ..
>> if $requirements eq $traits
>> 
>> Should that be traits = all()?
> 
> No. Because later we say (effectively):
> 
>       print "True love\n"
>           if all(@desiderata) eq any(@traits)
> 
> In other words we want *all* the desired characteristics to be matched
> by *some* trait. If the comparison was C<all(...) eq all(...)>, then
> you're asking for every characteristic to be the same as every trait,
> which obviously can't happen.
> 
> This is just a case where the "logic" of English phraseology has
> several implicit assumptions that computational logic can't just
> fudge over.

I don't understand this either, but my quibble is where did the all in
the all(@desiderata) come from?  Lets see if I've got this straight

a & b is equivalent to all(a, b)
x | y is equivalent to any(x, y)

Yes?

so:

  all(a, b) eq any(a, b, c) 

should be true because all() of a and b are in the any() list.  Yes?

If I'm right about that, I would expect

  (a & b) | (c & d) eq any(a, e, g)
 
to be false because it should try ANY of the two junks (a & b) or  
(c & d) the first fails because there is no b and the second fails
because there is no c and no d.  I would also expect

  (a & b) | (c & d) | g eq any(a, e, g)

to be true because any() of the terms (g in this case) on the left is
fully satisfied by terms on the right.  In the original example the
@desiderata is an | junk at the topmost level.  I don't see why it
suddenly gets all() wrapped around it.  Wouldn't that just be

  all[  any< all(), all(), all() > ]

which is the same as

  any< all(), all(), all() >

I'm not sure I'm explaining this very well, let me try with the example
that's giving me bother.

     $requirements = "tall" & "dark" & "handsome"
                   | "old" & "rich"
                   | "Australian";

     for <> -> $candidate {
         my $traits = any( split /<ws>/, $candidate );
         print "True love: $candidate\n"
             if $requirements eq $traits;
     }

Lets say that $candidate = "tall dark rich Australian", traits then
becomes any("tall", "dark", "rich", "Australian").  So, does
$requirements eq $traits?  To me that expands to:

(
  (
    ("tall" eq "tall")           or \
    ("tall" eq "dark")           or   True because "tall" eq "tall"
    ("tall" eq "rich")           or  
    ("tall" eq "Australian")        /
  ) AND (
    ("dark" eq "tall")           or \
    ("dark" eq "dark")           or   True because "dark" eq "dark"
    ("dark" eq "rich")           or
    ("dark" eq "Australian")        /
  ) AND (
    ("handsome" eq "tall")       or \
    ("handsome" eq "dark")       or   False no matches
    ("handsome" eq "rich")       or
    ("handsome" eq "Australian")    /
  )
  
) ***OR*** (

  (
    ("old" eq "tall")            or \
    ("old" eq "dark")            or   False no matches
    ("old" eq "rich")            or
    ("old" eq "Australian")         /
  ) AND (
    ("rich" eq "tall")           or \
    ("rich" eq "dark")           or   True because "rich" eq "rich" 
    ("rich" eq "rich")           or
    ("rich" eq "Australian")        /
  )
  
) ***OR*** (

  ("Australian" eq "tall")     or \
  ("Australian" eq "dark")     or   True because "Australian" eq "Australian"
  ("Australian" eq "rich")     or
  ("Australian" eq "Australian")  /
) 

Junk 1: "tall" & "dark" & "handsome"
Junk 2: "old" & "rich"
Junk 3: "Australian";

Junk 1 fails because the candidate is not handsome.  Junk 2 fails because
the candidate is not old.  Junk 3 succeeds because the candidate is
Australian.

This means that the candidate matches overall because junks 1, 2 and 3
are related by | which is any.  I don't see how or why you would wrap an
all() around that.  There is all()ness going on, but it's represented in
the above by the ands which are in turn grouped with any (the ors).
Why isn't this example

        print "True love\n"
            if any(@desiderata) eq any(@traits)

Does whether it's any() or all() not depend on what the top level
operator in the junction is?  Am I missing something?

andrew
-- 
Gemini: (May 21 - June 21)
You will be the first one put up against the wall in next week's bloody
revolution in skin care.

Reply via email to