Proof Repair and (Co)algebra Equivalences
E. G Plante, Eric Paul, Cosmo Viola, G. A. Kavvos, Talia Ringer
cs.PL
2026-10-27
Agda shows a repair configuration is an initial-algebra isomorphism. Function extensionality suffices without univalence, and the dual covers streams.
Change a datatype in a large formal development and the programs and proofs written over it break with it. The standard picture is a verified library moving from Nat to a binary Bin: zero and succ become bzero and binSucc, and a zero test or the right unit law for addition has to be rewritten.
Wrapping the old function in toNat : Bin → Nat keeps the theorem, and every repaired call still goes back through Nat. Type-theoretic proof repair, in the sense of PUMPKIN Pi, takes a configuration that aligns constructors and eliminators on the two sides and rewrites terms into definitions that do not mention the old type. That algorithm was already described. What a configuration is as a mathematical object, which datatype changes it covers, and whether univalence is required, had not been proved.
A Config is a pair of inductive algebras in intensional Martin-Löf type theory. A signature lists constructors and separates ordinary arguments from recursive ones. An algebra interprets the constructors and comes with a dependent eliminator and a beta law. The two carriers share one signature. Bin has no successor constructor; the corresponding slot can hold the derived function binSucc. DepConstr, DepElim, and Iota, maintained by PUMPKIN Pi in the metalanguage, become internal data. The extra eta component required by Viola et al. is derivable, and the formalization deletes it.
Proposition 2.4 says that, once one side already carries an inductive algebra, type equivalences C ≃ D are equivalent to configurations. The maps are folds in each direction. A round trip is a fold of an algebra into itself, that fold is unique, and the composite is the identity. The argument uses function extensionality. A bare equivalence does not remember the inductive structure, so the algebra on one side still has to be given first.
What that equivalence misses is an initial algebra for a single polynomial functor. For P X = 1 + X an algebra is a zero and a successor, and Nat and Bin are two carriers. A constructor-preserving map is an algebra homomorphism, which is the old constrok condition. Homotopy-initial means the space of homomorphisms to any other algebra is contractible, so recursion and induction are determined and the isomorphism between two initial algebras is unique. Repair instantiates that same universal property at the new carrier.
Lemma 3.10 embeds a configuration over an arbitrary signature into a one-constructor W-type configuration and preserves the repair maps. Theorem 3.11 turns the slogan into a type equivalence: that canonical form is an algebra equivalence whose source is homotopy-initial, and the isomorphism is unique. Proposition 3.15 is the equation foldC γ = foldD γ ∘ φ. When the defining data does not mention the source type, the repaired term does not mention it either. Induction is a fold into the total space (x : C) × P x, after the motive has been moved along the isomorphism.
The inductive half does not use univalence. Its axioms are function extensionality, the computation rule for happly, and the uniqueness rule that every path of functions arises from extensionality. Ringer et al. used univalence to transport. The same reasoning therefore applies in a theory with uniqueness of identity proofs, Lean being the obvious case. The formalization stays in Agda.
Coinductive types reverse the structure map. Stream is observed through hd and tl; Stream' is observed through one field obs : A × Stream' A. A final coalgebra is what every coalgebra maps into by a unique homomorphism, and corecursion is that map. An identity type generated by refl cannot identify infinite objects, so this half is developed in Cubical Agda with path types and copatterns, again without univalence.
isFinal fixes only the underlying function. isHFinal also asks the type of coalgebra homomorphisms to be contractible. Homotopy-finality of native coinductive records is still open in Cubical Agda, so an M-type with function-level eta matches the weaker notion and sigma-level eta matches the stronger one. Under Theorem 4.24 a plain configuration is only logically equivalent to a coalgebra isomorphism of final coalgebras; the homotopy tier is a type equivalence.
The paper reports no tally of repaired lemmas, no success rate, and no runtime. Every comparison is a theorem against the PUMPKIN Pi conditions or against an earlier conjecture, and each one is proved in Agda.
| Result | Compared with | What holds |
| Proposition 2.3 | three coherence conditions | derived from a Config plus function extensionality, with univalence unused |
| eta | extra field in Viola et al. | derivable, then deleted |
| Proposition 2.4 | a type equivalence | equivalent to a Config once one inductive algebra is given |
| Theorem 3.11 | a W-type Config | a type equivalence with an algebra equivalence out of a homotopy-initial source; the isomorphism is unique |
| Proposition 3.14 | signature Configs and AlgConfigs | maps both ways; the forward map always yields a W-signature, so this is not a type equivalence |
| Proposition 3.15 | an outer conversion function | foldC γ = foldD γ ∘ φ |
| Theorem 4.21 | M-type rules and final coalgebras | a type equivalence at both tiers; round trips on the weak tier hold definitionally |
| Theorem 4.24 and Proposition 4.19 | coinductive Configs and coindok | only the homotopy tier is a type equivalence, and only there does coindok hold |
On Nat and Bin, recNat z s = recBin z s ∘ fromNat. Vec A n and Fin n → A are repaired once per index n, which leaves a change of the index type itself uncovered. When the element type is a set, Stream and Stream' form a homotopy configuration, and the repaired cons computes definitionally on the head and on the next element.
Once the polynomial is fixed, the datatype changes a configuration can repair are the algebra isomorphisms, and the rewrite is that isomorphism acting on terms. The three coherence conditions follow from initiality.
For Lean the shift is in the hypotheses. A development that assumes only function extensionality can be read in a theory with uniqueness of identity proofs. One that assumes univalence cannot. No repair tool for Lean is delivered.
Coinductive types had no repair tool. Final coalgebras put the two stream interfaces on one observable behavior. Swapping corecursion needs only ordinary finality. Carrying bisimulation proofs along needs homotopy-finality, which is the hypothesis coindok uses.
The algorithm is not faster than PUMPKIN Pi. Eta and univalence are no longer hypotheses, and coinductive types now have a rule-level interface. A change that cannot be presented as an initial algebra or a final coalgebra for one common functor is outside the theorem.
Rewriting the syntax of terms is outside the theorems. Whether a term mentions the source type cannot be stated inside the type theory.
Signatures carry no indices, so a change to the index type is not characterized. Useless configurations can still be written, and whether the shared functor is a natural one is left to the proof engineer. On a constant polynomial every type equivalence is an algebra isomorphism, so a functor chosen too coarsely makes the characterization empty.
Homotopy M-types are not established for Cubical Agda's native records. The formalization attempt hit a documented obstacle: higher-dimensional path spaces of those records lack a characterization. The limit construction of Ahrens et al. is homotopy-final and is not a native definition a tool can repair. Finality for coinductive types in Rocq is marked open. Stream enters a homotopy configuration only when the element type is a set, and the weak tier has no coindok.
The two halves live in different theories. The inductive half is intensional type theory plus function extensionality with a computation rule. The coinductive half is Cubical Agda. Nothing is replayed in Lean, so whether that computation rule can be supplied there is unchecked. The share of real library changes that fall into this class is not measured. The examples worked through are Nat and Bin, vectors and finite functions, and the two streams.