Artificial intelligent assistant

Help solving a challenge - relational algebra or second order logic 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

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) \
eq \hat{c} \\\ && g(M) \
eq 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)\
eq \hat{c}$, so $f^{-1}(\hat{c})\
eq 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)\
eq 25$ and $g(G)\
eq 25$, so we must have $g(K)=25$.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy f8d8dc309260aec4310c863b075db82a