ArticleslgStudy

computer science

Course-of-values recursion

Course-of-values recursion is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Course-of-values recursion rather than just read about it. In short: In computability theory, course-of-values recursion is a technique for defining number-theoretic functions by recursion. In a definition of a function f by course-of-values recursion, the value of f(n) is computed from the sequence ⟨f(0),f(1),…,f(n−1)⟩.

Key takeaways

  • Course-of-values recursion belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Course-of-values recursion to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Course-of-values recursion from memory before moving on to harder problems.

Reference excerpt

In computability theory, course-of-values recursion is a technique for defining number-theoretic functions by recursion. In a definition of a function f by course-of-values recursion, the value of f(n) is computed from the sequence ⟨f(0),f(1),…,f(n−1)⟩. The fact that such definitions can be converted into definitions using a simpler form of recursion is often used to prove that functions defined by course-of-values recursion are primitive recursive. Contrary to course-of-values recursion, in primitive recursion the computation of a value of a function requires only the previous value; for example, for a 1-ary primitive recursive function g the value of g(n+1) is computed only from g(n) and n.

Definition and examples The factorial function n! is recursively defined by the rules

0!=1, (n+1)!=n!(n+1). This recursion is a primitive recursion because it computes the next value (n+1)! of the function based on the value of n and the previous value n! of the function. On the other hand, the function Fib(n), which returns the nth Fibonacci number, is defined with the recursion equations

Fib(0)=0, Fib(1)=1, Fib(n+2)=Fib(n+1)+Fib(n). In order to compute Fib(n+2), the last two values of the Fib function are required. Finally, consider the function g defined with the recursion equations

g(0)=0, g(n+1)=∑i=0ng(i)n−i. To compute g(n+1) using these equations, all the previous values of g must be computed; no fixed finite number of previous values is sufficient in general for the computation of g. The functions Fib and g are examples of functions defined by course-of-values recursion. In general, a function f is defined by course-of-values recursion if there is a fixed primitive recursive function h such that for all n,

f(n)=h(n,⟨f(0),f(1),…,f(n−1)⟩) where ⟨f(0),f(1),…,f(n−1)⟩ is a Gödel number encoding the indicated sequence. In particular

f(0)=h(0,⟨⟩) provides the initial value of the recursion. The function h might test its first argument to provide explicit initial values, for instance for Fib one could use the function defined by

h(n,s)={nif n<2s[n−2]+s[n−1]if n≥2 where s[i] denotes extraction of the element i from an encoded sequence s; this is easily seen to be a primitive recursive function (assuming an appropriate Gödel numbering is used).

Equivalence to primitive recursion In order to convert a definition by course-of-values recursion into a primitive recursion, an auxiliary (helper) function is used. Suppose that one wants to have

f(n)=h(n,⟨f(0),f(1),…,f(n−1)⟩). To define f using primitive recursion, first define the auxiliary course-of-values function that should satisfy

f¯(n)=⟨f(0),f(1),…,f(n−1)⟩ where the right hand side is taken to be a Gödel numbering for sequences. Thus f¯(n) encodes the first n values of f. The function f¯ can be defined by primitive recursion because f¯(n+1) is obtained by appending to f¯(n) the new element h(n,f¯(n)):

f¯(0)=⟨⟩, f¯(n+1)=𝑎𝑝𝑝𝑒𝑛𝑑(n,f¯(n),h(n,f¯(n))), where append(n,s,x) computes, whenever s encodes a sequence of length n, a new sequence t of length n + 1 such that t[n] = x and t[i] = s[i] for all i < n. This is a primitive recursive function, under the assumption of an appropriate Gödel numbering; h is assumed primitive recursive to begin with. Thus the recursion relation can be written as primitive recursion:

f¯(n+1)=g(n,f¯(n)) where g is itself primitive recursive, being the composition of two such functions:

g(i,j)=𝑎𝑝𝑝𝑒𝑛𝑑(i,j,h(i,j)), Given f¯, the original function f can be defined by f(n)=f¯(n+1)[n], which shows that it is also a primitive recursive function.

Application to primitive recursive functions In the context of primitive recursive functions, it is convenient to have a means to represent finite sequences of natural numbers as single natural numbers. One such method, Gödel's encoding, represents a sequence of positive integers ⟨n0,n1,n2,…,nk⟩ as

∏i=0kpini, where pi represent the ith prime number. It can be shown that, with this representation, the ordinary operations on sequences are all primitive recursive. These operations include

Determining the length of a sequence, Extracting an element from a sequence given its index, Concatenating two sequences. Using this representation of sequences, it can be seen that if h(m) is primitive recursive then the function

f(n)=h(⟨f(0),f(1),f(2),…,f(n−1)⟩). is also primitive recursive. When the sequence ⟨n0,n1,n2,…,nk⟩ is allowed to include zeros, it is instead represented as

∏i=0kpi(ni+1), which makes it possible to distinguish the codes for the sequences ⟨0⟩ and ⟨0,0⟩.

Limitations Not every recursive definition can be transformed into a primitive recursive definition. One known example is Ackermann's function, which is of the form A(m,n) and is provably not primitive recursive. Indeed, every new value A(m+1, n+1) depends on the sequence of previously defined values A(i, j), but the i-s and j-s for which A(i, j) should be included in this sequence depend themselves on previously computed values of the function; namely (i, j) = (m, A(m+1, n)). Thus one cannot encode the previously computed sequence of values in a primitive recursive way in the manner suggested above (or at all, as it turns out this function is not primitive recursive).

References Hinman, P.G., 2006, Fundamentals of Mathematical Logic, A K Peters. Odifreddi, P.G., 1989, Classical Recursion Theory, North Holland; second edition, 1999.

Worked examples

Example 1 — a first encounter with Course-of-values recursion

Start with the simplest possible case. Write down what Course-of-values recursion claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Course-of-values recursion before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Course-of-values recursion ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Course-of-values recursion

In research
Course-of-values recursion appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Course-of-values recursion in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Course-of-values recursion is common in secondary-school and first-year university syllabi. It links to neighbouring topics Computability theory, Recursion, so understanding it makes those chapters shorter.
In everyday life
Look for Course-of-values recursion outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Course-of-values recursion” →

How to study Course-of-values recursion in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Course-of-values recursion means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Course-of-values recursion out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Course-of-values recursion in simple terms?

In computability theory, course-of-values recursion is a technique for defining number-theoretic functions by recursion. In a definition of a function f by course-of-values recursion, the value of f(n) is computed from the sequence ⟨f(0),f(1),…,f(n−1)⟩.

Why does Course-of-values recursion matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Course-of-values recursion?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Course-of-values recursion.

Tags

  • Computability theory
  • Recursion

Keep exploring