in reply to Re^5: Boolean math: Fill in the blanks.
in thread Boolean math: Fill in the blanks.

This is very cool code. I love that it produces the reductions.

Update: Even if they are sometimes a little ecclectic:

E(64/128) = E(32/64) = E(2/2) & E(32/64)

I'm having a little trouble wrapping it into my test harness, but it seem to produce exactly the results I am after. Thank you.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

Replies are listed 'Best First'.
Re^7: Boolean math: Fill in the blanks.
by pjotrik (Friar) on Oct 10, 2008 at 16:53 UTC
    Even if they are sometimes a little ecclectic

    Yes, originally, the code stopped searching when it found the first reduction. Given the order in which these are searched, it didn't produce this garbage. I only changed this behavior before pasting the code, because it may be interesting to see multiple possibilities (like with E(21/32) = E(3/4) & E(7/8) = E(1/2) | E(5/16)), and I didn't notice the noise.

    To fix it, change
    if ($denominator2 > $numerator2) {
    to
    if ($denominator1 > $numerator1 && $denominator2 > $numerator2) {
    but I'm sure you know that.