-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create coding style #19
Comments
I also think a style guide would be good. This way we can define how certain issues should be solved. On Zulip, Karl Palmskog listed some already existing style guides:
Other useful stuff he listed: I think using And your points above agree (more or less) with what I had in mind. Always explicitly declaring hypotheses if they are used later might be a bit hard to enforce... I have not a lot of experience using that approach. (I think Chlipala wrote something about that in CPDT...) Something I found useful to make my proofs less fragile is the following: match goal with
| H0 : ?a = true,
H1 : ?a = false |- _ =>
rewrite H0 in H1; discriminate H1
end. How about
or
I like these more, because I’m used to having each subproof indented another layer. I use the first variant more often.
Let’s start bikeshedding! :D On another day, I’ll write more concrete ideas and respond more to your above ideas. P.S. We might consider not defining every possible thing in the style guide, like every possible placement of braces and every possible ambiguity and corner case. |
It's
You can check for this with |
At least I'm going to put bullets in all existing proofs. |
Thanks for the clarification @Zimmi48. I agree with you (@stop-cran), about using bullets & braces where applicable. |
Other stuff that is sometimes inconsistent:
Lemma foo : bar.
Proof.
intros; reflexivity.
Qed. But there are also examples of this: Lemma foo : baz.
Proof.
intros; reflexivity.
Qed. The latter is the "default" setting of ProofGeneral. Instances of the latter style can be detected (very crudely) using |
I added a hint to automatically prove I think functions from/to topological spaces could be declared more concisely if we declare |
@Columbus240 yes, why not. I thought more about |
More in the direction of automatic proofs: We could declare topological properties as "typeclasses" and then write implications between the properties as instances. |
We could harmonize the naming of definitions/lemmas. A consistent (& hopefully) short naming style. Currently, because styles from the stdlib and the style of the library mix, we have |
I created a note on formatting. Mostly I wrote down how I (and for example the Coq stdlib) format and indent braces, bullets and proofs. |
The notes added in this commit were previously published at https://gist.github.com/Columbus240/a1ece869fd4df72d1b056767075d8eb5
Current code is somewhat hard to read. I'd suggest to create a coding style guide and amend all existing proofs to follow that style.
Below are my ideas about coding style to be discussed:
assert
tactic use curly braces to logically separate from other goals. Possibly with other bullets inside the assertion goal if needed. E.g.:... assert (forall a b:R, -b <= a -> a <= b -> Rabs a <= b). { intros. unfold Rabs. destruct Rcase_abs; lra. } intros. apply H. ...
The text was updated successfully, but these errors were encountered: