Skip to content

[Merged by Bors] - feat(SpecialFunctions/Artanh): basic definition and partial equivalence#32696

Closed
YuvalFilmus wants to merge 27 commits intoleanprover-community:masterfrom
YuvalFilmus:artanh
Closed

[Merged by Bors] - feat(SpecialFunctions/Artanh): basic definition and partial equivalence#32696
YuvalFilmus wants to merge 27 commits intoleanprover-community:masterfrom
YuvalFilmus:artanh

Conversation

@YuvalFilmus
Copy link
Copy Markdown
Collaborator

Definition of artanh, and proof that it is an inverse of tanh.


Open in Gitpod

@github-actions github-actions bot added the new-contributor This PR was made by a contributor with at most 5 merged PRs. Welcome to the community! label Dec 10, 2025
@YuvalFilmus

This comment was marked as outdated.

@github-actions github-actions bot added the t-analysis Analysis (normed *, calculus) label Dec 10, 2025
@github-actions
Copy link
Copy Markdown

github-actions bot commented Dec 10, 2025

PR summary b5195ed00f

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference
Mathlib.Analysis.SpecialFunctions.Artanh (new file) 1457

Declarations diff

+ abs_tanh_lt_one
+ artanh
+ artanh_bijOn
+ artanh_eq_half_log
+ artanh_eq_zero_iff
+ artanh_injOn
+ artanh_le_artanh
+ artanh_le_artanh_iff
+ artanh_lt_artanh
+ artanh_lt_artanh_iff
+ artanh_neg
+ artanh_nonneg
+ artanh_nonpos
+ artanh_pos
+ artanh_surjOn
+ artanh_tanh
+ artanh_zero
+ cosh_artanh
+ exp_artanh
+ neg_one_lt_tanh
+ sinh_artanh
+ strictMonoOn_artanh
+ strictMonoOn_one_add_div_one_sub
+ strictMonoOn_sqrt
+ tanhPartialEquiv
+ tanh_artanh
+ tanh_bijOn
+ tanh_injective
+ tanh_lt_one
+ tanh_sq_lt_one
+ tanh_surjOn

You can run this locally as follows
## summary with just the declaration names:
./scripts/declarations_diff.sh <optional_commit>

## more verbose report:
./scripts/declarations_diff.sh long <optional_commit>

The doc-module for script/declarations_diff.sh contains some details about this script.


No changes to technical debt.

You can run this locally as

./scripts/technical-debt-metrics.sh pr_summary
  • The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).

@mathlib4-merge-conflict-bot
Copy link
Copy Markdown
Collaborator

This pull request has conflicts, please merge master and resolve them.

@mathlib4-merge-conflict-bot mathlib4-merge-conflict-bot added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Dec 10, 2025
/-- `artanh` is defined using a logarithm, `arcosh x = log √((1 + x) / (1 - x))`. -/
@[pp_nodot]
def artanh (x : ℝ) :=
log √((1 + x) / (1 - x))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It is quite annoying that positivity doesn't work here (as well as elsewhere in this file).
Why is that the case?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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 : 01 + x := by grind
  have : 01 - x := by grind
  positivity

it just doesn't know how to convert -1 ≤ x to 0 ≤ 1 + x and x ≤ 1 to 0 ≤ 1 - x.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

YuvalFilmus and others added 2 commits December 10, 2025 23:08
Co-authored-by: SnirBroshi <26556598+SnirBroshi@users.noreply.github.com>
@YuvalFilmus YuvalFilmus removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Dec 10, 2025
@github-actions github-actions bot added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Dec 10, 2025
@YuvalFilmus YuvalFilmus removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Dec 10, 2025
Copy link
Copy Markdown
Collaborator

@SnirBroshi SnirBroshi left a comment

Choose a reason for hiding this comment

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

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.

YuvalFilmus and others added 10 commits December 11, 2025 15:46
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>
@YuvalFilmus YuvalFilmus reopened this Dec 11, 2025
@YuvalFilmus
Copy link
Copy Markdown
Collaborator Author

Added the monotonicity and positivity lemmas.

@j-loreaux j-loreaux added the awaiting-author A reviewer has asked the author a question or requested changes. label Dec 16, 2025
@YuvalFilmus YuvalFilmus removed the awaiting-author A reviewer has asked the author a question or requested changes. label Dec 16, 2025
Copy link
Copy Markdown
Contributor

@j-loreaux j-loreaux 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 reasonable now, aside from the last comment I have. Be sure to address it and then wait for CI before merging.

bors d+

@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Dec 17, 2025

✌️ YuvalFilmus can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@ghost ghost added the delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer). label Dec 17, 2025
@YuvalFilmus
Copy link
Copy Markdown
Collaborator Author

bors r+

mathlib-bors bot pushed a commit that referenced this pull request Dec 17, 2025
…ce (#32696)

Definition of `artanh`, and proof that it is an inverse of `tanh`.
@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Dec 17, 2025

Build failed:

Co-authored-by: SnirBroshi <26556598+SnirBroshi@users.noreply.github.com>
@YuvalFilmus
Copy link
Copy Markdown
Collaborator Author

bors r+

mathlib-bors bot pushed a commit that referenced this pull request Dec 18, 2025
…ce (#32696)

Definition of `artanh`, and proof that it is an inverse of `tanh`.
@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Dec 18, 2025

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title feat(SpecialFunctions/Artanh): basic definition and partial equivalence [Merged by Bors] - feat(SpecialFunctions/Artanh): basic definition and partial equivalence Dec 18, 2025
@mathlib-bors mathlib-bors bot closed this Dec 18, 2025
@YuvalFilmus YuvalFilmus deleted the artanh branch December 18, 2025 14:42
YuvalFilmus added a commit to YuvalFilmus/mathlib4 that referenced this pull request Dec 19, 2025
…ce (leanprover-community#32696)

Definition of `artanh`, and proof that it is an inverse of `tanh`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer). new-contributor This PR was made by a contributor with at most 5 merged PRs. Welcome to the community! t-analysis Analysis (normed *, calculus)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants