Lectures onType Theory
Chapter 124
Chapter 124Core route

Corecursive Definitions, Copatterns, and Productivity

No finite constructor value is the stream 0,1,2,. The equations head(from(n))=n,tail(from(n))=from(sucn) nevertheless answer every finite sequence of observations. A termination checker rejects the recursive call because sucn is larger than n. The relevant invariant is instead that each demanded observation is produced after finitely many definition steps.

Streams are observed, not constructed

Definition 124.1 — The Timpl-co system card

Timpl-co extends Timpl by the coinductive record Stream(A):Ui,head:Stream(A)A,tail:Stream(A)Stream(A). and by declarations made of the two copattern equations head(fx)=eh and tail(fx)=et, whose right sides are generated by eh::=thead(gu),et::=gu. One finite group is type homogeneous: in a common ambient context it fixes one A:Ui, and every declaration has type fj:(Δj)Stream(A). Declarations returning streams with different element types belong to separate groups, even when their call graph is disconnected. If δco(fj)=(Δj;eh,j;et,j), acceptance checks Γ0,Δjeh,j:A,Γ0,Δjet,j:Stream(A), in addition to the guardedness conditions below. Here g ranges over the declarations of the group, and t and every u are Timpl terms over x containing no declaration of the group. Every argument binder retains the inherited Timpl relevance mark of definition 121.5; the displayed Δj suppresses those superscripts. These marks control source evaluation and precede the erasure admissibility test: they do not by themselves select a target representation. Argument telescopes are Timpl telescopes, so no declared argument is itself a stream, and only calls among declarations in the same finite group are corecursive. Call a head right side of the first form a producer, one of the second form a head alias, and a tail right side a tail step. No deeper destructor above a group call is inside the card; remark 124.7 shows what the criterion below would cost if one were admitted.

Evaluation is weak-head and observation driven. It unfolds a definition only after a head or tail destructor reaches that definition. The guardedness checker records how many tail observations are discharged before each mutual call. The target is the primitive stream coiterator with the same two coprojection computation rules. No normalization theorem for streams, sized type, coinductive family, effect, clock, or arbitrary record corecursor is added. The elaboration may generate a finite nonrecursive state datatype accepted by Timpl-data; that signature declaration is program data and adds no rule to the target calculus.

Definition 124.2 — Source stream declaration dynamics

The operational delta has two explicit layers and hides no source evaluation judgment. Let Σ be the accepted group-free signature: Timpl together with the finite nonrecursive Timpl-data blocks used by the group and by its generated state. Extend the NbE normalizer of definition 49.37, theorem 111.76 with one semantic constructor and one readback clause for each constructor of those blocks, and with the generated Block-comp clause for each eliminator. Because no generated block is recursive, this extension is ordered by declaration order and introduces no semantic fixed point. Write the resulting typed normalizer as nfΣ,ΓA.

The accepted group-free subevaluation is the normalizer interface itself. For a closed group-free t:A and a typed normal form n:A, define tTnn=nfΣ,A(t). Thus every premise carrying T below asks for the unique typed βη-long normal form. It does not ask for a separately chosen weak evaluation strategy.

An implementation may compute that normal form in two stages. The first stage is the least call-by-value relation tT,cbvv displayed below; the second applies nf to v. This relation is an implementation layer and never defines preparation or a stream rule. Its values are lambdas under either relevance mark, pairs of values, reflexivity values, and primitive or declared constructors whose runtime fields are values and whose erased fields remain checked static syntax. If constructor field i has inherited mark κi, let a^i=vi when κi=runtime and aiT,cbvvi, and let a^i=ai when κi=erased. Values, applications, pairs, projections, declared constructors, and generated cases use XvT,cbvvTVal fT,cbvλϵ,runtime(x:A).baT,cbvvab[va/x]T,cbvvfϵ,runtimeaT,cbvvTAppR fT,cbvλϵ,erased(x:A).bb[a/x]T,cbvvfϵ,erasedaT,cbvvTAppE. aT,cbvvabT,cbvvb(a,b)T,cbv(va,vb)TPair sT,cbv(va,vb)pr1(s)T,cbvvaTFstsT,cbv(va,vb)pr2(s)T,cbvvbTSnd. (aiT,cbvvi)κi=runtimec(a1,,an)T,cbvc(a^1,,a^n)TCon eT,cbvck(a^)ek[a^/xk]T,cbvvcase e of {cj(xj)ej}jT,cbvvTCase. The primitive eliminators have their own instances: bT,cbvttetT,cbvvind2(x.C;et,ef,b)T,cbvvTBoolT bT,cbvffefT,cbvvind2(x.C;et,ef,b)T,cbvvTBoolF. Abbreviate NC(e0,es;m):=IC(e0;nϱn.rϱr.es;m). Then mT,cbv0e0T,cbvvNC(e0,es;m)T,cbvvTNatZ mT,cbvsuc(vn)NC(e0,es;vn)T,cbvvres[vn/n,vr/r]T,cbvvNC(e0,es;m)T,cbvvTNatS. Identity elimination and the two vector branches are eqT,cbvreflvqer[a/z]T,cbvvJA;a;b(x.y.p.C;zϱz.er;eq)T,cbvvTJ, mT,cbv0ysT,cbvvnile0T,cbvvvind(P;e0;nϱn.aϱa.xs.rϱr.es;m,ys)T,cbvvTVecNil mT,cbvsuc(vn)ysT,cbvvcons(vn,va,vxs)vind(P;e0;nϱn.aϱa.xs.rϱr.es;vn,vxs)T,cbvvres[vn/n,va/a,vxs/xs,vr/r]T,cbvvvind(P;e0;nϱn.aϱa.xs.rϱr.es;m,ys)T,cbvvTVecCons. There is no named-recursion rule in either interface: the group-free signature fixed above is Timpl plus nonrecursive Timpl-data blocks. A neutral or mismatched scrutinee has no CBV implementation rule. Define a preparation function from the inherited relevance marks by recursion on a dependent telescope: prep()=,prepΔ,xruntime:A(a,b)=(v,w)if prepΔ(a)=v and b[v/x]Tw,prepΔ,xerased:A(a,b)=(v,n)if prepΔ(a)=v and n=nfΣ,A[v/x](b[v/x]). A runtime component is normalized as demanded subevaluation. An erased component is canonicalized by the same typed normalizer at preparation time; it is never forced by an operational CBV frame. Thus every prepared component is a typed normal form, while the inherited mark still records which components survive runtime erasure. This preparation is not the erasure judgment that selects a target representation. The coinductive declarations add the following three rules and no eager unfolding rule for a bare stream call: δco(fi)=(Δi;t;et)prepΔi(a)=avt[av/x]Tvhead(fia)vCoHeadProducer, δco(fi)=(Δi;head(gu);et)prepΔi(a)=avprepΔg(u[av/x])=bhead(gb)vhead(fia)vCoHeadAlias, δco(fi)=(Δi;eh;gu)prepΔi(a)=avprepΔg(u[av/x])=btail(fia)gbCoTailUnfold. The first rule delegates only the group-free producer to the extended NbE subevaluation. The second follows one head-alias edge after preparing its group-free arguments. The third exposes one tail step with prepared arguments and stops, so a later observation controls whether the resulting stream call is unfolded again. Erased arguments are normalized statically, not forced by a runtime frame.

Lemma 124.3 — Group-free normalization and evaluation interface

For every accepted group-free signature Σ and Γe:A:

  1. nfΣ,ΓA(e) is total, well typed, and unique;

  2. enfΣ,ΓA(e) (soundness);

  3. for any Γe:A, eenfΣ,ΓA(e)=nfΣ,ΓA(e) up to α-equality (completeness);

  4. every typed normal form is fixed by nfΣ,ΓA (stability);

  5. if θ,θ:ΓΓ are well-typed substitutions with judgmentally equal corresponding components, write Aθ for A[θ] and convert e[θ] along A[θ]Aθ. Then nfΣ,ΓAθ(e[θ])=nfΣ,ΓAθ(e[θ]).

Consequently, for every closed well-typed e:A, there is exactly one typed normal form n:A with eTn, and eTn(en and n is normal). The optional implementation layer is deterministic on closed typed terms. If eT,cbvv, then ev,nf(e)=nf(v),eTnf(v).

Proof of Lemma 124.3 — Group-free normalization and evaluation interface

Proof. Induct on the declaration order of Σ. The empty extension is theorem 111.76, lemma 111.77. For one nonrecursive Timpl-data block, extend the semantic domain by disjoint constructor tags carrying the semantic interpretations of their already interpreted fields. Evaluation of an introduction returns that tag. Evaluation of its eliminator inspects the tag and applies the corresponding generated method; this is exactly Block-comp. A neutral scrutinee is reflected as a stuck eliminator, and readback reconstructs it. Structural induction on the finite constructor telescope proves that evaluation and readback are functional. The proof of the fundamental lemma gains precisely the introduction, neutral-elimination, and Block-comp cases just described; none recurses through the new family. The escape argument therefore gives typing and soundness, the semantic equality argument gives completeness, and induction on normal forms gives stability, exactly as in theorem 111.76, lemma 111.77. The same declaration-order induction proves definedness of the new semantic operations: every Block-comp clause consumes a constructor tag from the block being interpreted and invokes methods over previously interpreted field types, so no semantic call returns to the new family.

For item 5, ordinary substitution gives e[θ]e[θ] from the component equations, after the displayed classifier conversion. Completeness from item 3 makes their normal forms identical.

The definition of T makes existence and uniqueness immediate from item 1. Soundness gives the forward implication of the displayed characterization. Conversely, completeness and stability show that any normal n judgmentally equal to e is the normalizer output.

For the implementation claims, first prove determinism by induction on the first T,cbv derivation and inversion of a second derivation. Disjoint value constructors select the same rule; the induction hypotheses identify each runtime premise and then the selected branch. In T-Nat-S and T-Vec-Cons, apply the hypotheses first to the scrutinee, then to the strictly smaller recursive-eliminator premise, and finally to the branch body. These are the only rules with a recursive evaluation premise.

Finally, induct on a T,cbv derivation, retaining its typing derivation, to prove ev. Rule T-Val uses reflexivity. For T-App-R, inversion gives f:x:A0ϵ,runtimeB and a:A0. The induction hypotheses and the application computation rule give facongruence(λx.b)vaΠβb[va/x]IHv. Substitution congruence for ava converts the chain from B[va/x] to B[a/x]. Rule T-App-E uses the same chain with the unchanged checked argument a. Rule T-Pair uses dependent pair congruence, converting the second induction hypothesis along the first one. Rules T-Fst and T-Snd compose scrutinee congruence with the corresponding Σ-computation equation; the second projection result is converted along congruence of first projection.

Rule T-Con uses constructor congruence on each runtime field and reflexivity on each static field. For T-Case, scrutinee congruence reaches the selected constructor, Block-comp exposes the selected branch, and simultaneous substitution congruence followed by the branch induction hypothesis reaches v. Motive conversion follows the scrutinee equality. Rules T-Bool-T and T-Bool-F are the two primitive instances.

For T-Nat-Z, combine scrutinee congruence, Nat-comp1, and the base induction hypothesis. For T-Nat-S, scrutinee congruence and Nat-comp2 expose the step body. The predecessor and recursive-result induction hypotheses justify simultaneous substitution, and the branch induction hypothesis reaches v; conversion along msuc(vn) restores the original motive. In T-J, proof soundness gives eqreflvq. Identity-value inversion gives vqab; after those conversions, Id-comp exposes er[a/z], and its induction hypothesis reaches v.

Rule T-Vec-Nil uses the index and vector induction hypotheses, Vec-comp1, and conversion along m0 and ysvnil. Rule T-Vec-Cons uses Vec-comp2; simultaneous congruence substitutes the equal predecessor, head, tail, and recursive result, while conversion along msuc(vn) and ysvcons(vn,va,vxs) restores the declared indexed motive. These cases exhaust the implementation rule card. Normalizer completeness gives nf(e)=nf(v), and the definition of T gives eTnf(v). For example, λx.((λy.y)x)T,cbvλx.((λy.y)x) by T-Val, after which the required second stage returns the NbE normal form λx.x. ◻

Lemma 124.4 — Preparation is total and unique

Let a be a closed, well-typed tuple of group-free Timpl terms for a telescope Δ. There is a unique prepared tuple av such that prepΔ(a)=av.

Proof of Lemma 124.4 — Preparation is total and unique

Proof. Induct on Δ. The empty tuple has the unique empty result. For a runtime extension, apply the induction hypothesis to the prefix, substitute its result into the last component, and use lemma 124.3 to obtain its unique typed normal form. For an erased extension, the induction hypothesis fixes the prefix and totality and uniqueness of the same typed normalizer fix the canonical static component. These are exactly the two recursive clauses of prep. ◻

The rule delta permits the opening definition. It also permits zeros, given by head(zeros)=0,tail(zeros)=zeros. It does not permit the equation head(bad)=head(bad): evaluating the first observation repeats the same demand without producing a numeral.

Definition 124.5 — Finite observations

An observation word is generated by o::=headtailo. For a closed stream term s, the partial judgment sov means that weak-head evaluation of the destructor path o terminates at the closed value v:A. Its rules are head(s)vsheadvtail(s)ssovstailov. A closed stream is productive when for every observation word o there exists a closed value v with sov.

Exercise 124.1

★☆☆ Using prepn:N(0)=(0), give the complete derivation of from(0)tailhead1. Name the source declaration rule used at each destructor and the finite-observation rule that assembles them.

For from(0), the first three words compute to from(0)head0,from(0)tailhead1,from(0)tailtailhead2. The definition never returns a complete stream value. Productivity asks only for the value at each finite word.

Mutual calls need a guard cycle condition

One guarded edge per definition is too strong. A finite chain of aliases may precede the equation that produces an observation. What must be excluded is an entire cycle of aliases.

Definition 124.6 — Guard-weighted call graph

The guard-weighted call graph of a finite Timpl-co group has one vertex per defined stream function. Every group call occurs in exactly one of the two right-side forms of definition 124.1, so the weight of an edge is total and takes only two values: a head alias head(fx)=head(gu) emits f0g, and a tail step tail(fx)=gu emits f1g. A producer emits no edge. The weight is the number of observations discharged between the demand at f and the demand it passes to g: a head alias passes the same demand, a tail step passes a demand one symbol shorter.

The judgment G guarded holds when the subgraph of zero-weight edges is acyclic. Since every weight is 0 or 1, this says equivalently that every directed cycle carries a positive-weight edge, and also that every directed cycle has positive total weight. A topological rank r(f) of the zero-edge subgraph is stored in the certificate, decreasing along every zero edge.

For the mutually defined streams head(e)=0,tail(e)=o,head(o)=1,tail(o)=e, both call edges have weight one. For head(f)=head(g) and head(g)=head(f), both edges have weight zero, so the checker reports that cycle.

Remark 124.7 — Why deeper destructors are outside the card

Admitting a destructor above a group call forces a negative weight, and the criterion just stated then accepts a group that is not productive. Take head(f)=head(tail(g)),tail(f)=f,head(g)=0,tail(g)=f. Demanding head at f demands tailhead at g; the tail equation of g returns f, so the demand is head at f again. No numeral is ever produced, and the group is not productive. Its weights are f1g — the demand grows by one symbol — and g1f, together with f1f. Every directed cycle here does carry a positive edge, so the criterion accepts. Only the total-weight reading rejects it, and the two readings agree exactly when every weight is 0 or 1. Restricting the two right-side forms is what buys that agreement; a card with deeper destructors would have to replace the zero-cycle test by a minimum-mean-cycle computation and would lose the stored topological rank used below.

Lemma 124.8 — Guard checking terminates

The Timpl-co guardedness checker terminates on every finite declaration group. If it accepts, every zero-weight call strictly decreases the stored rank.

Proof of Lemma 124.8 — Guard checking terminates

Proof. The checker traverses each finite right side once, emitting a finite graph. It deletes positive edges and performs depth-first cycle detection on the remaining finite graph. If no back edge is found, reverse finishing order is a topological ranking. Every zero edge points to a vertex with smaller rank by construction. All traversals therefore terminate and the returned rank has the stated property. ◻

Exercise 124.2

★☆☆ Give the weighted call graph for the complete group head(f)=head(g),head(g)=head(h),head(h)=0,tail(f)=g,tail(g)=h,tail(h)=f. Delete the positive edges and give one valid rank assignment.

Every finite demand is met

The proof uses a lexicographic measure. The observation length decreases when a positive edge is crossed. Between positive edges, the stored topological rank decreases.

Lemma 124.9 — One demanded destructor makes progress

Let G be guarded. For a declared f and any tuple a of closed group-free Timpl terms in its input telescope, consider the closed call fa. For a demanded head observation, evaluation either returns a closed Timpl value or follows a zero-weight mutual call to gb, again with closed group-free arguments, and r(g)<r(f). For a demanded tail observation, evaluation returns such a closed declared call gb in one Co-Tail-Unfold step.

Proof of Lemma 124.9 — One demanded destructor makes progress

Proof. Inspect the selected copattern equation. A head right side is in the nonrecursive terminating Timpl fragment except for recorded zero-weight calls. By lemma 124.4, the preparation function first produces prepΔf(a)=av. Substitution of av leaves every alias argument closed and group-free, and its componentwise evaluation produces the closed tuple required by Co-Head-Alias. Each alias call decreases rank by lemma 124.8; finite induction on r(f) reaches a right side with no zero call and returns its normal form by the extended NbE subevaluation. A tail equation discharges the demanded tail and Co-Tail-Unfold returns its root mutual call after componentwise evaluation; the system-card side condition makes its arguments closed and group-free. These are the two coprojection forms of the system card. ◻

Proof of Theorem 124.10 — Productivity of accepted stream groups

Proof. Generalize over the declared function f and every closed group-free input tuple a, then fix an observation word o. Induct lexicographically on the number of tail symbols in o and the stored rank of f. For a head word, lemma 124.9 either returns a value or follows a zero edge and decreases the second component. For tailo, the same lemma computes the tail to a closed call gb. The recursive demand o has one fewer tail symbol, so the generalized outer induction hypothesis applies to the arbitrary closed tuple b and gives its value. The two clauses construct a finite derivation sov for every o. ◻

Definition 124.11 — Coiterator

Let G be guarded and type homogeneous. Fix its element type A, and generate the nonrecursive Timpl-data block StateG:U,ini:(a:Δi)StateG. No constructor argument mentions the generated family, so definition 122.4 accepts the block. Its universe level is the maximum accepted level of the input telescopes.

Head aliases are resolved statically first, because a head equation whose right side is head(gu) would otherwise make the head map of the coiterator call itself, and the coiterator takes a Timpl function, not a second recursive definition. Repeatedly replace such a right side by the head right side of g under the substitution u. Each replacement follows one zero-weight edge, so by lemma 124.8 it strictly decreases the stored rank; after at most r(fi) replacements the right side is a producer. Write e^i for the resulting group-free head right side of fi, and let tail(fix)=fτ(i)ui be its tail step. Now define h:StateGA,h(ini(a)):=e^i[a/x],t:StateGStateG,t(ini(a)):=inτ(i)(ui[a/x]), both by the eliminator of the generated state datatype. For later equations, abbreviate the normal state sti(a):=nfΣ,StateG(ini(a)). For a prepared tuple av, constructor normality and stability give sti(av)=ini(av). The abbreviation keeps the state-normalization premise visible when the input tuple has not yet been prepared. Elaboration sends a source call fia to coiter(h,t,ini(a)). Its primitive equations are head(coiter(h,t,s))0h(s),tail(coiter(h,t,s))0coiter(h,t,t(s)). The coiterator is strict in its state. More exactly, if sv and sv are closed typed normal forms of StateG, the two contractions induce the evaluation rules sTsvh(sv)Tvhead(coiter(h,t,s))vCoiterHead and sTsvt(sv)Tsvtail(coiter(h,t,s))coiter(h,t,sv)CoiterTail. Thus a tail observation evaluates the next state before returning the next stream. This convention is unobservable in the total, group-free state language, but it fixes the state normal form that the erasure translation stores in both target closures.

Exercise 124.3

★☆☆ For the two-vertex alternating group with head(e)=0, head(o)=1, tail(e)=o, and tail(o)=e, take StateG with nullary constructors ine,ino. Write the complete definitions of h and t, then derive tail(coiter(h,t,ine)) by Coiter-Tail, including both T premises.

Lemma 124.12 — Preparation composes with group-free substitution

Let Γ and Δ be dependent Timpl telescopes. Let η be a closed group-free tuple for Γ, and let θ be a group-free tuple for Δ in context Γ. If prepΓ(η)=ηv,prepΔ[ηv](θ[ηv])=θv, then preparation of the concatenated tuple is prepΓ,Δ(η,θ[η])=(ηv,θv). Moreover, for every group-free runtime term e typed under Δ and closed typed normal form w, e[θ[ηv]/Δ]Twe[θv/Δ]Tw.

Proof of Lemma 124.12 — Preparation composes with group-free substitution

Proof. Induct on Δ. The empty suffix gives the first equation immediately. At a runtime binder, substitution composition identifies the term prepared by the recursive clause with the corresponding component of θ[ηv]; totality and determinism in lemma 124.3 supply the component of θv. At an erased binder, substitution composition identifies the same typed input to the normalizer, whose uniqueness supplies the component of θv. This proves the concatenation equation.

For the second claim, compare the two simultaneous substitutions component by component. At a runtime position, the defining premise of preparation and soundness in lemma 124.3 give judgmental equality between the unprepared component and its normal form. At an erased position, normalizer soundness gives the same judgmental equality. Dependent substitution congruence, in telescope order, therefore gives e[θ[ηv]/Δ]e[θv/Δ] at the common converted result type. Completeness in lemma 124.3 identifies their normal forms. By the definition of T, either displayed subevaluation judgment holds exactly when that common normal form is w, which proves both implications. ◻

Lemma 124.13 — Prepared tuples are fixed points

If every component of a closed group-free tuple b:Δ is a typed normal form after substitution of its prefix, then prepΔ(b)=b.

Proof of Lemma 124.13 — Prepared tuples are fixed points

Proof. Induct on Δ. Both extensions use stability of closed typed normal forms; the relevance mark determines only which preparation clause records the normalizer call. In both cases the induction hypothesis fixes the prefix, so the dependent substitution into the final component is unchanged. ◻

Lemma 124.14 — Source/map evaluation agreement

Fix a declaration fi:(Δi)Stream(A) in an accepted group. Let a be a closed group-free tuple and suppose prepΔi(a)=av. For every closed typed normal form w:A, head(fia)wh(sti(av))Tw. For every group declaration fj and closed prepared tuple b, tail(fia)fjbt(sti(av))Tstj(b).

Proof of Lemma 124.14 — Source/map evaluation agreement

Proof. First, soundness of normalization and congruence give h(sti(av))h(ini(av)),t(sti(av))t(ini(av)). Completeness therefore lets either map be calculated at the constructor and then normalized.

For the head equivalence, induct on the stored rank of fi. A producer rule normalizes e^i[av/x], which is the branch selected by h(ini(av)). For an alias to fju, Co-Head-Alias first derives prepΔj(u[av/x])=b and then evaluates head(fjb). Static alias resolution defines e^i as e^j under the same simultaneous substitution. By lemma 124.12, the resolved expression receives the same prepared tuple b; the induction hypothesis for fj, whose rank is smaller, gives both implications. This treats the producer and alias rule families.

For the tail equivalence, invert Co-Tail-Unfold. It fixes j=τ(i) and derives prepΔj(ui[av/x])=b. The generated branch for t first contracts to inτ(i)(ui[av/x]). For every runtime component, preparation soundness identifies that component judgmentally with the corresponding component of b. For every erased component, preparation replaces the checked substitution term by its typed NbE normal form; normalizer soundness makes those two terms judgmentally equal. Constructor congruence and completeness therefore identify the branch normal form with stτ(i)(b). Conversely, injectivity of the generated constructor tag identifies the prepared components, and normalizer uniqueness identifies each erased canonical component with the one fixed by preparation. Hence the same prepared tuple is recovered and Co-Tail-Unfold applies. The declaration index fixes j=τ(i). ◻

Theorem 124.15 — Finite-observation simulation

Let s be a closed call accepted by Timpl-co and let s be its coiterator elaboration. For every observation word o and closed value v, sovsov.

Proof of Theorem 124.15 — Finite-observation simulation

Proof. Write s=fia. Generalize over fi and every closed group-free tuple a:Δi, then induct on o. Normalizer-defined preparation gives a unique tuple av with prepΔi(a)=av. Preparation soundness and constructor congruence identify the normal forms, so ini(a)Tsti(av).

For head, invert the source observation rule and apply the head equivalence of lemma 124.14. Its right side together with the displayed constructor evaluation is precisely Coiter-Head, so the elaborated call has the same head observation. Inverting Coiter-Head and using the converse implication of the lemma proves the reverse direction.

For tailo, source inversion gives a uniquely determined closed call fjb, together with tail(fia)fjb,fjbov. The tail equivalence of lemma 124.14 and Coiter-Tail derive tail(coiter(h,t,ini(a)))coiter(h,t,stj(b)). By lemma 124.13, the tuple b is fixed by preparation. The raw elaborated state inj(b) and the state stj(b) both subevaluate to the latter by definition and stability. Hence every first Coiter-Head or Coiter-Tail premise is identical for the two target streams. Apply the generalized induction hypothesis to the closed call fjb and the shorter word o. Conversely, inversion of Coiter-Tail, the converse tail equivalence, and the same induction hypothesis reconstruct the two source premises. These are the two forms of observation word. ◻

The observation-first presentation and copattern typing follow Abel, Pientka, Thibodeau, and Setzer, Sections 3–5 [APTS13]. Their paper intentionally separates typing from productivity. The cycle criterion and productivity theorem above belong only to the stream fragment fixed in definition 124.1; Giménez’s guarded schemes provide the historical boundary [Gim95].

Suggested first pass.

None of these problems is a prerequisite for a later chapter. Begin with exercise 124.4, then complete exercise 124.6.

Exercise 124.4

★★☆ Elaborate from to a coiterator with state N. Calculate the observation word with three tails followed by head on both source and target, annotating every coprojection contraction.

Exercise 124.5

★★☆ Take the complete group of exercise 124.2, whose zero-weight subgraph is the path fgh. Give its topological rank, say which edge every directed cycle must use and why that edge is positive, and prove productivity directly by the lexicographic measure used in theorem 124.10.

Exercise 124.6

★★★ Practical project.corecursive-group-observer Represent a declaration by its two copattern equations and derive the weighted call graph from them, so that a zero edge exists exactly when a head alias does. Compute a topological rank by one relaxation round per vertex and verify the stored certificate of definition 124.6: every zero edge strictly decreases the rank. Apply that test at every vertex, not at one chosen start. Also perform the static head-alias resolution of definition 124.11, bounded by the vertex count. Print the first four observations of from-0 as 0,1,2,3; accept alternating and the three-vertex alias-chain with their ranks; print the resolved head of every declaration in the alias chain; reject head-loop with the zero cycle you computed. Two mutations must fail the oracle: relaxing once instead of once per vertex, and dropping the strict rank decrease. The observer witnesses finite demands; it does not prove normalization of Timpl-co.

Search the book

Type to search the local edition.