Is there a standard/recommended style guide for Isabelle documented anywhere? From what code I've seen 2 space indentation seems to be the norm...
Even better would be a tool to automatically format Isabelle code
jedit auto-indents code (C-i
to reindent a selected part IIRC).
There are parts of the automatic indentation I really don't like (mostly related to inductive predicates and labels), but the default works mostly well.
See the following:
https://isabelle.systems/conventions/
https://proofcraft.org/blog/isabelle-style.html
Neither of these are official in any way though. The AFP also has some style guidelines, although most of them are more concerned with robustness than style:
https://www.isa-afp.org/submission/
Thanks to both of you, that jedit key bind seems pretty useful and those documents even more so :)
There's also a few more general tips here: https://isabelle.systems/cookbook/
Isaac Freund said:
Even better would be a tool to automatically format Isabelle code
I’m very happy that at least there is no such tool integrated into the Isabelle IDE. About two Isabelle versions ago, I had to switch off the auto-indenter, because it made decisions that were apparently ridiculous, so that I found myself spending a considerable amount of effort to manually correct indentation.
Autoformatters would be cool if their authors would have only sensible ideas regarding what a good style is. Sadly, it seems that the authors of autoformatters often have strange ideas regarding that. Maybe for the most part their ideas are reasonable, but one bad idea can be enough to spoil the whole idea of autoformatting. In addition, there might be situation where making exceptions to the rule is reasonable. Because of all that, I think the author should retain the final say regarding code formatting.
I am slightly curious: what did you dislike that much? The one I dislike, but this is more or less the only instance:
inductive rtranclp :: ‹('a ⇒ 'a ⇒ bool) ⇒ 'a ⇒ 'a ⇒ bool› for r :: ‹'a ⇒ 'a ⇒ bool› where
base:
‹rtranclp r a a› |
step:
‹rtranclp r a c›
if
‹r a b›
Last updated: Dec 21 2024 at 16:20 UTC