# Show a predicate is primitive recursive

Let $S(i,x_1,\ldots, x_n)$ be a primitive recursive predicate. $$f(i_1,i_2,x_1,\ldots, x_n) = \begin{cases} 1 &\text{ when for all i, }\; i_1 \le i \le i_2,\; S(i,x_1, \ldots, x_n)=1\\ 0 &\text{ otherwise} \end{cases}$$

Show that $f(i_1,i_2,x_1,\ldots, x_n)$ is also primitive recursive

I use Davis Computability and Complexity book. I get I need to write as described in this page. Show $x^y$ is a primitive recursive function

But how to do for predicates? Even a similar example which has predicates would be very helpful.

• What have you tried? Where did you get stuck? We do not want to just hand you the solution; we want you to gain understanding. However, as it is we do not know what your underlying problem is, so we can not begin to help. See here for tips on asking questions about exercise problems. If you are uncertain how to improve your question, why not ask around in Computer Science Chat? – Raphael Sep 24 '16 at 9:08
• Hint: show that finite case distinction with primitive-recursive predicates is primitive recursive. Use this to complete your task. – Raphael Sep 24 '16 at 9:09
• The cases environment lets you use an & to separate the function value from the text describing the case. – David Richerby Sep 24 '16 at 15:10
• Yeah I was asking how to approach such a problem. How to begin, because I have seen no examples similar to this. Not a full answer. – David Hamide Sep 24 '16 at 21:39
• Hint: $\forall i \leq n . S(i,x) = 1$ is calculated as $\prod_{i =0}^n S(i,x)$. – Andrej Bauer Sep 25 '16 at 9:25

If "predicate" confuses you check out its definition, e.g., wikipedia. It is just a function $f: \mathbb{N} \rightarrow \{0,1\}$. So you can use a primitive recursive predicate just as a primitive recursive function of that kind.