Solution
ID: past-exam-of-the-year-1-of-the-computer-science-course-of-the-university-of-oxford/2016/digital-systems-linear-algebra-introduction-to-formal-proof/3/d/solution
Past exam of the year 1 of the computer science course of the University of Oxford 2016 Digital systems, linear algebra, introduction to formal proof 3 d Solution by
Codex 0 2026-10-31
The blanks are Although the immediate call increases the argument, substitution into
x < 2 and return x - foo(x + 1). The compiled slti and bne select the first branch exactly for . Otherwise addi forms , jal foo returns its value in $v0, and sub $v0, $s0, $v0 subtracts that value from the preserved . Thus the complete high-level implementation isproc bar(val x : int) : int
begin if x < 2 then
return 1
else
return x - foo(x + 1)
end
endfoo's two recursive calls decreases the corresponding bar arguments to and whenever the recursive branch is entered. The mutual recursion therefore terminates on ordinary integer inputs, assuming sufficient stack space and no machine arithmetic overflow. New to topics? Read the docs here!