RE: Q: function to simplify a boolean expression

new topic     » goto parent     » topic index » view thread      » older message » newer message

On Thu, 17 Jan 2002 bensler at mail.com wrote:

> Am I missing something?
> Euphoria will reduce any expression you give it:
> print(1, (1 > 2) )
> print(1, (1 < 2) )

1st day: John Q. Fiddlesticks drinks beer and apple juice and gets drunk.
2nd day: JQF drinks beer and tomato juice and gets drunk.
3rd day: JQF drinks apple juice and tomato juice and does not get drunk.
4th day: JQF drinks vodka and apple juice and gets drunk.
..... etc. etc. .....

John Q. Fiddlesticks is trying to figure out what the hell is making him
drunk.

So he makes a truth table:
B = beer   V = vodka   A = apple juice   T = tomato juice

B   V   A   T      got drunk

0   0   0   0      0
0   0   0   1      0
0   0   1   0      0
0   0   1   1      0
0   1   0   0      1
0   1   0   1      1
0   1   1   0      1
0   1   1   1      1
1   0   0   0      1
1   0   0   1      1
1   0   1   0      1
1   0   1   1      1
1   1   0   0      1
1   1   0   1      1
1   1   1   0      1
1   1   1   1      1


John Q. Fiddlesticks collects all the cases where he gets drunk and
makes a boolean expression:

(-B,  V, -A, -T) or (-B,  V, -A,  T) or (-B,  V,  A, -T) or (-B,  V,  A,  T) or
( B, -V, -A, -T) or ( B, -V, -A,  T) or ( B, -V,  A, -T) or ( B, -V,  A,  T) or
( B,  V, -A, -T) or ( B,  V, -A,  T) or ( B,  V,  A, -T) or ( B,  V,  A,  T)

This boolean expression reduces to:  (B or V)

So JQF concludes that what is making him drunk is:  beer or vodka
---------------

Smurf Village is plagued with Smurfitis, a strange disease that results in
multi-colored polka dots all over your body.

Doctor Smurf has collected a large amount of data.  He is in a perfect
position to collect data because he is the doc.

The data has, not 4 variables but 8 variables.  From this data, he has
made a very long boolean expression.

Doctor Smurf wants to know how to simplify this very long boolean expression,
and others like it for other diseases.  Like maybe a function.
Doctor Smurf says: "I'm a doctor, not a programmer."  (paraphrasing McCoy)

All the wisest and most learned people in Smurf Village, all the
sages and soothsayers and astrologers and magicians have failed to solve
this problem.

But word got around that there exists a source, called the Euphoria list,
where anyone can ask any question and get an answer, and where there are
people who are far more learned and more wise than anyone in all of
Smurf Village.

Doctor Smurf and the people of Smurf Village eagerly await an answer.

-----------------

About espresso.zip:

This looks as complicated as hell.  I was hoping for something simple.
Like:

 s2 = simplify_boolean_expression(s1)

  (either written in Euphoria or easily translatable to Euphoria)

Maybe for my purpose it doesn't need to be as complicated as espresso.


       Jerry Story

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu