Skip to content

[Merged by Bors] - feat: port 'section relation' in Init/Logic#379

Closed
dwrensha wants to merge 2 commits intoleanprover-community:masterfrom
dwrensha:section-relation
Closed

[Merged by Bors] - feat: port 'section relation' in Init/Logic#379
dwrensha wants to merge 2 commits intoleanprover-community:masterfrom
dwrensha:section-relation

Conversation

@dwrensha
Copy link
Copy Markdown
Member

@dwrensha dwrensha commented Aug 24, 2022

#34 left section relation as a TODO. This PR fills it in.

Compare to the Lean 3 version: https://github.com/leanprover-community/lean/blob/741670c439f1ca266bc7fe61ef7212cc9afd9dd8/library/init/logic.lean#L1027-L1062

@dwrensha
Copy link
Copy Markdown
Member Author

The nolint on empty_relation is to avoid this error:


/- The `unusedArguments` linter reports:
UNUSED ARGUMENTS. -/
-- Mathlib.Init.Logic
#check empty_relation.{u} /- argument 2 x✝¹ : α, argument 3 x✝ : α -/

I suspect the linter has a bug.

@digama0
Copy link
Copy Markdown
Member

digama0 commented Aug 24, 2022

I think the linter is correct, and the @[nolint] annotation is also correct. This definition actually does have unused arguments.

@dwrensha
Copy link
Copy Markdown
Member Author

def empty_relation := λ _ _ : α => False

Yes, those _ arguments are unused, but shouldn't the linter ignore them because they are named _? In my editor I don't see them underlined by a warning squiggle -- it's only when I do runLinter that I get the error.

@digama0
Copy link
Copy Markdown
Member

digama0 commented Aug 24, 2022

There are two kinds of linters here: the lean core linters, and the mathlib linters. The lean core linters are reported as you type and are controlled by set_option linter.*, and the mathlib linters are run when you call runLinter or in CI and are controlled by the nolints.txt file and the @[nolint] annotation.

The mathlib linters generally look at declarations in the environment, and are of a more "semantic" nature than the lean core linters that look at the syntax of what you wrote. The unusedArguments linter is a mathlib linter, and it doesn't care if you wrote a _ or not, it's trying to determine if you actually didn't use an argument after all the tactics have run to produce a term. You are thinking of the linter.unusedVariables lean core linter, which checks whether you have actually referred to a variable in the written syntax and honors _x variable naming.

@gebner
Copy link
Copy Markdown
Member

gebner commented Aug 24, 2022

bors r+

bors bot pushed a commit that referenced this pull request Aug 24, 2022
@bors
Copy link
Copy Markdown

bors bot commented Aug 24, 2022

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title feat: port 'section relation' in Init/Logic [Merged by Bors] - feat: port 'section relation' in Init/Logic Aug 24, 2022
@bors bors bot closed this Aug 24, 2022
@dwrensha dwrensha deleted the section-relation branch August 24, 2022 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants