Skip to content

[Merged by Bors] - feat: Dyadic is an ordered ring - #43038

Closed
plp127 wants to merge 15 commits into
leanprover-community:masterfrom
plp127:aliu/dyadic-ring
Closed

plp127 wants to merge 15 commits into
leanprover-community:masterfrom
plp127:aliu/dyadic-ring

Conversation

@plp127

@plp127 plp127 commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

Prove Dyadic is a linearly ordered ring, providing instances for LinearOrder, CommRing, and IsStrictOrderedRing. Remove corresponding material from Mathlib/Tactic/Inclusion/Extension/IntervalDyadicReal/Dyadic. Follow-up to #45186.


From CGT.

Open in Gitpod

@github-actions

github-actions Bot commented Aug 22, 2026 •

Copy link
Copy Markdown

PR summary b1c21b3abc

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference
10 files Mathlib.Data.Dyadic Mathlib.Tactic.Inclusion.Extension.IntervalDyadicReal.Basic Mathlib.Tactic.Inclusion.Extension.IntervalDyadicReal.BinarySplit Mathlib.Tactic.Inclusion.Extension.IntervalDyadicReal.Dyadic Mathlib.Tactic.Inclusion.Extension.IntervalDyadicReal.Exp Mathlib.Tactic.Inclusion.Extension.IntervalDyadicReal.Hypotheses Mathlib.Tactic.Inclusion.Extension.IntervalDyadicReal.Init Mathlib.Tactic.Inclusion.Extension.IntervalDyadicReal.Rational Mathlib.Tactic.Inclusion.Extension.IntervalDyadicReal.Tactic Mathlib.Tactic
1
Mathlib.Data.Dyadic.Basic (new file) 580

Declarations diff (regex)

+ instance : CommRing Dyadic
+ instance : IsStrictOrderedRing Dyadic
+ intCast_add
+ intCast_natCast
+ intCast_neg
+ intCast_one
+ intCast_zero
+ natCast_add
+ natCast_one
+ natCast_zero
+ toRat_one
- instance : AddCommGroup Dyadic

You can run this locally as follows
## from your `mathlib4` directory:
git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci

## summary with just the declaration names:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh <optional_commit>

## more verbose report:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh long <optional_commit>

The doc-module for scripts/pr_summary/declarations_diff.sh in the mathlib-ci repository contains some details about this script.

Declarations diff (Lean)

✅ Lean-aware diff — post-build, computed from the Lean environment (commit b1c21b3).

  • +12 new declarations
  • −2 removed declarations
+Dyadic.instCommRing_1
+Dyadic.instIsStrictOrderedRing
+Dyadic.instLinearOrder
+Dyadic.intCast_add
+Dyadic.intCast_natCast
+Dyadic.intCast_neg
+Dyadic.intCast_one
+Dyadic.intCast_zero
+Dyadic.natCast_add
+Dyadic.natCast_one
+Dyadic.natCast_zero
+Dyadic.toRat_one
-Inclusion.IntervalDyadicReal.instAddCommGroupDyadic
-Inclusion.IntervalDyadicReal.instLinearOrderDyadic

No changes to strong technical debt.
No changes to weak technical debt.

Current commit b1c21b3abc
Reference commit 727d8bbe60

This script lives in the mathlib-ci repository. To run it locally, from your mathlib4 directory:

git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci
../mathlib-ci/scripts/reporting/technical-debt-metrics.py 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).

@github-actions github-actions Bot added the t-data Data (lists, quotients, numbers, etc) label Aug 22, 2026
@plp127
plp127 requested a review from vihdzp August 22, 2026 15:02
@plp127 plp127 mentioned this pull request Aug 22, 2026
1 task done
Comment thread Mathlib/Data/Dyadic/OrderedRing.lean Resolved
@ADedecker ADedecker added the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Aug 24, 2026
@plp127 plp127 removed the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Aug 24, 2026
@mathlib-merge-conflicts mathlib-merge-conflicts 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 Sep 7, 2026
@mathlib-merge-conflicts

Copy link
Copy Markdown

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

@github-actions github-actions Bot added tech debt Fixes cross-cutting technical debt, see the "technical debt counters" stream on zulip and removed merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) labels Sep 8, 2026
Comment thread Mathlib/Data/Dyadic/ToReal.lean Resolved
Comment thread Mathlib/Data/Dyadic/OrderedRing.lean Resolved
Comment thread Mathlib/Data/Dyadic/Basic.lean Resolved
@vihdzp

vihdzp commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

I think this material should be moved first, out of the Data folder, and the material that's used for the tactic should also be moved to that file.

@plp127

plp127 commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

I think this material should be moved first, out of the Data folder, and the material that's used for the tactic should also be moved to that file.

Can you clarify which material you think should be moved where? And which file is the tactic material going into?

@vihdzp

vihdzp commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

Hmm. I guess it wouldn't make sense to make an ordered ring file where you don't yet prove that dyadic numbers are an ordered ring.

The toReal and step stuff should be moved to the file where the inclusion tactic is defined. That can be its own PR, I think. Everything else can remain as is.

Comment on lines +23 to +43
@[simp] protected theorem natCast_zero : (Nat.cast 0 : Dyadic) = 0 := rfl
@[simp] protected theorem natCast_one : (Nat.cast 1 : Dyadic) = 1 := rfl

@[norm_cast]
protected theorem natCast_add (a b : ℕ) : (Nat.cast (a + b) : Dyadic) = a + b := by
simp [← Dyadic.toRat_inj]

@[simp] protected theorem intCast_zero : (Int.cast 0 : Dyadic) = 0 := rfl

@[simp] protected theorem intCast_one : (Int.cast 1 : Dyadic) = 1 := rfl

@[norm_cast]
protected theorem intCast_add (a b : ℤ) : (Int.cast (a + b) : Dyadic) = a + b := by
simp [← Dyadic.toRat_inj]

@[simp, norm_cast]
theorem intCast_natCast (n : ℕ) : (Int.cast n : Dyadic) = n := rfl

@[norm_cast]
protected theorem intCast_neg (a : Int) : ((-a : Int) : Dyadic) = -(a : Dyadic) := by
simp [← Dyadic.toRat_inj]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Aren't these true in all rings? I think therefore it would make sense for them to be private.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I just copied what's done for Rat

mul_lt_mul_of_pos_left := by simp +contextual [← Dyadic.toRat_lt_toRat_iff, Rat.mul_lt_mul_left]
mul_lt_mul_of_pos_right := by simp +contextual [← Dyadic.toRat_lt_toRat_iff, Rat.mul_lt_mul_right]
zero_le_one := by decide
exists_pair_ne := ⟨0, 1, by decide⟩

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This could perhaps be a standalone Nontrivial instance

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

What's special about Nontrivial that you're singling it out here?

@plp127 plp127 added the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Sep 30, 2026
@mathlib-merge-conflicts mathlib-merge-conflicts 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 Oct 9, 2026
@mathlib-merge-conflicts

Copy link
Copy Markdown

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

@plp127 plp127 removed the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Nov 6, 2026
@github-actions github-actions Bot removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Nov 6, 2026
DavidLedvinka pushed a commit to DavidLedvinka/mathlib4 that referenced this pull request Nov 6, 2026
Merge PR leanprover-community#43038 and use its order and ring instances. Move the rational coercion API to Data/Dyadic/Basic and compose a real-valued ring homomorphism for the inclusion tactic. Preserve the deprecated real-conversion API.
@ocfnash

ocfnash commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Thanks!

bors merge

@mathlib-bors mathlib-bors Bot added the ready-to-merge This PR has been sent to bors. label Nov 10, 2026
mathlib-bors Bot pushed a commit that referenced this pull request Nov 10, 2026
Prove `Dyadic` is a linearly ordered ring, providing instances for `LinearOrder`, `CommRing`, and `IsStrictOrderedRing`. Remove corresponding material from `Mathlib/Tactic/Inclusion/Extension/IntervalDyadicReal/Dyadic`. Follow-up to #45186.
@mathlib-bors mathlib-bors Bot added the bors-staging This PR is currently being built by bors on the staging branch. label Nov 10, 2026
@mathlib-bors

mathlib-bors Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

@mathlib-bors mathlib-bors Bot changed the title feat: Dyadic is an ordered ring [Merged by Bors] - feat: Dyadic is an ordered ring Nov 10, 2026
@mathlib-bors mathlib-bors Bot closed this Nov 10, 2026
@plp127
plp127 deleted the aliu/dyadic-ring branch November 10, 2026 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bors-staging This PR is currently being built by bors on the staging branch. ready-to-merge This PR has been sent to bors. t-data Data (lists, quotients, numbers, etc) tech debt Fixes cross-cutting technical debt, see the "technical debt counters" stream on zulip

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants