Past exam of the mathematics course of the University of Cambridge 2007 iii Paper 26 5 Solution Created 2026-10-03 Updated 2026-10-14
Let be nonempty first-order structures in one language and let be an ultrafilter on . In the ultraproduct , identify functions when , interpret functions coordinatewise and relations by their coordinate truth sets. The Łoś theorem states that for every first-order formula ,All interpretations are independent of representatives: changing finitely many arguments on -small sets changes truth only on their finite union, also -small.
Prove the theorem by structural induction on formulas. Terms evaluate coordinatewise by induction on terms. This proves the atomic cases of logical equality and relation symbols. For conjunction, intersect the two truth sets and use the filter laws. For negation, the truth set is complemented, and an ultrafilter contains exactly one of a set and its complement. These cases supply the other Boolean connectives too.
For the existential step, a witness in the ultraproduct makes the coordinate truth set for belong to by the induction hypothesis. That set is contained in the coordinate truth set of , so the latter is in . Conversely, if that existential truth set belongs to , choose a witness in for each , and any element of elsewhere. The axiom of choice supplies this function. The induction hypothesis makes a witness in the ultraproduct. Universal quantification follows by negation. This completes the proof.
For the compactness theorem, take to be the set of finite subsets of the given theory . For each , choose . For , the cone is nonempty, and any finite intersection of such cones contains their union as an index. Extend the filter they generate to an ultrafilter . By the proved Łoś theorem, the ultraproduct satisfies every , because its coordinate truth set contains . Thus . This proves compactness without assuming it in the ultraproduct construction.
Past exam of the mathematics course of the University of Cambridge 2010 iii Paper 20 1 Solution Created 2026-10-03 Updated 2026-10-14
The printed arrow is a partial-function arrow. Thus the central objects are partial computable functions , with total computable functions as the special case in which every input has an output. Here includes zero; changing this convention by a computable shift changes none of the results. A program computing must halt with output exactly on its domain, and run forever elsewhere. A finite program is a function in intension, whereas its possibly partial input-output map is a function in extension; many programs have the same extension.
A precise machine model is a register machine with finitely many instructions to increment a register, decrement it conditionally, jump, and halt. Registers hold natural numbers. A Turing machine instead uses a finite transition table, a finite alphabet and an unbounded tape. These models simulate one another: encode the finite nonblank tape, state and head position as numbers for the register simulation; conversely represent each register by a finite tape block and implement its increment and decrement by finite scans. Tuple inputs can be encoded by a primitive recursive pairing function. The equivalence of these formal models is a mathematical result. Their identification with every informal effective procedure is the Church–Turing thesis, rather than an additional mathematical theorem about an already formal notion.
There is also an algebraic description. Begin with zero, successor and projections, close under composition of partial functions and primitive recursion, and then under unbounded minimization. The primitive recursion scheme isApplied within the primitive recursive class it produces only total functions, by mathematical induction on . Unbounded minimization searches for the first zero of ; its output is defined only if that search reaches such a zero with every preceding necessary computation defined. Composition is likewise strict about the intermediate values it requires. These schemes compile into machine programs using finite subroutines, loops and an unbounded search loop.
For the converse, encode a machine's finite configurations and finite computation histories using Gödel numbering. Testing that a history starts with the specified input, that every adjacent pair follows the transition table, and that its final configuration halts is primitive recursive: all the tests are bounded by the finite code. Extracting the final output is primitive recursive too. For a suitable checking predicate and output decoder this proves the Kleene normal form theorem:The symbol means equality of values and of definedness. A halting computation has a passing history code and every passing history has its actual output; a nonhalting computation has none. This proves that the partial recursive and machine-computable functions coincide, including their domains of divergence.
Finite programs can be effectively listed. Simulating the program with index gives a universal partial computable function . Fixing some inputs is effective syntactically: prepend instructions writing those constants and then call the original program. This proves the S-m-n theorem in this machine presentation. In particular, reductions that construct a program from numerical parameters really do produce its index effectively.
The primitive recursive functions are a proper subclass of the total computable functions. Enumerate all valid unary primitive recursive descriptions, interpreting invalid descriptions as zero. Evaluating any fixed valid description terminates by structural induction. Thus the diagonal map is total and computable, but cannot be one of the enumerated primitive recursive maps, since . This is a total computable diagonal over primitive recursive syntax. The evaluator can terminate on every particular description without itself being primitive recursive.
In contrast, one cannot effectively enumerate exactly the programs for all total computable functions. If such an infinite enumeration were available, wait for its th program and run it on , then add one. Totality makes this another total computable function, while its diagonal disagrees with every listed function. Equivalently, there is no total computable universal evaluator listing precisely all total computable maps.
The halting problem is undecidable. If decided whether program halts on , construct a program which halts on input exactly when says that it does not halt. Taking to be 's own index gives a contradiction. The halting relation is nevertheless computably enumerable, since finite halting histories can be searched for.
More generally, a set is computably enumerable exactly when it is the domain of a partial computable function. From an enumeration, halt on when appears; in the other direction use dovetailing over all inputs of a partial program to enumerate its halting inputs. A set is a computable set exactly when both it and its complement are computably enumerable: dovetail the two searches and return the answer from the one that succeeds. Neither a semidecision procedure nor an unbounded search supplies a uniform negative answer.
Finally, the Rice theorem explains the scope of this obstruction. Let be a nontrivial property of the extension of a partial computable program. Choose a partial computable whose -status differs from that of the nowhere-defined function. Given a program and input , effectively form the program which, on , first waits for to halt and then computes . If never halts its extension is nowhere defined; otherwise its extension is . A decision procedure for would therefore decide the halting problem. Effective descriptions allow universal simulation and positive verification, but not a decision procedure for every semantic property or for termination.
Past exam of the mathematics course of the University of Cambridge 2010 iii Paper 20 3 Solution Created 2026-10-03 Updated 2026-10-14
Here and throughout, a filter on a set is proper: it contains the whole underlying set, excludes the empty set, and is upward closed and closed under finite intersections. An improper filter cannot be extended to a proper ultrafilter.
Order the proper filter extensions of by inclusion. The union of a chain is again a proper filter on a set: any two members already occur in one member of the chain, where their intersection belongs; the empty set never appears. By Zorn lemma, take a maximal proper extension . If , adjoining must make the generated filter improper, so some has . Upward closure then gives . Exactly one of belongs to , proving the ultrafilter lemma.
Let be nonempty structures for a common first-order language, and let be an ultrafilter on the index set . In the ultraproduct , identify functions when ; interpret function symbols coordinatewise and relations by membership of their coordinate truth sets in . The Łoś theorem states, for every first-order formula ,Changing representatives changes a coordinate truth set only outside a member of , so the definitions are well defined.
Prove the theorem by structural induction on formulas. An induction on terms gives , and therefore the required equivalence for atomic equality and relation formulas. For conjunction the truth set is an intersection, and a finite intersection belongs to a proper filter on a set exactly when each constituent does. For negation it is a complement, and the ultrafilter decides exactly one of a set and its complement. These prove the Boolean induction steps.
For the existential step, a witness in gives, by induction, a member of on which holds. It is contained in the coordinate existential truth set, so that set belongs to . Conversely, ifchoose a coordinate witness for , and any element of the nonempty factor otherwise. Then the truth set of contains . Induction gives a witness in the ultraproduct. Universal quantification follows from negation and existence. This completes the actual proof of the Łoś theorem.
For the compactness theorem, take to be the set of finite subsets of , and choose a model of each such subset. The conesare nonempty and satisfy . They generate a proper filter on a set, which extends to an ultrafilter by the proved lemma. For every , the coordinate truth set of contains . The Łoś theorem therefore givesThis proves the requested compactness theorem. In fact the same proof works without the countability restriction on the language.
Past exam of the mathematics course of the University of Cambridge 2017 iii Paper 135 5 Solution Created 2026-10-03 Updated 2026-10-05
Use the Gödel-Gentzen negative translation, writing for the translated first-order formula. On atomic formulas , including logical equality, put , and put . Extend recursively byLogical negation abbreviates logical implication to logical falsity, so . The displayed logical disjunction and existential clauses are intuitionistically equivalent to the usual negative clauses and , respectively. Thus these clauses specify the same negative interpretation. Translation commutes with capture-avoiding substitution of terms for free variables.
First prove by structural induction the stability of a formula under double negation:Every double logical negation is stable, since intuitionistic first-order logic proves ; logical falsity is stable as well. Stability passes to logical conjunction by obtaining double logical negation of each component. For a logical implication with stable , assume and . An assumption would give , a contradiction, so and then . For a universal first-order formula, implies for arbitrary fresh ; use stability pointwise and generalize. Logical disjunction and existential translations are already double negations. This proves all cases.
Now regard classical first-order natural deduction as intuitionistic natural deduction plus unrestricted double-negation elimination, and induct on a classical derivation. The rules for logical conjunction, logical implication, universal quantification and logical falsity translate directly. Logical disjunction introduction gives and then its double logical negation. For logical disjunction elimination, the translated premise is and the two translated branches yield the stable conclusion . Assuming makes each branch contradictory, giving and , hence , which contradicts the premise. We have and remove it by stability.
Existential introduction likewise adds a double logical negation to the ordinary witness introduction. In existential elimination, the witness branch has the original fresh-variable condition. Assuming makes that branch give ; generalization gives and therefore , contradicting the translated premise. Again stability supplies . The universal-rule side conditions are preserved because the translation introduces no new free variables.
For logical equality, reflexivity gives and then its double logical negation. For substitution, from and , temporarily assume . An assumption would transport to by intuitionistic logical equality substitution, so it gives a contradiction and hence . The first premise contradicts this. Thus holds and stability gives . Finally a classical double-negation elimination step translates precisely to , already proved. Every rule is therefore covered, giving negative translation of a classical proof:In particular a classical thesis has an intuitionistic, constructive translated proof. If nonlogical assumptions are present, they must be translated too.
In classical logic, double-negation elimination gives on atoms. Structural induction propagates equivalence through logical conjunction, logical implication and both quantifiers, and removes the added double negations on logical disjunction and existence. Therefore
Past exam of the mathematics course of the University of Cambridge 2017 iii Paper 135 6 Solution Created 2026-10-03 Updated 2026-10-05
Use untyped lambda calculus and normal-order beta reduction. Write for the Church numeral of . We will construct a closed term such thatwhen is defined, and with no head normal form otherwise. The latter condition implies that the result is not in beta equivalence with any Church numeral, so both definedness and the output are represented.
First represent all total primitive recursive functions. The zero function is , the successor function isand the th projection function is . Function composition in recursion theory is represented by . This composition claim is used here for total functions, whose inner terms all reduce to numerals.
For primitive recursion use Church pairs and iteration. PutSuppose represent the total constituents of and . DefineAfter iterations the pair reduces to , by mathematical induction on . Its second projection is the required result. This lambda definition of primitive recursion by pair iteration and structural induction on the primitive recursive construction give terms for all primitive recursive functions.
For an arbitrary partial computable function use the Kleene normal form theorem with its program index fixed. There are total primitive recursive functions and such that is zero exactly when codes a valid halting computation history on , and extracts that history's output. Checking finite coded configurations and each transition is primitive recursive. Determinism ensures that every accepted history on an input has the same output. HenceIf the input computation never halts, no history is accepted. Let be the total numeral-representing terms already obtained. The Church numeral zero test is , returning exactly on zero. A Church Boolean applied to two arguments selects the appropriate branch without evaluating the other.
Take the fixed-point combinator . For the input tuple defineExpanding the displayed abbreviations gives a genuine finite combinator. At a numeral code , the total predicate computation terminates. If it returns a positive numeral, the false Church Boolean selects the next search code. If it returns zero, the true Church Boolean selects , which reduces to the output numeral. If the least accepted code is , a finite sequence of these tests reaches it and then produces .
If there is no accepted code, every test is false and head reduction moves through codes forever. At no finite point can a head variable or an outer numeral abstraction be produced: the applied search term must first unfold the fixed point and evaluate the next total test, and the decoder branch is always discarded. Thus it has no head normal form. The standard head-normalization property, or the Church-Rosser theorem together with normalization of normal-order reduction, rules out beta equivalence to a numeral. In particular, we have avoided a lazy-composition pitfall: an outer function that discards an argument need not force a divergent inner computation. The decoder is reached only after the guarded search succeeds. This proves lambda representation of partial computable functions:
Past exam of the mathematics course of the University of Cambridge 2018 iii Paper 135 1 Solution Created 2026-10-03 Updated 2026-10-05
A proper filter on a set contains , excludes , is upward closed, and is closed under finite intersections. Order its proper extensions by inclusion. The union of a nonempty chain is again a proper filter: finitely many members lie together in one chain member. Zorn lemma, and hence the axiom of choice, gives a maximal extension . If neither nor belongs to , maximality of says adjoining either one produces the improper filter. There are therefore with and , contradicting . Thus is an ultrafilter.
For Łoś theorem, interpret the ultraproduct using when , with functions and relations interpreted coordinatewise. These interpretations are well defined because changing finitely many argument representatives changes them only outside the intersection of their agreement sets, which belongs to . For any first-order formula and sequences of parameters,Prove this by structural induction. Atomic formulas follow from the interpretation of terms. Conjunction uses finite intersections; negation uses the ultrafilter dichotomy between a set and its complement. If holds in the ultraproduct, a witness sequence gives a subset of in . Conversely, choose a witness for in every factor where one exists, and an arbitrary element in every other factor. This is the second explicit use of the axiom of choice; all factors have nonempty carriers. The inductive hypothesis applied to supplies the ultraproduct witness. The other connectives and universal quantification follow from these cases.
For the possible worlds, use free filters, equivalently proper filters extending the cofinite filter . Here “nonprincipal” must have this free-filter meaning: merely saying that a filter has no single generating subset need not make an accessible least world. The designated world is , and all worlds have carrier . Atoms, including equality, are forced byEquality may identify distinct sequences at a world; it is a persistent congruence, and at an ultrafilter world its quotient is the ordinary ultraproduct.
The required equivalence with all ultraproducts uses dense-extension filter semantics. Its recursive clauses areEvery extension in these clauses is a free proper filter. The dense clause for disjunction is essential; for propositional formulas, local disjunction would instead give a Kripke model for intuitionistic propositional logic and would invalidate the claimed equivalence.
The useful separation fact is membership in a free filter is detected by its ultrafilter extensions:Indeed, if , every has infinite intersection with : a finite intersection would imply after intersecting with a suitable cofinite set. Hence adjoining generates a free proper filter, which extends to a nonprincipal ultrafilter by the ultrafilter lemma.
Induction on formulas now gives . Negation and implication follow by adjoining the positive set on which their classical truth conditions fail. For disjunction, membership of lets every extension be refined to an ultrafilter containing one of the two sets. If that union is absent from , an ultrafilter extending contains its complement and has no further proper extension, contradicting the dense clause. For existence, choose coordinate witnesses on as in Łoś theorem. For universality, if , choose a counterexample in every factor outside it and arbitrary elements elsewhere. The resulting sequence has , so cannot force that instance. The converse follows from upward closure and persistence.
At the designated world, therefore,This semantics validates classical first-order logic, including law of excluded middle. For example, every free filter has an ultrafilter refinement deciding an atomic formula, so its excluded middle is forced even when neither disjunct is forced at the original world. To see concretely why local disjunction fails, take and an atom true exactly at even indices: neither its truth set nor its complement is cofinite, although every ultraproduct satisfies its excluded middle.
Past exam of the mathematics course of the University of Cambridge 2019 ii Paper 1 16I Solution Created 2026-09-24 Updated 2026-09-29
The completeness theorem for propositional logic states that for every set of formulae and formula ,With the soundness theorem for propositional logic, this is an equivalence. It is also equivalent to saying that every consistent set of formulae has a model.
The usual countable proof lists all formulae and extends a consistent theory one formula at a time. For an uncountable set of primitive propositions, use the uncountable-language proof of propositional completeness: order the consistent extensions of by inclusion. The union of every chain is consistent, since a proof of a contradiction would use only finitely many assumptions and hence would already lie in one member of the chain. Zorn lemma gives a maximal consistent set in propositional logic . Define a Boolean valuation by exactly when . The usual structural induction on formulae proves the truth lemmaso is a model of .
The propositional compactness theorem says that a set is satisfiable if and only if every finite subset of is satisfiable. Only the forward implication is immediate. For the converse, if had no model, then , so completeness would give . Every formal proof uses finitely many assumptions, so some finite would prove and, by soundness, would have no model, a contradiction.
The decidability theorem for propositional logic says that there is an algorithm deciding whether a propositional formula is a theorem. A formula contains only finitely many primitive propositions, even when the full language is uncountable. Its finite truth table decides whether it is valid, and completeness says that validity is equivalent to theoremhood.
Now let be the given partially ordered set. For every distinct , introduce propositions and . Form a propositional theory containing the following clauses:
- and for distinct ;
- and for pairwise distinct ;
- and whenever in the original order;
- and whenever and are incomparable in the original order.
The first two families say that and encode strict total orders. The third makes both orders extend , while the fourth makes them disagree on every incomparable pair.
Every finite subset mentions only a finite subset . By hypothesis, the induced order on is a two-dimensional poset, so choose two total orders realizing it and assign the finitely many and variables accordingly. This satisfies . Thus every finite subset of is satisfiable, and propositional compactness gives a model of all of .
Define when is true and when is true. The clauses make and total orders on . They both contain the original order, and their intersection contains no incomparable pair. Hencewhich proves the finite-local characterization of two-dimensional partially ordered sets.
Past exam of the mathematics course of the University of Cambridge 2021 ii Paper 1 12F iii Solution Created 2026-09-24 Updated 2026-09-25
Let , where is the total primitive-recursive parity function from part (ii), and apply unbounded minimization in :If is even, then and . If is odd, then for every , so the search never terminates and is undefined. Hence is partial recursive. Because every function built without minimization is total, cannot be defined without minimization; the functions and can.
It remains to characterize the functions built using only the initial functions and composition. They are exactly the functionsfor some and some input coordinate .
Indeed, the zero function is the first form, the successor function and each projection function have the second form, and composing functions of these forms preserves the classification: a constant outer function remains constant, while an outer function selects one inner function and adds . This proves necessity by structural induction. Conversely, applying the successor function times to zero produces the constant , and applying it times to produces .
Every function in this class is directly computable: an algorithm either writes the fixed constant , or copies the th input and performs successor steps.
Past exam of the mathematics course of the University of Cambridge 2023 iii Paper 124 5 ii Solution 2026-09-28
Proceed by structural induction on a Boolean formula . A leaf computes or , so its measure is , equal to its leaf count. If the root is an AND gate with subformulae computing , thenby property 2; the induction hypothesis bounds this by the sum of the two subformula sizes, which is the size of . Property 3 gives the identical argument for an OR gate. Consequently every formula computing has size at least , so is a formula-size lower bound.
For a structure in a countable language and any subset of its domain, there is an elementary substructure containing of cardinality at most . In particular a finite or countable lies in a countable elementary substructure. This is the downward Löwenheim-Skolem theorem.
Construct it directly inside the given structure . Start with containing , the interpretations of the constants, and one element if needed to ensure a nonempty domain. Given , for every formula with its finite parameter tuple from that is true in , choose one actual witness in and place it in . Retain as well. There are at most choices at each stage. Let .
The construction closes under every function of the language: for a tuple in , the formula forces its unique value into the next stage. Thus carries the induced substructure, and it has the asserted cardinal bound.
Prove elementarity by structural induction. Atomic formulas agree by the induced-substructure construction; logical connectives preserve agreement. For an existential formula with parameters in , if it is true in , all its parameters occur in some , so the chosen witness lies in . The induction hypothesis makes its matrix true in . In the other direction a witness in is also a witness in , again by induction. This is the Tarski-Vaught test, with its witness argument proved explicitly. No completeness or compactness theorem theorem enters the construction.
A context-free grammar with start symbol , terminal alphabet , and the following productions generates all binary palindromes:Each production preserves the palindrome property: it either supplies a central string of length zero or one, or wraps the same symbol around a shorter palindrome. This proves soundness by structural induction on the parse tree.
Conversely, any palindrome of length at least two has equal first and last symbols. Remove them to obtain a shorter palindrome, apply mathematical induction on length, and then use the corresponding wrapping production. The three base cases are , , and , proving completeness.
Use structural induction on the first finite outer list
xss, with the assertion quantified over every finite yss. For xss = [], both sides are []. For the nonempty case of structural induction, write xss = xs:xss'. If yss = [], both sides again truncate to []. Otherwise write yss = ys:yss'. Expanding the definitions givesThe second equality uses the defining equation for list concatenation and the induction hypothesis for the smaller outer list xss'. The argument covers unequal outer lengths because the empty second list was handled explicitly. HenceIn a preorder traversal, visit the root before the left subtree, then visit the right subtree. The
NIL test prevents visiting or dereferencing an empty binary tree:PROCEDURE preorder(t : node);
BEGIN
IF t # NIL THEN
visit(t);
preorder(t.left);
preorder(t.right)
END
END preorder;Structural induction proves correctness. The empty binary tree has nothing to visit. For a nonempty root,
visit(t) comes first; by the induction hypothesis, each recursive call visits exactly its own subtree in preorder traversal order, and the left call finishes before the right begins. Each recursive call receives a strictly smaller finite tree, proving termination. Assuming visit neither changes the child links nor fails to return, the procedure therefore realizesFor nodes, overhead is and recursion depth is for height , in addition to the cost of visit. The claim presumes an actual binary tree; cycles or shared nodes in an arbitrary pointer graph need additional handling if each object is to be visited exactly once.Use structural induction on the finite list
xs, strengthening the induction hypothesis to hold for every accumulator value . For the empty list, the defining equation of the left fold givesFor the inductive step, suppose the identity holds for the tail zs and every accumulator. Expand the first left fold, apply the induction hypothesis at accumulator , and then use the supplied compatibility law:HenceOnly equation (1) is needed for this part; the seed condition in equation (2) enters the next proof. Quantifying over the accumulator is essential because the recursive call changes it.Again use structural induction on the finite list. At
[], both the right fold and the left fold return the seed . If they agree on zs, thenThe third line uses part (a); the fourth uses equation (2). Thus the left-right fold equivalence isThis is a statement about values on finite, total inputs. It does not assert equal evaluation costs or equal behaviour on infinite lists.Use the empty list for an empty subtree, and join the left result, the current label and the right result:
flatten :: STree a -> [a]
flatten = foldSTree (\left x right -> left ++ (x : right)) []Thus . This is an inorder traversal. By structural induction, each subtree produces its labels in order; the binary search tree invariant places every left label below and every right label above , proving that the whole result is increasing. The definition works for any binary-tree shape, although its result is sorted only when the ordering invariant holds. Repeated list concatenation can give quadratic cost on a left chain; the question asks for a tree fold definition, rather than an optimal traversal implementation.
Search as for insertion. Removing a node with at most one nonempty child leaves that child in its place. With two children, use the smallest key in the right subtree as the replacement and remove that occurrence from the right subtree:
delete :: Ord a => a -> STree a -> STree a
delete _ Empty = Empty
delete y (Node left x right) =
case compare y x of
LT -> Node (delete y left) x right
GT -> Node left x (delete y right)
EQ -> join left right
where
-- Join two search trees with every left key below every right key.
join :: STree a -> STree a -> STree a
join Empty r = r
join l Empty = l
join l r = let (smallest, rest) = takeMin r
in Node l smallest rest
-- Precondition: the input tree is nonempty.
takeMin :: STree a -> (a, STree a)
takeMin Empty = error "takeMin: empty tree"
takeMin (Node Empty x right) = (x, right)
takeMin (Node left x right) =
let (smallest, rest) = takeMin left
in (smallest, Node rest x right)The call to
takeMin occurs only after both empty cases have been excluded. Its structural recursion follows left children until it reaches the minimum label and rebuilds the path with that occurrence removed.For a matching label and successor , all left labels are below , while every label remaining on the right is strictly above . Thus replacing by preserves the binary search tree invariant. Every other branch preserves the invariant by structural induction. The resulting set is exactlyWhether the key is absent or present, untouched subtrees can be shared. The search path followed by the successor path uses time and fresh nodes for original height of a binary tree , so the worst case is without balancing. This is persistent binary search tree deletion: the original value remains available.
The two constructors encode a natural number by its number of successors. Structural recursion replaces the zero constructor by zero and every successor by one addition:
convert :: Natural -> Integer
convert Zero = 0
convert (Succ n) = 1 + convert nStructural induction gives . The output uses unbounded integers, so there is no machine-word overflow.
Recurse on the first argument for addition and multiplication, and on the exponent for exponentiation:
add :: Natural -> Natural -> Natural
add Zero n = n
add (Succ m) n = Succ (add m n)
mul :: Natural -> Natural -> Natural
mul Zero n = Zero
mul (Succ m) n = add n (mul m n)
power :: Natural -> Natural -> Natural
power m Zero = Succ Zero
power m (Succ n) = mul m (power m n)The defining arithmetic identities areEach recursive call consumes one constructor. The base of exponentiation makes
power Zero Zero equal to one, the empty-product convention. Applying convert and using structural induction verifies all three operations.Let . The equations derived in part (e) become and , where . Replacing zero and successor by that seed and step is exactly a natural-number fold:
twoFibsNat :: Natural -> (Integer, Integer)
twoFibsNat = foldNat step (0, 1)
where
step :: (Integer, Integer) -> (Integer, Integer)
step (a, b) = (b, a + b)
fibNat :: Natural -> Integer
fibNat = fst . twoFibsNatConsequentlyStructural induction follows the constructors of
Natural: the seed gives the first two Fibonacci numbers, and the successor step uses the Fibonacci recurrence. The extra component carries exactly the information needed for the next update.