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

feat: abbrev produces theorems where appropriate #6083

Closed
wants to merge 3 commits into from
Closed

Conversation

kim-em
Copy link
Collaborator

@kim-em kim-em commented Nov 14, 2024

This PR modifies the abbrev keyword, ensuring that it produces a theorem when the declaration is a Prop. This is convenient for the frequent current use case of abbrev to set up deprecations.

@github-actions github-actions bot added changes-stage0 Contains stage0 changes, merge manually using rebase toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN labels Nov 14, 2024
@leanprover-community-bot
Copy link
Collaborator

leanprover-community-bot commented Nov 14, 2024

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase e0d7c3ac79bd9167ce7d295f51bf3779a04f7a07 --onto 9a8543347796e52070ff7936661ae48fcebfea60. (2024-11-14 23:35:49)
  • ✅ Mathlib branch lean-pr-testing-6083 has successfully built against this PR. (2024-11-21 08:55:45) View Log
  • ✅ Mathlib branch lean-pr-testing-6083 has successfully built against this PR. (2024-11-26 07:13:12) View Log
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 827062f807cd869709fb71d5d04a00ff10320be3 --onto 6d495586a1836da3e12efb4fbf9946bd9088ac5f. (2024-11-29 01:12:55)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 904404303b5b7f2f597498af14f793ab72d82c87 --onto 3c5e612dc54733cd707becb929457d2f9d8ca6fd. (2024-12-03 04:27:53)

@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc November 14, 2024 23:37 Inactive
@eric-wieser
Copy link
Contributor

Is there any advantage of using abbrev over theorem in this case?

@kim-em
Copy link
Collaborator Author

kim-em commented Nov 17, 2024

Is there any advantage of using abbrev over theorem in this case?

Yes, we can use abbrev X := @Y, to avoid having the type out the signature, when deprecating. In Batteries and below, we have alias, but I don't think alias is ready to move upstream (precisely because it results in us having too many ways to do the same thing: eventually I would like a unification of abbrev and alias functionality into a single keyword).

@kim-em kim-em force-pushed the abbrev_thm branch 2 times, most recently from a4b2b68 to 1431cba Compare November 21, 2024 07:48
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Nov 21, 2024
@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc November 21, 2024 08:13 Inactive
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Nov 21, 2024
@leanprover-community-bot leanprover-community-bot added the builds-mathlib CI has verified that Mathlib builds against this PR label Nov 21, 2024
@kim-em kim-em added the awaiting-review Waiting for someone to review the PR label Nov 26, 2024
@kim-em
Copy link
Collaborator Author

kim-em commented Nov 26, 2024

I'm adding the awaiting-review tag as I would like another set of eyes on this before merging. It feels a bit hacky to me still. :-(

This is an intermediate measure until we decide on a unification of alias / abbrev etc.

@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc November 26, 2024 06:30 Inactive
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Nov 26, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Nov 26, 2024
@kim-em kim-em marked this pull request as ready for review November 26, 2024 06:44
@kim-em kim-em added the changelog-language Language features, tactics, and metaprograms label Nov 26, 2024
@kim-em kim-em force-pushed the abbrev_thm branch 2 times, most recently from 7872b4a to 1801d74 Compare November 29, 2024 00:48
@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc November 29, 2024 01:11 Inactive
@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc December 3, 2024 04:21 Inactive
@kim-em kim-em added the release-ci Enable all CI checks for a PR, like is done for releases label Dec 3, 2024
@nomeata
Copy link
Collaborator

nomeata commented Dec 6, 2024

For just offering something under a different name, I guess that can be done on the level of renaming variables.

theorem foo : True := .intro

open _root_ renaming foo → alias

(Likely this idiom doens't work completely the way it seems to work, e.g. across modules.)

Unfortunately deprecation attributes are attached to the underlying constant, not to the alias:

theorem foo : True := .intro

open _root_ renaming foo → alias

attribute [deprecated "test"] alias

/-- warning: `foo` has been deprecated: test -/
#guard_msgs in def ok := foo
/-- warning: `foo` has been deprecated: test -/
#guard_msgs in def not_ok := alias

If the latter could change then the whole use-case of providing alternative names could be moved from the level of definitions to the level of name resolution, which is likely more robust anyways?

@Kha
Copy link
Member

Kha commented Dec 10, 2024

@kim-em Could you explain what the limitations of the current behavior are, i.e. abbrev not creating a theorem?

Note that declarations changing their kind post-hoc can also be an issue for parallelism.

@kim-em
Copy link
Collaborator Author

kim-em commented Dec 10, 2024

@kim-em Could you explain what the limitations of the current behavior are, i.e. abbrev not creating a theorem?

Note that declarations changing their kind post-hoc can also be an issue for parallelism.

It's not super important, but I have been trying to get the Batteries environment linter suite running on Lean itself, and all the abbrevs currently make the defLemma linter very noisy, and hard to be sure we're otherwise satisfying.

@Kha
Copy link
Member

Kha commented Dec 11, 2024

Ok, given the additional complication with parallelism, I'd prefer adjusting the linter instead

@kim-em kim-em closed this Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-review Waiting for someone to review the PR builds-mathlib CI has verified that Mathlib builds against this PR changelog-language Language features, tactics, and metaprograms changes-stage0 Contains stage0 changes, merge manually using rebase release-ci Enable all CI checks for a PR, like is done for releases toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants