What does “no drinking or eating” mean to a computer

I saw a this signage while travelling on the circle line.

Prohibition signage on train

When I saw this sign, I was wondering if a computer is to decide who had violated the "no eating or drinking" rule, under which circumstance(s) will it identify a person as a offender?

To answer this question, let's create a simple computer algorithm that will search for offenders. To be more explicit to our computer, we can take "no eating or drinking" to mean "no eating or no drinking".

Converting the rule into codes for our computer, we get:

// If a person is not eating or not drinking
if (!eating || !drinking) {
    // Continue search for offenders
}
else {
    // Impose a fine on the person who broke the rule
} // end if

A person will not be identified as an offender when the condition in the if clause evaluates to true. With a truth table, we can work out the cases that a person will not be identified as an offender by our computer.

!eating !drinking !eating || !drinking
false false false
false true true
true false true
true true true

From the truth table, we can see that a person will not be identified as an offender when he/she is:

  • not eating but drinking
  • eating but not drinking
  • not eating and not drinking

Our computer will only impose a fine people who are eating and drinking.

A better rule for our computer

Ideally, we would want our computer to impose fines on people who are either eating or drinking. Hence, we should use the rule "No eating and no drinking" as the condition in our if clause instead. We can verify our new rule with a truth table:

!eating !drinking !eating && !drinking
false false false
false true false
true false false
true true true

This time round, only those who are not eating and not drinking are spared from being fined by our computer.

Please do not eat and/or drink on trains

Compared to our dumb computer, humans are many times smarter. We all know that we should not eat and/or drink whenever we see similar prohibition signage. Since thirst is more unbearable than hunger, I feel that occasional sips from your water bottle should be ok.

About Clivant

Clivant a.k.a Chai Heng enjoys composing software and building systems to serve people. He owns techcoil.com and hopes that whatever he had written and built so far had benefited people. All views expressed belongs to him and are not representative of the company that he works/worked for.