How to write a function defined by segments in a formula?

97 Views Asked by At

I would like to define a function like $f(x) = 5$ if x is even, and $f(x) = 8$ if x is odd by using a first order logic formula. Is it possible? if yes, how?

1

There are 1 best solutions below

8
On

Is not that clear what you mean "_by defining a function....by using a first-order logic formula".

I suppose that you meant if there is a formula in the the first-order language of arithmetic (also known as Peano Arithmetic or PA for short).

If that is the case then you can simply rephrase you can define your function through the following functional formula

$$\varphi_f(x,y) \equiv((\exists z. 2z=x) \rightarrow y=5) \land ((\forall z. 2z \ne x) \rightarrow y=8)$$

Using the axioms of PA it is possible to prove that indeed $$\forall x \exists ! y \ \varphi_f(x,y)$$ that is $\varphi_f$ is really a functional formula. Then you can say that $f(x)=y$ is a short-hand for $\varphi_f(x,y)$.

Alternatively if you are using also $\mu$-recursion in your arithmetic language you can define $f$ as $$f(x)=\mu_y \varphi_f(x,y)$$ (if you are not familiar with the formalism that means $f(x)$ is the minimal $y$ such that $\varphi_f(x,y)$ holds).

I hope this address your question.