Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Nested Quantum::Superpositions

by tilly (Archbishop)
on Nov 07, 2003 at 00:36 UTC ( #305200=note: print w/ replies, xml ) Need Help??


in reply to Nested Quantum::Superpositions

Allow me to clarify runrig's answer in case it didn't make sense to you. all(1,4) == all(1,4) would be true if 1 == all(1,4) and 4 == all(1,4).

For the first statement to be true we must have 1 == 1 and 1 == 4 Since 1 is not 4, the first one is false.

The second one is false for the same reason. A fact that we didn't actually need to check since the failure of either the first or the second statement is enough to make the overall comparison fail.

Therefore in quantum logic, all(1,4) != all(1,4), no matter how much that violates your classical prejudices.

And that is why the match that you expected to find in the more complex example, wasn't found.

UPDATE Here is a simple example to make you think that the way that Quantum::Superpositions works is reasonable. Just read the statement all(1, 2, 3) < all(4, 5, 6) as plain English. All of (1, 2, 3) are less than all of (4, 5, 6). Which is true. So the code evaluates to true. By contrast all(1, 2, 4) < all(3, 5, 6) says that All of (1, 2, 4) are less than all of (3, 5, 6). Which is false because 4 is not less than 3. And so the code evaluates to false.

And this is exactly how Quantum::Superpositions works. When you read all(1,4) == all(1,4), don't think of all(1,4) as a "thing" in and of itself. It isn't. Think of the whole statement as being a sentence asserting something, and think about whether that assertion is correct.

Yes, at some level all(1,4) has to be a single Perl scalar. But the illusion is that it isn't, and with TheDamian doing the illusioning, you can bet that it is a pretty darned good illusion!


Comment on Re: Nested Quantum::Superpositions
Select or Download Code
Re: Re: Nested Quantum::Superpositions
by welchavw (Pilgrim) on Nov 07, 2003 at 14:49 UTC

    Ok. Realizing that all(1,4)!= all(1,4) helps me a bunch - thanks to all posters. As a followup, it seems to me that the docs must be in error when they imply that the following code could ever work...

    $ideal = any( all("tall", "rich", "handsome"), all("rich", "old"), all("smart","Australian","rich") ); while (@features = get_description) { if (any(@features) eq $ideal) { print "True love"; } }

    After all, I think that it has been illustrated that an "n-all" where n>1 cannot eq anything. Am I wrong?

    update: Of course, I am wrong about this. I must have had those Friday-morning blinders on. An "n-all" cannot eq an "n-all" of the same order (update: except if ni=C for 0<=i<=ordern-1 (e.g. all(1,1,1) == all(1,1,1)), but that doesn't mean that an any can't match "n-all" of order > 1. My bad.

    upupdate: Fantastic! Now, I actually understand the Q::S operators. Many thanks to Tilly (and also for reporting the docs bug). I really had to struggle to get used to distributing the operator joining each composite superposition across the cross-products (or something like that!). Then, everything clicked (here's to hoping it stays clicked). Q::S is really a neat package, IMHO, but a bit of a mind-bender initially.

    ,welchavw

      Let's try it.
      use Quantum::Superpositions; my $all = all("smart","Australian","rich"); my $any = any("smart","Australian","rich"); print "Yes 1\n" if $all eq $any; print "Yes 2\n" if $any eq $all; __END__ Yes 1
      Reading this as I suggested above explains the result. Unfortunately the documentation doesn't clarify this important point, and worse yet, gets it backwards in its example. I'll send a bug report to the current maintainer (Steven Lembark).

      UPDATE: Reported. (BTW I find it charming that "True love" is impossible to find...)

      Q::S is really a neat package, IMHO, but a bit of a mind-bender initially.
      Obviously for their inventor too, since he apparently couldn't even get a simple example right in the docs! ;-)

      I'm sure the module's new maintainer will update them accordingly for the next release.

      Meanwile I do appreciate the bug report. One of the projects I'm currently working on is finalizing the semantics of Perl 6 junctions, which are an evolution of quantum superpositions. One of my goals is to simplify those semantics to make them a little more intuitive/predictable, and a lot less mind-bending.

      Being able to watch your learning process in this thread has been of real value to me in doing that. Thank-you.

      And thanks to tilly for the usual masterful explanations, for the bug report, and especially for drawing my (all too thinly spread) attention to this thread.

        Just a bit more of mind-bending: is there a solution the the equation: x = all(1,4)?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://305200]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (12)
As of 2014-08-29 22:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (289 votes), past polls