Logic

My wife asked me: Buy sausages, if you’ll find eggs, buy 10. What happens next?

Option #1:

if eggs >= 10 then buy(sausages, eggs=10);

Option #2:

if sausages > 0 then buy(sausages);
if eggs >= 10 then buy(eggs, 10);

Option #3

buy(sausages);
if eggs >= 10 then buy(eggs, 10);

The 3rd option is dangerous one because it could end up with never-ending run in the city looking for sausages, never buying eggs and never coming back home.

…and more. Why?

Asking me to make shopping, my wife did not stick to the principles of valid inference and correct reasoning. That’s the reason why not everybody can be a programmer :-)

8 Responses to “Logic”

  1. Paul Spencer says:

    buy(sausages,2); // sausages is plural, need to buy 2 otherwise its a sausage
    if eggs then buy(sausages,8); // if you find eggs, you better come home with 10 sausages!

  2. Eric Wolf says:
    if (requester == wife) then
        expect_valid_inferences_and_correct_reasoning = False
    else
        divorce = True
    
    if (divorce == True)
       buy(beer, 12)
    else
       buy(sausages, 10)
       buy(eggs, 12)
       buy(flowers, 1)

    P.S. Sum of five + ten = fifteen, not 15.

  3. Eric Wolf says:

    FYI: Your comments don’t allow Pythonic code blocks. Indentation is stripped.

  4. mloskot says:

    Paul,

    This is an interesting insight that could be tweaked to if eggs buy(sausages) && buy(beer, 10);

  5. mloskot says:

    Eric,

    Hehe, isn’t it too radical? By the way, my wife does not mind whether I have some beer, so assuming the execution does not fall into divorce case, I’d replace 12 eggs with 10, 1 flower – let’s leave as is, and add 2 beers. Yes. looks good now :-)

  6. Tyler says:

    I think the problem also shows that not all people can do the shopping too ;-) hehe

  7. mloskot says:

    Tyler,

    This is the very truth :-)

  8. Regina says:

    Mateusz,
    Me thinks you’ve been staring at a screen too long. Its all about context. That’s what separates humans from computers. Hmm I wonder if that’s what separates real people from geeks too. :)

Leave a Reply