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

[Merged by Bors] - feat: value of f (x + n * c), where f is antiperiodic with antiperiod c #11436

Closed
wants to merge 26 commits into from

Conversation

trivial1711
Copy link
Collaborator

@trivial1711 trivial1711 commented Mar 17, 2024

Add @[simp] theorem negOnePow_two_mul_add_one to Algebra.GroupPower.NegOnePow, which states that (2 * n + 1).negOnePow = -1.

Add theorems to Algebra.Periodic about the value of f (x + n • c), f (x - n • c), and f (n • c - x), where we have Antiperiodic f c. All these theorems have variants for either n : ℕ or n : ℤ, and they also have variants using * instead of if the domain and codomain of f are rings.

For all real numbers x and all integers n. deduce the following. All these theorems are in Analysis.SpecialFunctions.Trigonometric.Basic, they are not @[simp], and they have a variation (using the notation (-1) ^ n instead of n.negOnePow) for natural number n.

  • sin (x + n * π) = n.negOnePow * sin x
  • sin (x - n * π) = n.negOnePow * sin x
  • sin (n * π - x) = -(n.negOnePow * sin x)
  • cos (x + n * π) = n.negOnePow * cos x
  • cos (x - n * π) = n.negOnePow * cos x
  • cos (n * π - x) = n.negOnePow * cos x

Open in Gitpod

@trivial1711 trivial1711 added easy < 20s of review time. See the lifecycle page for guidelines. awaiting-review The author would like community review of the PR and removed easy < 20s of review time. See the lifecycle page for guidelines. labels Mar 17, 2024
Copy link
Collaborator

@grunweg grunweg left a comment

Choose a reason for hiding this comment

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

Thank you for this contribution, it's nice for such API gaps to get filled!

I have a few golfing suggestions, which should be quick to address.

Mathlib/Algebra/GroupPower/NegOnePow.lean Outdated Show resolved Hide resolved
Mathlib/Analysis/SpecialFunctions/Trigonometric/Basic.lean Outdated Show resolved Hide resolved
Mathlib/Analysis/SpecialFunctions/Trigonometric/Basic.lean Outdated Show resolved Hide resolved
Mathlib/Analysis/SpecialFunctions/Trigonometric/Basic.lean Outdated Show resolved Hide resolved
Mathlib/Analysis/SpecialFunctions/Trigonometric/Basic.lean Outdated Show resolved Hide resolved
Mathlib/Analysis/SpecialFunctions/Trigonometric/Basic.lean Outdated Show resolved Hide resolved
Mathlib/Analysis/SpecialFunctions/Trigonometric/Basic.lean Outdated Show resolved Hide resolved
@grunweg grunweg added the t-analysis Analysis (normed *, calculus) label Mar 17, 2024
@grunweg grunweg changed the title feat: add lemmas about the value of sin (x + n * π), etc. feat: value of sin, cos (x + n * π), etc. Mar 17, 2024
@trivial1711
Copy link
Collaborator Author

Thanks for the feedback. I have made the changes you suggest.

@trivial1711 trivial1711 added the new-contributor This PR was made by a contributor with fewer than 5 merged PRs. Welcome to the community! label Mar 18, 2024
@trivial1711
Copy link
Collaborator Author

I wonder whether these theorems should all be a special case of more general theorems for Antiperiodic functions (https://leanprover-community.github.io/mathlib4_docs/Mathlib/Algebra/Periodic.html#Function.Antiperiodic).

@grunweg
Copy link
Collaborator

grunweg commented Mar 18, 2024

At first thought, that certainly sounds useful. In any case, these results for anti-periodic functions would be nice to have (and the identities for sin and cos and be deduced from that).

@trivial1711
Copy link
Collaborator Author

Hello, I've redone this branch so that it deduces the facts about sin and cos from more general facts about Antiperiodic functions.

@trivial1711 trivial1711 changed the title feat: value of sin, cos (x + n * π), etc. feat: value of f (x + n * c), where f is antiperiodic with antiperiod c Mar 19, 2024
@YaelDillies
Copy link
Collaborator

In a field, you certainly can?

@trivial1711
Copy link
Collaborator Author

Good point. Does that mean I should state the lemmas about trigonometric functions using (-1) ^ n, but continue to use negOnePow for the general lemmas about antiperiodic functions?

@YaelDillies
Copy link
Collaborator

Yes, that seems best. From my limited understanding, negOnePow is meant to be used on non-field rings.

@trivial1711
Copy link
Collaborator Author

After playing around with this, I now think that Field.zpow is so difficult to work with that it would be better to leave it as negOnePow for now. Unless I am missing something, there are no lemmas in mathlib about Field.zpow at all, aside from the ones that are part of the definition of a field: https://loogle.lean-lang.org/?q=Field.zpow.

For example, let K be a field. It's almost comically difficult to prove something like (-1 : K) ^ (m + n) = (-1 : K) ^ m * (-1 : K) ^ n. On the other hand, this equation is very easy if you use negOnePow instead.

Even if the API of Field.zpow were filled out more to include the equation x ^ (m + n) = x ^ m * x ^ n for nonzero x (note that it's not true for x = 0), you'd still have to include a proof that -1 ≠ 0 every time you want to do the simplification (-1 : K) ^ (m + n) = (-1 : K) ^ m * (-1 : K) ^ n.

I think part of the purpose of negOnePow is to be able to write expressions like (-1) ^ n without using Field.zpow.

@YaelDillies
Copy link
Collaborator

Nobody uses Field.zpow in real life. We use ^ notation instead and the lemmas refer to it as zpow, eg x ^ (m + n) = x ^ m * x ^ n for nonzero x is zpow_add₀.

@trivial1711
Copy link
Collaborator Author

ok, I've fixed it. thanks!

Copy link
Collaborator

@YaelDillies YaelDillies 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 alright to me but I need a second pair of eyes

maintainer merge

Copy link

github-actions bot commented Apr 2, 2024

🚀 Pull request has been placed on the maintainer queue by YaelDillies.

Copy link
Member

@fpvandoorn fpvandoorn left a comment

Choose a reason for hiding this comment

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

LGTM

bors merge

@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added ready-to-merge This PR has been sent to bors. and removed awaiting-review The author would like community review of the PR labels Apr 2, 2024
mathlib-bors bot pushed a commit that referenced this pull request Apr 2, 2024
… c (#11436)

Add `@[simp]` theorem `negOnePow_two_mul_add_one` to `Algebra.GroupPower.NegOnePow`, which states that `(2 * n + 1).negOnePow = -1`.

Add theorems to `Algebra.Periodic` about the value of `f (x + n • c)`, `f (x - n • c)`, and `f (n • c - x)`, where we have `Antiperiodic f c`. All these theorems have variants for either `n : ℕ` or `n : ℤ`, and they also have variants using `*` instead of `•` if the domain and codomain of `f` are rings.

For all real numbers `x` and all integers `n`. deduce the following. All these theorems are in `Analysis.SpecialFunctions.Trigonometric.Basic`, they are not `@[simp]`, and they have a variation (using the notation `(-1) ^ n` instead of `n.negOnePow`) for natural number `n`.
- `sin (x + n * π) = n.negOnePow * sin x`
- `sin (x - n * π) = n.negOnePow * sin x`
- `sin (n * π - x) = -(n.negOnePow * sin x)`
- `cos (x + n * π) = n.negOnePow * cos x`
- `cos (x - n * π) = n.negOnePow * cos x`
- `cos (n * π - x) = n.negOnePow * cos x`
@mathlib-bors
Copy link

mathlib-bors bot commented Apr 2, 2024

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title feat: value of f (x + n * c), where f is antiperiodic with antiperiod c [Merged by Bors] - feat: value of f (x + n * c), where f is antiperiodic with antiperiod c Apr 2, 2024
@mathlib-bors mathlib-bors bot closed this Apr 2, 2024
@mathlib-bors mathlib-bors bot deleted the trivial1711-sin_add_int_mul_pi branch April 2, 2024 13:53
Louddy pushed a commit that referenced this pull request Apr 15, 2024
… c (#11436)

Add `@[simp]` theorem `negOnePow_two_mul_add_one` to `Algebra.GroupPower.NegOnePow`, which states that `(2 * n + 1).negOnePow = -1`.

Add theorems to `Algebra.Periodic` about the value of `f (x + n • c)`, `f (x - n • c)`, and `f (n • c - x)`, where we have `Antiperiodic f c`. All these theorems have variants for either `n : ℕ` or `n : ℤ`, and they also have variants using `*` instead of `•` if the domain and codomain of `f` are rings.

For all real numbers `x` and all integers `n`. deduce the following. All these theorems are in `Analysis.SpecialFunctions.Trigonometric.Basic`, they are not `@[simp]`, and they have a variation (using the notation `(-1) ^ n` instead of `n.negOnePow`) for natural number `n`.
- `sin (x + n * π) = n.negOnePow * sin x`
- `sin (x - n * π) = n.negOnePow * sin x`
- `sin (n * π - x) = -(n.negOnePow * sin x)`
- `cos (x + n * π) = n.negOnePow * cos x`
- `cos (x - n * π) = n.negOnePow * cos x`
- `cos (n * π - x) = n.negOnePow * cos x`
atarnoam pushed a commit that referenced this pull request Apr 16, 2024
… c (#11436)

Add `@[simp]` theorem `negOnePow_two_mul_add_one` to `Algebra.GroupPower.NegOnePow`, which states that `(2 * n + 1).negOnePow = -1`.

Add theorems to `Algebra.Periodic` about the value of `f (x + n • c)`, `f (x - n • c)`, and `f (n • c - x)`, where we have `Antiperiodic f c`. All these theorems have variants for either `n : ℕ` or `n : ℤ`, and they also have variants using `*` instead of `•` if the domain and codomain of `f` are rings.

For all real numbers `x` and all integers `n`. deduce the following. All these theorems are in `Analysis.SpecialFunctions.Trigonometric.Basic`, they are not `@[simp]`, and they have a variation (using the notation `(-1) ^ n` instead of `n.negOnePow`) for natural number `n`.
- `sin (x + n * π) = n.negOnePow * sin x`
- `sin (x - n * π) = n.negOnePow * sin x`
- `sin (n * π - x) = -(n.negOnePow * sin x)`
- `cos (x + n * π) = n.negOnePow * cos x`
- `cos (x - n * π) = n.negOnePow * cos x`
- `cos (n * π - x) = n.negOnePow * cos x`
uniwuni pushed a commit that referenced this pull request Apr 19, 2024
… c (#11436)

Add `@[simp]` theorem `negOnePow_two_mul_add_one` to `Algebra.GroupPower.NegOnePow`, which states that `(2 * n + 1).negOnePow = -1`.

Add theorems to `Algebra.Periodic` about the value of `f (x + n • c)`, `f (x - n • c)`, and `f (n • c - x)`, where we have `Antiperiodic f c`. All these theorems have variants for either `n : ℕ` or `n : ℤ`, and they also have variants using `*` instead of `•` if the domain and codomain of `f` are rings.

For all real numbers `x` and all integers `n`. deduce the following. All these theorems are in `Analysis.SpecialFunctions.Trigonometric.Basic`, they are not `@[simp]`, and they have a variation (using the notation `(-1) ^ n` instead of `n.negOnePow`) for natural number `n`.
- `sin (x + n * π) = n.negOnePow * sin x`
- `sin (x - n * π) = n.negOnePow * sin x`
- `sin (n * π - x) = -(n.negOnePow * sin x)`
- `cos (x + n * π) = n.negOnePow * cos x`
- `cos (x - n * π) = n.negOnePow * cos x`
- `cos (n * π - x) = n.negOnePow * cos x`
callesonne pushed a commit that referenced this pull request Apr 22, 2024
… c (#11436)

Add `@[simp]` theorem `negOnePow_two_mul_add_one` to `Algebra.GroupPower.NegOnePow`, which states that `(2 * n + 1).negOnePow = -1`.

Add theorems to `Algebra.Periodic` about the value of `f (x + n • c)`, `f (x - n • c)`, and `f (n • c - x)`, where we have `Antiperiodic f c`. All these theorems have variants for either `n : ℕ` or `n : ℤ`, and they also have variants using `*` instead of `•` if the domain and codomain of `f` are rings.

For all real numbers `x` and all integers `n`. deduce the following. All these theorems are in `Analysis.SpecialFunctions.Trigonometric.Basic`, they are not `@[simp]`, and they have a variation (using the notation `(-1) ^ n` instead of `n.negOnePow`) for natural number `n`.
- `sin (x + n * π) = n.negOnePow * sin x`
- `sin (x - n * π) = n.negOnePow * sin x`
- `sin (n * π - x) = -(n.negOnePow * sin x)`
- `cos (x + n * π) = n.negOnePow * cos x`
- `cos (x - n * π) = n.negOnePow * cos x`
- `cos (n * π - x) = n.negOnePow * cos x`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintainer-merge new-contributor This PR was made by a contributor with fewer than 5 merged PRs. Welcome to the community! ready-to-merge This PR has been sent to bors. t-analysis Analysis (normed *, calculus)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants