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
to_additive fails for integer literals #4210
Comments
The problem here is that |
One possible check we can do (which is a hack): if the first argument of a constant is another constant (not applied to any arguments), then we don't replace it. The assumption is that the first argument is always the type in question, and if that is another fixed (i.e. an If the first argument is something applied to arguments, it could be something like This does not take care of |
Related Zulip threads: |
Prove the uniqueness of Haar measure (up to a scalar) following *Measure Theory* by Paul Halmos. This proof seems to contain an omission which we fix by adding an extra hypothesis to an intermediate lemma. Add some lemmas about left invariant regular measures. We add the file `measure_theory.prod_group` which contain various measure-theoretic properties of products of topological groups, needed for the uniqueness. We add `@[to_additive]` to some declarations in `measure_theory`, but leave it out for many because of #4210. This causes some renamings in concepts, like `is_left_invariant` -> `is_mul_left_invariant` and `measure.conj` -> `measure.inv` (though a better naming suggestion for this one is welcome).
…ypes (#7792) * Fixes #4210 * Adds a heuristic to `@[to_additive]` that decides which multiplicative identifiers to replace with their additive counterparts. * See [Zulip](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/to_additive.20and.20fixed.20types) thread or documentation for the precise heuristic. * We tag some types with `@[to_additive]`, so that they are handled correctly by the heurstic. These types `pempty`, `empty`, `unit` and `punit`. * We make the following change to enable to above bullet point: you are allowed to translate a declaration to itself, only if you write its name again as argument of the attribute (if you don't specify an argument we want to raise an error, since that likely is a mistake). * Because of this heuristic, all declarations with the `@[to_additive]` attribute should have a type with a multiplicative structure on it as its first argument. The first argument should not be an arbitrary indexing type. This means that in `finset.prod` and `finprod` we reorder the first two (implicit) arguments, so that the first argument is the codomain of the function. * This will eliminate many (but not all) type mismatches generated by `@[to_additive]`. * This heuristic doesn't catch all cases: for example, the declaration could have two type arguments with multiplicative structure, and the second one is `ℕ`, but the first one is a variable. Co-authored-by: Floris van Doorn <fpv@andrew.cmu.edu>
…ypes (#7792) * Fixes #4210 * Adds a heuristic to `@[to_additive]` that decides which multiplicative identifiers to replace with their additive counterparts. * See [Zulip](https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/to_additive.20and.20fixed.20types) thread or documentation for the precise heuristic. * We tag some types with `@[to_additive]`, so that they are handled correctly by the heurstic. These types `pempty`, `empty`, `unit` and `punit`. * We make the following change to enable to above bullet point: you are allowed to translate a declaration to itself, only if you write its name again as argument of the attribute (if you don't specify an argument we want to raise an error, since that likely is a mistake). * Because of this heuristic, all declarations with the `@[to_additive]` attribute should have a type with a multiplicative structure on it as its first argument. The first argument should not be an arbitrary indexing type. This means that in `finset.prod` and `finprod` we reorder the first two (implicit) arguments, so that the first argument is the codomain of the function. * This will eliminate many (but not all) type mismatches generated by `@[to_additive]`. * This heuristic doesn't catch all cases: for example, the declaration could have two type arguments with multiplicative structure, and the second one is `ℕ`, but the first one is a variable. Co-authored-by: Floris van Doorn <fpv@andrew.cmu.edu>
I'm not sure what's going on here, but
fails with
The text was updated successfully, but these errors were encountered: