| FazBrowse Wikipedia Viewer | Main Page | | |
| Viewing: https://en.wikipedia.org/wiki/Primitive_recursive_function#Examples |
| Contents |
|---|
| Doubling |
| Multiplication |
| Predecessor |
| Connectives |
| Equality predicate |
| Other operations on natural numbers |
In computability theory, a primitive recursive function is, roughly speaking, a function that can be computed by a computer program whose loops are all "for" loops (that is, an upper bound of the number of iterations of every loop is fixed before entering the loop). Primitive recursive functions form a strict subset of those general recursive functions that are also total functions.
The importance of primitive recursive functions lies in the fact that most computable functions that are studied in number theory (and more generally in mathematics) are primitive recursive. For example, addition and division, the factorial and exponential function, and the function which returns the nth prime are all primitive recursive. In fact, for showing that a computable function is primitive recursive, it suffices to show that its time complexity is bounded above by a primitive recursive function of the input size. It is hence not particularly easy to devise a computable function that is not primitive recursive; some examples are shown in section § Limitations below.
The set of primitive recursive functions is known as PR in computational complexity theory.
Cnk: For each natural number Cnk(x1,…,xk) =def n, is primitive recursive.where each component C01 is a 1-ary function which returns C11 is a 1-ary function which returns C30 is a 0-ary function, i.e. a constant: P11(x)=x.
Given (Add∘(P11,P11))(x)=Add(x,x)=x+x.
In a similar way as addition, multiplication can be defined by Mul(S(x),y)=ρ(C01,Add∘(P23,P33))(S(x),y) by Def. Mul=(Add∘(P23,P33))(x,Mul(x,y),y) by case ρ(g,h)(S(...),...)=Add(Mul(x,y),y) by Def. ∘,P23,P33=Mul(x,y)+y by property of Add.
The predecessor function acts as the "opposite" of the successor function and is recursively defined by the rules Pred=ρ(C00,P12). As a computation example,
As an example for a primitive recursive predicate, the 1-ary function x=0, and IsZero(0)=ρ(C10,C02)(0)=C10()=1, and e.g. Predicate "Less or equal"edit
Using the property Leq=IsZero∘Sub. Then Leq(x,y)=0 otherwise. As a computation example,
Once a definition of Geq(x,y)=Leq(y,x) is true (more precisely: has value 1) if and only if x,
Based on the And(x,y)=If(x,y,0), that is, y are true (logical conjunction of Or=If∘(P12,C12,P22) and Not(x)=If(x,0,1).
Using the above functions And, the definition x equals Gt=Not∘Leq implements "greater-than".
Exponentiation and primality testing are primitive recursive. Given primitive recursive functions g, and e≤f and the value of
| View original on Wikipedia | Back | FazBrowse Home |