Help solving a challenge - relational algebra or second order logic

110 Views Asked by At

I am a self-taught man and I'm posting my first question here. I'm facing a challenge I'd like to solve. Based on what I know it fits propositional calculus (hope it is).

Suppose 3 people: a captain, a helmsman, a cook. They all come from different countries: Marocco, Korea, Greece (no specific order). They all have different ages: 35, 42, 25 (no specific order).

I know that: The Moroccan man is not a captain; he is not 25. The Greek helmsman is more than 25.

How old is the captain?

Can you please give me some insight on how to solve it? Thanks for your help

1

There are 1 best solutions below

2
On BEST ANSWER

I think it's more natural to think in terms of second order logic here, rather than propositional calculus.

Let $A=\{25,35,42\}$, $R=\{\hat{c},h,c\}$, ($\hat{c}$ is the captain since it has a fancy hat!) and $N=\{K,M,G\}$ be the sets of ages, roles, and nationalities, respectively, and let $f:N\to R$ and $g:N\to A$ be the role and age functions. We assume that $f$ and $g$ are invertible.

We want to identify $g\circ f^{-1}(\hat{c})$.

What do we know?
\begin{eqnarray} && f(M) \neq \hat{c} \\ && g(M) \neq 25 \\ && f(G) =h \\ && g(G) > 25 \end{eqnarray}

Well, $f^{-1}(\hat{c})\in\{G,M,K\}$. But $f^{-1}(h)=G$ so, $f^{-1}(\hat{c})\in\{M,K\}$. We also know that $f(M)\neq \hat{c}$, so $f^{-1}(\hat{c})\neq M$. It must therefore be the case that $f^{-1}(\hat{c})=K$. The captain is the Korean.

So, how old is the Korean? What is $g(K)$? Well, $g$ is onto, but $g(M)\neq 25$ and $g(G)\neq 25$, so we must have $g(K)=25$.