Cat Girl Program Analysis · Powered by Rabbithole

📌 Coinductive Program Analysis — Is Anyone Actually Doing This?

Started by AbstractKitty · 44 replies · 1,872 views · Board: Static Analysis · ⭐ Archived to Best-Of
🐱
AbstractKitty
⬛ Senior Member
Coalgebra Club
Posts: 1,204

Alright, I've been lurking on my own thread for the past few days trying to synthesise everything that's been said here. The discussion went way further than I expected and I feel like there's actually enough material here for a paper.

So I drafted an abstract. Rough, very rough. Posting it here to get feedback before I send it anywhere:

📄 Draft Abstract — "Bridging Coalgebra and Abstract Interpretation: Towards a Unified Framework for Coinductive Program Analysis"

Abstract: We investigate the relationship between coalgebraic semantics and classical abstract interpretation. Classical abstract interpretation computes over-approximations of program semantics as least fixpoints in a Galois connection framework. We propose a dual formulation in which program properties are encoded as elements of a final coalgebra, and abstract domains are equipped with a greatest-fixpoint semantics admitting a coinductive proof principle. We demonstrate that this framework subsumes certain classes of liveness and productivity analyses that are ill-suited to inductive formulations, and give a translation functor between the Galois-connection lattice and the coinductive domain category. Soundness is established via a bisimulation argument. Prototype results for stream programs are reported.

Keywords: coinduction, abstract interpretation, coalgebra, Galois connection, bisimulation, greatest fixpoints, program analysis, liveness

Very draft-y. The "translation functor" claim is aspirational — I have the construction for a specific class of domains but not the general case yet. Feedback welcome.

🐾 Mrrp (18) 💜 This is publishable (9) ⚗️ Needs more formalism (4)
AbstractKitty · "A coalgebra is just an algebra seen from the other side of the telescope."
🔄
MeownadTransformer
⬛ Senior Member
Corecursion Enjoyer
Posts: 876
AbstractKitty wrote:
Feedback welcome.

Okay so this is kind of funny timing — I've been working on exactly this for the last few months and I finally pushed the repo to GitHub last night. Here's the link:

🐙
meownadtransformer / coind-analyser
Haskell · MIT License · Last commit: 2025-11-02

A coinductive program analyser for stream-processing Haskell programs. Models abstract domains as F-coalgebras and computes greatest fixpoints via anamorphic iteration. Supports productivity checking, liveness properties, and stream invariant inference.

47 stars  ·  🍴 8 forks  ·  🐛 12 open issues  ·  📦 Hackage (pending)

The core of it is a type class hierarchy that treats abstract domains as coalgebras over a base functor F. The anamorphism gives you the abstract semantics "for free" from the coalgebra structure:

-- | An abstract domain is an F-coalgebra with a widening operator. class Functor f => AbsDomain f d where unfold :: d -> f d -- coalgebra structure map widen :: d -> d -> d -- widening for convergence top :: d -- greatest element (⊤) bottom :: d -- least element (⊥) refine :: d -> d -> Maybe d -- narrowing step -- | Greatest fixpoint via coinductive iteration (with widening) gfp :: (AbsDomain f d, Eq d) => (d -> d) -> d gfp f = go top where go x = let x' = widen x (f x) in if x' == x then x else go x'

It's very much a research prototype — don't use it in production. But the tests on the stream examples from pages 1 and 2 of this thread work correctly. Productivity and liveness both check out.

AbstractKitty, want me to add you as a contributor? I think your abstract + this impl could become an actual workshop paper.

🐾 Mrrp (24) 🚀 Shipping it (15) 👀 Eyes (8)
MeownadTransformer · "Every catamorphism has a dual. Don't forget the dual."
😼
GaloisCat
⬛ Veteran
Lattice Lawposter
Posts: 3,102

I've been putting off saying this for a few pages but I suppose I've been cornered. Fine.

This thread changed my mind.

I came in here ready to dunk on coinductive analysis as pure theory-brained category-cat navel-gazing with zero practical relevance. And I still think a lot of coalgebra papers are written specifically to obfuscate the fact that they contain 3 pages of content padded with 30 pages of diagrams. But:

  • The productivity analysis use-case (page 2, posts 18–22) is genuinely not expressible cleanly via lfp. I was wrong about that.
  • MeownadTransformer's code above is real and not just a thought experiment.
  • AbstractKitty's draft abstract is actually coherent and the bisimulation soundness argument is the right move.
🐱 GaloisCat's Concession Stand
Greatest fixpoints are load-bearing for reactive/liveness analysis. The dual framework is not just "neat", it handles a genuinely different class of properties. I will stop calling this "vibes-based abstraction" in future posts. Probably.

I maintain that the Galois connection formulation is still the right backbone and that the "translation functor" in the draft abstract needs to be made precise (the functoriality conditions aren't trivial). But the core claim stands. I was wrong. There, I said it.

Now can someone explain to me why widening even makes sense in the coinductive setting? If you're computing gfp, widening should make things bigger, not smaller. That's backward from the usual. MeownadTransformer's widen above widens toward top, which is the gfp initialisation point, so it's actually shrinking the over-approximation on each step... right? Am I reading this correctly?

🎖️ Concession accepted (31) 🐾 Mrrp (19) 👏 Character growth (14)
GaloisCat · Galois connection purist · Will argue about lattices for free
🧶
FixpointFeline
🟣 Power User
Least Fixed Point Stan
Posts: 588
GaloisCat wrote:
This thread changed my mind.

SCREAMING. I never thought I'd see the day. Screenshot saved forever. 🖼️

GaloisCat wrote:
Now can someone explain to me why widening even makes sense in the coinductive setting?

Yes! Great question and I was going to ask this too. The intuition is:

  • In the inductive (lfp) setting: we start at ⊥ and widen upward to force convergence. Widening is "jump to something bigger".
  • In the coinductive (gfp) setting: we start at ⊤ and narrow downward toward the fixpoint. But convergence isn't guaranteed either! So "coinductive widening" is actually a kind of forced upward jump during the narrowing descent — it's more like a backtracking escape hatch.

MeownadTransformer's widen x (f x) is confusingly named — it should maybe be called accelerate. It joins the current point with the transfer-function image and jumps if we're cycling. In the gfp case this is still sound because you're staying ≥ the fixpoint (you can't over-shoot below).

Anyway — the main reason I'm posting: we should start a reading group. This thread has clearly assembled the cats who care about this stuff. I propose:

📚 Proposed: CGPA Coinductive Analysis Reading Group
Meeting cadence: biweekly, voice chat on CGPA Discord #reading-group-theory
Starting material: Jacobs' "Introduction to Coalgebra" (ch. 1–3), then Cousot & Cousot 1977, then AbstractKitty's paper draft once it exists
First session: Vote below — second or fourth Saturday of November?
📊 Reading Group First Session — When?
Saturday Nov 15 (2nd Sat)
62%
Saturday Nov 29 (4th Sat)
28%
Neither / propose another date
10%
21 votes · Poll closes Nov 8
📚 I'm in (23) 🐾 Mrrp (12) ⏰ Bad timing for me (3)
FixpointFeline · μ is love, μ is life · but ν is interesting too apparently
🔄
MeownadTransformer
⬛ Senior Member
Corecursion Enjoyer
Posts: 876
FixpointFeline wrote:
MeownadTransformer's widen is confusingly named — it should maybe be called accelerate.

You're completely right and I've already pushed a commit renaming it. The README now has a proper explanation of the semantics. GaloisCat's confusion was valid and I should've documented this better.

Also — reading group: yes, absolutely yes. I'll set up the Discord event. I can lead the coalgebra chapters since I've read Jacobs front-to-back already (send help). AbstractKitty can handle the abstract interpretation side.

And yes AbstractKitty, I've already sent the GitHub collaborator invite 😸

🐾 Mrrp (9) 📝 Good commit message (6)
MeownadTransformer · github.com/meownadtransformer · she/her
😸
CatamorphismCleo
🟣 Power User
Wiki Editor
Posts: 432

Okay I have been watching this thread from the sidelines wearing my wiki-editor hat and I need to say: this is exactly the kind of thread the CGPA wiki needs a page for.

I'm proposing a new wiki article:

📖 Proposed Wiki Page: Coinductive Program Analysis
Sections planned:
  • Motivation: what inductive/lfp-based AI can't do well
  • Coalgebraic background (assuming CGPA's existing Abstract Algebra primer)
  • Greatest fixpoints as semantic objects
  • Bisimulation as the soundness argument
  • Practical considerations: widening/narrowing in gfp iteration
  • Known implementations (including MeownadTransformer's repo)
  • Open problems & reading list
  • Forum threads of note (this one + the older liveness thread)

I'll start a draft in the wiki sandbox. ΛatticeWhiskers or any other mod: is this in scope for the main wiki? I know we've been trying to keep the theory pages at an accessible level but I think there's a way to write this that's readable with just the coalgebra primer prereq.

Also: this thread is an argument that the CGPA wiki needs more theory depth. We've had this discussion on the meta board before and I think the evidence is now in front of us.

📖 Please write this (21) 🐾 Mrrp (11) 🖊️ I'll help edit (7)
CatamorphismCleo · CGPA wiki editor since 2023 · she/they · "fold responsibly"
😼
GaloisCat
⬛ Veteran
Lattice Lawposter
Posts: 3,102
FixpointFeline wrote:
SCREAMING. I never thought I'd see the day. Screenshot saved forever.

I will have you know that updating one's priors in response to evidence is the epistemically correct behaviour, and if you screenshot that I will systematically undermine every argument you make about domain theory for the next calendar year.

That is not a threat. It is a promise and a lattice.

💀 (27) 🐾 Mrrp (14) ⚖️ "a lattice" (22)
GaloisCat · Galois connection purist · Will argue about lattices for free
🌙
StreamingSchrodinger
⬜ Member
Lurker Emeritus
Posts: 91

De-lurking for the first time in like four months just to say: this is the best thread on this forum since the denotational-vs-operational semantics debate of 2023. Archiving this in my own notes.

AbstractKitty — the abstract looks great. Tiny suggestion: the phrase "coinductive proof principle" might confuse reviewers who aren't from the coalgebra world. Consider "greatest-fixpoint induction principle" or just "coinduction (Pous & Sangiorgi, 2012)" with a citation. Sounds more familiar to the SAS/POPL crowd.

Also the "translation functor" framing is interesting but you might want to be careful — functoriality of the translation between Galois-connection lattices and the coinductive domain category is going to get asked about in review. Make sure you have the naturality squares ready.

Good luck. I'll read the preprint when it's up.

🐾 Mrrp (8) 👍 Good notes (12)
StreamingSchrodinger · "the cat is in a superposition of having finished the proof"
🐱
AbstractKitty
⬛ Senior Member
Coalgebra Club
Posts: 1,204
StreamingSchrodinger wrote:
Consider "greatest-fixpoint induction principle" or just "coinduction (Pous & Sangiorgi, 2012)" with a citation.

This is an excellent point and I've updated the draft. Pous & Sangiorgi is exactly the right citation for that audience. Thank you, lurker-who-emerges-bearing-gifts 🎁

GaloisCat wrote:
I will have you know that updating one's priors in response to evidence is the epistemically correct behaviour

GaloisCat this is the most you've ever sounds like a fully functional scientist and I mean that with complete sincerity and also I will absolutely be quoting this in the paper acknowledgements section ("we thank GaloisCat for updating priors").

Accepting MeownadTransformer's collaborator invite now. Let's do this. 🐾

🐾 Mrrp (16) 💜 "fully functional scientist" (20)
AbstractKitty · "A coalgebra is just an algebra seen from the other side of the telescope."
🧮
BisimulationBea
⬜ Member
Process Theory
Posts: 147

Late to this thread but I want to add one thing that hasn't been mentioned: the connection to up-to techniques. If you're using bisimulation as your soundness argument (as AbstractKitty's draft proposes), the proofs get enormously simpler if you use coinduction up-to rather than bare coinduction. Pous & Sangiorgi 2012 covers this extensively.

Specifically: bisimulation up-to contextual closure gives you a much coarser equivalence that still respects the observable properties you care about. This could be the key that makes the "translation functor" claim tractable — you don't need full functoriality if you have the right up-to technique.

Just dropping this here before someone reinvents it from scratch in the paper 🐱

📚 Reference
Pous, D., & Sangiorgi, D. (2012). Enhancements of the bisimulation proof method. In Advanced Topics in Bisimulation and Coinduction. Cambridge University Press. — The chapter on up-to techniques is the one you want.
🐾 Mrrp (7) 💡 Good catch (13)
BisimulationBea · process theory appreciator · she/her
😸
CatamorphismCleo
🟣 Power User
Wiki Editor
Posts: 432

Quick update: I've started the wiki draft in the sandbox. It's very rough but the structure is there. If anyone wants to contribute before I move it to mainspace, ping me or just edit directly (sandbox is open):

wiki/Coinductive_Program_Analysis SANDBOX DRAFT

I've pulled in the core definitions from this thread (with attribution), linked MeownadTransformer's GitHub, and stubbed out the "open problems" section. That section currently has three entries:

  • Widening/narrowing in gfp iteration — is there a canonical framework?
  • Translation functor between Galois-connection and coalgebraic domains — characterise the naturality conditions
  • Scaling to non-stream programs (what's the right functor for control flow?)

BisimulationBea — adding the up-to techniques note right now, thank you.

📖 Wiki-ing (18) 🐾 Mrrp (8)
CatamorphismCleo · CGPA wiki editor since 2023 · she/they · "fold responsibly"
🌌
KleeneKitten
⬜ Member
Ordinal arithmetic
Posts: 203

I mostly want to ask: is anyone thinking about the complexity side of this? Gfp iteration starting from ⊤ is dual to lfp from ⊥ but in practice the abstract domains we care about for coinductive analysis might have very different structural properties. For stream abstractions you often have infinite descending chains (even in abstract domains!) which makes the widening question non-trivial.

Specifically: do the coinductive abstract domains in MeownadTransformer's framework satisfy the descending chain condition? If not, gfp as written might not terminate without a very careful widening strategy.

Not trying to block progress on the paper — the framework is clearly interesting and right. Just flagging this as something to address in the "limitations" section before reviewers do.

🐾 Mrrp (6) 🔥 Valid concern (11)
KleeneKitten · ordinals all the way down · she/her
🔄
MeownadTransformer
⬛ Senior Member
Corecursion Enjoyer
Posts: 876
KleeneKitten wrote:
do the coinductive abstract domains satisfy the descending chain condition?

They don't in general, you're right. The current prototype implicitly assumes the abstract domains are finite (or at least have finite height in the relevant direction), which is fine for the stream interval domains I've been using but won't hold for, say, arbitrary trace properties.

I've opened an issue on the repo: #13 — DCC assumption: document and check. This is going into the paper's limitations section, and also it's probably the next research problem to solve after the paper. KleeneKitten — do you want to be on the author list? This seems like your wheelhouse.

Good thread everyone. This started as AbstractKitty asking "is anyone actually doing this" and the answer turned out to be "kind of, messily, but now more so." 🐱

🐾 Mrrp (15) 🎯 Perfect summary (19) 🚀 Ship it (8)
MeownadTransformer · github.com/meownadtransformer · she/her
🌸
ΛatticeWhiskers
★ Moderator
Mod · Theory Wing
Posts: 5,771

Hello everyone. I've been watching this thread with great pleasure. It's rare to see a CGPA theory thread that:

  • ✅ Started with a genuine research question
  • ✅ Produced real code
  • ✅ Produced a paper draft
  • ✅ Changed GaloisCat's mind (historic event)
  • ✅ Spawned a reading group
  • ✅ Spawned a wiki article
  • ✅ Remained civil throughout (GaloisCat notwithstanding, but they came around)
🏆 🐾 🏆
⭐ ADDED TO CGPA BEST-OF ARCHIVE ⭐

This thread has been archived to the CGPA Best-Of Collection under the category Theory / Program Analysis. It will be linked from the wiki article and from the Static Analysis board index as a recommended read.

Archival is a recognition of exceptional thread quality. The thread remains readable and searchable. No further replies will be accepted.

To everyone who contributed: AbstractKitty, GaloisCat, MeownadTransformer, FixpointFeline, CatamorphismCleo, BisimulationBea, StreamingSchrodinger, KleeneKitten, and all the others across three pages — thank you. This is what CGPA is for.

CatamorphismCleo: yes, the wiki page is absolutely in scope. Feel free to move the sandbox draft to mainspace once you're happy with it. I'd suggest keeping the prerequisites at "coalgebra primer + basic abstract interpretation" as you proposed.

FixpointFeline: Discord event for the reading group has been approved and pinned in #reading-group-theory. 📌

Thread locked by ΛatticeWhiskers (Moderator) · 2025-11-04 15:00 UTC · Reason: Archived to Best-Of, natural conclusion reached.

🌸 ΛatticeWhiskers bestowed (44) ⭐ Best-Of worthy (38) 🐾 Mrrp (61) 💜 Thank you mod (29)
ΛatticeWhiskers · CGPA Moderator, Theory Wing · "the lattice holds us all"
🔒 This thread is locked. It has been archived to the CGPA Best-Of collection. Start a new thread to continue discussion. Post a new thread in Static Analysis  ·  → View the Wiki Article  ·  → CGPA Best-Of Archive