Skip to Content.
Sympa Menu

coq-club - [Coq-Club] PUMPKIN PATCH now has some basic refactoring support

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

[Coq-Club] PUMPKIN PATCH now has some basic refactoring support


Chronological Thread 
  • From: Talia Ringer <tringer AT cs.washington.edu>
  • To: Coq-Club <coq-club AT inria.fr>
  • Subject: [Coq-Club] PUMPKIN PATCH now has some basic refactoring support
  • Date: Wed, 13 Nov 2019 17:51:02 -0800
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=tringer AT cs.washington.edu; spf=None smtp.mailfrom=tringer AT cs.washington.edu; spf=None smtp.helo=postmaster AT mail-il1-f172.google.com
  • Ironport-phdr: 9a23:/bFdcxMTkc3F2SQIICsl6mtUPXoX/o7sNwtQ0KIMzox0LfT6rarrMEGX3/hxlliBBdydt6sfzbON6eu7CSQp2tWoiDg6aptCVhsI2409vjcLJ4q7M3D9N+PgdCcgHc5PBxdP9nC/NlVJSo6lPwWB6nK94iQPFRrhKAF7Ovr6GpLIj8Swyuu+54Dfbx9HiTagb75+Ngi6oAvPusUZj4ZvKbs6xwfUrHdPZ+lY335jK0iJnxb76Mew/Zpj/DpVtvk86cNOUrj0crohQ7BAAzsoL2465MvwtRneVgSP/WcTUn8XkhVTHQfI6gzxU4rrvSv7sup93zSaPdHzQLspVzmu87tnRRn1gyoBKjU38nzYitZoga1UoByvqR9xzZPKbo6JL/dxZL/RcMkASGZdQspcVSpMCZ68YYsVCOoBOP5VoZfnqFsKrBuxHxSnCv/uyj9OiX/5w7c62PkmHAHaxgwgHtQOsHvKo9XvL6odTfu1wLPGzDrZdPNW2Tb96I7HchA9pvGMW6h8ftTMxkkyDg7IiEibp4LiPzOQzOsNsm6b4vJvVeKul24nqxxxrSO1ysgwjYnJg4QYwU3H+yVh2Is5O8G0RUphbdOnEJZcrTyWOop3T884Xm1lujg2x7sbspChZicK0o4oxxvHZvyHbYeI5hXjWf6UIThihXJlfKuzhxe28US90+H8WNS43VRUoiZfndnMsXcN1xPX6seZUPdy4kCh2TOX2wDS7OFLP1w0mLLFJ5I9xrM8jJkevETZEiPrmUj7jbWaelgm9+S28+jnZ6/ppp6YN496kAH+NaEul9SjAeQiMwgOWWeb9vqm1LD44UL5W69Gj/MsnanCsJDaJMIbpqGlAw9S1IYv8QiwACq70NgAh3kIMEpFeA6bj4juI1zBPPf4De6mj1uwlDdr2uvJM6b6ApTNK3jDiK3ucax8605a0gozzMpQ64haCrEbc7rPXRras8WdJRskOUTgyOH+Td55y4k2WGSVA6bfPrmE4nGS4ed6H+CIZYZdgjf7JPU/r6ryl34/llIHVaKym4Qec3C5GPt6JEPfbHbx1IRSWVwWtxYzGbS5wGaJViReMi7rDvAMowojAYfjNr/tA4WkgbiPxiC+R8wEbXsAFVmXEXbueJmDXbEBZD/AepY8wAxBbqCoTsoa7T/rtAL+zOA5fO/d+yldtJa6kdYsuLeVmhY1+jh5Sc+a1jPVFj0mriYzXzYzmZtHjwll0F7agPpzmLpHHMdT5vVGTgA8c5PQ0r4iBg==

Hi coq-club,

I've implemented some simple refactoring support in PUMPKIN PATCH for a user. Even though it is preliminary (I started implementing it yesterday), I want to share in case it is useful for anyone else, and also so that I can think more about good interfaces.

The functionality that I implemented is just a way to replace terms with convertible terms systematically, either in a definition or across an entire module. The idea being that sometimes people have automatically generated specifications or just handwritten specifications that are kind of ugly, but they would prefer to reason about cleaned up versions, or at least present those to the user.

Using this

You just write:

Replace Convertible t1 t2 t3 in ugly as pretty.

To define a new term "pretty" that is "ugly" with all occurrences of subterms convertible with t1, t2, or t3 replaced with t1, t2, and t3 themselves. To do this across an entire module, you write:

Replace Convertible t1 t2 t3 in Ugly as Pretty.

And this gives you back a new module "Pretty" that is "Ugly," but with all subterms convertible to t1, t2, and t3 in all terms of Ugly replaced with t1, t2, and t3 themselves.

OK, now what?

After using this you'll get back a new definition or module. This is nice for some users who just want a way to deal with automatically generated, not very pretty specifications.

But probably a lot of you want this sort of functionality to directly change your existing definitions or modules. Right now you have to copy and paste the result back in if you want that, and that's kind of annoying, especially since the module will give you back proof terms and you might need to tweak proof scripts (say, to unfold the definition you just replaced).

I'd like to make an interface that is good for this!  And of course we want to support this across files! I don't know the best way to do this. So, for now I've just built some basic infrastructure.

I really want your input! This is why I'm sharing this early. So, if you have an idea for what you'd like the user experience to be for a tool like this, please let me know by cutting an issue inside of the PUMPKIN PATCH repository with the ideal user experience you imagine.

Correctness

If you do plan to keep the old definitions around, or if you want a certificate, you will eventually be able to get this by setting the option "PUMPKIN Prove Replace." This is a WIP (I just started implementing it today) but will eventually generate correctness proofs for all of the replacements. Right now it generates the correctness proofs that are reflexivity, and soon it will generate correctness proofs for inductive types (equivalence), but correctness proofs about theorems that use those inductive types will take longer (transport along the equivalence).

Other refactoring support

Implementing some more basic refactoring is on my roadmap, so if you would like any kind of basic refactor in Coq, please also cut an issue in the PUMPKIN PATCH repository so I have things that people want documented. One that is on my roadmap is renaming definitions (I still want to hear from you if you want this, so I know how to build a good interface for it). The same holds for renaming modules. Just like with repairs, if you encounter annoying refactors during development, please do think of me and cut an issue as a wish so I can eventually support it, if I don't support it yet.

Talia







Archive powered by MHonArc 2.6.18.

Top of Page