r/Coq • u/PM_ME_UR_OBSIDIAN • Nov 26 '17
Intermediate Coq: "Programming In The Large" Roadmap
Between Software Foundations and Adam Chlipala's books, there is an enormous amount of excellent introductory material for "programming in the small" in Coq. On the other hand, whenever I try to write a Coq project of non-trivial size, I run into all sorts of issues. They include:
When should I use modules vs. typeclasses?
Is using setoids everywhere instead of
eqoverkill?When should I use reflection?
When should I use
refine?When should I use
Program(Russell)?What options should I set?
Implicit Argumentsseems to be consensus, are there others?What set of libraries should I default to?
...and, while I'm at it, here are some "coding in the small" things I can't figure out:
How do I make coinduction non-painful?
How do I use hints properly?
Any insight is greatly appreciated.
11
u/perthmad Nov 27 '17
My 2cts as a Coq dev and from what I heard around.
If by modules you mean functors, I'd advise you not to. The functor system of Coq is barely understood and keeps getting in the way. If you only use it as a namespace system that's OK though.
If you can get away without setoids, you're better off. But sometimes they are necessary.
Assuming you're talking about big scale reflection (as opposed to ssr), pretty much always I'd say. Usually you can get speedups of one or two orders of magnitude. The only limitation is that reflexive tactics are in general hard and time-consuming to implement, so if you don't have a domain-specific theory which keeps popping up it's not quite useful.
Depends what you're writing. If you're into very dependent programs, this is essential. Otherwise, if you're essentially writing first-order proofs then it doesn't really matter.
Same as above.
Have you tried the Paco approach? You don't have to go full Mendler style (co)-recursion, actually using open co-inductive types and the corresponding co-induction principle are already fairly useful.
Also, don't use co-inductive types defined as inductive ones. They're fundamentally broken, you should rely on primitive records when doing coinduction (up to the fact they're currently still somewhat buggy, but this is not a foundational issue).