Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Conversation

@0x182d4454fb211940
Copy link
Collaborator

@0x182d4454fb211940 0x182d4454fb211940 commented Jul 18, 2022

Adds an attribute expand_exists, which takes a proof that something exists with some property, and outputs a value using classical.some, and a proof that it has that property using classical.some_spec.

Closes #11682


Open in Gitpod

@robertylewis robertylewis added awaiting-review The author would like community review of the PR t-meta Tactics, attributes or user commands modifies-tactic-syntax This PR adds a new interactive tactic or modifies the syntax of an existing tactic. labels Jul 18, 2022
Copy link
Member

@alexjbest alexjbest left a comment

Choose a reason for hiding this comment

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

This looks really good, thanks! I left some mostly superficial comments
Adding a test file would also be good, demonstrating the usage too.
Also adding something to the PR description is nice, as that becomes the final commit message that people will see when they git blame your code.

It would also be good, to (maybe in a separate PR) identify examples of this pattern that can be replaced by your attribute, grepping for def.*:=.*some already reveals many!

@robertylewis robertylewis added awaiting-author A reviewer has asked the author a question or requested changes and removed awaiting-review The author would like community review of the PR labels Jul 18, 2022
@0x182d4454fb211940 0x182d4454fb211940 added awaiting-review The author would like community review of the PR and removed awaiting-author A reviewer has asked the author a question or requested changes labels Jul 19, 2022
Copy link
Member

@robertylewis robertylewis left a comment

Choose a reason for hiding this comment

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

This is nifty! A very clean implementation, a lot easier to follow than one based on choose. Two comments:

  • Do you think you could add the user command version? It's probably only occasionally useful, but it should just involve factoring a few lines out of expand_exists_attr.
  • In the test file, dependant -> dependent. (I just now learned BrE uses "dependant" for the noun form, but this is an adjective.)

@robertylewis robertylewis added awaiting-author A reviewer has asked the author a question or requested changes and removed awaiting-review The author would like community review of the PR labels Jul 20, 2022
@alexjbest
Copy link
Member

I'm not sure I agree with needing a user command version, attribute [expand_exists blah foo] my_existential can already be used anywhere, and it just seems adding extra random syntaxes with no clear benefit makes more work porting to lean 4 at this point.
Do you have a use case in mind @robertylewis ?

@robertylewis
Copy link
Member

I'm not sure I agree with needing a user command version, attribute [expand_exists blah foo] my_existential can already be used anywhere, and it just seems adding extra random syntaxes with no clear benefit makes more work porting to lean 4 at this point. Do you have a use case in mind @robertylewis ?

On the one hand, I think it's very little overhead (even in Lean 3, especially in Lean 4). On the other hand I don't think it's important, and you're right that the attribute version has the same effect with slightly clunkier syntax. So let's not worry about it for now.

Copy link
Member

@robertylewis robertylewis left a comment

Choose a reason for hiding this comment

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

Could you import this file in src/tactic/default.lean so it's available with import tactic?

Copy link
Member

@robertylewis robertylewis left a comment

Choose a reason for hiding this comment

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

This looks great, thanks again! If you're interested, I second Alex's suggestion for a follow-up PR adding some uses of the attribute to mathlib.

bors merge

@leanprover-community-bot-assistant leanprover-community-bot-assistant added ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.) and removed awaiting-author A reviewer has asked the author a question or requested changes labels Jul 20, 2022
bors bot pushed a commit that referenced this pull request Jul 20, 2022
Adds an attribute `expand_exists`, which takes a proof that something exists with some property, and outputs a value using `classical.some`, and a proof that it has that property using `classical.some_spec`.

Closes #11682
@bors
Copy link

bors bot commented Jul 20, 2022

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title feat(tactic/attribute): add expand_exists [Merged by Bors] - feat(tactic/attribute): add expand_exists Jul 20, 2022
@bors bors bot closed this Jul 20, 2022
@bors bors bot deleted the expand_exists branch July 20, 2022 19:03
joelriou pushed a commit that referenced this pull request Jul 23, 2022
Adds an attribute `expand_exists`, which takes a proof that something exists with some property, and outputs a value using `classical.some`, and a proof that it has that property using `classical.some_spec`.

Closes #11682
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

modifies-tactic-syntax This PR adds a new interactive tactic or modifies the syntax of an existing tactic. ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.) t-meta Tactics, attributes or user commands

Projects

None yet

Development

Successfully merging this pull request may close these issues.

command to unpack an existential with classical.some

5 participants