Skip to content
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

Style guide: _tac instantiations and attributes #834

Merged
merged 3 commits into from
Dec 9, 2024

Conversation

Xaphiosis
Copy link
Member

Adds two sections:

I also added consistent double-newline before sections, and added some more emphasis on 2 being the standard indent at the start of the indentation section.

Commits are independent so can be reviewed separately. Let the bikeshedding begin.

Copy link
Member

@lsf37 lsf37 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy with this colour of the bike shed as it is. Thanks for adding these.

@lsf37 lsf37 linked an issue Dec 6, 2024 that may be closed by this pull request
Copy link
Contributor

@michaelmcinerney michaelmcinerney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

Copy link
Member

@corlewis corlewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some very minor bikeshedding, thanks for updating the style guide for these!

docs/Style.thy Outdated
Isabelle code is much easier to maintain when indented consistently. In apply style proofs we
indent by 2 spaces, and add an additional space for every additional subgoal.
Isabelle code is much easier to maintain when indented consistently.
When in doubt, and not constrained by vertically aligning items or subgoal-count offsets, use
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extremely minor grammar nitpick

Suggested change
When in doubt, and not constrained by vertically aligning items or subgoal-count offsets, use
When in doubt and not constrained by vertically aligning items or subgoal-count offsets, use

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shrug ... if it helps, I'll add the comma

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm suggesting to remove the comma, I don't think it's right.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, yes, will do then

docs/Style.thy Outdated
section \<open>Wrapping/indenting complex rule instantiations, usually as part of @{text "_tac"} methods\<close>

text \<open>
For simple instantiations, they can fit it on one line, like so.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sentence is a bit unclear to me. Are you saying that simple instantiations that can fit on one line should look like the following?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I should make that more explicit.

docs/Style.thy Outdated

lemma
"\<lbrakk>a; b\<rbrakk> \<Longrightarrow> a \<and> b"
apply (frule_tac P=a and Q="id b" in conjI) \<comment> \<open>when @{text a} and @{text b} contain bound vars\<close>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not clear to me what the intention of the comment is here. Is it about using the _tac form instead of where?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is correct. I want to avoid guiding people towards writing out the rule_tac version when a fact[where ...] will suffice. The rule_tac version is less generic, as it applies only to the _tacs, but the attribute version has many more uses.

Copy link
Member

@corlewis corlewis Dec 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with that goal but then I think that the comment needs to be more explicit. As it is, the mention of bound variables seems to come out of nowhere and the alternative attribute version isn't mentioned.

However, I'm then struggling to think of a way to keep it short. Would it make sense to add it as a note instead, with something vaguely like
@{text "_tac"} methods as shown here are generally used when the instantiations contain bound vars, otherwise instantiations with the @{text "[where ...]" attribute are preferred as they are more general.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, tuned, how does the latest commit look to you?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One potential typo, otherwise looks good to me!

Comment on lines +256 to +259
text \<open>
There is an important principle here: telling apart transformed/attributed facts from unaltered
facts at a glance. In other words avoid:\<close>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very useful comment, good thinking to include it. People are generally much better at following rules if they know the intention behind it, as opposed to it just being some arbitrary thing that they need to remember.

docs/Style.thy Outdated
(@{text "fact[where ...]"}) as they are more general.\<close>

text \<open>
For simple instantiations which can fit it on one line, style them as follows.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
For simple instantiations which can fit it on one line, style them as follows.
For simple instantiations which can fit on one line, style them as follows.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mondays. Thanks. Ok, then I can squash it all together now.

We generally tend to do two newlines before a section, and the style
guide was inconsistent about it.

Add extra subcoal-count indent example (in words).

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
@Xaphiosis Xaphiosis merged commit 3d8703e into seL4:master Dec 9, 2024
8 of 14 checks passed
@Xaphiosis Xaphiosis deleted the tac_style branch December 9, 2024 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation, READMEs, etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Decide on style for [def]rule_tac ... [and ...] in ...
4 participants