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

Tactic to transfer theorems / definitions using an equivalence. #1868

Open
urkud opened this issue Jan 8, 2020 · 9 comments
Open

Tactic to transfer theorems / definitions using an equivalence. #1868

urkud opened this issue Jan 8, 2020 · 9 comments
Labels
feature-request This issue is a feature request, either for mathematics, tactics, or CI t-meta Tactics, attributes or user commands

Comments

@urkud
Copy link
Member

urkud commented Jan 8, 2020

It would be nice to have a tactic that can transfer definitions and / or theorems through equivalences. E.g., all theorems in the upper half of data/equiv/algebra should be by equiv_transfer e.

In its simplest form it should assume that there is no structure on the target type, and transfer everything from the source type. I.e., it should analyze the requested type, and substitute e, e.symm, e.apply_symm_apply and e.symm_apply_apply as needed.

A more advanced version should be able to work with a target type that already has some structure but this structure agrees with that on the source type (e.g., e (a * b) = e a * e b), and the lemmas that prove these equalities either have predictable names, or are given as arguments to the tactic.

With the second type of tactic, it would be easy to define new types that are mathematically equivalent to old ones but provide better performance (more precisely, to prove theorems about these types).

@jcommelin
Copy link
Member

Related: #408

@cipher1024
Copy link
Collaborator

cipher1024 commented Jan 8, 2020

Also related: @CohenCyril spent a couple of intense weeks on the problem (his repo). It is not an easy problem and we'll have to be patient.

@gebner
Copy link
Member

gebner commented Jan 8, 2020

Since I didn't see this mentioned either here or at #408, there's the transfer tactic that Johannes wrote a long time ago. Here's an example in mathlib where it transfers theorems between and znum (an isomorphic copy of ).

@cipher1024
Copy link
Collaborator

It was mentioned in the conversation earlier. I think the consensus was that this machinery is too ad hoc and not very extendible. I don't personally have experience with it but that's what I got from the conversation. @CohenCyril on the other hand is formalizing a theory of parametricity to base transport on which promises to be more principled and more solid.

@jcommelin
Copy link
Member

Note that the transfer that @gebner mentions is indeed quite ad hoc: https://github.com/leanprover-community/mathlib/blob/master/src/data/num/lemmas.lean#L955
There is also: https://github.com/leanprover-community/mathlib/blob/master/src/tactic/transfer.lean I have no experience with this tactic.

@urkud
Copy link
Member Author

urkud commented Jan 9, 2020

@johoelzl Could you please explain what does src/tactic/transfer do?

@semorrison semorrison added t-meta Tactics, attributes or user commands feature-request This issue is a feature request, either for mathematics, tactics, or CI and removed tactic feature labels Mar 28, 2020
@semorrison
Copy link
Collaborator

I've done a bunch of work towards this, so far appearing in #2246 (an equiv_rw tactic) and #2251 (a transport tactic).

@urkud
Copy link
Member Author

urkud commented Mar 29, 2020

Can it do all the transfers in data/equiv/transfer_instance? Does it produce the same definitional equalities?

@semorrison
Copy link
Collaborator

Oh, I didn't even realise that file existed. Yes, I will certainly aspire to automate everything there away. (And hopefully synthesize lots of missing lemmas about these transferred instances.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request This issue is a feature request, either for mathematics, tactics, or CI t-meta Tactics, attributes or user commands
Projects
None yet
Development

No branches or pull requests

5 participants