Skip to content

feat(Tactic): tactic for computing asymptotics of real functions#18486

Closed
vasnesterov wants to merge 52 commits intomasterfrom
vasnesterov/tendsto_tactic
Closed

feat(Tactic): tactic for computing asymptotics of real functions#18486
vasnesterov wants to merge 52 commits intomasterfrom
vasnesterov/tendsto_tactic

Conversation

@vasnesterov
Copy link
Copy Markdown
Collaborator

@vasnesterov vasnesterov commented Oct 31, 2024

It's an auxiliary PR which implements the entire compute_asymptotics tactic. I will split it into multiple small PRs.


In this PR I implement the compute_asymptotics tactic. Its purpose is to compute asymptotics of functions from to . So far it is able to compute the limit of any function constructed using arithmetic operations (+, -, *, /, inversion) and powers with constant real exponent.

example :
  let f := fun (x : ℝ) ↦ (4 * x)/(3 + 2 * x);
  Tendsto f atTop (nhds 2) := by
  simp only
  compute_asymptotics
  
example :
  let f := fun (x : ℝ) ↦ x^(1/2 : ℝ) / (x^(1/3 : ℝ) + x^(-1/3 : ℝ) + 18);
  Tendsto f atTop atTop := by
  simp only
  compute_asymptotics

It also supports non-numerical constants:

example (a : ℝ) (h : 0 < a) :
  let f := fun (x : ℝ) ↦ a * x;
  Tendsto f atTop atTop := by
  simp only
  compute_asymptotics
  
example :
  let f := fun (x : ℝ) ↦ Real.pi * x;
  Tendsto f atTop atTop := by
  simp only
  have : 0 < Real.pi := Real.pi_pos
  compute_asymptotics

(for more examples see compute_asymptotics.lean in tests)

Isn't it undecidable?

In general, finding the limit of a given function is undecidable problem, due to undecidability of the problem of comparing real numbers. So far I use linarith tactic for this under the hood. When it's unable to prove neither of x < y, y < x, x = y, the tactic fails.

TODO

  • Prove the goals of the form f =o[l] g and similarly for other O-notations.
  • Add sin, cos, exp, and log support.

References

I am basically implementing this article about computing asymptotics in Isabelle by Manuel Eberl.

Open in Gitpod

@vasnesterov vasnesterov added the WIP Work in progress label Oct 31, 2024
Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

lint-style (comment with "bot fix style" to have the bot commit all style suggestions)

[lint-style (comment with "bot fix style" to have the bot commit all style suggestions)] reported by reviewdog 🐶


[lint-style (comment with "bot fix style" to have the bot commit all style suggestions)] reported by reviewdog 🐶


[lint-style (comment with "bot fix style" to have the bot commit all style suggestions)] reported by reviewdog 🐶


[lint-style (comment with "bot fix style" to have the bot commit all style suggestions)] reported by reviewdog 🐶


[lint-style (comment with "bot fix style" to have the bot commit all style suggestions)] reported by reviewdog 🐶


[lint-style (comment with "bot fix style" to have the bot commit all style suggestions)] reported by reviewdog 🐶


[lint-style (comment with "bot fix style" to have the bot commit all style suggestions)] reported by reviewdog 🐶


[lint-style (comment with "bot fix style" to have the bot commit all style suggestions)] reported by reviewdog 🐶


[lint-style (comment with "bot fix style" to have the bot commit all style suggestions)] reported by reviewdog 🐶


[lint-style (comment with "bot fix style" to have the bot commit all style suggestions)] reported by reviewdog 🐶


[lint-style (comment with "bot fix style" to have the bot commit all style suggestions)] reported by reviewdog 🐶


[lint-style (comment with "bot fix style" to have the bot commit all style suggestions)] reported by reviewdog 🐶


[lint-style (comment with "bot fix style" to have the bot commit all style suggestions)] reported by reviewdog 🐶


[lint-style (comment with "bot fix style" to have the bot commit all style suggestions)] reported by reviewdog 🐶


[lint-style (comment with "bot fix style" to have the bot commit all style suggestions)] reported by reviewdog 🐶


[lint-style (comment with "bot fix style" to have the bot commit all style suggestions)] reported by reviewdog 🐶


[lint-style (comment with "bot fix style" to have the bot commit all style suggestions)] reported by reviewdog 🐶


[lint-style (comment with "bot fix style" to have the bot commit all style suggestions)] reported by reviewdog 🐶


[lint-style (comment with "bot fix style" to have the bot commit all style suggestions)] reported by reviewdog 🐶


[lint-style (comment with "bot fix style" to have the bot commit all style suggestions)] reported by reviewdog 🐶


[lint-style (comment with "bot fix style" to have the bot commit all style suggestions)] reported by reviewdog 🐶


[lint-style (comment with "bot fix style" to have the bot commit all style suggestions)] reported by reviewdog 🐶


[lint-style (comment with "bot fix style" to have the bot commit all style suggestions)] reported by reviewdog 🐶


[lint-style (comment with "bot fix style" to have the bot commit all style suggestions)] reported by reviewdog 🐶


[lint-style (comment with "bot fix style" to have the bot commit all style suggestions)] reported by reviewdog 🐶


[lint-style (comment with "bot fix style" to have the bot commit all style suggestions)] reported by reviewdog 🐶


[lint-style (comment with "bot fix style" to have the bot commit all style suggestions)] reported by reviewdog 🐶


[lint-style (comment with "bot fix style" to have the bot commit all style suggestions)] reported by reviewdog 🐶


[lint-style (comment with "bot fix style" to have the bot commit all style suggestions)] reported by reviewdog 🐶


[lint-style (comment with "bot fix style" to have the bot commit all style suggestions)] reported by reviewdog 🐶


[lint-style (comment with "bot fix style" to have the bot commit all style suggestions)] reported by reviewdog 🐶


[lint-style (comment with "bot fix style" to have the bot commit all style suggestions)] reported by reviewdog 🐶

apply Approximates_sub_zero h_tl
rw [eventuallyEq_iff_sub]
eta_expand
simp
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[lint-style (comment with "bot fix style" to have the bot commit all style suggestions)] reported by reviewdog 🐶

Suggested change
simp
simp?

apply Approximates_sub_zero h_tl
rw [eventuallyEq_iff_sub]
eta_expand
simp
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[lint-style (comment with "bot fix style" to have the bot commit all style suggestions)] reported by reviewdog 🐶

Suggested change
simp
simp?

have h_XY : HAdd.hAdd (α := PreMS (basis_hd :: basis_tl)) (Seq.cons (X_exp, X_coef) X_tl)
(Seq.cons (Y_exp, Y_coef) Y_tl) = ?_ := by
rw [add_unfold, add']
simp
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[lint-style (comment with "bot fix style" to have the bot commit all style suggestions)] reported by reviewdog 🐶

Suggested change
simp
simp?

have h_YZ : HAdd.hAdd (α := PreMS (basis_hd :: basis_tl)) (Seq.cons (Y_exp, Y_coef) Y_tl)
(Seq.cons (Z_exp, Z_coef) Z_tl) = ?_ := by
rw [add_unfold, add']
simp
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[lint-style (comment with "bot fix style" to have the bot commit all style suggestions)] reported by reviewdog 🐶

Suggested change
simp
simp?

· exact hY_comp
simp only [motive]
use .nil, Y_tl
simp
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[lint-style (comment with "bot fix style" to have the bot commit all style suggestions)] reported by reviewdog 🐶

Suggested change
simp
simp?

simp
exact ⟨hY_tl_wo, hX_coef_wo⟩
| cast j =>
simp
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[lint-style (comment with "bot fix style" to have the bot commit all style suggestions)] reported by reviewdog 🐶

Suggested change
simp
simp?

constructor
· exact h_left_comp
· rw [← h_right_eq.2, ← h_right_eq.1.1] -- copypaste
simp
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[lint-style (comment with "bot fix style" to have the bot commit all style suggestions)] reported by reviewdog 🐶

Suggested change
simp
simp?

· intro j
cases j using Fin.lastCases with
| last =>
simp
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[lint-style (comment with "bot fix style" to have the bot commit all style suggestions)] reported by reviewdog 🐶

Suggested change
simp
simp?

simp
exact ⟨hY_tl_wo, hX_coef_wo⟩
| cast j =>
simp
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[lint-style (comment with "bot fix style" to have the bot commit all style suggestions)] reported by reviewdog 🐶

Suggested change
simp
simp?

cases' b with b_exp b_coef b_tl
· apply Approximates_nil at hb_approx
left
simp
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[lint-style (comment with "bot fix style" to have the bot commit all style suggestions)] reported by reviewdog 🐶

Suggested change
simp
simp?

@leanprover-community-bot-assistant leanprover-community-bot-assistant 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, 2024
@vasnesterov vasnesterov changed the title feat(Tactic): Tactic for computing asymptotics of real functions feat(Tactic): tactic for computing asymptotics of real functions Apr 9, 2025
@mathlib4-dependent-issues-bot mathlib4-dependent-issues-bot added the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label May 8, 2025
@vasnesterov
Copy link
Copy Markdown
Collaborator Author

This PR has been migrated to a fork-based workflow: #28291

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) migrated-to-fork t-meta Tactics, attributes or user commands WIP Work in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants