Safe Haskell | None |
---|---|

Language | Haskell2010 |

Author : Levent Erkok License : BSD3 Maintainer: erkokl@gmail.com Stability : experimental

The origin of this puzzle is Raymond Smullyan's "The Flower Garden" riddle:

In a certain flower garden, each flower was either red, yellow, or blue, and all three colors were represented. A statistician once visited the garden and made the observation that whatever three flowers you picked, at least one of them was bound to be red. A second statistician visited the garden and made the observation that whatever three flowers you picked, at least one was bound to be yellow.

Two logic students heard about this and got into an argument. The first student said: “It therefore follows that whatever three flowers you pick, at least one is bound to be blue, doesn’t it?” The second student said: “Of course not!”

Which student was right, and why?

We slightly modify the puzzle. Assuming the first student is right, we use SBV to show that the garden must contain exactly 3 flowers. In any other case, the second student would be right.

# Documentation

Colors of the flowers

## Instances

validPick :: SInteger -> Flower -> Flower -> Flower -> SBool Source #

Describe a valid pick of three flowers `i`

, `j`

, `k`

, assuming
we have `n`

flowers to start with. Essentially the numbers should
be within bounds and distinct.

count :: Color -> [Flower] -> SInteger Source #

Count the number of flowers that occur in a given set of flowers.

flowerCount :: IO () Source #

Solve the puzzle. We have:

`>>>`

Solution #1: N = 3 :: Integer This is the only solution. (Unique up to prefix existentials.)`flowerCount`

So, a garden with 3 flowers is the only solution. (Note that we simply skip over the prefix existentials for model purposes here, as they don't represent a different solution.)