How to present the properties of a piecewise function in first order logic

logicnotation

I am unsure on how to present the properties ofa piecewise function in first order logic with equality (FOL=).

As an example I will use the function that computes the $nth$ number in the Fibonacci sequence.

\begin{align*}
\forall n \colon \mathbb{N} \colon \mathsf{fib}(n) = \begin{cases}
0 & \text{if $n=0$}, \\
1 & \text{if $n=1$}, \\
\mathsf{fib}(n-2)+\mathsf{fib}(n-1) & \text{if $n>1$}. \\
\end{cases}
\end{align*}

I ignore the fact that subtraction is a partial function in $\mathbb{N}$.

Attempt 1

My first attempt is to write each case as a implication and then write the entire function as a conjunction of cases. When the antecedent is false then the case is true. Given the domain is $\mathbb{N}$ I think all cases are covered.

\begin{align*}
(\forall n \colon \mathbb{N} \colon ((n=0) \implies (\mathsf{fib}(n) = 0))) \land \\
(\forall n \colon \mathbb{N} \colon ((n=1) \implies (\mathsf{fib}(n) = 1))) \land \\
(\forall n \colon \mathbb{N} \colon (\neg((n=1) \lor (n=0)) \implies (\mathsf{fib}(n) = \mathsf{fib}(n – 1)+\mathsf{fib}(n – 2))))
\end{align*}

Attempt 2

My second attempt uses the disjunction of 3 equations, the first two equations are for constants 0 and 1:
\begin{align*}
(\mathsf{fib}(0) = 1) \lor \\
(\mathsf{fib}(1) = 1) \lor \\
\forall n \colon \mathbb{N} \colon((n>1) \implies (\mathsf{fib}(n + 2) =\mathsf{fib}(n) + \mathsf{fib}(n+1)). \\
\end{align*}

Are either of these valid approaches to presenting the properties of the function in FOL=?

What would be an appropriate approach?

Maybe I need to rewrite the equalities as relations?

Best Answer

If you just want to express the property of the function $\mathsf{fib}$, the following may be ok.

$$ \forall n\,[(n=0\to\mathsf{fib}(n)=0)\vee (n=1\to\mathsf{fib}(n)=1)\vee(n>1\to \mathsf{fib}(n)=\mathsf{fib}(n-1)+\mathsf{fib}(n-2))]. $$

Note that the premises is that the signature of the first order language is $\{+,-,\mathsf{fib},0,1,2\}$ and $n$ is a variable of the first order language.

But I don't know what's the meaning of your "represent"!!!