How do I count thee? Let me count the ways?

"You get a free drink if you order a Burger or a Salad and a Dessert."

      A restaurant advertises, "You get a free drink if you order a Burger or a Salad and a Dessert." Suppose you only orde...

Monday, November 16, 2026

"You get a free drink if you order a Burger or a Salad and a Dessert."

      A restaurant advertises, "You get a free drink if you order a Burger or a Salad and a Dessert." Suppose you only order a Burger. Should the restaurant give you a free drink?

      Employee #1 says, "Burger alone gets the free drink!" Employee #2 says, "No, you need dessert too!"

      How different is this question than the calculation of 1 + 2 * 3 ? Many people would do the calculation left to right and get 9. Mathematics has established conventions for the order of operation rules (remember the acronym PEMDAS, or BODMAS?), such as parentheses P come first (evaluate expressions inside parentheses first), and multiplication M precedes (is performed before) addition A. Under those rules, math people would do the calculation as 1 + 2 * 3 = 1 + (2 * 3) and calculate it as 7.

      The burger question essentially asks, which operation takes precedence, OR or AND? Should we interpret A or B and C as (A or B) and C, or else as A or (B and C)? Unlike mathematical notation, ordinary English does not necessarily provide an unambigious answer.

      Although the burger question sounds silly, what if we asked an A or B and C in a web search? "Please provide a list of businesses offering services involving cats or dogs and providing instruction"? Or what if your homeowners insurance policy contained a policy exclusion that is of the form A or B and C?

      For convenience, let's call the burger A, the salad B, and the dessert C. In the original example, you only order a burger, so let's agree that A = True, B = False, and C = False.

      To a non-math person, A or B and C is probably ambiguous. Such a person might evaluate it left to right. Then A or B and C becomes (A or B) and C = (True or False) and False = True and False = False, so no free drink. Or, maybe the common customer expectation is that they deserve the free drink, which essentially says AND has precedence over OR, so A or (B and C) = True or (False and False) = True or False = True, so yes a free drink.

      A court might rule in favor of the common customer expectation, partucularly if the restaurant's wording is considered misleading. If the restaurant wrote a confusing promotion, the customer may get the benefit of the doubt. In insurance law there is a legal principle that when the policy was written solely by the insurer, ambiguities are interpreted strictly in favor of the policyholder.

      What would Microsoft Excel say? You can enter TRUE in cell A1, and FALSE in cells B1 and C1. Excel has AND and OR functions. But you can not normally test precedence because Excel forces you to nest one function inside the other, so you force the priority. What you can do is use the fact that TRUE equals 1 and FALSE equals 0, and that AND is similar to multiplication while OR is similar to addition. So if cell D1 contains the formula = (A1 + B1 * C1) > 0 the result is TRUE, so yes a free drink.

      Programming languages have their own precedence rules, but both R and Python give precedence to AND over OR.

      Bottom line: The restaurant's wording is ambiguous when viewed as a logical expression. A math or programming person would give AND precedence over OR, interpreting the offer as A or (B and C). That means the burger alone gets a free drink. Interestingly, this may also be what the ordinary customer would understand from the wording, although they might arrive at that interpretation therough ordinary English rather than mathematical rules.

      The lesson: Don't leave the interpretation of AND and OR to chance. Use parentheses, or rewrite the sentence to make the intention unmistakenable.

      The following code examples demonstrate actual programming precedence.



# calculate A or B and C:
# In R:
A <- TRUE
B <- FALSE
C <- FALSE
print(A | B & C)   # result is TRUE

# In Python:
A = True
B = False
C = False
print(A or B and C)   # result is True

Cartoon from Microsoft Copilot
Survey: https://docs.google.com/forms/d/e/1FAIpQLSf69ub5jZ493HFBkZCg23_lBT_-vNafy0SAS4kik2q7q2Eq_g/viewform End

No comments:

Post a Comment