[Merged by Bors] - feat(SpecialFunctions/Artanh): basic definition and partial equivalence#32696
[Merged by Bors] - feat(SpecialFunctions/Artanh): basic definition and partial equivalence#32696YuvalFilmus wants to merge 27 commits intoleanprover-community:masterfrom
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
PR summary b5195ed00fImport changes for modified filesNo significant changes to the import graph Import changes for all files
|
|
This pull request has conflicts, please merge |
| /-- `artanh` is defined using a logarithm, `arcosh x = log √((1 + x) / (1 - x))`. -/ | ||
| @[pp_nodot] | ||
| def artanh (x : ℝ) := | ||
| log √((1 + x) / (1 - x)) |
There was a problem hiding this comment.
Mathlib/Analysis/SpecialFunctions/Log/Deriv.lean uses the expression 1 / 2 * log ((1 + x) / (1 - x)) a few times (see #31487) as a stand-in for artanh.
I agree with the choice to go with sqrt so that the junk values outside of the domain will all be zero, but perhaps you should add a lemma for 1 / 2 * log ((1 + x) / (1 - x)) = artanh x for all 0 ≤ x (using Real.log_sqrt and one_div_mul_eq_div). That file should probably import this file and use the new artanh in those places.
There was a problem hiding this comment.
Added a theorem artanh_eq_half_log.
Perhaps the name could be improved.
I don't immediately see how to prove it for all 0 ≤ x.
There was a problem hiding this comment.
It is quite annoying that positivity doesn't work here (as well as elsewhere in this file).
Why is that the case?
There was a problem hiding this comment.
I don't immediately see how to prove it for all 0 ≤ x.
Oh yes sorry I meant for all x where the thing inside the square root is non-negative.
You can extend the Ioo to Icc:
theorem artanh_eq_half_log {x : ℝ} (hx : x ∈ Icc (-1) 1) :
artanh x = 1 / 2 * log ((1 + x) / (1 - x)) := by
rw [artanh, log_sqrt <| div_nonneg (by grind) (by grind), one_div_mul_eq_div]It is quite annoying that positivity doesn't work here (as well as elsewhere in this file).
Why is that the case?
I think that positivity won't do ring operations, but I'm not sure. It does know how to handle the division if you help it:
theorem artanh_eq_half_log {x : ℝ} (hx : x ∈ Icc (-1) 1) :
artanh x = 1 / 2 * log ((1 + x) / (1 - x)) := by
rw [artanh, log_sqrt, one_div_mul_eq_div]
have : 0 ≤ 1 + x := by grind
have : 0 ≤ 1 - x := by grind
positivityit just doesn't know how to convert -1 ≤ x to 0 ≤ 1 + x and x ≤ 1 to 0 ≤ 1 - x.
There was a problem hiding this comment.
Probably it doesn't matter, but I'll mention that if one instead chooses artanh x := 1 / 2 * log ((1 + x) / (1 - x)), then the junk values for Real.log guarantee that artanh x⁻¹ = (artanh x)⁻¹ for all x.
Co-authored-by: SnirBroshi <26556598+SnirBroshi@users.noreply.github.com>
SnirBroshi
left a comment
There was a problem hiding this comment.
Since you asked for advice on proofs, here's how to make grind do a bit of the work for you.
In the future grind will probably be able to deduce the positivity stuff on its own too.
Though I'd probably wait for an opinion from an official Mathlib reviewer/maintainer on whether these grind proofs are better, since passing many numeric lemmas to grind is considered brittle as grind is still being worked on so its behavior isn't finalized.
Co-authored-by: SnirBroshi <26556598+SnirBroshi@users.noreply.github.com>
Co-authored-by: SnirBroshi <26556598+SnirBroshi@users.noreply.github.com>
Co-authored-by: SnirBroshi <26556598+SnirBroshi@users.noreply.github.com>
Co-authored-by: SnirBroshi <26556598+SnirBroshi@users.noreply.github.com>
Co-authored-by: SnirBroshi <26556598+SnirBroshi@users.noreply.github.com>
|
Added the monotonicity and positivity lemmas. |
j-loreaux
left a comment
There was a problem hiding this comment.
This looks reasonable now, aside from the last comment I have. Be sure to address it and then wait for CI before merging.
bors d+
|
✌️ YuvalFilmus can now approve this pull request. To approve and merge a pull request, simply reply with |
|
bors r+ |
…ce (#32696) Definition of `artanh`, and proof that it is an inverse of `tanh`.
|
Build failed: |
Co-authored-by: SnirBroshi <26556598+SnirBroshi@users.noreply.github.com>
|
bors r+ |
…ce (#32696) Definition of `artanh`, and proof that it is an inverse of `tanh`.
|
Pull request successfully merged into master. Build succeeded: |
…ce (leanprover-community#32696) Definition of `artanh`, and proof that it is an inverse of `tanh`.
Definition of
artanh, and proof that it is an inverse oftanh.