Lectures onType Theory
ch:well-founded-recursion: ch:well-founded-recursion
appendix sectionsolutions

ch:well-founded-recursion: ch:well-founded-recursion

Exercise 82.1.

Fix q:aRa. Define F:AccR(a)0 by structural induction on its accessibility-certificate argument. In its sole case, F(acca(h)):=F(haq). The displayed recursive call is on the immediate accessibility proof haq:AccR(a) stored by the constructor. Thus a hypothetical p:AccR(a) gives F(p):0. This is the proof-dependent eliminator of definition 82.4, with a motive over the certificate at the fixed index a. Its nondependent specialization with P(x):=0 would demand a step producing 0 at every x:A; the single proof q:aRa cannot supply those other cases. The construction does not inspect or decide R; it uses q only at the fixed index.

Exercise 82.2.

Define ρ(a,b)=μ(a)+ν(b). If μ(a)<μ(a) and ν(b)<ν(b), monotonicity and transitivity of addition give ρ(a,b)=definitionμ(a)+ν(b)<monotonicity in the left summandμ(a)+ν(b)<monotonicity in the right summandμ(a)+ν(b)=definitionρ(a,b). Hence the relation is contained in <ρ and is well founded by theorem 82.14: an accessibility proof for the larger measure relation restricts to one for the smaller relation. It is also contained in the lexicographic relation because its first coordinate decreases. The containment can be strict: a lexicographic predecessor may decrease μ while increasing ν, whereas the relation in the exercise requires both coordinates to decrease.

Exercise 82.3.

The complete calculation is gcd(1071,462)=1071rem462=147<462gcd(462,147)=462rem147=21<147gcd(147,21)=147rem21=0<21gcd(21,0)=theorem82.2021. Thus the second-coordinate measure sequence is 462>147>21>0.

Exercise 82.4.

Partitioning the tail gives |l|+|r|=|xs|. Therefore |l||xs|<suc(|xs|)=|p::xs|,|r||xs|<|p::xs|. These are the two certificates for the recursive calls on l and r. If the pivot is not removed and the partition equation instead accounts for the entire input, one side may have the full input length and the other length zero. The equation then yields only a non-strict inequality for that side, so it cannot justify the corresponding recursive call.

Exercise 82.5.

For pacca(h), the constructor field has type h:b:AbRaAccR(b). The induction hypothesis applied to hbr gives a result in P(b). After abstraction, the step receives k:=λb.λr.accindP(s,b,hbr):b:AbRaP(b). Taking P(a):=N gives s(a,k):N, and the constructor computation rule is wfrecR,P(s,a,acca(h))s(a,λb.λr.wfrecR,P(s,b,hbr)). Every recursive call is therefore indexed by both a predecessor b and its proof r:bRa.

Exercise 82.6.

Put (a,b,c)<(a,b,c) when either aRa, or a=a and bSb, or a=a, b=b, and cTc. Induct first on the R-accessibility of a, with all b,c quantified. Inside that case, induct on the S-accessibility of b, with all c quantified; inside that case, induct on the T-accessibility of c. For a predecessor, the first disjunct uses the outer induction hypothesis and leaves b,c unrestricted. The second uses the middle hypothesis and leaves c unrestricted after transporting along a=a. The third uses the inner hypothesis after transporting along a=a and b=b. These three clauses form the predecessor function for acc(a,b,c).

Search the book

Type to search the local edition.