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

feat(Data/Nat/Find): Nat.find_mono_of_le and Nat.find_congr #22811

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

pechersky
Copy link
Collaborator

@pechersky pechersky commented Mar 10, 2025

Both strong versions (p and q agree below some x) and weak (p and q agree everywhere)

helper for not juggling generalize_proofs


Open in Gitpod

helper for not juggling generalize_proofs
@pechersky pechersky added easy < 20s of review time. See the lifecycle page for guidelines. t-data Data (lists, quotients, numbers, etc) labels Mar 10, 2025
Copy link

github-actions bot commented Mar 10, 2025

PR summary f22fa274d0

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff

+ find_congr
+ find_congr'
+ find_mono_of_le

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).

Copy link
Collaborator

@Ruben-VandeVelde Ruben-VandeVelde left a comment

Choose a reason for hiding this comment

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

Thanks, this seems reasonable.

maintainer merge

Copy link

🚀 Pull request has been placed on the maintainer queue by Ruben-VandeVelde.

Copy link
Contributor

@Vierkantor Vierkantor left a comment

Choose a reason for hiding this comment

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

The declaration itself looks reasonable otherwise. Thanks!

bors d+

@mathlib-bors
Copy link
Contributor

mathlib-bors bot commented Mar 11, 2025

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

Copy link
Member

@eric-wieser eric-wieser left a comment

Choose a reason for hiding this comment

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

Please update the PR description.

I claim that actually generalize_proofs probably was never needed, and simp_rw would have worked fine; but I don't know your original use case.

@pechersky pechersky changed the title feat(Data/Nat/Find): Nat.find_congr feat(Data/Nat/Find): Nat.find_mono_of_le and Nat.find_congr Mar 12, 2025
@pechersky
Copy link
Collaborator Author

I claim that actually generalize_proofs probably was never needed, and simp_rw would have worked fine; but I don't know your original use case.

You're right:

import Mathlib

attribute [local instance] PiNat.metricSpace

open PiNat

lemma foo (x y c : ℕ → ℕ) : firstDiff (x + c) (y + c) = firstDiff x y := by
  rw [firstDiff, firstDiff]
  rcases eq_or_ne x y with rfl|h
  · simp
  rw [dif_pos, dif_pos h]
  · congr -- you were right
    simp
  -- another option now
  -- · convert Nat.find_congr' _
  --   simp
  · simp [h]

lemma bar (x y c : ℕ → ℕ) : dist (x + c) (y + c) = dist x y := by
  rcases eq_or_ne x y with rfl|h
  · simp
  rw [dist_eq_of_ne, dist_eq_of_ne h]
  · simp [foo]
  · simp [h]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
delegated easy < 20s of review time. See the lifecycle page for guidelines. t-data Data (lists, quotients, numbers, etc)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants